Merge branch 'drm-next-4.6' of git://people.freedesktop.org/~agd5f/linux into drm...
authorDave Airlie <airlied@redhat.com>
Wed, 16 Mar 2016 22:25:04 +0000 (08:25 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 16 Mar 2016 22:25:04 +0000 (08:25 +1000)
A few more fixes and cleanups for 4.6:
- DCE code cleanups
- HDP flush/invalidation fixes
- GPUVM fixes
- switch to drm_vblank_[on|off]
- PX fixes
- misc bug fixes

* 'drm-next-4.6' of git://people.freedesktop.org/~agd5f/linux: (50 commits)
  drm/amdgpu: split pipeline sync out of SDMA vm_flush() as well
  drm/amdgpu: Revert "add mutex for ba_va->valids/invalids"
  drm/amdgpu: Revert "add lock for interval tree in vm"
  drm/amdgpu: Revert "add spin lock to protect freed list in vm (v3)"
  drm/amdgpu: reserve the PD during unmap and remove
  drm/amdgpu: Fix two bugs in amdgpu_vm_bo_split_mapping
  drm/radeon: Don't drop DP 2.7 Ghz link setup on some cards.
  MAINTAINERS: update radeon entry to include amdgpu as well
  drm/amdgpu: disable runtime pm on PX laptops without dGPU power control
  drm/radeon: disable runtime pm on PX laptops without dGPU power control
  drm/amd/amdgpu: Fix indentation in do_set_base() (DCEv8)
  drm/amd/amdgpu: make afmt_init cleanup if alloc fails (DCEv8)
  drm/amd/amdgpu: Move config init flag to bottom of sw_init (DCEv8)
  drm/amd/amdgpu: Don't proceed into audio_fini if audio is disabled (DCEv8)
  drm/amd/amdgpu: Fix identation in do_set_base() (DCEv10)
  drm/amd/amdgpu: Make afmt_init cleanup if alloc fails (DCEv10)
  drm/amd/amdgpu: Move initialized flag to bottom of sw_init (DCEv10)
  drm/amd/amdgpu: Don't proceed in audio_fini if disabled (DCEv10)
  drm/amd/amdgpu: Fix indentation in dce_v11_0_crtc_do_set_base()
  drm/amd/amdgpu: Make afmt_init() cleanup if alloc fails (DCEv11)
  ...

1802 files changed:
Documentation/DocBook/device-drivers.tmpl
Documentation/DocBook/gpu.tmpl
Documentation/DocBook/media/v4l/controls.xml
Documentation/DocBook/media/v4l/media-ioc-g-topology.xml
Documentation/DocBook/media/v4l/media-types.xml
Documentation/DocBook/media/v4l/pixfmt-yuv420m.xml
Documentation/DocBook/media/v4l/pixfmt-yuv422m.xml [moved from Documentation/DocBook/media/v4l/pixfmt-yvu420m.xml with 58% similarity]
Documentation/DocBook/media/v4l/pixfmt-yuv444m.xml [new file with mode: 0644]
Documentation/DocBook/media/v4l/pixfmt.xml
Documentation/DocBook/media/v4l/vidioc-query-dv-timings.xml
Documentation/DocBook/media/v4l/vidioc-querystd.xml
Documentation/cgroup-v2.txt
Documentation/devicetree/bindings/arm/omap/omap.txt
Documentation/devicetree/bindings/clock/rockchip,rk3036-cru.txt
Documentation/devicetree/bindings/display/brcm,bcm-vc4.txt
Documentation/devicetree/bindings/display/exynos/exynos_dsim.txt
Documentation/devicetree/bindings/display/exynos/samsung-fimd.txt
Documentation/devicetree/bindings/display/msm/dsi.txt
Documentation/devicetree/bindings/display/msm/hdmi.txt
Documentation/devicetree/bindings/display/panel/lg,lp120up1.txt [new file with mode: 0644]
Documentation/devicetree/bindings/display/panel/urt,umsh-8596md.txt [new file with mode: 0644]
Documentation/devicetree/bindings/display/renesas,du.txt
Documentation/devicetree/bindings/interrupt-controller/arm,gic-v3.txt
Documentation/devicetree/bindings/media/i2c/mt9v032.txt
Documentation/devicetree/bindings/media/i2c/tvp5150.txt [new file with mode: 0644]
Documentation/devicetree/bindings/media/rcar_vin.txt
Documentation/devicetree/bindings/media/renesas,jpu.txt
Documentation/devicetree/bindings/media/renesas,vsp1.txt
Documentation/devicetree/bindings/media/ti-cal.txt [new file with mode: 0644]
Documentation/devicetree/bindings/net/renesas,ravb.txt
Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt
Documentation/devicetree/bindings/pci/rcar-pci.txt
Documentation/devicetree/bindings/regulator/tps65217.txt
Documentation/devicetree/bindings/rtc/s3c-rtc.txt
Documentation/devicetree/bindings/serial/fsl-imx-uart.txt
Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
Documentation/devicetree/bindings/thermal/rcar-thermal.txt
Documentation/devicetree/bindings/vendor-prefixes.txt
Documentation/dvb/README.dvb-usb
Documentation/filesystems/efivarfs.txt
Documentation/kernel-parameters.txt
Documentation/timers/hpet.txt
Documentation/video4linux/v4l2-controls.txt
Documentation/virtual/kvm/mmu.txt
Documentation/watchdog/watchdog-parameters.txt
MAINTAINERS
Makefile
arch/arc/Kconfig
arch/arc/Makefile
arch/arc/configs/axs101_defconfig
arch/arc/configs/axs103_defconfig
arch/arc/configs/axs103_smp_defconfig
arch/arc/configs/nsim_700_defconfig
arch/arc/configs/nsim_hs_defconfig
arch/arc/configs/nsim_hs_smp_defconfig
arch/arc/configs/nsimosci_defconfig
arch/arc/configs/nsimosci_hs_defconfig
arch/arc/configs/nsimosci_hs_smp_defconfig
arch/arc/configs/tb10x_defconfig
arch/arc/configs/vdk_hs38_smp_defconfig
arch/arc/include/asm/arcregs.h
arch/arc/include/asm/irq.h
arch/arc/include/asm/irqflags-arcv2.h
arch/arc/include/asm/mcip.h
arch/arc/include/asm/pgtable.h
arch/arc/kernel/entry-arcv2.S
arch/arc/kernel/intc-arcv2.c
arch/arc/kernel/intc-compact.c
arch/arc/kernel/mcip.c
arch/arc/kernel/setup.c
arch/arc/kernel/smp.c
arch/arc/kernel/time.c
arch/arm/boot/compressed/Makefile
arch/arm/boot/dts/am335x-bone-common.dtsi
arch/arm/boot/dts/am335x-chilisom.dtsi
arch/arm/boot/dts/am335x-nano.dts
arch/arm/boot/dts/am335x-pepper.dts
arch/arm/boot/dts/am335x-shc.dts
arch/arm/boot/dts/am335x-sl50.dts
arch/arm/boot/dts/am57xx-beagle-x15.dts
arch/arm/boot/dts/am57xx-cl-som-am57x.dts
arch/arm/boot/dts/armada-xp-axpwifiap.dts
arch/arm/boot/dts/armada-xp-db.dts
arch/arm/boot/dts/armada-xp-gp.dts
arch/arm/boot/dts/armada-xp-lenovo-ix4-300d.dts
arch/arm/boot/dts/armada-xp-linksys-mamba.dts
arch/arm/boot/dts/armada-xp-matrix.dts
arch/arm/boot/dts/armada-xp-netgear-rn2120.dts
arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts
arch/arm/boot/dts/armada-xp-synology-ds414.dts
arch/arm/boot/dts/dra7.dtsi
arch/arm/boot/dts/imx6qdl.dtsi
arch/arm/boot/dts/kirkwood-ds112.dts
arch/arm/boot/dts/orion5x-linkstation-lswtgl.dts
arch/arm/boot/dts/r8a7791-porter.dts
arch/arm/boot/dts/sama5d2-pinfunc.h
arch/arm/boot/dts/tps65217.dtsi [new file with mode: 0644]
arch/arm/common/icst.c
arch/arm/configs/omap2plus_defconfig
arch/arm/crypto/aes-ce-glue.c
arch/arm/include/asm/arch_gicv3.h
arch/arm/include/asm/xen/page-coherent.h
arch/arm/kernel/Makefile
arch/arm/kvm/guest.c
arch/arm/kvm/mmio.c
arch/arm/mach-omap2/board-generic.c
arch/arm/mach-omap2/gpmc-onenand.c
arch/arm/mach-omap2/omap_device.c
arch/arm/mach-omap2/omap_hwmod.c
arch/arm/mach-omap2/omap_hwmod.h
arch/arm/mach-shmobile/common.h
arch/arm/mach-shmobile/headsmp-scu.S
arch/arm/mach-shmobile/headsmp.S
arch/arm/mach-shmobile/platsmp-apmu.c
arch/arm/mach-shmobile/platsmp-scu.c
arch/arm/mach-shmobile/smp-r8a7779.c
arch/arm/mm/mmap.c
arch/arm/mm/pageattr.c
arch/arm64/Makefile
arch/arm64/boot/Makefile
arch/arm64/boot/install.sh
arch/arm64/crypto/aes-glue.c
arch/arm64/include/asm/arch_gicv3.h
arch/arm64/include/asm/kvm_arm.h
arch/arm64/include/asm/kvm_emulate.h
arch/arm64/include/asm/pgtable.h
arch/arm64/kernel/debug-monitors.c
arch/arm64/kernel/image.h
arch/arm64/kernel/sleep.S
arch/arm64/kernel/stacktrace.c
arch/arm64/kernel/traps.c
arch/arm64/kvm/guest.c
arch/arm64/kvm/hyp-init.S
arch/arm64/kvm/hyp/switch.c
arch/arm64/kvm/hyp/vgic-v3-sr.c
arch/arm64/kvm/inject_fault.c
arch/arm64/kvm/sys_regs.c
arch/arm64/lib/strnlen.S
arch/arm64/mm/dma-mapping.c
arch/arm64/mm/fault.c
arch/arm64/mm/hugetlbpage.c
arch/arm64/mm/init.c
arch/arm64/mm/mmap.c
arch/m68k/configs/amiga_defconfig
arch/m68k/configs/apollo_defconfig
arch/m68k/configs/atari_defconfig
arch/m68k/configs/bvme6000_defconfig
arch/m68k/configs/hp300_defconfig
arch/m68k/configs/mac_defconfig
arch/m68k/configs/multi_defconfig
arch/m68k/configs/mvme147_defconfig
arch/m68k/configs/mvme16x_defconfig
arch/m68k/configs/q40_defconfig
arch/m68k/configs/sun3_defconfig
arch/m68k/configs/sun3x_defconfig
arch/m68k/include/asm/unistd.h
arch/m68k/include/uapi/asm/unistd.h
arch/m68k/kernel/syscalltable.S
arch/mips/Kconfig
arch/mips/boot/dts/brcm/bcm6328.dtsi
arch/mips/boot/dts/brcm/bcm7125.dtsi
arch/mips/boot/dts/brcm/bcm7346.dtsi
arch/mips/boot/dts/brcm/bcm7358.dtsi
arch/mips/boot/dts/brcm/bcm7360.dtsi
arch/mips/boot/dts/brcm/bcm7362.dtsi
arch/mips/boot/dts/brcm/bcm7420.dtsi
arch/mips/boot/dts/brcm/bcm7425.dtsi
arch/mips/boot/dts/brcm/bcm7435.dtsi
arch/mips/include/asm/elf.h
arch/mips/include/asm/fpu.h
arch/mips/include/asm/octeon/octeon-feature.h
arch/mips/include/asm/processor.h
arch/mips/include/asm/stackframe.h
arch/mips/include/asm/syscall.h
arch/mips/include/uapi/asm/unistd.h
arch/mips/jz4740/gpio.c
arch/mips/kernel/binfmt_elfn32.c
arch/mips/kernel/binfmt_elfo32.c
arch/mips/kernel/process.c
arch/mips/kernel/r2300_fpu.S
arch/mips/kernel/r4k_fpu.S
arch/mips/kernel/scall32-o32.S
arch/mips/kernel/scall64-64.S
arch/mips/kernel/scall64-n32.S
arch/mips/kernel/scall64-o32.S
arch/mips/kernel/setup.c
arch/mips/kernel/traps.c
arch/mips/kvm/mips.c
arch/mips/mm/mmap.c
arch/mips/mm/sc-mips.c
arch/mips/mti-malta/malta-init.c
arch/mips/pci/pci-mt7620.c
arch/parisc/include/asm/floppy.h
arch/parisc/include/uapi/asm/unistd.h
arch/parisc/kernel/ptrace.c
arch/parisc/kernel/syscall.S
arch/parisc/kernel/syscall_table.S
arch/powerpc/Kconfig
arch/powerpc/include/asm/book3s/64/pgtable.h
arch/powerpc/include/asm/eeh.h
arch/powerpc/include/asm/trace.h
arch/powerpc/kernel/eeh_driver.c
arch/powerpc/kernel/eeh_pe.c
arch/powerpc/kernel/hw_breakpoint.c
arch/powerpc/kernel/module_64.c
arch/powerpc/kernel/process.c
arch/powerpc/kvm/book3s_hv_rmhandlers.S
arch/powerpc/mm/hash64_64k.c
arch/powerpc/mm/hugepage-hash64.c
arch/powerpc/mm/hugetlbpage-book3e.c
arch/powerpc/mm/mmap.c
arch/powerpc/mm/pgtable_64.c
arch/powerpc/platforms/powernv/eeh-powernv.c
arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/platforms/powernv/pci.c
arch/powerpc/platforms/powernv/pci.h
arch/s390/include/asm/fpu/internal.h
arch/s390/include/asm/livepatch.h
arch/s390/include/asm/mmu_context.h
arch/s390/include/asm/pgalloc.h
arch/s390/kernel/compat_signal.c
arch/s390/kernel/head64.S
arch/s390/kernel/perf_event.c
arch/s390/kernel/stacktrace.c
arch/s390/kernel/trace.c
arch/s390/kvm/kvm-s390.c
arch/s390/mm/maccess.c
arch/s390/oprofile/backtrace.c
arch/sparc/Makefile
arch/sparc/include/uapi/asm/unistd.h
arch/sparc/kernel/entry.S
arch/sparc/kernel/hvcalls.S
arch/sparc/kernel/signal_64.c
arch/sparc/kernel/sparc_ksyms_64.c
arch/sparc/kernel/sys_sparc_64.c
arch/sparc/kernel/syscalls.S
arch/sparc/kernel/systbls_32.S
arch/sparc/kernel/systbls_64.S
arch/um/kernel/reboot.c
arch/um/kernel/signal.c
arch/x86/Kconfig
arch/x86/entry/entry_32.S
arch/x86/entry/entry_64_compat.S
arch/x86/include/asm/livepatch.h
arch/x86/include/asm/pci_x86.h
arch/x86/include/asm/processor.h
arch/x86/include/asm/uaccess_32.h
arch/x86/include/asm/xen/pci.h
arch/x86/kernel/acpi/sleep.c
arch/x86/kernel/cpu/perf_event_amd_uncore.c
arch/x86/kvm/emulate.c
arch/x86/kvm/mmu.c
arch/x86/kvm/paging_tmpl.h
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c
arch/x86/lib/copy_user_64.S
arch/x86/mm/fault.c
arch/x86/mm/gup.c
arch/x86/mm/mmap.c
arch/x86/mm/mpx.c
arch/x86/mm/numa.c
arch/x86/mm/pageattr.c
arch/x86/pci/common.c
arch/x86/pci/intel_mid_pci.c
arch/x86/pci/irq.c
arch/x86/pci/xen.c
arch/x86/platform/intel-quark/imr.c
arch/x86/um/os-Linux/task_size.c
block/Kconfig
block/bio.c
block/blk-cgroup.c
block/blk-core.c
block/blk-map.c
block/blk-merge.c
block/blk-mq.c
block/blk-settings.c
block/blk-sysfs.c
block/deadline-iosched.c
crypto/algif_skcipher.c
crypto/crypto_user.c
drivers/acpi/acpica/psargs.c
drivers/acpi/nfit.c
drivers/acpi/pci_irq.c
drivers/acpi/pci_link.c
drivers/android/binder.c
drivers/ata/ahci.c
drivers/ata/ahci.h
drivers/ata/ahci_brcmstb.c
drivers/ata/ahci_xgene.c
drivers/ata/libahci.c
drivers/ata/libata-core.c
drivers/ata/libata-scsi.c
drivers/ata/libata-sff.c
drivers/ata/pata_rb532_cf.c
drivers/base/component.c
drivers/base/property.c
drivers/base/regmap/regmap-mmio.c
drivers/block/floppy.c
drivers/block/null_blk.c
drivers/block/xen-blkfront.c
drivers/char/agp/intel-gtt.c
drivers/char/hpet.c
drivers/char/random.c
drivers/clk/Makefile
drivers/clk/clk-gpio.c
drivers/clk/clk-scpi.c
drivers/clk/mvebu/dove-divider.c
drivers/clk/qcom/gcc-apq8084.c
drivers/clk/qcom/gcc-ipq806x.c
drivers/clk/qcom/gcc-msm8660.c
drivers/clk/qcom/gcc-msm8916.c
drivers/clk/qcom/gcc-msm8960.c
drivers/clk/qcom/gcc-msm8974.c
drivers/clk/qcom/lcc-ipq806x.c
drivers/clk/qcom/lcc-msm8960.c
drivers/clk/qcom/mmcc-apq8084.c
drivers/clk/qcom/mmcc-msm8960.c
drivers/clk/qcom/mmcc-msm8974.c
drivers/clk/rockchip/clk-rk3036.c
drivers/clk/rockchip/clk-rk3368.c
drivers/clk/tegra/clk-emc.c
drivers/clk/tegra/clk-id.h
drivers/clk/tegra/clk-pll.c
drivers/clk/tegra/clk-tegra-periph.c
drivers/clk/tegra/clk-tegra-super-gen4.c
drivers/clk/tegra/clk-tegra210.c
drivers/clk/ti/dpll3xxx.c
drivers/clk/versatile/clk-icst.c
drivers/cpufreq/Kconfig
drivers/cpufreq/Kconfig.arm
drivers/cpufreq/mt8173-cpufreq.c
drivers/crypto/atmel-sha.c
drivers/crypto/marvell/cesa.c
drivers/devfreq/tegra-devfreq.c
drivers/dma/at_xdmac.c
drivers/dma/dw/core.c
drivers/dma/dw/pci.c
drivers/dma/edma.c
drivers/dma/fsldma.c
drivers/dma/ioat/dma.c
drivers/dma/pxa_dma.c
drivers/edac/sb_edac.c
drivers/firmware/efi/efivars.c
drivers/firmware/efi/vars.c
drivers/gpio/gpio-altera.c
drivers/gpio/gpio-davinci.c
drivers/gpio/gpio-rcar.c
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c
drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/amd/amdgpu/atombios_dp.c
drivers/gpu/drm/amd/amdgpu/ci_dpm.c
drivers/gpu/drm/amd/amdgpu/cik.c
drivers/gpu/drm/amd/amdgpu/cik_sdma.c
drivers/gpu/drm/amd/amdgpu/cz_dpm.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
drivers/gpu/drm/amd/amdgpu/kv_dpm.c
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
drivers/gpu/drm/amd/amdgpu/vi.c
drivers/gpu/drm/amd/amdkfd/kfd_dbgdev.c
drivers/gpu/drm/amd/amdkfd/kfd_module.c
drivers/gpu/drm/amd/include/amd_shared.h
drivers/gpu/drm/amd/include/cgs_common.h
drivers/gpu/drm/amd/include/kgd_kfd_interface.h
drivers/gpu/drm/amd/powerplay/amd_powerplay.c
drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c
drivers/gpu/drm/amd/powerplay/eventmgr/eventmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c
drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c
drivers/gpu/drm/ast/ast_main.c
drivers/gpu/drm/ast/ast_mode.c
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
drivers/gpu/drm/bochs/bochs_kms.c
drivers/gpu/drm/cirrus/cirrus_mode.c
drivers/gpu/drm/drm_atomic.c
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/drm_bridge.c
drivers/gpu/drm/drm_crtc.c
drivers/gpu/drm/drm_crtc_helper.c
drivers/gpu/drm/drm_dp_mst_topology.c
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/drm_irq.c
drivers/gpu/drm/drm_mipi_dsi.c
drivers/gpu/drm/drm_of.c
drivers/gpu/drm/etnaviv/etnaviv_buffer.c
drivers/gpu/drm/etnaviv/etnaviv_drv.h
drivers/gpu/drm/etnaviv/etnaviv_gem.c
drivers/gpu/drm/etnaviv/etnaviv_gem.h
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.c
drivers/gpu/drm/etnaviv/etnaviv_gpu.h
drivers/gpu/drm/etnaviv/etnaviv_mmu.c
drivers/gpu/drm/etnaviv/state_3d.xml.h [new file with mode: 0644]
drivers/gpu/drm/exynos/Kconfig
drivers/gpu/drm/exynos/Makefile
drivers/gpu/drm/exynos/exynos5433_drm_decon.c
drivers/gpu/drm/exynos/exynos7_drm_decon.c
drivers/gpu/drm/exynos/exynos_dp_core.c
drivers/gpu/drm/exynos/exynos_dp_core.h
drivers/gpu/drm/exynos/exynos_drm_drv.c
drivers/gpu/drm/exynos/exynos_drm_drv.h
drivers/gpu/drm/exynos/exynos_drm_dsi.c
drivers/gpu/drm/exynos/exynos_drm_fbdev.c
drivers/gpu/drm/exynos/exynos_drm_fimc.c
drivers/gpu/drm/exynos/exynos_drm_fimd.c
drivers/gpu/drm/exynos/exynos_drm_g2d.c
drivers/gpu/drm/exynos/exynos_drm_gem.c
drivers/gpu/drm/exynos/exynos_drm_gem.h
drivers/gpu/drm/exynos/exynos_drm_gsc.c
drivers/gpu/drm/exynos/exynos_drm_iommu.c
drivers/gpu/drm/exynos/exynos_drm_iommu.h
drivers/gpu/drm/exynos/exynos_drm_ipp.c
drivers/gpu/drm/exynos/exynos_drm_mic.c
drivers/gpu/drm/exynos/exynos_drm_rotator.c
drivers/gpu/drm/exynos/exynos_drm_vidi.c
drivers/gpu/drm/exynos/exynos_hdmi.c
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_kms.c
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
drivers/gpu/drm/gma500/cdv_intel_display.c
drivers/gpu/drm/gma500/gma_display.c
drivers/gpu/drm/gma500/gma_display.h
drivers/gpu/drm/gma500/mdfld_intel_display.c
drivers/gpu/drm/gma500/oaktrail_crtc.c
drivers/gpu/drm/gma500/psb_intel_display.c
drivers/gpu/drm/i2c/tda998x_drv.c
drivers/gpu/drm/i915/Kconfig
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_drv.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_gem_evict.c
drivers/gpu/drm/i915/i915_gem_execbuffer.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_gem_gtt.h
drivers/gpu/drm/i915/i915_gem_shrinker.c
drivers/gpu/drm/i915/i915_gem_stolen.c
drivers/gpu/drm/i915/i915_gem_userptr.c
drivers/gpu/drm/i915/i915_gpu_error.c
drivers/gpu/drm/i915/i915_guc_submission.c
drivers/gpu/drm/i915/i915_irq.c
drivers/gpu/drm/i915/i915_params.c
drivers/gpu/drm/i915/i915_params.h
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/i915_suspend.c
drivers/gpu/drm/i915/i915_trace.h
drivers/gpu/drm/i915/intel_atomic.c
drivers/gpu/drm/i915/intel_audio.c
drivers/gpu/drm/i915/intel_crt.c
drivers/gpu/drm/i915/intel_csr.c
drivers/gpu/drm/i915/intel_ddi.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_dp_link_training.c
drivers/gpu/drm/i915/intel_dp_mst.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_dsi.c
drivers/gpu/drm/i915/intel_dsi.h
drivers/gpu/drm/i915/intel_dsi_panel_vbt.c
drivers/gpu/drm/i915/intel_dsi_pll.c
drivers/gpu/drm/i915/intel_fbc.c
drivers/gpu/drm/i915/intel_fbdev.c
drivers/gpu/drm/i915/intel_guc.h
drivers/gpu/drm/i915/intel_guc_fwif.h
drivers/gpu/drm/i915/intel_guc_loader.c
drivers/gpu/drm/i915/intel_hdmi.c [changed mode: 0755->0644]
drivers/gpu/drm/i915/intel_i2c.c
drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/intel_lrc.h
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_pm.c
drivers/gpu/drm/i915/intel_psr.c
drivers/gpu/drm/i915/intel_ringbuffer.c
drivers/gpu/drm/i915/intel_ringbuffer.h
drivers/gpu/drm/i915/intel_runtime_pm.c
drivers/gpu/drm/i915/intel_sdvo.c
drivers/gpu/drm/i915/intel_sideband.c
drivers/gpu/drm/i915/intel_sprite.c
drivers/gpu/drm/i915/intel_tv.c
drivers/gpu/drm/i915/intel_uncore.c
drivers/gpu/drm/imx/dw_hdmi-imx.c
drivers/gpu/drm/imx/imx-drm-core.c
drivers/gpu/drm/imx/imx-drm.h
drivers/gpu/drm/imx/imx-ldb.c
drivers/gpu/drm/imx/ipuv3-crtc.c
drivers/gpu/drm/imx/ipuv3-plane.c
drivers/gpu/drm/mgag200/mgag200_mode.c
drivers/gpu/drm/msm/Makefile
drivers/gpu/drm/msm/adreno/a2xx.xml.h
drivers/gpu/drm/msm/adreno/a3xx.xml.h
drivers/gpu/drm/msm/adreno/a4xx.xml.h
drivers/gpu/drm/msm/adreno/a4xx_gpu.c
drivers/gpu/drm/msm/adreno/adreno_common.xml.h
drivers/gpu/drm/msm/adreno/adreno_device.c
drivers/gpu/drm/msm/adreno/adreno_gpu.c
drivers/gpu/drm/msm/adreno/adreno_gpu.h
drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h
drivers/gpu/drm/msm/dsi/dsi.xml.h
drivers/gpu/drm/msm/dsi/dsi_cfg.c
drivers/gpu/drm/msm/dsi/dsi_host.c
drivers/gpu/drm/msm/dsi/mmss_cc.xml.h
drivers/gpu/drm/msm/dsi/pll/dsi_pll.h
drivers/gpu/drm/msm/dsi/sfpb.xml.h
drivers/gpu/drm/msm/edp/edp.xml.h
drivers/gpu/drm/msm/hdmi/hdmi.c
drivers/gpu/drm/msm/hdmi/hdmi.h
drivers/gpu/drm/msm/hdmi/hdmi.xml.h
drivers/gpu/drm/msm/hdmi/hdmi_audio.c
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c
drivers/gpu/drm/msm/hdmi/hdmi_connector.c
drivers/gpu/drm/msm/hdmi/hdmi_hdcp.c
drivers/gpu/drm/msm/hdmi/hdmi_i2c.c
drivers/gpu/drm/msm/hdmi/hdmi_phy.c [new file with mode: 0644]
drivers/gpu/drm/msm/hdmi/hdmi_phy_8960.c
drivers/gpu/drm/msm/hdmi/hdmi_phy_8996.c [new file with mode: 0644]
drivers/gpu/drm/msm/hdmi/hdmi_phy_8x60.c
drivers/gpu/drm/msm/hdmi/hdmi_phy_8x74.c
drivers/gpu/drm/msm/hdmi/hdmi_pll_8960.c [new file with mode: 0644]
drivers/gpu/drm/msm/hdmi/qfprom.xml.h
drivers/gpu/drm/msm/mdp/mdp4/mdp4.xml.h
drivers/gpu/drm/msm/mdp/mdp4/mdp4_crtc.c
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.h
drivers/gpu/drm/msm/mdp/mdp5/mdp5.xml.h
drivers/gpu/drm/msm/mdp/mdp5/mdp5_crtc.c
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
drivers/gpu/drm/msm/mdp/mdp_common.xml.h
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_drv.h
drivers/gpu/drm/msm/msm_gem_submit.c
drivers/gpu/drm/msm/msm_iommu.c
drivers/gpu/drm/msm/msm_mmu.h
drivers/gpu/drm/nouveau/dispnv04/crtc.c
drivers/gpu/drm/nouveau/include/nvif/cla06f.h
drivers/gpu/drm/nouveau/include/nvif/class.h
drivers/gpu/drm/nouveau/include/nvif/device.h
drivers/gpu/drm/nouveau/include/nvkm/core/device.h
drivers/gpu/drm/nouveau/include/nvkm/core/firmware.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/include/nvkm/core/gpuobj.h
drivers/gpu/drm/nouveau/include/nvkm/engine/ce.h
drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h
drivers/gpu/drm/nouveau/include/nvkm/engine/fifo.h
drivers/gpu/drm/nouveau/include/nvkm/engine/gr.h
drivers/gpu/drm/nouveau/include/nvkm/engine/msenc.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/include/nvkm/engine/nvenc.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/include/nvkm/engine/vic.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/extdev.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/iccsense.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/include/nvkm/subdev/clk.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/devinit.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/ibus.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/iccsense.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/include/nvkm/subdev/ltc.h
drivers/gpu/drm/nouveau/include/nvkm/subdev/secboot.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/include/nvkm/subdev/volt.h
drivers/gpu/drm/nouveau/nouveau_abi16.c
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/nouveau/nouveau_chan.c
drivers/gpu/drm/nouveau/nouveau_display.c
drivers/gpu/drm/nouveau/nouveau_drm.c
drivers/gpu/drm/nouveau/nouveau_hwmon.c
drivers/gpu/drm/nouveau/nouveau_platform.c
drivers/gpu/drm/nouveau/nv50_display.c
drivers/gpu/drm/nouveau/nvkm/core/Kbuild
drivers/gpu/drm/nouveau/nvkm/core/firmware.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/core/gpuobj.c
drivers/gpu/drm/nouveau/nvkm/core/ramht.c
drivers/gpu/drm/nouveau/nvkm/core/subdev.c
drivers/gpu/drm/nouveau/nvkm/engine/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/ce/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/ce/gm107.c [moved from drivers/gpu/drm/nouveau/nvkm/engine/gr/gm206.c with 62% similarity]
drivers/gpu/drm/nouveau/nvkm/engine/ce/gm200.c [moved from drivers/gpu/drm/nouveau/nvkm/engine/ce/gm204.c with 87% similarity]
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c
drivers/gpu/drm/nouveau/nvkm/engine/device/priv.h
drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/disp/coregm200.c [moved from drivers/gpu/drm/nouveau/nvkm/engine/disp/coregm204.c with 95% similarity]
drivers/gpu/drm/nouveau/nvkm/engine/disp/dmacnv50.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/dport.c
drivers/gpu/drm/nouveau/nvkm/engine/disp/dport.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/gm200.c [moved from drivers/gpu/drm/nouveau/nvkm/engine/disp/gm204.c with 88% similarity]
drivers/gpu/drm/nouveau/nvkm/engine/disp/outp.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/outpdp.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgm200.c [moved from drivers/gpu/drm/nouveau/nvkm/engine/disp/rootgm204.c with 86% similarity]
drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.h
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm200.c [moved from drivers/gpu/drm/nouveau/nvkm/engine/disp/sorgm204.c with 79% similarity]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/fifo/changk104.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gf100.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.h
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk110.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm107.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm200.c [moved from drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm204.c with 89% similarity]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm20b.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk104.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk110.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogm200.c [moved from drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogm204.c with 97% similarity]
drivers/gpu/drm/nouveau/nvkm/engine/gr/Kbuild
drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf100.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm200.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm204.c [deleted file]
drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm206.c [deleted file]
drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm20b.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf100.fuc3.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf117.fuc3.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk104.fuc3.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk110.fuc3.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk208.fuc5.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/hub.fuc
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/hubgf100.fuc3.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/hubgf117.fuc3.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/hubgk104.fuc3.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/hubgk110.fuc3.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/hubgk208.fuc5.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/hubgm107.fuc5.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h
drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c
drivers/gpu/drm/nouveau/nvkm/engine/gr/gm200.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c [deleted file]
drivers/gpu/drm/nouveau/nvkm/engine/gr/gm20b.c
drivers/gpu/drm/nouveau/nvkm/engine/msenc/Kbuild [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/nvdec/Kbuild [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/nvenc/Kbuild [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/engine/pm/nv40.c
drivers/gpu/drm/nouveau/nvkm/engine/vic/Kbuild [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/bios/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/bios/extdev.c
drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/bios/init.c
drivers/gpu/drm/nouveau/nvkm/subdev/clk/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c
drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/clk/gm20b.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gf100.c
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm107.c
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm200.c [moved from drivers/gpu/drm/nouveau/nvkm/subdev/devinit/gm204.c with 95% similarity]
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv50.c
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/nv50.h
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.h
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c [moved from drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c with 88% similarity]
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/gm200.c [moved from drivers/gpu/drm/nouveau/nvkm/subdev/i2c/gm204.c with 88% similarity]
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/pad.h
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/padgm200.c [moved from drivers/gpu/drm/nouveau/nvkm/subdev/i2c/padgm204.c with 81% similarity]
drivers/gpu/drm/nouveau/nvkm/subdev/ibus/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gm200.c [moved from drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gm204.c with 91% similarity]
drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/Kbuild [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/gf100.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/priv.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
drivers/gpu/drm/nouveau/nvkm/subdev/ltc/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gf100.c
drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm107.c
drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm200.c [moved from drivers/gpu/drm/nouveau/nvkm/subdev/ltc/gm204.c with 87% similarity]
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf100.fuc3.h
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gf119.fuc4.h
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gk208.fuc5.h
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/gt215.fuc3.h
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/host.fuc
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/kernel.fuc
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/macros.fuc
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/fuc/test.fuc
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/Kbuild [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/base.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm200.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm20b.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/priv.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/volt/Kbuild
drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c
drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.h [new file with mode: 0644]
drivers/gpu/drm/nouveau/nvkm/subdev/volt/gm20b.c [new file with mode: 0644]
drivers/gpu/drm/omapdrm/Kconfig
drivers/gpu/drm/omapdrm/Makefile
drivers/gpu/drm/omapdrm/displays/connector-dvi.c
drivers/gpu/drm/omapdrm/displays/connector-hdmi.c
drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c
drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c
drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c
drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c
drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c
drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c
drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c
drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c
drivers/gpu/drm/omapdrm/dss/Makefile
drivers/gpu/drm/omapdrm/dss/apply.c [deleted file]
drivers/gpu/drm/omapdrm/dss/core.c
drivers/gpu/drm/omapdrm/dss/dispc-compat.c [deleted file]
drivers/gpu/drm/omapdrm/dss/dispc-compat.h [deleted file]
drivers/gpu/drm/omapdrm/dss/dispc.c
drivers/gpu/drm/omapdrm/dss/display-sysfs.c [deleted file]
drivers/gpu/drm/omapdrm/dss/display.c
drivers/gpu/drm/omapdrm/dss/dpi.c
drivers/gpu/drm/omapdrm/dss/dsi.c
drivers/gpu/drm/omapdrm/dss/dss.h
drivers/gpu/drm/omapdrm/dss/hdmi4.c
drivers/gpu/drm/omapdrm/dss/hdmi5.c
drivers/gpu/drm/omapdrm/dss/hdmi5_core.c
drivers/gpu/drm/omapdrm/dss/hdmi_wp.c
drivers/gpu/drm/omapdrm/dss/manager-sysfs.c [deleted file]
drivers/gpu/drm/omapdrm/dss/manager.c [deleted file]
drivers/gpu/drm/omapdrm/dss/omapdss.h [new file with mode: 0644]
drivers/gpu/drm/omapdrm/dss/output.c
drivers/gpu/drm/omapdrm/dss/overlay-sysfs.c [deleted file]
drivers/gpu/drm/omapdrm/dss/overlay.c [deleted file]
drivers/gpu/drm/omapdrm/dss/rfbi.c
drivers/gpu/drm/omapdrm/dss/sdi.c
drivers/gpu/drm/omapdrm/dss/venc.c
drivers/gpu/drm/omapdrm/omap_connector.c
drivers/gpu/drm/omapdrm/omap_crtc.c
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
drivers/gpu/drm/omapdrm/omap_drv.c
drivers/gpu/drm/omapdrm/omap_drv.h
drivers/gpu/drm/omapdrm/omap_encoder.c
drivers/gpu/drm/omapdrm/omap_fb.c
drivers/gpu/drm/omapdrm/omap_gem.c
drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c
drivers/gpu/drm/omapdrm/omap_plane.c
drivers/gpu/drm/panel/panel-simple.c
drivers/gpu/drm/qxl/qxl_ioctl.c
drivers/gpu/drm/qxl/qxl_prime.c
drivers/gpu/drm/radeon/atombios_dp.c
drivers/gpu/drm/radeon/radeon_device.c
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/radeon/radeon_drv.c
drivers/gpu/drm/radeon/radeon_kfd.c
drivers/gpu/drm/radeon/radeon_kfd.h
drivers/gpu/drm/radeon/radeon_pm.c
drivers/gpu/drm/radeon/radeon_sa.c
drivers/gpu/drm/radeon/radeon_ttm.c
drivers/gpu/drm/rcar-du/Kconfig
drivers/gpu/drm/rcar-du/Makefile
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_group.c
drivers/gpu/drm/rcar-du/rcar_du_group.h
drivers/gpu/drm/rcar-du/rcar_du_hdmicon.c
drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c
drivers/gpu/drm/rcar-du/rcar_du_kms.c
drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
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_regs.h
drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
drivers/gpu/drm/rcar-du/rcar_du_vsp.c [new file with mode: 0644]
drivers/gpu/drm/rcar-du/rcar_du_vsp.h [new file with mode: 0644]
drivers/gpu/drm/rcar-du/rcar_lvds_regs.h
drivers/gpu/drm/rockchip/dw-mipi-dsi.c
drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
drivers/gpu/drm/rockchip/rockchip_drm_drv.c
drivers/gpu/drm/rockchip/rockchip_drm_drv.h
drivers/gpu/drm/shmobile/shmob_drm_crtc.c
drivers/gpu/drm/sti/sti_crtc.c
drivers/gpu/drm/tilcdc/tilcdc_crtc.c
drivers/gpu/drm/tilcdc/tilcdc_drv.c
drivers/gpu/drm/tilcdc/tilcdc_drv.h
drivers/gpu/drm/tilcdc/tilcdc_panel.c
drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
drivers/gpu/drm/udl/udl_modeset.c
drivers/gpu/drm/vc4/vc4_bo.c
drivers/gpu/drm/vc4/vc4_crtc.c
drivers/gpu/drm/vc4/vc4_drv.h
drivers/gpu/drm/vc4/vc4_gem.c
drivers/gpu/drm/vc4/vc4_hdmi.c
drivers/gpu/drm/vc4/vc4_irq.c
drivers/gpu/drm/vc4/vc4_regs.h
drivers/gpu/drm/vc4/vc4_render_cl.c
drivers/gpu/drm/vc4/vc4_v3d.c
drivers/gpu/drm/vc4/vc4_validate.c
drivers/gpu/drm/virtio/virtgpu_display.c
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
drivers/gpu/host1x/bus.c
drivers/gpu/host1x/dev.c
drivers/gpu/host1x/dev.h
drivers/gpu/host1x/job.c
drivers/gpu/ipu-v3/ipu-common.c
drivers/gpu/ipu-v3/ipu-dc.c
drivers/hwmon/ads1015.c
drivers/hwmon/gpio-fan.c
drivers/i2c/busses/i2c-brcmstb.c
drivers/i2c/busses/i2c-i801.c
drivers/i2c/busses/i2c-omap.c
drivers/i2c/busses/i2c-uniphier-f.c
drivers/i2c/busses/i2c-uniphier.c
drivers/infiniband/core/device.c
drivers/infiniband/core/sa_query.c
drivers/infiniband/core/sysfs.c
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/hw/mlx4/mad.c
drivers/infiniband/hw/mlx4/qp.c
drivers/infiniband/hw/mlx5/qp.c
drivers/infiniband/hw/mlx5/srq.c
drivers/infiniband/hw/ocrdma/ocrdma.h
drivers/infiniband/hw/ocrdma/ocrdma_main.c
drivers/infiniband/hw/ocrdma/ocrdma_stats.c
drivers/infiniband/hw/ocrdma/ocrdma_stats.h
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
drivers/infiniband/ulp/ipoib/ipoib_ib.c
drivers/infiniband/ulp/ipoib/ipoib_multicast.c
drivers/input/joystick/xpad.c
drivers/input/keyboard/adp5589-keys.c
drivers/input/keyboard/cap11xx.c
drivers/input/misc/Kconfig
drivers/input/misc/sirfsoc-onkey.c
drivers/input/mouse/vmmouse.c
drivers/input/serio/serio.c
drivers/input/touchscreen/colibri-vf50-ts.c
drivers/input/touchscreen/edt-ft5x06.c
drivers/iommu/amd_iommu.c
drivers/iommu/amd_iommu_init.c
drivers/iommu/dmar.c
drivers/iommu/intel-iommu.c
drivers/iommu/intel-svm.c
drivers/iommu/intel_irq_remapping.c
drivers/irqchip/irq-gic-v3-its.c
drivers/irqchip/irq-gic.c
drivers/irqchip/irq-sun4i.c
drivers/isdn/gigaset/ser-gigaset.c
drivers/isdn/hardware/mISDN/netjet.c
drivers/lightnvm/core.c
drivers/lightnvm/rrpc.c
drivers/lightnvm/rrpc.h
drivers/md/dm.c
drivers/media/common/b2c2/flexcop-fe-tuner.c
drivers/media/common/b2c2/flexcop.c
drivers/media/common/cypress_firmware.c
drivers/media/common/cypress_firmware.h
drivers/media/common/siano/smscoreapi.c
drivers/media/common/siano/smsdvb-main.c
drivers/media/dvb-core/dvb-usb-ids.h
drivers/media/dvb-core/dvb_frontend.c
drivers/media/dvb-core/dvb_frontend.h
drivers/media/dvb-core/dvbdev.c
drivers/media/dvb-frontends/af9013.c
drivers/media/dvb-frontends/af9033.c
drivers/media/dvb-frontends/as102_fe.c
drivers/media/dvb-frontends/atbm8830.c
drivers/media/dvb-frontends/au8522_dig.c
drivers/media/dvb-frontends/bcm3510.c
drivers/media/dvb-frontends/bcm3510.h
drivers/media/dvb-frontends/bcm3510_priv.h
drivers/media/dvb-frontends/cx22700.c
drivers/media/dvb-frontends/cx22702.c
drivers/media/dvb-frontends/cx24110.c
drivers/media/dvb-frontends/cx24117.c
drivers/media/dvb-frontends/cx24120.c
drivers/media/dvb-frontends/cx24123.c
drivers/media/dvb-frontends/cxd2820r_c.c
drivers/media/dvb-frontends/cxd2820r_core.c
drivers/media/dvb-frontends/cxd2820r_priv.h
drivers/media/dvb-frontends/cxd2820r_t.c
drivers/media/dvb-frontends/cxd2820r_t2.c
drivers/media/dvb-frontends/cxd2841er.c
drivers/media/dvb-frontends/dib0070.c
drivers/media/dvb-frontends/dib0090.c
drivers/media/dvb-frontends/dib3000.h
drivers/media/dvb-frontends/dib3000mb.c
drivers/media/dvb-frontends/dib3000mb_priv.h
drivers/media/dvb-frontends/dib3000mc.c
drivers/media/dvb-frontends/dib3000mc.h
drivers/media/dvb-frontends/dib7000m.c
drivers/media/dvb-frontends/dib7000p.c
drivers/media/dvb-frontends/dib8000.c
drivers/media/dvb-frontends/dib9000.c
drivers/media/dvb-frontends/dibx000_common.c
drivers/media/dvb-frontends/dvb_dummy_fe.c
drivers/media/dvb-frontends/hd29l2.c
drivers/media/dvb-frontends/l64781.c
drivers/media/dvb-frontends/lg2160.c
drivers/media/dvb-frontends/lgdt3305.c
drivers/media/dvb-frontends/lgdt3306a.c
drivers/media/dvb-frontends/lgdt330x.c
drivers/media/dvb-frontends/lgs8gl5.c
drivers/media/dvb-frontends/lgs8gxx.c
drivers/media/dvb-frontends/m88ds3103.c
drivers/media/dvb-frontends/m88rs2000.c
drivers/media/dvb-frontends/mb86a20s.c
drivers/media/dvb-frontends/mt312.c
drivers/media/dvb-frontends/mt352.c
drivers/media/dvb-frontends/or51132.c
drivers/media/dvb-frontends/rtl2830.c
drivers/media/dvb-frontends/rtl2832.c
drivers/media/dvb-frontends/s5h1409.c
drivers/media/dvb-frontends/s5h1411.c
drivers/media/dvb-frontends/s5h1420.c
drivers/media/dvb-frontends/s921.c
drivers/media/dvb-frontends/si2165.c
drivers/media/dvb-frontends/stb0899_drv.c
drivers/media/dvb-frontends/stb6100.c
drivers/media/dvb-frontends/stv0297.c
drivers/media/dvb-frontends/stv0299.c
drivers/media/dvb-frontends/stv0367.c
drivers/media/dvb-frontends/stv0900_core.c
drivers/media/dvb-frontends/stv6110x.c
drivers/media/dvb-frontends/stv6110x.h
drivers/media/dvb-frontends/stv6110x_priv.h
drivers/media/dvb-frontends/tc90522.c
drivers/media/dvb-frontends/tda10021.c
drivers/media/dvb-frontends/tda10023.c
drivers/media/dvb-frontends/tda10048.c
drivers/media/dvb-frontends/tda1004x.c
drivers/media/dvb-frontends/tda10071.c
drivers/media/dvb-frontends/tda10086.c
drivers/media/dvb-frontends/tda8083.c
drivers/media/dvb-frontends/ts2020.c
drivers/media/dvb-frontends/ves1820.c
drivers/media/dvb-frontends/ves1x93.c
drivers/media/dvb-frontends/zl10353.c
drivers/media/i2c/adp1653.c
drivers/media/i2c/adv7511.c
drivers/media/i2c/adv7604.c
drivers/media/i2c/adv7842.c
drivers/media/i2c/msp3400-driver.c
drivers/media/i2c/msp3400-driver.h
drivers/media/i2c/mt9v011.c
drivers/media/i2c/mt9v032.c
drivers/media/i2c/ov2659.c
drivers/media/i2c/ov9650.c
drivers/media/i2c/s5c73m3/s5c73m3-core.c
drivers/media/i2c/s5c73m3/s5c73m3-spi.c
drivers/media/i2c/s5k5baf.c
drivers/media/i2c/saa7115.c
drivers/media/i2c/soc_camera/mt9m001.c
drivers/media/i2c/soc_camera/mt9t031.c
drivers/media/i2c/soc_camera/mt9v022.c
drivers/media/i2c/tc358743.c
drivers/media/i2c/tvp514x.c
drivers/media/i2c/tvp5150.c
drivers/media/i2c/tvp7002.c
drivers/media/i2c/vpx3220.c
drivers/media/media-device.c
drivers/media/media-devnode.c
drivers/media/media-entity.c
drivers/media/pci/b2c2/flexcop-pci.c
drivers/media/pci/bt8xx/bttv-driver.c
drivers/media/pci/bt8xx/dst.c
drivers/media/pci/bt8xx/dvb-bt8xx.c
drivers/media/pci/cx23885/cx23885-dvb.c
drivers/media/pci/cx88/cx88-dvb.c
drivers/media/pci/ddbridge/ddbridge-core.c
drivers/media/pci/netup_unidvb/netup_unidvb_core.c
drivers/media/pci/ngene/ngene-cards.c
drivers/media/pci/saa7134/saa7134-cards.c
drivers/media/pci/saa7134/saa7134-core.c
drivers/media/pci/saa7134/saa7134-dvb.c
drivers/media/pci/saa7134/saa7134-empress.c
drivers/media/pci/saa7134/saa7134-go7007.c
drivers/media/pci/saa7134/saa7134-tvaudio.c
drivers/media/pci/saa7134/saa7134-video.c
drivers/media/pci/saa7134/saa7134.h
drivers/media/pci/ttpci/av7110.c
drivers/media/pci/ttpci/budget.c
drivers/media/platform/Kconfig
drivers/media/platform/Makefile
drivers/media/platform/coda/coda-bit.c
drivers/media/platform/davinci/dm644x_ccdc.c
drivers/media/platform/exynos-gsc/gsc-m2m.c
drivers/media/platform/exynos4-is/media-dev.c
drivers/media/platform/exynos4-is/mipi-csis.c
drivers/media/platform/omap3isp/isp.c
drivers/media/platform/omap3isp/ispccdc.c
drivers/media/platform/omap3isp/isppreview.c
drivers/media/platform/omap3isp/ispvideo.c
drivers/media/platform/omap3isp/omap3isp.h
drivers/media/platform/rcar_jpu.c
drivers/media/platform/s5p-mfc/s5p_mfc_enc.c
drivers/media/platform/soc_camera/rcar_vin.c
drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
drivers/media/platform/sti/c8sectpfe/c8sectpfe-dvb.c
drivers/media/platform/ti-vpe/Makefile
drivers/media/platform/ti-vpe/cal.c [new file with mode: 0644]
drivers/media/platform/ti-vpe/cal_regs.h [new file with mode: 0644]
drivers/media/platform/vim2m.c
drivers/media/platform/vivid/vivid-osd.c
drivers/media/platform/vivid/vivid-tpg.h
drivers/media/platform/vsp1/Makefile
drivers/media/platform/vsp1/vsp1.h
drivers/media/platform/vsp1/vsp1_bru.c
drivers/media/platform/vsp1/vsp1_bru.h
drivers/media/platform/vsp1/vsp1_dl.c [new file with mode: 0644]
drivers/media/platform/vsp1/vsp1_dl.h [new file with mode: 0644]
drivers/media/platform/vsp1/vsp1_drm.c [new file with mode: 0644]
drivers/media/platform/vsp1/vsp1_drm.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_lut.c
drivers/media/platform/vsp1/vsp1_pipe.c [new file with mode: 0644]
drivers/media/platform/vsp1/vsp1_pipe.h [new file with mode: 0644]
drivers/media/platform/vsp1/vsp1_regs.h
drivers/media/platform/vsp1/vsp1_rpf.c
drivers/media/platform/vsp1/vsp1_rwpf.h
drivers/media/platform/vsp1/vsp1_sru.c
drivers/media/platform/vsp1/vsp1_uds.c
drivers/media/platform/vsp1/vsp1_video.c
drivers/media/platform/vsp1/vsp1_video.h
drivers/media/platform/vsp1/vsp1_wpf.c
drivers/media/radio/radio-si476x.c
drivers/media/radio/tea575x.c
drivers/media/radio/wl128x/fmdrv_common.c
drivers/media/rc/nuvoton-cir.c
drivers/media/rc/nuvoton-cir.h
drivers/media/rc/rc-core-priv.h
drivers/media/rc/rc-ir-raw.c
drivers/media/rc/rc-main.c
drivers/media/tuners/m88rs6000t.c
drivers/media/tuners/r820t.c
drivers/media/tuners/si2157.c
drivers/media/tuners/si2157.h
drivers/media/tuners/si2157_priv.h
drivers/media/tuners/tuner-xc2028.c
drivers/media/usb/as102/as102_drv.h
drivers/media/usb/as102/as102_usb_drv.c
drivers/media/usb/au0828/au0828-core.c
drivers/media/usb/au0828/au0828-dvb.c
drivers/media/usb/au0828/au0828-video.c
drivers/media/usb/au0828/au0828.h
drivers/media/usb/b2c2/flexcop-usb.c
drivers/media/usb/cpia2/cpia2_core.c
drivers/media/usb/cx231xx/cx231xx-417.c
drivers/media/usb/cx231xx/cx231xx-audio.c
drivers/media/usb/cx231xx/cx231xx-cards.c
drivers/media/usb/cx231xx/cx231xx-dvb.c
drivers/media/usb/cx231xx/cx231xx-video.c
drivers/media/usb/cx231xx/cx231xx.h
drivers/media/usb/dvb-usb-v2/af9035.c
drivers/media/usb/dvb-usb-v2/af9035.h
drivers/media/usb/dvb-usb-v2/dvb_usb.h
drivers/media/usb/dvb-usb-v2/dvb_usb_common.h
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c
drivers/media/usb/dvb-usb-v2/dvbsky.c
drivers/media/usb/dvb-usb-v2/mxl111sf-demod.c
drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.c
drivers/media/usb/dvb-usb-v2/mxl111sf-tuner.h
drivers/media/usb/dvb-usb-v2/mxl111sf.c
drivers/media/usb/dvb-usb-v2/rtl28xxu.c
drivers/media/usb/dvb-usb-v2/usb_urb.c
drivers/media/usb/dvb-usb/a800.c
drivers/media/usb/dvb-usb/af9005-fe.c
drivers/media/usb/dvb-usb/cxusb.c
drivers/media/usb/dvb-usb/dib0700_core.c
drivers/media/usb/dvb-usb/dib0700_devices.c
drivers/media/usb/dvb-usb/dibusb-common.c
drivers/media/usb/dvb-usb/dibusb-mb.c
drivers/media/usb/dvb-usb/dibusb-mc.c
drivers/media/usb/dvb-usb/dibusb.h
drivers/media/usb/dvb-usb/digitv.c
drivers/media/usb/dvb-usb/dtt200u-fe.c
drivers/media/usb/dvb-usb/dtt200u.c
drivers/media/usb/dvb-usb/dtt200u.h
drivers/media/usb/dvb-usb/dvb-usb-common.h
drivers/media/usb/dvb-usb/dvb-usb-dvb.c
drivers/media/usb/dvb-usb/dvb-usb-firmware.c
drivers/media/usb/dvb-usb/dvb-usb-i2c.c
drivers/media/usb/dvb-usb/dvb-usb-init.c
drivers/media/usb/dvb-usb/dvb-usb-remote.c
drivers/media/usb/dvb-usb/dvb-usb-urb.c
drivers/media/usb/dvb-usb/dvb-usb.h
drivers/media/usb/dvb-usb/dw2102.c
drivers/media/usb/dvb-usb/friio-fe.c
drivers/media/usb/dvb-usb/nova-t-usb2.c
drivers/media/usb/dvb-usb/technisat-usb2.c
drivers/media/usb/dvb-usb/ttusb2.c
drivers/media/usb/dvb-usb/umt-010.c
drivers/media/usb/dvb-usb/usb-urb.c
drivers/media/usb/dvb-usb/vp702x-fe.c
drivers/media/usb/dvb-usb/vp702x.c
drivers/media/usb/dvb-usb/vp7045-fe.c
drivers/media/usb/dvb-usb/vp7045.c
drivers/media/usb/dvb-usb/vp7045.h
drivers/media/usb/em28xx/em28xx-camera.c
drivers/media/usb/em28xx/em28xx-cards.c
drivers/media/usb/em28xx/em28xx-dvb.c
drivers/media/usb/em28xx/em28xx-video.c
drivers/media/usb/em28xx/em28xx.h
drivers/media/usb/go7007/go7007-priv.h
drivers/media/usb/go7007/go7007-usb.c
drivers/media/usb/hdpvr/hdpvr-core.c
drivers/media/usb/hdpvr/hdpvr-video.c
drivers/media/usb/msi2500/msi2500.c
drivers/media/usb/pvrusb2/pvrusb2-context.c
drivers/media/usb/pwc/pwc-if.c
drivers/media/usb/siano/smsusb.c
drivers/media/usb/stk1160/stk1160-video.c
drivers/media/usb/usbtv/usbtv-video.c
drivers/media/usb/usbtv/usbtv.h
drivers/media/usb/usbvision/usbvision-video.c
drivers/media/v4l2-core/Kconfig
drivers/media/v4l2-core/Makefile
drivers/media/v4l2-core/tuner-core.c
drivers/media/v4l2-core/v4l2-async.c
drivers/media/v4l2-core/v4l2-compat-ioctl32.c
drivers/media/v4l2-core/v4l2-ctrls.c
drivers/media/v4l2-core/v4l2-dv-timings.c
drivers/media/v4l2-core/v4l2-ioctl.c
drivers/media/v4l2-core/v4l2-mc.c [new file with mode: 0644]
drivers/media/v4l2-core/v4l2-of.c
drivers/media/v4l2-core/videobuf2-core.c
drivers/media/v4l2-core/videobuf2-dvb.c
drivers/mfd/db8500-prcmu.c
drivers/misc/cxl/pci.c
drivers/misc/mei/main.c
drivers/mmc/card/block.c
drivers/mmc/host/mmc_spi.c
drivers/mmc/host/omap_hsmmc.c
drivers/mmc/host/pxamci.c
drivers/mmc/host/sdhci-acpi.c
drivers/mmc/host/sdhci-of-at91.c
drivers/mmc/host/sdhci-pci-core.c
drivers/mmc/host/sdhci.c
drivers/mmc/host/sdhci.h
drivers/mmc/host/sh_mmcif.c
drivers/mtd/ubi/upd.c
drivers/net/bonding/bond_main.c
drivers/net/can/spi/mcp251x.c
drivers/net/can/usb/ems_usb.c
drivers/net/can/usb/gs_usb.c
drivers/net/dsa/mv88e6352.c
drivers/net/dsa/mv88e6xxx.c
drivers/net/ethernet/3com/3c59x.c
drivers/net/ethernet/8390/pcnet_cs.c
drivers/net/ethernet/agere/et131x.c
drivers/net/ethernet/altera/altera_tse_main.c
drivers/net/ethernet/amd/am79c961a.c
drivers/net/ethernet/amd/lance.c
drivers/net/ethernet/arc/emac_main.c
drivers/net/ethernet/aurora/nb8800.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_reg.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
drivers/net/ethernet/broadcom/genet/bcmgenet.c
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/brocade/bna/bna_tx_rx.c
drivers/net/ethernet/cavium/liquidio/lio_main.c
drivers/net/ethernet/cavium/liquidio/octeon_droq.c
drivers/net/ethernet/cavium/thunder/nic.h
drivers/net/ethernet/cavium/thunder/nic_main.c
drivers/net/ethernet/cavium/thunder/nic_reg.h
drivers/net/ethernet/cavium/thunder/nicvf_main.c
drivers/net/ethernet/cavium/thunder/nicvf_queues.c
drivers/net/ethernet/cavium/thunder/nicvf_queues.h
drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h
drivers/net/ethernet/cisco/enic/enic.h
drivers/net/ethernet/cisco/enic/vnic_dev.c
drivers/net/ethernet/davicom/dm9000.c
drivers/net/ethernet/emulex/benet/be.h
drivers/net/ethernet/emulex/benet/be_cmds.h
drivers/net/ethernet/emulex/benet/be_main.c
drivers/net/ethernet/ethoc.c
drivers/net/ethernet/freescale/fman/fman.c
drivers/net/ethernet/freescale/gianfar.c
drivers/net/ethernet/fujitsu/fmvj18x_cs.c
drivers/net/ethernet/hisilicon/Kconfig
drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h
drivers/net/ethernet/hisilicon/hns/hns_dsaf_reg.h
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c
drivers/net/ethernet/ibm/ibmveth.c
drivers/net/ethernet/ibm/ibmvnic.c
drivers/net/ethernet/ibm/ibmvnic.h
drivers/net/ethernet/jme.c
drivers/net/ethernet/marvell/mvneta.c
drivers/net/ethernet/marvell/mvpp2.c
drivers/net/ethernet/mellanox/mlx4/catas.c
drivers/net/ethernet/mellanox/mlx4/cmd.c
drivers/net/ethernet/mellanox/mlx4/cq.c
drivers/net/ethernet/mellanox/mlx4/en_clock.c
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/en_port.c
drivers/net/ethernet/mellanox/mlx4/en_resources.c
drivers/net/ethernet/mellanox/mlx4/en_tx.c
drivers/net/ethernet/mellanox/mlx4/eq.c
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlx4/pd.c
drivers/net/ethernet/mellanox/mlx4/port.c
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en_clock.c
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c
drivers/net/ethernet/mellanox/mlxsw/pci.c
drivers/net/ethernet/mellanox/mlxsw/port.h
drivers/net/ethernet/mellanox/mlxsw/reg.h
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
drivers/net/ethernet/moxa/moxart_ether.c
drivers/net/ethernet/qualcomm/qca_spi.c
drivers/net/ethernet/realtek/r8169.c
drivers/net/ethernet/renesas/ravb_main.c
drivers/net/ethernet/renesas/sh_eth.c
drivers/net/ethernet/smsc/smc91x.c
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
drivers/net/ethernet/synopsys/dwc_eth_qos.c
drivers/net/ethernet/ti/cpsw-phy-sel.c
drivers/net/ethernet/ti/netcp_core.c
drivers/net/geneve.c
drivers/net/hyperv/netvsc_drv.c
drivers/net/phy/bcm7xxx.c
drivers/net/phy/marvell.c
drivers/net/phy/micrel.c
drivers/net/phy/phy_device.c
drivers/net/ppp/ppp_generic.c
drivers/net/ppp/pppoe.c
drivers/net/usb/Kconfig
drivers/net/usb/Makefile
drivers/net/usb/ax88172a.c
drivers/net/usb/cdc_ncm.c
drivers/net/usb/qmi_wwan.c
drivers/net/usb/usbnet.c
drivers/net/vmxnet3/vmxnet3_defs.h
drivers/net/vmxnet3/vmxnet3_drv.c
drivers/net/vmxnet3/vmxnet3_int.h
drivers/net/vrf.c
drivers/net/vxlan.c
drivers/net/wan/dscc4.c
drivers/net/wireless/intel/iwlwifi/Kconfig
drivers/net/wireless/intel/iwlwifi/iwl-8000.c
drivers/net/wireless/intel/iwlwifi/iwl-drv.c
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
drivers/net/wireless/intel/iwlwifi/mvm/scan.c
drivers/net/wireless/intel/iwlwifi/mvm/tx.c
drivers/net/wireless/intel/iwlwifi/pcie/internal.h
drivers/net/wireless/intel/iwlwifi/pcie/rx.c
drivers/net/wireless/intel/iwlwifi/pcie/trans.c
drivers/net/wireless/realtek/rtlwifi/rc.c
drivers/net/wireless/ti/wlcore/io.c
drivers/net/wireless/ti/wlcore/io.h
drivers/nvdimm/bus.c
drivers/nvdimm/pmem.c
drivers/nvme/host/Kconfig
drivers/nvme/host/core.c
drivers/nvme/host/lightnvm.c
drivers/nvme/host/nvme.h
drivers/nvme/host/pci.c
drivers/nvmem/core.c
drivers/nvmem/qfprom.c
drivers/of/irq.c
drivers/of/of_mdio.c
drivers/pci/host/Kconfig
drivers/pci/host/pci-keystone-dw.c
drivers/pci/host/pci-layerscape.c
drivers/pci/host/pcie-iproc.c
drivers/pci/pci.c
drivers/pci/pcie/aer/aerdrv.c
drivers/pci/pcie/aer/aerdrv.h
drivers/pci/pcie/aer/aerdrv_core.c
drivers/pci/xen-pcifront.c
drivers/phy/Kconfig
drivers/phy/phy-core.c
drivers/phy/phy-twl4030-usb.c
drivers/pinctrl/mediatek/pinctrl-mtk-common.c
drivers/pinctrl/mvebu/pinctrl-mvebu.c
drivers/pinctrl/nomadik/pinctrl-abx500.c
drivers/pinctrl/pxa/pinctrl-pxa2xx.c
drivers/pinctrl/samsung/pinctrl-samsung.c
drivers/pinctrl/sunxi/pinctrl-sun8i-h3.c
drivers/platform/x86/intel-hid.c
drivers/platform/x86/intel_scu_ipcutil.c
drivers/power/bq27xxx_battery_i2c.c
drivers/s390/block/dasd.c
drivers/s390/block/dasd_alias.c
drivers/s390/block/dasd_diag.c
drivers/scsi/device_handler/scsi_dh_rdac.c
drivers/scsi/hisi_sas/Kconfig
drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
drivers/scsi/ipr.c
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_isr.c
drivers/scsi/qla2xxx/qla_mid.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla2xxx/qla_target.c
drivers/scsi/qla2xxx/qla_target.h
drivers/scsi/qla2xxx/qla_tmpl.c
drivers/scsi/qla2xxx/tcm_qla2xxx.c
drivers/scsi/scsi_devinfo.c
drivers/scsi/scsi_lib.c
drivers/scsi/scsi_sysfs.c
drivers/scsi/sd.c
drivers/scsi/storvsc_drv.c
drivers/sh/pm_runtime.c
drivers/spi/spi-atmel.c
drivers/spi/spi-bcm2835aux.c
drivers/spi/spi-fsl-espi.c
drivers/spi/spi-imx.c
drivers/spi/spi-loopback-test.c
drivers/spi/spi-omap2-mcspi.c
drivers/spi/spi-rockchip.c
drivers/ssb/Kconfig
drivers/staging/media/Kconfig
drivers/staging/media/Makefile
drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h
drivers/staging/media/davinci_vpfe/vpfe_video.c
drivers/staging/media/lirc/lirc_parallel.c
drivers/staging/media/timb/Kconfig [new file with mode: 0644]
drivers/staging/media/timb/Makefile [new file with mode: 0644]
drivers/staging/media/timb/timblogiw.c [moved from drivers/media/platform/timblogiw.c with 100% similarity]
drivers/target/target_core_configfs.c
drivers/target/target_core_device.c
drivers/target/target_core_file.c
drivers/target/target_core_iblock.c
drivers/target/target_core_internal.h
drivers/target/target_core_tmr.c
drivers/target/target_core_transport.c
drivers/target/target_core_user.c
drivers/thermal/Kconfig
drivers/thermal/cpu_cooling.c
drivers/thermal/of-thermal.c
drivers/thermal/rcar_thermal.c
drivers/thermal/spear_thermal.c
drivers/tty/pty.c
drivers/tty/serial/8250/8250_pci.c
drivers/tty/serial/omap-serial.c
drivers/tty/tty_io.c
drivers/tty/tty_mutex.c
drivers/usb/chipidea/ci_hdrc_pci.c
drivers/usb/chipidea/debug.c
drivers/usb/chipidea/otg.c
drivers/usb/core/hub.c
drivers/usb/dwc2/Kconfig
drivers/usb/dwc2/core.c
drivers/usb/dwc2/hcd_ddma.c
drivers/usb/dwc2/hcd_intr.c
drivers/usb/dwc3/core.h
drivers/usb/dwc3/ep0.c
drivers/usb/dwc3/gadget.c
drivers/usb/gadget/legacy/inode.c
drivers/usb/gadget/udc/fsl_qe_udc.c
drivers/usb/gadget/udc/net2280.h
drivers/usb/gadget/udc/udc-core.c
drivers/usb/musb/musb_host.c
drivers/usb/phy/phy-msm-usb.c
drivers/usb/serial/Kconfig
drivers/usb/serial/Makefile
drivers/usb/serial/cp210x.c
drivers/usb/serial/mxu11x0.c [deleted file]
drivers/usb/serial/option.c
drivers/usb/serial/qcserial.c
drivers/vfio/pci/vfio_pci.c
drivers/vfio/platform/vfio_platform_common.c
drivers/vfio/vfio_iommu_type1.c
drivers/vhost/vhost.c
drivers/video/console/fbcon.c
drivers/video/fbdev/da8xx-fb.c
drivers/video/fbdev/exynos/s6e8ax0.c
drivers/video/fbdev/imxfb.c
drivers/video/fbdev/mmp/hw/mmp_ctrl.c
drivers/video/fbdev/ocfb.c
drivers/video/fbdev/omap2/omapfb/dss/dispc.h
drivers/video/fbdev/omap2/omapfb/dss/dss.h
drivers/virtio/virtio_pci_modern.c
drivers/watchdog/Kconfig
drivers/watchdog/Makefile
drivers/watchdog/sun4v_wdt.c [new file with mode: 0644]
drivers/xen/xen-pciback/pciback_ops.c
drivers/xen/xen-scsiback.c
drivers/xen/xenbus/xenbus_dev_frontend.c
fs/affs/file.c
fs/binfmt_elf.c
fs/block_dev.c
fs/btrfs/backref.c
fs/btrfs/compression.c
fs/btrfs/delayed-inode.c
fs/btrfs/delayed-inode.h
fs/btrfs/extent_io.c
fs/btrfs/extent_io.h
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/root-tree.c
fs/ceph/addr.c
fs/ceph/caps.c
fs/ceph/inode.c
fs/ceph/mds_client.c
fs/ceph/mds_client.h
fs/ceph/super.h
fs/cifs/cifs_dfs_ref.c
fs/cifs/cifsencrypt.c
fs/cifs/cifsfs.c
fs/cifs/cifsfs.h
fs/cifs/cifssmb.c
fs/cifs/connect.c
fs/cifs/smb2pdu.c
fs/dax.c
fs/dcache.c
fs/devpts/inode.c
fs/direct-io.c
fs/efivarfs/file.c
fs/efivarfs/inode.c
fs/efivarfs/internal.h
fs/efivarfs/super.c
fs/ext2/file.c
fs/ext2/inode.c
fs/ext4/balloc.c
fs/ext4/crypto.c
fs/ext4/dir.c
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/file.c
fs/ext4/ialloc.c
fs/ext4/inode.c
fs/ext4/ioctl.c
fs/ext4/mballoc.c
fs/ext4/move_extent.c
fs/ext4/namei.c
fs/ext4/resize.c
fs/fs-writeback.c
fs/hpfs/namei.c
fs/inode.c
fs/jffs2/README.Locking
fs/jffs2/build.c
fs/jffs2/dir.c
fs/jffs2/file.c
fs/jffs2/gc.c
fs/jffs2/nodelist.h
fs/namei.c
fs/ncpfs/dir.c
fs/nfs/blocklayout/extent_tree.c
fs/nfs/nfs42proc.c
fs/nfs/nfs4proc.c
fs/nfs/pnfs.c
fs/notify/mark.c
fs/ocfs2/aops.c
fs/ocfs2/mmap.c
fs/overlayfs/dir.c
fs/overlayfs/inode.c
fs/overlayfs/super.c
fs/pnode.c
fs/read_write.c
fs/super.c
fs/userfaultfd.c
fs/xattr.c
fs/xfs/xfs_aops.c
fs/xfs/xfs_aops.h
fs/xfs/xfs_bmap_util.c
fs/xfs/xfs_log_recover.c
include/asm-generic/cputime_nsecs.h
include/asm-generic/pgtable.h
include/drm/drm_atomic_helper.h
include/drm/drm_crtc.h
include/drm/drm_crtc_helper.h
include/drm/drm_mipi_dsi.h
include/drm/drm_of.h
include/drm/exynos_drm.h [deleted file]
include/drm/i915_pciids.h
include/dt-bindings/clock/tegra210-car.h
include/dt-bindings/media/tvp5150.h [moved from include/media/i2c/tvp5150.h with 87% similarity]
include/linux/ata.h
include/linux/bio.h
include/linux/blkdev.h
include/linux/ceph/ceph_features.h
include/linux/cgroup-defs.h
include/linux/compiler.h
include/linux/cpuset.h
include/linux/dax.h
include/linux/dcache.h
include/linux/devpts_fs.h
include/linux/dma-mapping.h
include/linux/efi.h
include/linux/fsnotify_backend.h
include/linux/ftrace.h
include/linux/intel-iommu.h
include/linux/kasan.h
include/linux/libata.h
include/linux/libnvdimm.h
include/linux/lightnvm.h
include/linux/list.h
include/linux/lockdep.h
include/linux/mlx4/device.h
include/linux/mlx5/mlx5_ifc.h
include/linux/module.h
include/linux/netdevice.h
include/linux/nfs_fs.h
include/linux/nfs_xdr.h
include/linux/pci.h
include/linux/perf_event.h
include/linux/pfn.h
include/linux/pfn_t.h
include/linux/power/bq27xxx_battery.h
include/linux/random.h
include/linux/skbuff.h
include/linux/soc/ti/knav_dma.h
include/linux/stmmac.h
include/linux/trace_events.h
include/linux/tracepoint.h
include/linux/ucs2_string.h
include/linux/workqueue.h
include/linux/writeback.h
include/media/media-device.h
include/media/rc-core.h
include/media/tuner.h
include/media/v4l2-ctrls.h
include/media/v4l2-mc.h [new file with mode: 0644]
include/media/v4l2-subdev.h
include/media/videobuf2-dvb.h
include/media/vsp1.h [new file with mode: 0644]
include/net/af_unix.h
include/net/inet_connection_sock.h
include/net/ip_fib.h
include/net/ip_tunnels.h
include/net/iw_handler.h
include/net/scm.h
include/net/tcp.h
include/sound/hdaudio.h
include/target/target_core_backend.h
include/target/target_core_base.h
include/trace/events/asoc.h
include/uapi/drm/drm_mode.h
include/uapi/drm/exynos_drm.h
include/uapi/drm/i915_drm.h
include/uapi/drm/msm_drm.h
include/uapi/linux/bpf.h
include/uapi/linux/media.h
include/uapi/linux/ndctl.h
include/uapi/linux/v4l2-common.h
include/uapi/linux/v4l2-controls.h
include/uapi/linux/videodev2.h
include/video/omap-panel-data.h
include/video/omapdss.h
ipc/shm.c
kernel/bpf/verifier.c
kernel/cgroup.c
kernel/cpuset.c
kernel/events/core.c
kernel/locking/lockdep.c
kernel/memremap.c
kernel/module.c
kernel/resource.c
kernel/sched/core.c
kernel/sched/deadline.c
kernel/trace/ftrace.c
kernel/trace/trace_events.c
kernel/trace/trace_events_filter.c
kernel/trace/trace_stack.c
kernel/workqueue.c
lib/Kconfig.debug
lib/Kconfig.ubsan
lib/klist.c
lib/list_debug.c
lib/scatterlist.c
lib/ucs2_string.c
lib/vsprintf.c
mm/backing-dev.c
mm/filemap.c
mm/huge_memory.c
mm/hugetlb.c
mm/kasan/kasan.c
mm/memory.c
mm/mempolicy.c
mm/migrate.c
mm/mmap.c
mm/mprotect.c
mm/mremap.c
mm/pgtable-generic.c
mm/slab.c
mm/slab.h
mm/slab_common.c
mm/slob.c
mm/slub.c
net/appletalk/ddp.c
net/batman-adv/gateway_client.c
net/batman-adv/hard-interface.c
net/batman-adv/translation-table.c
net/bluetooth/hci_core.c
net/bridge/br_fdb.c
net/bridge/br_mdb.c
net/caif/cfrfml.c
net/ceph/messenger.c
net/ceph/osd_client.c
net/core/dev.c
net/core/filter.c
net/core/flow_dissector.c
net/core/rtnetlink.c
net/core/scm.c
net/core/skbuff.c
net/core/sysctl_net_core.c
net/dccp/ipv4.c
net/dccp/ipv6.c
net/dsa/slave.c
net/ipv4/devinet.c
net/ipv4/igmp.c
net/ipv4/inet_connection_sock.c
net/ipv4/ip_gre.c
net/ipv4/ip_output.c
net/ipv4/ip_sockglue.c
net/ipv4/ip_tunnel.c
net/ipv4/ping.c
net/ipv4/raw.c
net/ipv4/route.c
net/ipv4/tcp.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_metrics.c
net/ipv4/tcp_minisocks.c
net/ipv4/udp.c
net/ipv4/udp_tunnel.c
net/ipv6/addrconf.c
net/ipv6/exthdrs_core.c
net/ipv6/ip6_flowlabel.c
net/ipv6/ip6_gre.c
net/ipv6/ip6_tunnel.c
net/ipv6/mcast.c
net/ipv6/netfilter/nf_nat_masquerade_ipv6.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c
net/l2tp/l2tp_netlink.c
net/mac80211/agg-rx.c
net/mac80211/ieee80211_i.h
net/mac80211/rc80211_minstrel.c
net/mac80211/rc80211_minstrel_ht.c
net/mac80211/rx.c
net/netfilter/Kconfig
net/netfilter/nf_conntrack_core.c
net/netfilter/nfnetlink.c
net/netfilter/nfnetlink_cttimeout.c
net/netfilter/nft_counter.c
net/netfilter/xt_TEE.c
net/openvswitch/vport-vxlan.c
net/sched/act_ipt.c
net/sched/sch_api.c
net/sctp/ipv6.c
net/sctp/proc.c
net/sctp/protocol.c
net/sctp/socket.c
net/sunrpc/auth_gss/auth_gss.c
net/sunrpc/cache.c
net/sunrpc/xprtrdma/backchannel.c
net/switchdev/switchdev.c
net/tipc/link.c
net/tipc/node.c
net/tipc/socket.c
net/tipc/subscr.c
net/unix/af_unix.c
net/unix/diag.c
net/unix/garbage.c
net/vmw_vsock/af_vsock.c
net/wireless/core.c
net/wireless/nl80211.c
net/wireless/sme.c
net/wireless/wext-core.c
scripts/prune-kernel [new file with mode: 0755]
security/integrity/evm/evm_main.c
security/selinux/hooks.c
security/selinux/nlmsgtab.c
sound/core/control_compat.c
sound/core/pcm_compat.c
sound/core/pcm_native.c
sound/core/rawmidi_compat.c
sound/core/seq/oss/seq_oss.c
sound/core/seq/oss/seq_oss_device.h
sound/core/seq/oss/seq_oss_init.c
sound/core/seq/seq_memory.c
sound/core/seq/seq_ports.c
sound/core/timer.c
sound/core/timer_compat.c
sound/drivers/dummy.c
sound/firewire/digi00x/amdtp-dot.c
sound/firewire/tascam/tascam-transaction.c
sound/firewire/tascam/tascam.c
sound/firewire/tascam/tascam.h
sound/hda/hdac_controller.c
sound/pci/hda/hda_controller.c
sound/pci/hda/hda_generic.c
sound/pci/hda/hda_intel.c
sound/pci/hda/hda_jack.c
sound/pci/hda/hda_jack.h
sound/pci/hda/patch_ca0132.c
sound/pci/hda/patch_hdmi.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c
sound/pci/rme9652/hdsp.c
sound/pci/rme9652/hdspm.c
sound/soc/amd/acp-pcm-dma.c
sound/soc/codecs/ab8500-codec.c
sound/soc/codecs/adau17x1.h
sound/soc/codecs/arizona.c
sound/soc/codecs/cs42l51.c
sound/soc/codecs/da732x.c
sound/soc/codecs/max98088.c
sound/soc/codecs/max98095.c
sound/soc/codecs/rt286.c
sound/soc/codecs/rt5645.c
sound/soc/codecs/rt5659.c
sound/soc/codecs/rt5659.h
sound/soc/codecs/sigmadsp-i2c.c
sound/soc/codecs/tlv320dac33.c
sound/soc/codecs/wl1273.c
sound/soc/codecs/wm5110.c
sound/soc/codecs/wm8753.c
sound/soc/codecs/wm8904.c
sound/soc/codecs/wm8958-dsp2.c
sound/soc/codecs/wm8960.c
sound/soc/codecs/wm8983.c
sound/soc/codecs/wm8985.c
sound/soc/codecs/wm8994.c
sound/soc/codecs/wm8996.c
sound/soc/codecs/wm9081.c
sound/soc/codecs/wm9713.c
sound/soc/codecs/wm_adsp.c
sound/soc/dwc/designware_i2s.c
sound/soc/fsl/imx-spdif.c
sound/soc/generic/simple-card.c
sound/soc/intel/Kconfig
sound/soc/intel/atom/sst-mfld-platform-pcm.c
sound/soc/intel/boards/cht_bsw_rt5645.c
sound/soc/intel/boards/mfld_machine.c
sound/soc/intel/boards/skl_rt286.c
sound/soc/intel/common/Makefile
sound/soc/intel/common/sst-acpi.c
sound/soc/intel/common/sst-match-acpi.c
sound/soc/intel/skylake/skl-messages.c
sound/soc/intel/skylake/skl-pcm.c
sound/soc/intel/skylake/skl-topology.c
sound/soc/intel/skylake/skl.c
sound/soc/mediatek/Kconfig
sound/soc/mxs/mxs-saif.c
sound/soc/omap/n810.c
sound/soc/omap/rx51.c
sound/soc/pxa/corgi.c
sound/soc/pxa/magician.c
sound/soc/pxa/poodle.c
sound/soc/pxa/spitz.c
sound/soc/pxa/tosa.c
sound/soc/qcom/lpass-cpu.c
sound/soc/qcom/lpass-platform.c
sound/soc/samsung/i2s.c
sound/soc/soc-dapm.c
sound/soc/soc-pcm.c
sound/usb/midi.c
sound/usb/quirks.c
tools/perf/util/intel-pt.c
tools/perf/util/parse-events.c
tools/perf/util/probe-finder.c
tools/perf/util/probe-finder.h
tools/perf/util/stat.c
tools/testing/nvdimm/test/nfit.c
tools/testing/selftests/efivarfs/efivarfs.sh
tools/testing/selftests/efivarfs/open-unlink.c
tools/testing/selftests/ftrace/test.d/instances/instance.tc
virt/kvm/arm/arch_timer.c
virt/kvm/arm/vgic.c
virt/kvm/async_pf.c
virt/kvm/kvm_main.c

index cdd8b24..cc303a2 100644 (file)
@@ -229,6 +229,7 @@ X!Isound/sound_firmware.c
 !Iinclude/media/v4l2-dv-timings.h
 !Iinclude/media/v4l2-event.h
 !Iinclude/media/v4l2-flash-led-class.h
+!Iinclude/media/v4l2-mc.h
 !Iinclude/media/v4l2-mediabus.h
 !Iinclude/media/v4l2-mem2mem.h
 !Iinclude/media/v4l2-of.h
index fe6b36a..1692c4d 100644 (file)
@@ -1816,7 +1816,7 @@ void intel_crt_init(struct drm_device *dev)
        <td valign="top" >Description/Restrictions</td>
        </tr>
        <tr>
-       <td rowspan="37" valign="top" >DRM</td>
+       <td rowspan="42" valign="top" >DRM</td>
        <td valign="top" >Generic</td>
        <td valign="top" >“rotation”</td>
        <td valign="top" >BITMASK</td>
@@ -2068,7 +2068,7 @@ void intel_crt_init(struct drm_device *dev)
        <td valign="top" >property to suggest an Y offset for a connector</td>
        </tr>
        <tr>
-       <td rowspan="3" valign="top" >Optional</td>
+       <td rowspan="8" valign="top" >Optional</td>
        <td valign="top" >“scaling mode”</td>
        <td valign="top" >ENUM</td>
        <td valign="top" >{ "None", "Full", "Center", "Full aspect" }</td>
@@ -2092,6 +2092,61 @@ void intel_crt_init(struct drm_device *dev)
        <td valign="top" >TBD</td>
        </tr>
        <tr>
+       <td valign="top" >“DEGAMMA_LUT”</td>
+       <td valign="top" >BLOB</td>
+       <td valign="top" >0</td>
+       <td valign="top" >CRTC</td>
+       <td valign="top" >DRM property to set the degamma lookup table
+               (LUT) mapping pixel data from the framebuffer before it is
+               given to the transformation matrix. The data is an interpreted
+               as an array of struct drm_color_lut elements. Hardware might
+               choose not to use the full precision of the LUT elements nor
+               use all the elements of the LUT (for example the hardware
+               might choose to interpolate between LUT[0] and LUT[4]). </td>
+       </tr>
+       <tr>
+       <td valign="top" >“DEGAMMA_LUT_SIZE”</td>
+       <td valign="top" >RANGE | IMMUTABLE</td>
+       <td valign="top" >Min=0, Max=UINT_MAX</td>
+       <td valign="top" >CRTC</td>
+       <td valign="top" >DRM property to gives the size of the lookup
+               table to be set on the DEGAMMA_LUT property (the size depends
+               on the underlying hardware).</td>
+       </tr>
+       <tr>
+       <td valign="top" >“CTM”</td>
+       <td valign="top" >BLOB</td>
+       <td valign="top" >0</td>
+       <td valign="top" >CRTC</td>
+       <td valign="top" >DRM property to set the current
+               transformation matrix (CTM) apply to pixel data after the
+               lookup through the degamma LUT and before the lookup through
+               the gamma LUT. The data is an interpreted as a struct
+               drm_color_ctm.</td>
+       </tr>
+       <tr>
+       <td valign="top" >“GAMMA_LUT”</td>
+       <td valign="top" >BLOB</td>
+       <td valign="top" >0</td>
+       <td valign="top" >CRTC</td>
+       <td valign="top" >DRM property to set the gamma lookup table
+               (LUT) mapping pixel data after to the transformation matrix to
+               data sent to the connector. The data is an interpreted as an
+               array of struct drm_color_lut elements. Hardware might choose
+               not to use the full precision of the LUT elements nor use all
+               the elements of the LUT (for example the hardware might choose
+               to interpolate between LUT[0] and LUT[4]).</td>
+       </tr>
+       <tr>
+       <td valign="top" >“GAMMA_LUT_SIZE”</td>
+       <td valign="top" >RANGE | IMMUTABLE</td>
+       <td valign="top" >Min=0, Max=UINT_MAX</td>
+       <td valign="top" >CRTC</td>
+       <td valign="top" >DRM property to gives the size of the lookup
+               table to be set on the GAMMA_LUT property (the size depends on
+               the underlying hardware).</td>
+       </tr>
+       <tr>
        <td rowspan="20" valign="top" >i915</td>
        <td rowspan="2" valign="top" >Generic</td>
        <td valign="top" >"Broadcast RGB"</td>
index f13a429..361040e 100644 (file)
@@ -2330,6 +2330,14 @@ vertical search range for motion estimation module in video encoder.</entry>
              </row>
 
              <row><entry></entry></row>
+             <row id="v4l2-mpeg-video-force-key-frame">
+               <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME</constant>&nbsp;</entry>
+               <entry>button</entry>
+             </row><row><entry spanname="descr">Force a key frame for the next queued buffer. Applicable to encoders.
+This is a general, codec-agnostic keyframe control.</entry>
+             </row>
+
+             <row><entry></entry></row>
              <row>
                <entry spanname="id"><constant>V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE</constant>&nbsp;</entry>
                <entry>integer</entry>
@@ -5070,6 +5078,46 @@ interface and may change in the future.</para>
            </entry>
          </row>
          <row>
+           <entry spanname="id"><constant>V4L2_CID_DV_TX_IT_CONTENT_TYPE</constant></entry>
+           <entry id="v4l2-dv-content-type">enum v4l2_dv_it_content_type</entry>
+         </row>
+         <row><entry spanname="descr">Configures the IT Content Type
+           of the transmitted video. This information is sent over HDMI and DisplayPort connectors
+           as part of the AVI InfoFrame. The term 'IT Content' is used for content that originates
+           from a computer as opposed to content from a TV broadcast or an analog source. The
+           enum&nbsp;v4l2_dv_it_content_type defines the possible content types:</entry>
+         </row>
+         <row>
+           <entrytbl spanname="descr" cols="2">
+             <tbody valign="top">
+               <row>
+                 <entry><constant>V4L2_DV_IT_CONTENT_TYPE_GRAPHICS</constant>&nbsp;</entry>
+                 <entry>Graphics content. Pixel data should be passed unfiltered and without
+                 analog reconstruction.</entry>
+               </row>
+               <row>
+                 <entry><constant>V4L2_DV_IT_CONTENT_TYPE_PHOTO</constant>&nbsp;</entry>
+                 <entry>Photo content. The content is derived from digital still pictures.
+                 The content should be passed through with minimal scaling and picture
+                 enhancements.</entry>
+               </row>
+               <row>
+                 <entry><constant>V4L2_DV_IT_CONTENT_TYPE_CINEMA</constant>&nbsp;</entry>
+                 <entry>Cinema content.</entry>
+               </row>
+               <row>
+                 <entry><constant>V4L2_DV_IT_CONTENT_TYPE_GAME</constant>&nbsp;</entry>
+                 <entry>Game content. Audio and video latency should be minimized.</entry>
+               </row>
+               <row>
+                 <entry><constant>V4L2_DV_IT_CONTENT_TYPE_NO_ITC</constant>&nbsp;</entry>
+                 <entry>No IT Content information is available and the ITC bit in the AVI
+                 InfoFrame is set to 0.</entry>
+               </row>
+             </tbody>
+           </entrytbl>
+         </row>
+         <row>
            <entry spanname="id"><constant>V4L2_CID_DV_RX_POWER_PRESENT</constant></entry>
            <entry>bitmask</entry>
          </row>
@@ -5098,6 +5146,16 @@ interface and may change in the future.</para>
            This control is applicable to VGA, DVI-A/D, HDMI and DisplayPort connectors.
            </entry>
          </row>
+         <row>
+           <entry spanname="id"><constant>V4L2_CID_DV_RX_IT_CONTENT_TYPE</constant></entry>
+           <entry>enum v4l2_dv_it_content_type</entry>
+         </row>
+         <row><entry spanname="descr">Reads the IT Content Type
+           of the received video. This information is sent over HDMI and DisplayPort connectors
+           as part of the AVI InfoFrame. The term 'IT Content' is used for content that originates
+           from a computer as opposed to content from a TV broadcast or an analog source. See
+           <constant>V4L2_CID_DV_TX_IT_CONTENT_TYPE</constant> for the available content types.</entry>
+         </row>
          <row><entry></entry></row>
        </tbody>
       </tgroup>
index 63152ab..e0d49fa 100644 (file)
@@ -48,9 +48,6 @@
 
   <refsect1>
     <title>Description</title>
-
-    <para><emphasis role="bold">NOTE:</emphasis> This new ioctl is programmed to be added on Kernel 4.6. Its definition/arguments may change until its final version.</para>
-
     <para>The typical usage of this ioctl is to call it twice.
     On the first call, the structure defined at &media-v2-topology; should
     be zeroed. At return, if no errors happen, this ioctl will return the
index 1af3842..8b4fa39 100644 (file)
            <entry>Connector for a RGB composite signal.</entry>
          </row>
          <row>
-           <entry><constant>MEDIA_ENT_F_CONN_TEST</constant></entry>
-           <entry>Connector for a test generator.</entry>
-         </row>
-         <row>
            <entry><constant>MEDIA_ENT_F_CAM_SENSOR</constant></entry>
            <entry>Camera video sensor entity.</entry>
          </row>
          </row>
          <row>
            <entry><constant>MEDIA_ENT_F_TUNER</constant></entry>
-           <entry>Digital TV, analog TV, radio and/or software radio tuner.</entry>
+           <entry>Digital TV, analog TV, radio and/or software radio tuner,
+                  with consists on a PLL tuning stage that converts radio
+                  frequency (RF) signal into an Intermediate Frequency (IF).
+                  Modern tuners have internally IF-PLL decoders for audio
+                  and video, but older models have those stages implemented
+                  on separate entities.
+           </entry>
+         </row>
+         <row>
+           <entry><constant>MEDIA_ENT_F_IF_VID_DECODER</constant></entry>
+           <entry>IF-PLL video decoder. It receives the IF from a PLL
+                  and decodes the analog TV video signal. This is commonly
+                  found on some very old analog tuners, like Philips MK3
+                  designs. They all contain a tda9887 (or some software
+                  compatible similar chip, like tda9885). Those devices
+                  use a different I2C address than the tuner PLL.
+           </entry>
+         </row>
+         <row>
+           <entry><constant>MEDIA_ENT_F_IF_AUD_DECODER</constant></entry>
+           <entry>IF-PLL sound decoder. It receives the IF from a PLL
+                  and decodes the analog TV audio signal. This is commonly
+                  found on some very old analog hardware, like Micronas
+                  msp3400, Philips tda9840, tda985x, etc. Those devices
+                  use a different I2C address than the tuner PLL and
+                  should be controlled together with the IF-PLL video
+                  decoder.
+           </entry>
          </row>
        </tbody>
       </tgroup>
index e781cc6..7d13fe9 100644 (file)
@@ -1,35 +1,43 @@
-    <refentry id="V4L2-PIX-FMT-YUV420M">
+    <refentry>
       <refmeta>
-       <refentrytitle>V4L2_PIX_FMT_YUV420M ('YM12')</refentrytitle>
+       <refentrytitle>V4L2_PIX_FMT_YUV420M ('YM12'), V4L2_PIX_FMT_YVU420M ('YM21')</refentrytitle>
        &manvol;
       </refmeta>
       <refnamediv>
-       <refname> <constant>V4L2_PIX_FMT_YUV420M</constant></refname>
-       <refpurpose>Variation of <constant>V4L2_PIX_FMT_YUV420</constant>
-         with planes non contiguous in memory. </refpurpose>
+       <refname id="V4L2-PIX-FMT-YUV420M"><constant>V4L2_PIX_FMT_YUV420M</constant></refname>
+       <refname id="V4L2-PIX-FMT-YVU420M"><constant>V4L2_PIX_FMT_YVU420M</constant></refname>
+       <refpurpose>Variation of <constant>V4L2_PIX_FMT_YUV420</constant> and
+         <constant>V4L2_PIX_FMT_YVU420</constant> with planes non contiguous
+         in memory.</refpurpose>
       </refnamediv>
 
       <refsect1>
        <title>Description</title>
 
        <para>This is a multi-planar format, as opposed to a packed format.
-The three components are separated into three sub- images or planes.
+The three components are separated into three sub-images or planes.</para>
 
-The Y plane is first. The Y plane has one byte per pixel. The Cb data
+       <para>The Y plane is first. The Y plane has one byte per pixel.
+For <constant>V4L2_PIX_FMT_YUV420M</constant> the Cb data
 constitutes the second plane which is half the width and half
 the height of the Y plane (and of the image). Each Cb belongs to four
 pixels, a two-by-two square of the image. For example,
 Cb<subscript>0</subscript> belongs to Y'<subscript>00</subscript>,
 Y'<subscript>01</subscript>, Y'<subscript>10</subscript>, and
 Y'<subscript>11</subscript>. The Cr data, just like the Cb plane, is
-in the third plane. </para>
+in the third plane.</para>
+
+       <para><constant>V4L2_PIX_FMT_YVU420M</constant> is the same except
+the Cr data is stored in the second plane and the Cb data in the third plane.
+</para>
 
        <para>If the Y plane has pad bytes after each row, then the Cb
 and Cr planes have half as many pad bytes after their rows. In other
 words, two Cx rows (including padding) is exactly as long as one Y row
 (including padding).</para>
 
-       <para><constant>V4L2_PIX_FMT_YUV420M</constant> is intended to be
+       <para><constant>V4L2_PIX_FMT_YUV420M</constant> and
+<constant>V4L2_PIX_FMT_YVU420M</constant> are intended to be
 used only in drivers and applications that support the multi-planar API,
 described in <xref linkend="planar-apis"/>. </para>
 
@@ -1,40 +1,45 @@
-    <refentry id="V4L2-PIX-FMT-YVU420M">
+    <refentry>
       <refmeta>
-       <refentrytitle>V4L2_PIX_FMT_YVU420M ('YM21')</refentrytitle>
+       <refentrytitle>V4L2_PIX_FMT_YUV422M ('YM16'), V4L2_PIX_FMT_YVU422M ('YM61')</refentrytitle>
        &manvol;
       </refmeta>
       <refnamediv>
-       <refname> <constant>V4L2_PIX_FMT_YVU420M</constant></refname>
-       <refpurpose>Variation of <constant>V4L2_PIX_FMT_YVU420</constant>
-         with planes non contiguous in memory. </refpurpose>
+       <refname id="V4L2-PIX-FMT-YUV422M"><constant>V4L2_PIX_FMT_YUV422M</constant></refname>
+       <refname id="V4L2-PIX-FMT-YVU422M"><constant>V4L2_PIX_FMT_YVU422M</constant></refname>
+       <refpurpose>Planar formats with &frac12; horizontal resolution, also
+       known as YUV and YVU 4:2:2</refpurpose>
       </refnamediv>
 
       <refsect1>
        <title>Description</title>
 
        <para>This is a multi-planar format, as opposed to a packed format.
-The three components are separated into three sub-images or planes.
+The three components are separated into three sub-images or planes.</para>
 
-The Y plane is first. The Y plane has one byte per pixel. The Cr data
-constitutes the second plane which is half the width and half
-the height of the Y plane (and of the image). Each Cr belongs to four
-pixels, a two-by-two square of the image. For example,
-Cr<subscript>0</subscript> belongs to Y'<subscript>00</subscript>,
-Y'<subscript>01</subscript>, Y'<subscript>10</subscript>, and
-Y'<subscript>11</subscript>. The Cb data, just like the Cr plane, constitutes
-the third plane. </para>
+       <para>The Y plane is first. The Y plane has one byte per pixel.
+For <constant>V4L2_PIX_FMT_YUV422M</constant> the Cb data
+constitutes the second plane which is half the width of the Y plane (and of the
+image). Each Cb belongs to two pixels. For example,
+Cb<subscript>0</subscript> belongs to Y'<subscript>00</subscript>,
+Y'<subscript>01</subscript>. The Cr data, just like the Cb plane, is
+in the third plane. </para>
 
-       <para>If the Y plane has pad bytes after each row, then the Cr
-and Cb planes have half as many pad bytes after their rows. In other
+       <para><constant>V4L2_PIX_FMT_YVU422M</constant> is the same except
+the Cr data is stored in the second plane and the Cb data in the third plane.
+</para>
+
+       <para>If the Y plane has pad bytes after each row, then the Cb
+and Cr planes have half as many pad bytes after their rows. In other
 words, two Cx rows (including padding) is exactly as long as one Y row
 (including padding).</para>
 
-       <para><constant>V4L2_PIX_FMT_YVU420M</constant> is intended to be
+       <para><constant>V4L2_PIX_FMT_YUV422M</constant> and
+<constant>V4L2_PIX_FMT_YVU422M</constant> are intended to be
 used only in drivers and applications that support the multi-planar API,
 described in <xref linkend="planar-apis"/>. </para>
 
        <example>
-         <title><constant>V4L2_PIX_FMT_YVU420M</constant> 4 &times; 4
+         <title><constant>V4L2_PIX_FMT_YUV422M</constant> 4 &times; 4
 pixel image</title>
 
          <formalpara>
@@ -75,24 +80,44 @@ pixel image</title>
                    <row><entry></entry></row>
                    <row>
                      <entry>start1&nbsp;+&nbsp;0:</entry>
-                     <entry>Cr<subscript>00</subscript></entry>
-                     <entry>Cr<subscript>01</subscript></entry>
+                     <entry>Cb<subscript>00</subscript></entry>
+                     <entry>Cb<subscript>01</subscript></entry>
                    </row>
                    <row>
                      <entry>start1&nbsp;+&nbsp;2:</entry>
-                     <entry>Cr<subscript>10</subscript></entry>
-                     <entry>Cr<subscript>11</subscript></entry>
+                     <entry>Cb<subscript>10</subscript></entry>
+                     <entry>Cb<subscript>11</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start1&nbsp;+&nbsp;4:</entry>
+                     <entry>Cb<subscript>20</subscript></entry>
+                     <entry>Cb<subscript>21</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start1&nbsp;+&nbsp;6:</entry>
+                     <entry>Cb<subscript>30</subscript></entry>
+                     <entry>Cb<subscript>31</subscript></entry>
                    </row>
                    <row><entry></entry></row>
                    <row>
                      <entry>start2&nbsp;+&nbsp;0:</entry>
-                     <entry>Cb<subscript>00</subscript></entry>
-                     <entry>Cb<subscript>01</subscript></entry>
+                     <entry>Cr<subscript>00</subscript></entry>
+                     <entry>Cr<subscript>01</subscript></entry>
                    </row>
                    <row>
                      <entry>start2&nbsp;+&nbsp;2:</entry>
-                     <entry>Cb<subscript>10</subscript></entry>
-                     <entry>Cb<subscript>11</subscript></entry>
+                     <entry>Cr<subscript>10</subscript></entry>
+                     <entry>Cr<subscript>11</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start2&nbsp;+&nbsp;4:</entry>
+                     <entry>Cr<subscript>20</subscript></entry>
+                     <entry>Cr<subscript>21</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start2&nbsp;+&nbsp;6:</entry>
+                     <entry>Cr<subscript>30</subscript></entry>
+                     <entry>Cr<subscript>31</subscript></entry>
                    </row>
                  </tbody>
                </tgroup>
@@ -113,36 +138,23 @@ pixel image</title>
                    </row>
                    <row>
                      <entry>0</entry>
-                     <entry>Y</entry><entry></entry><entry>Y</entry><entry></entry>
-                     <entry>Y</entry><entry></entry><entry>Y</entry>
-                   </row>
-                   <row>
-                     <entry></entry>
-                     <entry></entry><entry>C</entry><entry></entry><entry></entry>
-                     <entry></entry><entry>C</entry><entry></entry>
+                     <entry>Y</entry><entry>C</entry><entry>Y</entry><entry></entry>
+                     <entry>Y</entry><entry>C</entry><entry>Y</entry>
                    </row>
                    <row>
                      <entry>1</entry>
-                     <entry>Y</entry><entry></entry><entry>Y</entry><entry></entry>
-                     <entry>Y</entry><entry></entry><entry>Y</entry>
-                   </row>
-                   <row>
-                     <entry></entry>
+                     <entry>Y</entry><entry>C</entry><entry>Y</entry><entry></entry>
+                     <entry>Y</entry><entry>C</entry><entry>Y</entry>
                    </row>
                    <row>
                      <entry>2</entry>
-                     <entry>Y</entry><entry></entry><entry>Y</entry><entry></entry>
-                     <entry>Y</entry><entry></entry><entry>Y</entry>
-                   </row>
-                   <row>
-                     <entry></entry>
-                     <entry></entry><entry>C</entry><entry></entry><entry></entry>
-                     <entry></entry><entry>C</entry><entry></entry>
+                     <entry>Y</entry><entry>C</entry><entry>Y</entry><entry></entry>
+                     <entry>Y</entry><entry>C</entry><entry>Y</entry>
                    </row>
                    <row>
                      <entry>3</entry>
-                     <entry>Y</entry><entry></entry><entry>Y</entry><entry></entry>
-                     <entry>Y</entry><entry></entry><entry>Y</entry>
+                     <entry>Y</entry><entry>C</entry><entry>Y</entry><entry></entry>
+                     <entry>Y</entry><entry>C</entry><entry>Y</entry>
                    </row>
                  </tbody>
                </tgroup>
diff --git a/Documentation/DocBook/media/v4l/pixfmt-yuv444m.xml b/Documentation/DocBook/media/v4l/pixfmt-yuv444m.xml
new file mode 100644 (file)
index 0000000..1b73359
--- /dev/null
@@ -0,0 +1,177 @@
+    <refentry>
+      <refmeta>
+       <refentrytitle>V4L2_PIX_FMT_YUV444M ('YM24'), V4L2_PIX_FMT_YVU444M ('YM42')</refentrytitle>
+       &manvol;
+      </refmeta>
+      <refnamediv>
+       <refname id="V4L2-PIX-FMT-YUV444M"><constant>V4L2_PIX_FMT_YUV444M</constant></refname>
+       <refname id="V4L2-PIX-FMT-YVU444M"><constant>V4L2_PIX_FMT_YVU444M</constant></refname>
+       <refpurpose>Planar formats with full horizontal resolution, also
+       known as YUV and YVU 4:4:4</refpurpose>
+      </refnamediv>
+
+      <refsect1>
+       <title>Description</title>
+
+       <para>This is a multi-planar format, as opposed to a packed format.
+The three components are separated into three sub-images or planes.</para>
+
+       <para>The Y plane is first. The Y plane has one byte per pixel.
+For <constant>V4L2_PIX_FMT_YUV444M</constant> the Cb data
+constitutes the second plane which is the same width and height as the Y plane
+(and as the image). The Cr data, just like the Cb plane, is in the third plane.
+</para>
+
+       <para><constant>V4L2_PIX_FMT_YVU444M</constant> is the same except
+the Cr data is stored in the second plane and the Cb data in the third plane.
+</para>
+       <para>If the Y plane has pad bytes after each row, then the Cb
+and Cr planes have the same number of pad bytes after their rows.</para>
+
+       <para><constant>V4L2_PIX_FMT_YUV444M</constant> and
+<constant>V4L2_PIX_FMT_YUV444M</constant> are intended to be
+used only in drivers and applications that support the multi-planar API,
+described in <xref linkend="planar-apis"/>. </para>
+
+       <example>
+         <title><constant>V4L2_PIX_FMT_YUV444M</constant> 4 &times; 4
+pixel image</title>
+
+         <formalpara>
+           <title>Byte Order.</title>
+           <para>Each cell is one byte.
+               <informaltable frame="none">
+               <tgroup cols="5" align="center">
+                 <colspec align="left" colwidth="2*" />
+                 <tbody valign="top">
+                   <row>
+                     <entry>start0&nbsp;+&nbsp;0:</entry>
+                     <entry>Y'<subscript>00</subscript></entry>
+                     <entry>Y'<subscript>01</subscript></entry>
+                     <entry>Y'<subscript>02</subscript></entry>
+                     <entry>Y'<subscript>03</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start0&nbsp;+&nbsp;4:</entry>
+                     <entry>Y'<subscript>10</subscript></entry>
+                     <entry>Y'<subscript>11</subscript></entry>
+                     <entry>Y'<subscript>12</subscript></entry>
+                     <entry>Y'<subscript>13</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start0&nbsp;+&nbsp;8:</entry>
+                     <entry>Y'<subscript>20</subscript></entry>
+                     <entry>Y'<subscript>21</subscript></entry>
+                     <entry>Y'<subscript>22</subscript></entry>
+                     <entry>Y'<subscript>23</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start0&nbsp;+&nbsp;12:</entry>
+                     <entry>Y'<subscript>30</subscript></entry>
+                     <entry>Y'<subscript>31</subscript></entry>
+                     <entry>Y'<subscript>32</subscript></entry>
+                     <entry>Y'<subscript>33</subscript></entry>
+                   </row>
+                   <row><entry></entry></row>
+                   <row>
+                     <entry>start1&nbsp;+&nbsp;0:</entry>
+                     <entry>Cb<subscript>00</subscript></entry>
+                     <entry>Cb<subscript>01</subscript></entry>
+                     <entry>Cb<subscript>02</subscript></entry>
+                     <entry>Cb<subscript>03</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start1&nbsp;+&nbsp;4:</entry>
+                     <entry>Cb<subscript>10</subscript></entry>
+                     <entry>Cb<subscript>11</subscript></entry>
+                     <entry>Cb<subscript>12</subscript></entry>
+                     <entry>Cb<subscript>13</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start1&nbsp;+&nbsp;8:</entry>
+                     <entry>Cb<subscript>20</subscript></entry>
+                     <entry>Cb<subscript>21</subscript></entry>
+                     <entry>Cb<subscript>22</subscript></entry>
+                     <entry>Cb<subscript>23</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start1&nbsp;+&nbsp;12:</entry>
+                     <entry>Cb<subscript>20</subscript></entry>
+                     <entry>Cb<subscript>21</subscript></entry>
+                     <entry>Cb<subscript>32</subscript></entry>
+                     <entry>Cb<subscript>33</subscript></entry>
+                   </row>
+                   <row><entry></entry></row>
+                   <row>
+                     <entry>start2&nbsp;+&nbsp;0:</entry>
+                     <entry>Cr<subscript>00</subscript></entry>
+                     <entry>Cr<subscript>01</subscript></entry>
+                     <entry>Cr<subscript>02</subscript></entry>
+                     <entry>Cr<subscript>03</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start2&nbsp;+&nbsp;4:</entry>
+                     <entry>Cr<subscript>10</subscript></entry>
+                     <entry>Cr<subscript>11</subscript></entry>
+                     <entry>Cr<subscript>12</subscript></entry>
+                     <entry>Cr<subscript>13</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start2&nbsp;+&nbsp;8:</entry>
+                     <entry>Cr<subscript>20</subscript></entry>
+                     <entry>Cr<subscript>21</subscript></entry>
+                     <entry>Cr<subscript>22</subscript></entry>
+                     <entry>Cr<subscript>23</subscript></entry>
+                   </row>
+                   <row>
+                     <entry>start2&nbsp;+&nbsp;12:</entry>
+                     <entry>Cr<subscript>30</subscript></entry>
+                     <entry>Cr<subscript>31</subscript></entry>
+                     <entry>Cr<subscript>32</subscript></entry>
+                     <entry>Cr<subscript>33</subscript></entry>
+                   </row>
+                 </tbody>
+               </tgroup>
+               </informaltable>
+             </para>
+         </formalpara>
+
+         <formalpara>
+           <title>Color Sample Location.</title>
+           <para>
+               <informaltable frame="none">
+               <tgroup cols="7" align="center">
+                 <tbody valign="top">
+                   <row>
+                     <entry></entry>
+                     <entry>0</entry><entry></entry><entry>1</entry><entry></entry>
+                     <entry>2</entry><entry></entry><entry>3</entry>
+                   </row>
+                   <row>
+                     <entry>0</entry>
+                     <entry>YC</entry><entry></entry><entry>YC</entry><entry></entry>
+                     <entry>YC</entry><entry></entry><entry>YC</entry>
+                   </row>
+                   <row>
+                     <entry>1</entry>
+                     <entry>YC</entry><entry></entry><entry>YC</entry><entry></entry>
+                     <entry>YC</entry><entry></entry><entry>YC</entry>
+                   </row>
+                   <row>
+                     <entry>2</entry>
+                     <entry>YC</entry><entry></entry><entry>YC</entry><entry></entry>
+                     <entry>YC</entry><entry></entry><entry>YC</entry>
+                   </row>
+                   <row>
+                     <entry>3</entry>
+                     <entry>YC</entry><entry></entry><entry>YC</entry><entry></entry>
+                     <entry>YC</entry><entry></entry><entry>YC</entry>
+                   </row>
+                 </tbody>
+               </tgroup>
+               </informaltable>
+             </para>
+         </formalpara>
+       </example>
+      </refsect1>
+    </refentry>
index d871245..2f02f94 100644 (file)
@@ -1628,7 +1628,8 @@ information.</para>
     &sub-y41p;
     &sub-yuv420;
     &sub-yuv420m;
-    &sub-yvu420m;
+    &sub-yuv422m;
+    &sub-yuv444m;
     &sub-yuv410;
     &sub-yuv422p;
     &sub-yuv411p;
index e9c70a8..0c93677 100644 (file)
@@ -60,9 +60,19 @@ input</refpurpose>
 automatically, similar to sensing the video standard. To do so, applications
 call <constant>VIDIOC_QUERY_DV_TIMINGS</constant> with a pointer to a
 &v4l2-dv-timings;. Once the hardware detects the timings, it will fill in the
-timings structure.
+timings structure.</para>
 
-If the timings could not be detected because there was no signal, then
+<para>Please note that drivers shall <emphasis>not</emphasis> switch timings automatically
+if new timings are detected. Instead, drivers should send the
+<constant>V4L2_EVENT_SOURCE_CHANGE</constant> event (if they support this) and expect
+that userspace will take action by calling <constant>VIDIOC_QUERY_DV_TIMINGS</constant>.
+The reason is that new timings usually mean different buffer sizes as well, and you
+cannot change buffer sizes on the fly. In general, applications that receive the
+Source Change event will have to call <constant>VIDIOC_QUERY_DV_TIMINGS</constant>,
+and if the detected timings are valid they will have to stop streaming, set the new
+timings, allocate new buffers and start streaming again.</para>
+
+<para>If the timings could not be detected because there was no signal, then
 <errorcode>ENOLINK</errorcode> is returned. If a signal was detected, but
 it was unstable and the receiver could not lock to the signal, then
 <errorcode>ENOLCK</errorcode> is returned. If the receiver could lock to the signal,
index 2223485..3ceae35 100644 (file)
@@ -59,6 +59,16 @@ then the driver will return V4L2_STD_UNKNOWN. When detection is not
 possible or fails, the set must contain all standards supported by the
 current video input or output.</para>
 
+<para>Please note that drivers shall <emphasis>not</emphasis> switch the video standard
+automatically if a new video standard is detected. Instead, drivers should send the
+<constant>V4L2_EVENT_SOURCE_CHANGE</constant> event (if they support this) and expect
+that userspace will take action by calling <constant>VIDIOC_QUERYSTD</constant>.
+The reason is that a new video standard can mean different buffer sizes as well, and you
+cannot change buffer sizes on the fly. In general, applications that receive the
+Source Change event will have to call <constant>VIDIOC_QUERYSTD</constant>,
+and if the detected video standard is valid they will have to stop streaming, set the new
+standard, allocate new buffers and start streaming again.</para>
+
   </refsect1>
 
   <refsect1>
index e8d25e7..ff49cf9 100644 (file)
@@ -7,7 +7,7 @@ This is the authoritative documentation on the design, interface and
 conventions of cgroup v2.  It describes all userland-visible aspects
 of cgroup including core and specific controller behaviors.  All
 future changes must be reflected in this document.  Documentation for
-v1 is available under Documentation/cgroup-legacy/.
+v1 is available under Documentation/cgroup-v1/.
 
 CONTENTS
 
index a2bd593..66422d6 100644 (file)
@@ -23,6 +23,7 @@ Optional properties:
   during suspend.
 - ti,no-reset-on-init: When present, the module should not be reset at init
 - ti,no-idle-on-init: When present, the module should not be idled at init
+- ti,no-idle: When present, the module is never allowed to idle.
 
 Example:
 
index ace0599..20df350 100644 (file)
@@ -30,7 +30,7 @@ that they are defined using standard clock bindings with following
 clock-output-names:
  - "xin24m" - crystal input - required,
  - "ext_i2s" - external I2S clock - optional,
- - "ext_gmac" - external GMAC clock - optional
+ - "rmii_clkin" - external EMAC clock - optional
 
 Example: Clock controller node:
 
index 56a961a..9f97df4 100644 (file)
@@ -35,6 +35,12 @@ Optional properties for HDMI:
                  as an interrupt/status bit in the HDMI controller
                  itself).  See bindings/pinctrl/brcm,bcm2835-gpio.txt
 
+Required properties for V3D:
+- compatible:  Should be "brcm,bcm2835-v3d"
+- reg:         Physical base address and length of the V3D's registers
+- interrupts:  The interrupt number
+                 See bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
+
 Example:
 pixelvalve@7e807000 {
        compatible = "brcm,bcm2835-pixelvalve2";
@@ -60,6 +66,12 @@ hdmi: hdmi@7e902000 {
        clock-names = "pixel", "hdmi";
 };
 
+v3d: v3d@7ec00000 {
+       compatible = "brcm,bcm2835-v3d";
+       reg = <0x7ec00000 0x1000>;
+       interrupts = <1 10>;
+};
+
 vc4: gpu {
        compatible = "brcm,bcm2835-vc4";
 };
index 0e6f0c0..22756b3 100644 (file)
@@ -6,6 +6,7 @@ Required properties:
                "samsung,exynos4210-mipi-dsi" /* for Exynos4 SoCs */
                "samsung,exynos4415-mipi-dsi" /* for Exynos4415 SoC */
                "samsung,exynos5410-mipi-dsi" /* for Exynos5410/5420/5440 SoCs */
+               "samsung,exynos5422-mipi-dsi" /* for Exynos5422/5800 SoCs */
                "samsung,exynos5433-mipi-dsi" /* for Exynos5433 SoCs */
   - reg: physical base address and length of the registers set for the device
   - interrupts: should contain DSI interrupt
index 27c3ce0..c7c6b9a 100644 (file)
@@ -12,7 +12,8 @@ Required properties:
                "samsung,exynos3250-fimd"; /* for Exynos3250/3472 SoCs */
                "samsung,exynos4210-fimd"; /* for Exynos4 SoCs */
                "samsung,exynos4415-fimd"; /* for Exynos4415 SoC */
-               "samsung,exynos5250-fimd"; /* for Exynos5 SoCs */
+               "samsung,exynos5250-fimd"; /* for Exynos5250 SoCs */
+               "samsung,exynos5420-fimd"; /* for Exynos5420/5422/5800 SoCs */
 
 - reg: physical base address and length of the FIMD registers set.
 
index e7423be..f5948c4 100644 (file)
@@ -44,9 +44,34 @@ Optional properties:
 - pinctrl-names: the pin control state names; should contain "default"
 - pinctrl-0: the default pinctrl state (active)
 - pinctrl-n: the "sleep" pinctrl state
-- port: DSI controller output port. This contains one endpoint subnode, with its
-  remote-endpoint set to the phandle of the connected panel's endpoint.
-  See Documentation/devicetree/bindings/graph.txt for device graph info.
+- port: DSI controller output port, containing one endpoint subnode.
+
+  DSI Endpoint properties:
+  - remote-endpoint: set to phandle of the connected panel's endpoint.
+    See Documentation/devicetree/bindings/graph.txt for device graph info.
+  - qcom,data-lane-map: this describes how the logical DSI lanes are mapped
+    to the physical lanes on the given platform. The value contained in
+    index n describes what logical data lane is mapped to the physical data
+    lane n (DATAn, where n lies between 0 and 3).
+
+    For example:
+
+    qcom,data-lane-map = <3 0 1 2>;
+
+    The above mapping describes that the logical data lane DATA3 is mapped to
+    the physical data lane DATA0, logical DATA0 to physical DATA1, logic DATA1
+    to phys DATA2 and logic DATA2 to phys DATA3.
+
+    There are only a limited number of physical to logical mappings possible:
+
+    "0123": Logic 0->Phys 0; Logic 1->Phys 1; Logic 2->Phys 2; Logic 3->Phys 3;
+    "3012": Logic 3->Phys 0; Logic 0->Phys 1; Logic 1->Phys 2; Logic 2->Phys 3;
+    "2301": Logic 2->Phys 0; Logic 3->Phys 1; Logic 0->Phys 2; Logic 1->Phys 3;
+    "1230": Logic 1->Phys 0; Logic 2->Phys 1; Logic 3->Phys 2; Logic 0->Phys 3;
+    "0321": Logic 0->Phys 0; Logic 3->Phys 1; Logic 2->Phys 2; Logic 1->Phys 3;
+    "1032": Logic 1->Phys 0; Logic 0->Phys 1; Logic 3->Phys 2; Logic 2->Phys 3;
+    "2103": Logic 2->Phys 0; Logic 1->Phys 1; Logic 0->Phys 2; Logic 3->Phys 3;
+    "3210": Logic 3->Phys 0; Logic 2->Phys 1; Logic 1->Phys 2; Logic 0->Phys 3;
 
 DSI PHY:
 Required properties:
@@ -131,6 +156,7 @@ Example:
                port {
                        dsi0_out: endpoint {
                                remote-endpoint = <&panel_in>;
+                               lanes = <0 1 2 3>;
                        };
                };
        };
index 379ee2e..b63f614 100644 (file)
@@ -11,6 +11,7 @@ Required properties:
 - reg: Physical base address and length of the controller's registers
 - reg-names: "core_physical"
 - interrupts: The interrupt signal from the hdmi block.
+- power-domains: Should be <&mmcc MDSS_GDSC>.
 - clocks: device clocks
   See ../clocks/clock-bindings.txt for details.
 - qcom,hdmi-tx-ddc-clk-gpio: ddc clk pin
@@ -18,6 +19,8 @@ Required properties:
 - qcom,hdmi-tx-hpd-gpio: hpd pin
 - core-vdda-supply: phandle to supply regulator
 - hdmi-mux-supply: phandle to mux regulator
+- phys: the phandle for the HDMI PHY device
+- phy-names: the name of the corresponding PHY device
 
 Optional properties:
 - qcom,hdmi-tx-mux-en-gpio: hdmi mux enable pin
@@ -27,15 +30,38 @@ Optional properties:
 - pinctrl-0: the default pinctrl state (active)
 - pinctrl-1: the "sleep" pinctrl state
 
+HDMI PHY:
+Required properties:
+- compatible: Could be the following
+  * "qcom,hdmi-phy-8660"
+  * "qcom,hdmi-phy-8960"
+  * "qcom,hdmi-phy-8974"
+  * "qcom,hdmi-phy-8084"
+  * "qcom,hdmi-phy-8996"
+- #phy-cells: Number of cells in a PHY specifier; Should be 0.
+- reg: Physical base address and length of the registers of the PHY sub blocks.
+- reg-names: The names of register regions. The following regions are required:
+  * "hdmi_phy"
+  * "hdmi_pll"
+  For HDMI PHY on msm8996, these additional register regions are required:
+    * "hdmi_tx_l0"
+    * "hdmi_tx_l1"
+    * "hdmi_tx_l3"
+    * "hdmi_tx_l4"
+- power-domains: Should be <&mmcc MDSS_GDSC>.
+- clocks: device clocks
+  See Documentation/devicetree/bindings/clocks/clock-bindings.txt for details.
+- core-vdda-supply: phandle to vdda regulator device node
+
 Example:
 
 / {
        ...
 
-       hdmi: qcom,hdmi-tx-8960@4a00000 {
+       hdmi: hdmi@4a00000 {
                compatible = "qcom,hdmi-tx-8960";
                reg-names = "core_physical";
-               reg = <0x04a00000 0x1000>;
+               reg = <0x04a00000 0x2f0>;
                interrupts = <GIC_SPI 79 0>;
                power-domains = <&mmcc MDSS_GDSC>;
                clock-names =
@@ -54,5 +80,21 @@ Example:
                pinctrl-names = "default", "sleep";
                pinctrl-0 = <&hpd_active  &ddc_active  &cec_active>;
                pinctrl-1 = <&hpd_suspend &ddc_suspend &cec_suspend>;
+
+               phys = <&hdmi_phy>;
+               phy-names = "hdmi_phy";
+       };
+
+       hdmi_phy: phy@4a00400 {
+               compatible = "qcom,hdmi-phy-8960";
+               reg-names = "hdmi_phy",
+                           "hdmi_pll";
+               reg = <0x4a00400 0x60>,
+                     <0x4a00500 0x100>;
+               #phy-cells = <0>;
+               power-domains = <&mmcc MDSS_GDSC>;
+               clock-names = "slave_iface_clk";
+               clocks = <&mmcc HDMI_S_AHB_CLK>;
+               core-vdda-supply = <&pm8921_hdmi_mvs>;
        };
 };
diff --git a/Documentation/devicetree/bindings/display/panel/lg,lp120up1.txt b/Documentation/devicetree/bindings/display/panel/lg,lp120up1.txt
new file mode 100644 (file)
index 0000000..8c5de69
--- /dev/null
@@ -0,0 +1,7 @@
+LG 12.0" (1920x1280 pixels) TFT LCD panel
+
+Required properties:
+- compatible: should be "lg,lp120up1"
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
diff --git a/Documentation/devicetree/bindings/display/panel/urt,umsh-8596md.txt b/Documentation/devicetree/bindings/display/panel/urt,umsh-8596md.txt
new file mode 100644 (file)
index 0000000..088a6ce
--- /dev/null
@@ -0,0 +1,16 @@
+United Radiant Technology UMSH-8596MD-xT 7.0" WVGA TFT LCD panel
+
+Supported are LVDS versions (-11T, -19T) and parallel ones
+(-T, -1T, -7T, -20T).
+
+Required properties:
+- compatible: should be one of:
+  "urt,umsh-8596md-t",
+  "urt,umsh-8596md-1t",
+  "urt,umsh-8596md-7t",
+  "urt,umsh-8596md-11t",
+  "urt,umsh-8596md-19t",
+  "urt,umsh-8596md-20t".
+
+This binding is compatible with the simple-panel binding, which is specified
+in simple-panel.txt in this directory.
index eccd4f4..0d30e42 100644 (file)
@@ -8,6 +8,7 @@ Required Properties:
     - "renesas,du-r8a7791" for R8A7791 (R-Car M2-W) compatible DU
     - "renesas,du-r8a7793" for R8A7793 (R-Car M2-N) compatible DU
     - "renesas,du-r8a7794" for R8A7794 (R-Car E2) compatible DU
+    - "renesas,du-r8a7795" for R8A7795 (R-Car H3) compatible DU
 
   - reg: A list of base address and length of each memory resource, one for
     each entry in the reg-names property.
@@ -24,7 +25,7 @@ Required Properties:
   - clock-names: Name of the clocks. This property is model-dependent.
     - R8A7779 uses a single functional clock. The clock doesn't need to be
       named.
-    - R8A779[0134] use one functional clock per channel and one clock per LVDS
+    - R8A779[01345] use one functional clock per channel and one clock per LVDS
       encoder (if available). The functional clocks must be named "du.x" with
       "x" being the channel numerical index. The LVDS clocks must be named
       "lvds.x" with "x" being the LVDS encoder numerical index.
@@ -41,13 +42,14 @@ bindings specified in Documentation/devicetree/bindings/graph.txt.
 The following table lists for each supported model the port number
 corresponding to each DU output.
 
-               Port 0          Port1           Port2
+               Port 0          Port1           Port2           Port3
 -----------------------------------------------------------------------------
- R8A7779 (H1)  DPAD 0          DPAD 1          -
- R8A7790 (H2)  DPAD            LVDS 0          LVDS 1
- R8A7791 (M2-W)        DPAD            LVDS 0          -
- R8A7793 (M2-N)        DPAD            LVDS 0          -
- R8A7794 (E2)  DPAD 0          DPAD 1          -
+ R8A7779 (H1)  DPAD 0          DPAD 1          -               -
+ R8A7790 (H2)  DPAD            LVDS 0          LVDS 1          -
+ R8A7791 (M2-W)        DPAD            LVDS 0          -               -
+ R8A7793 (M2-N)        DPAD            LVDS 0          -               -
+ R8A7794 (E2)  DPAD 0          DPAD 1          -               -
+ R8A7795 (H3)  DPAD            HDMI 0          HDMI 1          LVDS
 
 
 Example: R8A7790 (R-Car H2) DU
index 7803e77..007a5b4 100644 (file)
@@ -24,9 +24,8 @@ Main node required properties:
                1 = edge triggered
                4 = level triggered
 
-  Cells 4 and beyond are reserved for future use. When the 1st cell
-  has a value of 0 or 1, cells 4 and beyond act as padding, and may be
-  ignored. It is recommended that padding cells have a value of 0.
+  Cells 4 and beyond are reserved for future use and must have a value
+  of 0 if present.
 
 - reg : Specifies base physical address(s) and size of the GIC
   registers, in the following order:
index 2025653..100f0ae 100644 (file)
@@ -20,6 +20,8 @@ Optional Properties:
 
 - link-frequencies: List of allowed link frequencies in Hz. Each frequency is
        expressed as a 64-bit big-endian integer.
+- reset-gpios: GPIO handle which is connected to the reset pin of the chip.
+- standby-gpios: GPIO handle which is connected to the standby pin of the chip.
 
 For further reading on port node refer to
 Documentation/devicetree/bindings/media/video-interfaces.txt.
diff --git a/Documentation/devicetree/bindings/media/i2c/tvp5150.txt b/Documentation/devicetree/bindings/media/i2c/tvp5150.txt
new file mode 100644 (file)
index 0000000..daa20e4
--- /dev/null
@@ -0,0 +1,88 @@
+* Texas Instruments TVP5150 and TVP5151 video decoders
+
+The TVP5150 and TVP5151 are video decoders that convert baseband NTSC and PAL
+(and also SECAM in the TVP5151 case) video signals to either 8-bit 4:2:2 YUV
+with discrete syncs or 8-bit ITU-R BT.656 with embedded syncs output formats.
+
+Required Properties:
+- compatible: value must be "ti,tvp5150"
+- reg: I2C slave address
+
+Optional Properties:
+- pdn-gpios: phandle for the GPIO connected to the PDN pin, if any.
+- reset-gpios: phandle for the GPIO connected to the RESETB pin, if any.
+
+Optional nodes:
+- connectors: The input connectors of tvp5150 have to be defined under
+  a subnode name "connectors" using the following format:
+
+       input-connector-name {
+               input connector properties
+       };
+
+Each input connector must contain the following properties:
+
+       - label: a name for the connector.
+       - input: the input connector.
+
+The possible values for the "input" property are:
+       0: Composite0
+       1: Composite1
+       2: S-Video
+
+and on a tvp5150am1 and tvp5151 there is another:
+       4: Signal generator
+
+The list of valid input connectors are defined in dt-bindings/media/tvp5150.h
+header file and can be included by device tree source files.
+
+Each input connector can be defined only once.
+
+The device node must contain one 'port' child node for its digital output
+video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Required Endpoint Properties for parallel synchronization:
+
+- hsync-active: active state of the HSYNC signal. Must be <1> (HIGH).
+- vsync-active: active state of the VSYNC signal. Must be <1> (HIGH).
+- field-even-active: field signal level during the even field data
+  transmission. Must be <0>.
+
+If none of hsync-active, vsync-active and field-even-active is specified,
+the endpoint is assumed to use embedded BT.656 synchronization.
+
+Example:
+
+&i2c2 {
+       ...
+       tvp5150@5c {
+               compatible = "ti,tvp5150";
+               reg = <0x5c>;
+               pdn-gpios = <&gpio4 30 GPIO_ACTIVE_LOW>;
+               reset-gpios = <&gpio6 7 GPIO_ACTIVE_LOW>;
+
+               connectors {
+                       composite0 {
+                               label = "Composite0";
+                               input = <TVP5150_COMPOSITE0>;
+                       };
+
+                       composite1 {
+                               label = "Composite1";
+                               input = <TVP5150_COMPOSITE1>;
+                       };
+
+                       s-video {
+                               label = "S-Video";
+                               input = <TVP5150_SVIDEO>;
+                       };
+               };
+
+               port {
+                       tvp5150_1: endpoint {
+                               remote-endpoint = <&ccdc_ep>;
+                       };
+               };
+       };
+};
index 9dafe6b..619193c 100644 (file)
@@ -6,6 +6,7 @@ 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-r8a7795" for the R8A7795 device
    - "renesas,vin-r8a7794" for the R8A7794 device
    - "renesas,vin-r8a7793" for the R8A7793 device
    - "renesas,vin-r8a7791" for the R8A7791 device
index 0cb9420..d3436e5 100644 (file)
@@ -5,11 +5,12 @@ and decoding function conforming to the JPEG baseline process, so that the JPU
 can encode image data and decode JPEG data quickly.
 
 Required properties:
-  - compatible: should containg one of the following:
-                       - "renesas,jpu-r8a7790" for R-Car H2
-                       - "renesas,jpu-r8a7791" for R-Car M2-W
-                       - "renesas,jpu-r8a7792" for R-Car V2H
-                       - "renesas,jpu-r8a7793" for R-Car M2-N
+- compatible: "renesas,jpu-<soctype>", "renesas,rcar-gen2-jpu" as fallback.
+       Examples with soctypes are:
+         - "renesas,jpu-r8a7790" for R-Car H2
+         - "renesas,jpu-r8a7791" for R-Car M2-W
+         - "renesas,jpu-r8a7792" for R-Car V2H
+         - "renesas,jpu-r8a7793" for R-Car M2-N
 
   - reg: Base address and length of the registers block for the JPU.
   - interrupts: JPU interrupt specifier.
@@ -17,7 +18,7 @@ Required properties:
 
 Example: R8A7790 (R-Car H2) JPU node
        jpeg-codec@fe980000 {
-               compatible = "renesas,jpu-r8a7790";
+               compatible = "renesas,jpu-r8a7790", "renesas,rcar-gen2-jpu";
                reg = <0 0xfe980000 0 0x10300>;
                interrupts = <0 272 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp1_clks R8A7790_CLK_JPU>;
index 87fe08a..627405a 100644 (file)
@@ -1,30 +1,18 @@
-* Renesas VSP1 Video Processing Engine
+* Renesas VSP Video Processing Engine
 
-The VSP1 is a video processing engine that supports up-/down-scaling, alpha
+The VSP 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"
+  - compatible: Must contain one of the following values
+    - "renesas,vsp1" for the R-Car Gen2 VSP1
+    - "renesas,vsp2" for the R-Car Gen3 VSP2
 
-  - 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.
+  - reg: Base address and length of the registers block for the VSP.
+  - interrupts: VSP interrupt specifier.
+  - clocks: A phandle + clock-specifier pair for the VSP functional clock.
 
 
 Example: R8A7790 (R-Car H2) VSP1-S node
@@ -34,10 +22,4 @@ Example: R8A7790 (R-Car H2) VSP1-S node
                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>;
        };
diff --git a/Documentation/devicetree/bindings/media/ti-cal.txt b/Documentation/devicetree/bindings/media/ti-cal.txt
new file mode 100644 (file)
index 0000000..ae9b52f
--- /dev/null
@@ -0,0 +1,72 @@
+Texas Instruments DRA72x CAMERA ADAPTATION LAYER (CAL)
+------------------------------------------------------
+
+The Camera Adaptation Layer (CAL) is a key component for image capture
+applications. The capture module provides the system interface and the
+processing capability to connect CSI2 image-sensor modules to the
+DRA72x device.
+
+Required properties:
+- compatible: must be "ti,dra72-cal"
+- reg: CAL Top level, Receiver Core #0, Receiver Core #1 and Camera RX
+       control address space
+- reg-names: cal_top, cal_rx_core0, cal_rx_core1, and camerrx_control
+            registers
+- interrupts: should contain IRQ line for the CAL;
+
+CAL supports 2 camera port nodes on MIPI bus. Each CSI2 camera port nodes
+should contain a 'port' child node with child 'endpoint' node. Please
+refer to the bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+       cal: cal@4845b000 {
+               compatible = "ti,dra72-cal";
+               ti,hwmods = "cal";
+               reg = <0x4845B000 0x400>,
+                     <0x4845B800 0x40>,
+                     <0x4845B900 0x40>,
+                     <0x4A002e94 0x4>;
+               reg-names = "cal_top",
+                           "cal_rx_core0",
+                           "cal_rx_core1",
+                           "camerrx_control";
+               interrupts = <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               ports {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+
+                       csi2_0: port@0 {
+                               reg = <0>;
+                               endpoint {
+                                       slave-mode;
+                                       remote-endpoint = <&ar0330_1>;
+                               };
+                       };
+                       csi2_1: port@1 {
+                               reg = <1>;
+                       };
+               };
+       };
+
+       i2c5: i2c@4807c000 {
+               ar0330@10 {
+                       compatible = "ti,ar0330";
+                       reg = <0x10>;
+
+                       port {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               ar0330_1: endpoint {
+                                       reg = <0>;
+                                       clock-lanes = <1>;
+                                       data-lanes = <0 2 3 4>;
+                                       remote-endpoint = <&csi2_0>;
+                               };
+                       };
+               };
+       };
index 81a9f9e..c8ac222 100644 (file)
@@ -82,8 +82,8 @@ Example:
                                  "ch16", "ch17", "ch18", "ch19",
                                  "ch20", "ch21", "ch22", "ch23",
                                  "ch24";
-               clocks = <&mstp8_clks R8A7795_CLK_ETHERAVB>;
-               power-domains = <&cpg_clocks>;
+               clocks = <&cpg CPG_MOD 812>;
+               power-domains = <&cpg>;
                phy-mode = "rgmii-id";
                phy-handle = <&phy0>;
 
index 4e8b90e..07a7509 100644 (file)
@@ -8,6 +8,7 @@ OHCI and EHCI controllers.
 Required properties:
 - compatible: "renesas,pci-r8a7790" for the R8A7790 SoC;
              "renesas,pci-r8a7791" for the R8A7791 SoC;
+             "renesas,pci-r8a7793" for the R8A7793 SoC;
              "renesas,pci-r8a7794" for the R8A7794 SoC;
              "renesas,pci-rcar-gen2" for a generic R-Car Gen2 compatible device
 
index 558fe52..6cf9969 100644 (file)
@@ -4,6 +4,7 @@ Required properties:
 compatible: "renesas,pcie-r8a7779" for the R8A7779 SoC;
            "renesas,pcie-r8a7790" for the R8A7790 SoC;
            "renesas,pcie-r8a7791" for the R8A7791 SoC;
+           "renesas,pcie-r8a7793" for the R8A7793 SoC;
            "renesas,pcie-r8a7795" for the R8A7795 SoC;
            "renesas,pcie-rcar-gen2" for a generic R-Car Gen2 compatible device.
 
index d181096..4f05d20 100644 (file)
@@ -26,11 +26,7 @@ Example:
                ti,pmic-shutdown-controller;
 
                regulators {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-
                        dcdc1_reg: dcdc1 {
-                               reg = <0>;
                                regulator-min-microvolt = <900000>;
                                regulator-max-microvolt = <1800000>;
                                regulator-boot-on;
@@ -38,7 +34,6 @@ Example:
                        };
 
                        dcdc2_reg: dcdc2 {
-                               reg = <1>;
                                regulator-min-microvolt = <900000>;
                                regulator-max-microvolt = <3300000>;
                                regulator-boot-on;
@@ -46,7 +41,6 @@ Example:
                        };
 
                        dcdc3_reg: dcc3 {
-                               reg = <2>;
                                regulator-min-microvolt = <900000>;
                                regulator-max-microvolt = <1500000>;
                                regulator-boot-on;
@@ -54,7 +48,6 @@ Example:
                        };
 
                        ldo1_reg: ldo1 {
-                               reg = <3>;
                                regulator-min-microvolt = <1000000>;
                                regulator-max-microvolt = <3300000>;
                                regulator-boot-on;
@@ -62,7 +55,6 @@ Example:
                        };
 
                        ldo2_reg: ldo2 {
-                               reg = <4>;
                                regulator-min-microvolt = <900000>;
                                regulator-max-microvolt = <3300000>;
                                regulator-boot-on;
@@ -70,7 +62,6 @@ Example:
                        };
 
                        ldo3_reg: ldo3 {
-                               reg = <5>;
                                regulator-min-microvolt = <1800000>;
                                regulator-max-microvolt = <3300000>;
                                regulator-boot-on;
@@ -78,7 +69,6 @@ Example:
                        };
 
                        ldo4_reg: ldo4 {
-                               reg = <6>;
                                regulator-min-microvolt = <1800000>;
                                regulator-max-microvolt = <3300000>;
                                regulator-boot-on;
index ac2fcd6..1068ffc 100644 (file)
@@ -14,6 +14,10 @@ Required properties:
   interrupt number is the rtc alarm interrupt and second interrupt number
   is the rtc tick interrupt. The number of cells representing a interrupt
   depends on the parent interrupt controller.
+- clocks: Must contain a list of phandle and clock specifier for the rtc
+          and source clocks.
+- clock-names: Must contain "rtc" and "rtc_src" entries sorted in the
+               same order as the clocks property.
 
 Example:
 
@@ -21,4 +25,6 @@ Example:
                compatible = "samsung,s3c6410-rtc";
                reg = <0x10070000 0x100>;
                interrupts = <44 0 45 0>;
+               clocks = <&clock CLK_RTC>, <&s2mps11_osc S2MPS11_CLK_AP>;
+               clock-names = "rtc", "rtc_src";
        };
index 35ae1fb..ed94c21 100644 (file)
@@ -9,7 +9,7 @@ Optional properties:
 - fsl,uart-has-rtscts : Indicate the uart has rts and cts
 - fsl,irda-mode : Indicate the uart supports irda mode
 - fsl,dte-mode : Indicate the uart works in DTE mode. The uart works
-                  is DCE mode by default.
+                  in DCE mode by default.
 
 Note: Each uart controller should have an alias correctly numbered
 in "aliases" node.
index ce55c0a..4da41bf 100644 (file)
@@ -30,6 +30,8 @@ The compatible list for this generic sound card currently:
  "fsl,imx-audio-sgtl5000"
  (compatible with Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt)
 
+ "fsl,imx-audio-wm8960"
+
 Required properties:
 
   - compatible         : Contains one of entries in the compatible list.
index 332e625..e5ee3f1 100644 (file)
@@ -1,8 +1,9 @@
 * Renesas R-Car Thermal
 
 Required properties:
-- compatible           : "renesas,thermal-<soctype>", "renesas,rcar-thermal"
-                         as fallback.
+- compatible           : "renesas,thermal-<soctype>",
+                          "renesas,rcar-gen2-thermal" (with thermal-zone) or
+                          "renesas,rcar-thermal" (without thermal-zone) as fallback.
                          Examples with soctypes are:
                            - "renesas,thermal-r8a73a4" (R-Mobile APE6)
                            - "renesas,thermal-r8a7779" (R-Car H1)
@@ -36,3 +37,35 @@ thermal@e61f0000 {
                0xe61f0300 0x38>;
        interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
 };
+
+Example (with thermal-zone):
+
+thermal-zones {
+       cpu_thermal: cpu-thermal {
+               polling-delay-passive   = <1000>;
+               polling-delay           = <5000>;
+
+               thermal-sensors = <&thermal>;
+
+               trips {
+                       cpu-crit {
+                               temperature     = <115000>;
+                               hysteresis      = <0>;
+                               type            = "critical";
+                       };
+               };
+               cooling-maps {
+               };
+       };
+};
+
+thermal: thermal@e61f0000 {
+       compatible =    "renesas,thermal-r8a7790",
+                       "renesas,rcar-gen2-thermal",
+                       "renesas,rcar-thermal";
+       reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
+       interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
+       clocks = <&mstp5_clks R8A7790_CLK_THERMAL>;
+       power-domains = <&cpg_clocks>;
+       #thermal-sensor-cells = <0>;
+};
index 72e2c5a..1bcef73 100644 (file)
@@ -240,6 +240,7 @@ tplink      TP-LINK Technologies Co., Ltd.
 tronfy Tronfy
 truly  Truly Semiconductors Limited
 upisemi        uPI Semiconductor Corp.
+urt    United Radiant Technology Corporation
 usi    Universal Scientific Industrial Co., Ltd.
 v3     V3 Semiconductor
 variscite      Variscite Ltd.
index 669dc6c..6f4b12f 100644 (file)
@@ -190,7 +190,7 @@ and watch another one.
 Patches, comments and suggestions are very very welcome.
 
 3. Acknowledgements
-   Amaury Demol (ademol@dibcom.fr) and Francois Kanounnikoff from DiBcom for
+   Amaury Demol (Amaury.Demol@parrot.com) and Francois Kanounnikoff from DiBcom for
     providing specs, code and help, on which the dvb-dibusb, dib3000mb and
     dib3000mc are based.
 
index c477af0..686a64b 100644 (file)
@@ -14,3 +14,10 @@ filesystem.
 efivarfs is typically mounted like this,
 
        mount -t efivarfs none /sys/firmware/efi/efivars
+
+Due to the presence of numerous firmware bugs where removing non-standard
+UEFI variables causes the system firmware to fail to POST, efivarfs
+files that are not well-known standardized variables are created
+as immutable files.  This doesn't prevent removal - "chattr -i" will work -
+but it does prevent this kind of failure from being accomplished
+accidentally.
index 551ecf0..9a53c92 100644 (file)
@@ -4235,6 +4235,17 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
                        The default value of this parameter is determined by
                        the config option CONFIG_WQ_POWER_EFFICIENT_DEFAULT.
 
+       workqueue.debug_force_rr_cpu
+                       Workqueue used to implicitly guarantee that work
+                       items queued without explicit CPU specified are put
+                       on the local CPU.  This guarantee is no longer true
+                       and while local CPU is still preferred work items
+                       may be put on foreign CPUs.  This debug option
+                       forces round-robin CPU selection to flush out
+                       usages which depend on the now broken guarantee.
+                       When enabled, memory and cache locality will be
+                       impacted.
+
        x2apic_phys     [X86-64,APIC] Use x2apic physical mode instead of
                        default x2apic cluster mode on platforms
                        supporting x2apic.
index 767392f..a484d2c 100644 (file)
@@ -1,9 +1,7 @@
                High Precision Event Timer Driver for Linux
 
 The High Precision Event Timer (HPET) hardware follows a specification
-by Intel and Microsoft which can be found at
-
-       http://www.intel.com/hardwaredesign/hpetspec_1.pdf
+by Intel and Microsoft, revision 1.
 
 Each HPET has one fixed-rate counter (at 10+ MHz, hence "High Precision")
 and up to 32 comparators.  Normally three or more comparators are provided,
index 5517db6..5e759ca 100644 (file)
@@ -647,7 +647,6 @@ Or you can add specific controls to a handler:
        volume = v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_AUDIO_VOLUME, ...);
        v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_BRIGHTNESS, ...);
        v4l2_ctrl_new_std(&video_ctrl_handler, &ops, V4L2_CID_CONTRAST, ...);
-       v4l2_ctrl_add_ctrl(&radio_ctrl_handler, volume);
 
 What you should not do is make two identical controls for two handlers.
 For example:
index daf9c0f..c817310 100644 (file)
@@ -358,7 +358,8 @@ In the first case there are two additional complications:
 - if CR4.SMEP is enabled: since we've turned the page into a kernel page,
   the kernel may now execute it.  We handle this by also setting spte.nx.
   If we get a user fetch or read fault, we'll change spte.u=1 and
-  spte.nx=gpte.nx back.
+  spte.nx=gpte.nx back.  For this to work, KVM forces EFER.NX to 1 when
+  shadow paging is in use.
 - if CR4.SMAP is disabled: since the page has been changed to a kernel
   page, it can not be reused when CR4.SMAP is enabled. We set
   CR4.SMAP && !CR0.WP into shadow page's role to avoid this case. Note,
index 9f9ec9f..4e4b6f1 100644 (file)
@@ -400,3 +400,7 @@ wm8350_wdt:
 nowayout: Watchdog cannot be stopped once started
        (default=kernel config parameter)
 -------------------------------------------------
+sun4v_wdt:
+timeout_ms: Watchdog timeout in milliseconds 1..180000, default=60000)
+nowayout: Watchdog cannot be stopped once started
+-------------------------------------------------
index 20166fb..a32d2ff 100644 (file)
@@ -926,17 +926,24 @@ M:        Emilio López <emilio@elopez.com.ar>
 S:     Maintained
 F:     drivers/clk/sunxi/
 
-ARM/Amlogic MesonX SoC support
+ARM/Amlogic Meson SoC support
 M:     Carlo Caione <carlo@caione.org>
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+L:     linux-meson@googlegroups.com
+W:     http://linux-meson.com/
 S:     Maintained
-F:     drivers/media/rc/meson-ir.c
-N:     meson[x68]
+F:     arch/arm/mach-meson/
+F:     arch/arm/boot/dts/meson*
+N:     meson
 
 ARM/Annapurna Labs ALPINE ARCHITECTURE
 M:     Tsahee Zidenberg <tsahee@annapurnalabs.com>
+M:     Antoine Tenart <antoine.tenart@free-electrons.com>
 S:     Maintained
 F:     arch/arm/mach-alpine/
+F:     arch/arm/boot/dts/alpine*
+F:     arch/arm64/boot/dts/al/
+F:     drivers/*/*alpine*
 
 ARM/ATMEL AT91RM9200, AT91SAM9 AND SAMA5 SOC SUPPORT
 M:     Nicolas Ferre <nicolas.ferre@atmel.com>
@@ -1448,8 +1455,8 @@ S:        Maintained
 ARM/RENESAS ARM64 ARCHITECTURE
 M:     Simon Horman <horms@verge.net.au>
 M:     Magnus Damm <magnus.damm@gmail.com>
-L:     linux-sh@vger.kernel.org
-Q:     http://patchwork.kernel.org/project/linux-sh/list/
+L:     linux-renesas-soc@vger.kernel.org
+Q:     http://patchwork.kernel.org/project/linux-renesas-soc/list/
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git next
 S:     Supported
 F:     arch/arm64/boot/dts/renesas/
@@ -2368,14 +2375,6 @@ T:       git git://git.kernel.org/pub/scm/linux/kernel/git/rpi/linux-rpi.git
 S:     Maintained
 N:     bcm2835
 
-BROADCOM BCM33XX MIPS ARCHITECTURE
-M:     Kevin Cernekee <cernekee@gmail.com>
-L:     linux-mips@linux-mips.org
-S:     Maintained
-F:     arch/mips/bcm3384/*
-F:     arch/mips/include/asm/mach-bcm3384/*
-F:     arch/mips/kernel/*bmips*
-
 BROADCOM BCM47XX MIPS ARCHITECTURE
 M:     Hauke Mehrtens <hauke@hauke-m.de>
 M:     Rafał Miłecki <zajec5@gmail.com>
@@ -3458,7 +3457,6 @@ F:        drivers/usb/dwc2/
 DESIGNWARE USB3 DRD IP DRIVER
 M:     Felipe Balbi <balbi@kernel.org>
 L:     linux-usb@vger.kernel.org
-L:     linux-omap@vger.kernel.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
 S:     Maintained
 F:     drivers/usb/dwc3/
@@ -3766,7 +3764,7 @@ F:        include/drm/exynos*
 F:     include/uapi/drm/exynos*
 
 DRM DRIVERS FOR FREESCALE DCU
-M:     Jianwei Wang <jianwei.wang.chn@gmail.com>
+M:     Stefan Agner <stefan@agner.ch>
 M:     Alison Wang <alison.wang@freescale.com>
 L:     dri-devel@lists.freedesktop.org
 S:     Supported
@@ -4528,6 +4526,12 @@ L:       linuxppc-dev@lists.ozlabs.org
 S:     Maintained
 F:     drivers/dma/fsldma.*
 
+FREESCALE GPMI NAND DRIVER
+M:     Han Xu <han.xu@nxp.com>
+L:     linux-mtd@lists.infradead.org
+S:     Maintained
+F:     drivers/mtd/nand/gpmi-nand/*
+
 FREESCALE I2C CPM DRIVER
 M:     Jochen Friedrich <jochen@scram.de>
 L:     linuxppc-dev@lists.ozlabs.org
@@ -4544,7 +4548,7 @@ F:        include/linux/platform_data/video-imxfb.h
 F:     drivers/video/fbdev/imxfb.c
 
 FREESCALE QUAD SPI DRIVER
-M:     Han Xu <han.xu@freescale.com>
+M:     Han Xu <han.xu@nxp.com>
 L:     linux-mtd@lists.infradead.org
 S:     Maintained
 F:     drivers/mtd/spi-nor/fsl-quadspi.c
@@ -4558,6 +4562,15 @@ S:       Maintained
 F:     drivers/net/ethernet/freescale/fs_enet/
 F:     include/linux/fs_enet_pd.h
 
+FREESCALE IMX / MXC FEC DRIVER
+M:     Fugang Duan <fugang.duan@nxp.com>
+L:     netdev@vger.kernel.org
+S:     Maintained
+F:     drivers/net/ethernet/freescale/fec_main.c
+F:     drivers/net/ethernet/freescale/fec_ptp.c
+F:     drivers/net/ethernet/freescale/fec.h
+F:     Documentation/devicetree/bindings/net/fsl-fec.txt
+
 FREESCALE QUICC ENGINE LIBRARY
 L:     linuxppc-dev@lists.ozlabs.org
 S:     Orphan
@@ -6144,7 +6157,7 @@ F:        include/uapi/linux/sunrpc/
 
 KERNEL SELFTEST FRAMEWORK
 M:     Shuah Khan <shuahkh@osg.samsung.com>
-L:     linux-api@vger.kernel.org
+L:     linux-kselftest@vger.kernel.org
 T:     git git://git.kernel.org/pub/scm/shuah/linux-kselftest
 S:     Maintained
 F:     tools/testing/selftests
@@ -6774,6 +6787,7 @@ S:        Maintained
 F:     Documentation/networking/mac80211-injection.txt
 F:     include/net/mac80211.h
 F:     net/mac80211/
+F:     drivers/net/wireless/mac80211_hwsim.[ch]
 
 MACVLAN DRIVER
 M:     Patrick McHardy <kaber@trash.net>
@@ -7370,7 +7384,7 @@ F:        drivers/tty/isicom.c
 F:     include/linux/isicom.h
 
 MUSB MULTIPOINT HIGH SPEED DUAL-ROLE CONTROLLER
-M:     Felipe Balbi <balbi@kernel.org>
+M:     Bin Liu <b-liu@ti.com>
 L:     linux-usb@vger.kernel.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
 S:     Maintained
@@ -7702,13 +7716,13 @@ S:      Maintained
 F:     arch/nios2/
 
 NOKIA N900 POWER SUPPLY DRIVERS
-M:     Pali Rohár <pali.rohar@gmail.com>
-S:     Maintained
+R:     Pali Rohár <pali.rohar@gmail.com>
 F:     include/linux/power/bq2415x_charger.h
 F:     include/linux/power/bq27xxx_battery.h
 F:     include/linux/power/isp1704_charger.h
 F:     drivers/power/bq2415x_charger.c
 F:     drivers/power/bq27xxx_battery.c
+F:     drivers/power/bq27xxx_battery_i2c.c
 F:     drivers/power/isp1704_charger.c
 F:     drivers/power/rx51_battery.c
 
@@ -7939,11 +7953,9 @@ F:       drivers/media/platform/omap3isp/
 F:     drivers/staging/media/omap4iss/
 
 OMAP USB SUPPORT
-M:     Felipe Balbi <balbi@kernel.org>
 L:     linux-usb@vger.kernel.org
 L:     linux-omap@vger.kernel.org
-T:     git git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git
-S:     Maintained
+S:     Orphan
 F:     drivers/usb/*/*omap*
 F:     arch/arm/*omap*/usb*
 
@@ -9574,6 +9586,12 @@ M:       Andreas Noever <andreas.noever@gmail.com>
 S:     Maintained
 F:     drivers/thunderbolt/
 
+TI BQ27XXX POWER SUPPLY DRIVER
+R:     Andrew F. Davis <afd@ti.com>
+F:     include/linux/power/bq27xxx_battery.h
+F:     drivers/power/bq27xxx_battery.c
+F:     drivers/power/bq27xxx_battery_i2c.c
+
 TIMEKEEPING, CLOCKSOURCE CORE, NTP, ALARMTIMER
 M:     John Stultz <john.stultz@linaro.org>
 M:     Thomas Gleixner <tglx@linutronix.de>
@@ -9795,10 +9813,11 @@ S:      Supported
 F:     drivers/scsi/be2iscsi/
 
 Emulex 10Gbps NIC BE2, BE3-R, Lancer, Skyhawk-R DRIVER
-M:     Sathya Perla <sathya.perla@avagotech.com>
-M:     Ajit Khaparde <ajit.khaparde@avagotech.com>
-M:     Padmanabh Ratnakar <padmanabh.ratnakar@avagotech.com>
-M:     Sriharsha Basavapatna <sriharsha.basavapatna@avagotech.com>
+M:     Sathya Perla <sathya.perla@broadcom.com>
+M:     Ajit Khaparde <ajit.khaparde@broadcom.com>
+M:     Padmanabh Ratnakar <padmanabh.ratnakar@broadcom.com>
+M:     Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
+M:     Somnath Kotur <somnath.kotur@broadcom.com>
 L:     netdev@vger.kernel.org
 W:     http://www.emulex.com
 S:     Supported
@@ -10857,6 +10876,14 @@ L:     linux-omap@vger.kernel.org
 S:     Maintained
 F:     drivers/thermal/ti-soc-thermal/
 
+TI VPE/CAL DRIVERS
+M:     Benoit Parrot <bparrot@ti.com>
+L:     linux-media@vger.kernel.org
+W:     http://linuxtv.org/
+Q:     http://patchwork.linuxtv.org/project/linux-media/list/
+S:     Maintained
+F:     drivers/media/platform/ti-vpe/
+
 TI CDCE706 CLOCK DRIVER
 M:     Max Filippov <jcmvbkbc@gmail.com>
 S:     Maintained
@@ -12028,7 +12055,6 @@ F:      arch/arm64/xen/
 F:     arch/arm64/include/asm/xen/
 
 XEN NETWORK BACKEND DRIVER
-M:     Ian Campbell <ian.campbell@citrix.com>
 M:     Wei Liu <wei.liu2@citrix.com>
 L:     xen-devel@lists.xenproject.org (moderated for non-subscribers)
 L:     netdev@vger.kernel.org
index 6828408..2d519d2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 4
 PATCHLEVEL = 5
 SUBLEVEL = 0
-EXTRAVERSION = -rc3
+EXTRAVERSION = -rc7
 NAME = Blurry Fish Butt
 
 # *DOCUMENTATION*
index 76dde9d..8a188bc 100644 (file)
@@ -12,8 +12,6 @@ config ARC
        select BUILDTIME_EXTABLE_SORT
        select COMMON_CLK
        select CLONE_BACKWARDS
-       # ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
-       select DEVTMPFS if !INITRAMFS_SOURCE=""
        select GENERIC_ATOMIC64
        select GENERIC_CLOCKEVENTS
        select GENERIC_FIND_FIRST_BIT
@@ -275,14 +273,6 @@ config ARC_DCCM_BASE
        default "0xA0000000"
        depends on ARC_HAS_DCCM
 
-config ARC_HAS_HW_MPY
-       bool "Use Hardware Multiplier (Normal or Faster XMAC)"
-       default y
-       help
-         Influences how gcc generates code for MPY operations.
-         If enabled, MPYxx insns are generated, provided by Standard/XMAC
-         Multipler. Otherwise software multipy lib is used
-
 choice
        prompt "MMU Version"
        default ARC_MMU_V3 if ARC_CPU_770
@@ -338,6 +328,19 @@ config ARC_PAGE_SIZE_4K
 
 endchoice
 
+choice
+       prompt "MMU Super Page Size"
+       depends on ISA_ARCV2 && TRANSPARENT_HUGEPAGE
+       default ARC_HUGEPAGE_2M
+
+config ARC_HUGEPAGE_2M
+       bool "2MB"
+
+config ARC_HUGEPAGE_16M
+       bool "16MB"
+
+endchoice
+
 if ISA_ARCOMPACT
 
 config ARC_COMPACT_IRQ_LEVELS
@@ -410,7 +413,7 @@ config ARC_HAS_RTC
        default n
        depends on !SMP
 
-config ARC_HAS_GRTC
+config ARC_HAS_GFRC
        bool "SMP synchronized 64-bit cycle counter"
        default y
        depends on SMP
@@ -529,14 +532,6 @@ config ARC_DBG_TLB_MISS_COUNT
          Counts number of I and D TLB Misses and exports them via Debugfs
          The counters can be cleared via Debugfs as well
 
-if SMP
-
-config ARC_IPI_DBG
-       bool "Debug Inter Core interrupts"
-       default n
-
-endif
-
 endif
 
 config ARC_UBOOT_SUPPORT
@@ -566,6 +561,12 @@ endmenu
 endmenu         # "ARC Architecture Configuration"
 
 source "mm/Kconfig"
+
+config FORCE_MAX_ZONEORDER
+       int "Maximum zone order"
+       default "12" if ARC_HUGEPAGE_16M
+       default "11"
+
 source "net/Kconfig"
 source "drivers/Kconfig"
 source "fs/Kconfig"
index aeb1902..c8230f3 100644 (file)
@@ -74,10 +74,6 @@ ldflags-$(CONFIG_CPU_BIG_ENDIAN)     += -EB
 # --build-id w/o "-marclinux". Default arc-elf32-ld is OK
 ldflags-$(upto_gcc44)                  += -marclinux
 
-ifndef CONFIG_ARC_HAS_HW_MPY
-       cflags-y        += -mno-mpy
-endif
-
 LIBGCC := $(shell $(CC) $(cflags-y) --print-libgcc-file-name)
 
 # Modules with short calls might break for calls into builtin-kernel
index f1ac981..5d4e2a0 100644 (file)
@@ -39,6 +39,7 @@ CONFIG_IP_PNP_RARP=y
 # CONFIG_INET_XFRM_MODE_TUNNEL is not set
 # CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_IPV6 is not set
+CONFIG_DEVTMPFS=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FIRMWARE_IN_KERNEL is not set
@@ -73,7 +74,6 @@ CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_DESIGNWARE_PLATFORM=y
 # CONFIG_HWMON is not set
 CONFIG_FB=y
-# CONFIG_VGA_CONSOLE is not set
 CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
 CONFIG_LOGO=y
@@ -91,12 +91,10 @@ CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_DW=y
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_EXT3_FS=y
-CONFIG_EXT4_FS=y
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
 CONFIG_NTFS_FS=y
 CONFIG_TMPFS=y
-CONFIG_JFFS2_FS=y
 CONFIG_NFS_FS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ISO8859_1=y
index 323486d..87ee46b 100644 (file)
@@ -39,14 +39,10 @@ CONFIG_IP_PNP_RARP=y
 # CONFIG_INET_XFRM_MODE_TUNNEL is not set
 # CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_IPV6 is not set
+CONFIG_DEVTMPFS=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FIRMWARE_IN_KERNEL is not set
-CONFIG_MTD=y
-CONFIG_MTD_CMDLINE_PARTS=y
-CONFIG_MTD_BLOCK=y
-CONFIG_MTD_NAND=y
-CONFIG_MTD_NAND_AXS=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_NETDEVICES=y
@@ -78,14 +74,12 @@ CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_DESIGNWARE_PLATFORM=y
 # CONFIG_HWMON is not set
 CONFIG_FB=y
-# CONFIG_VGA_CONSOLE is not set
 CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
 CONFIG_LOGO=y
 # CONFIG_LOGO_LINUX_MONO is not set
 # CONFIG_LOGO_LINUX_VGA16 is not set
 # CONFIG_LOGO_LINUX_CLUT224 is not set
-CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_HCD_PLATFORM=y
 CONFIG_USB_OHCI_HCD=y
@@ -97,12 +91,10 @@ CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_DW=y
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_EXT3_FS=y
-CONFIG_EXT4_FS=y
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
 CONFIG_NTFS_FS=y
 CONFIG_TMPFS=y
-CONFIG_JFFS2_FS=y
 CONFIG_NFS_FS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ISO8859_1=y
index 66191cd..d80daf4 100644 (file)
@@ -40,14 +40,10 @@ CONFIG_IP_PNP_RARP=y
 # CONFIG_INET_XFRM_MODE_TUNNEL is not set
 # CONFIG_INET_XFRM_MODE_BEET is not set
 # CONFIG_IPV6 is not set
+CONFIG_DEVTMPFS=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FIRMWARE_IN_KERNEL is not set
-CONFIG_MTD=y
-CONFIG_MTD_CMDLINE_PARTS=y
-CONFIG_MTD_BLOCK=y
-CONFIG_MTD_NAND=y
-CONFIG_MTD_NAND_AXS=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_NETDEVICES=y
@@ -79,14 +75,12 @@ CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_DESIGNWARE_PLATFORM=y
 # CONFIG_HWMON is not set
 CONFIG_FB=y
-# CONFIG_VGA_CONSOLE is not set
 CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
 CONFIG_LOGO=y
 # CONFIG_LOGO_LINUX_MONO is not set
 # CONFIG_LOGO_LINUX_VGA16 is not set
 # CONFIG_LOGO_LINUX_CLUT224 is not set
-CONFIG_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_HCD_PLATFORM=y
 CONFIG_USB_OHCI_HCD=y
@@ -98,12 +92,10 @@ CONFIG_MMC_SDHCI_PLTFM=y
 CONFIG_MMC_DW=y
 # CONFIG_IOMMU_SUPPORT is not set
 CONFIG_EXT3_FS=y
-CONFIG_EXT4_FS=y
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
 CONFIG_NTFS_FS=y
 CONFIG_TMPFS=y
-CONFIG_JFFS2_FS=y
 CONFIG_NFS_FS=y
 CONFIG_NLS_CODEPAGE_437=y
 CONFIG_NLS_ISO8859_1=y
index 138f9d8..f410953 100644 (file)
@@ -4,6 +4,7 @@ CONFIG_DEFAULT_HOSTNAME="ARCLinux"
 # CONFIG_SWAP is not set
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
+# CONFIG_CROSS_MEMORY_ATTACH is not set
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
@@ -26,7 +27,6 @@ CONFIG_ARC_PLAT_SIM=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsim_700"
 CONFIG_PREEMPT=y
 # CONFIG_COMPACTION is not set
-# CONFIG_CROSS_MEMORY_ATTACH is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -34,6 +34,7 @@ CONFIG_UNIX_DIAG=y
 CONFIG_NET_KEY=y
 CONFIG_INET=y
 # CONFIG_IPV6 is not set
+CONFIG_DEVTMPFS=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FIRMWARE_IN_KERNEL is not set
@@ -51,7 +52,6 @@ CONFIG_SERIAL_ARC=y
 CONFIG_SERIAL_ARC_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
 # CONFIG_HWMON is not set
-# CONFIG_VGA_CONSOLE is not set
 # CONFIG_HID is not set
 # CONFIG_USB_SUPPORT is not set
 # CONFIG_IOMMU_SUPPORT is not set
@@ -63,4 +63,3 @@ CONFIG_NFS_FS=y
 # CONFIG_ENABLE_WARN_DEPRECATED is not set
 # CONFIG_ENABLE_MUST_CHECK is not set
 # CONFIG_DEBUG_PREEMPT is not set
-CONFIG_XZ_DEC=y
index f68838e..cfaa33c 100644 (file)
@@ -35,6 +35,7 @@ CONFIG_UNIX_DIAG=y
 CONFIG_NET_KEY=y
 CONFIG_INET=y
 # CONFIG_IPV6 is not set
+CONFIG_DEVTMPFS=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FIRMWARE_IN_KERNEL is not set
@@ -49,7 +50,6 @@ CONFIG_SERIAL_ARC=y
 CONFIG_SERIAL_ARC_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
 # CONFIG_HWMON is not set
-# CONFIG_VGA_CONSOLE is not set
 # CONFIG_HID is not set
 # CONFIG_USB_SUPPORT is not set
 # CONFIG_IOMMU_SUPPORT is not set
@@ -61,4 +61,3 @@ CONFIG_NFS_FS=y
 # CONFIG_ENABLE_WARN_DEPRECATED is not set
 # CONFIG_ENABLE_MUST_CHECK is not set
 # CONFIG_DEBUG_PREEMPT is not set
-CONFIG_XZ_DEC=y
index 96bd1c2..bb2a8dc 100644 (file)
@@ -2,6 +2,7 @@ CONFIG_CROSS_COMPILE="arc-linux-"
 # CONFIG_LOCALVERSION_AUTO is not set
 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
 # CONFIG_SWAP is not set
+# CONFIG_CROSS_MEMORY_ATTACH is not set
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_IKCONFIG=y
 CONFIG_IKCONFIG_PROC=y
@@ -21,13 +22,11 @@ CONFIG_MODULES=y
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
 CONFIG_ARC_PLAT_SIM=y
-CONFIG_ARC_BOARD_ML509=y
 CONFIG_ISA_ARCV2=y
 CONFIG_SMP=y
 CONFIG_ARC_BUILTIN_DTB_NAME="nsim_hs_idu"
 CONFIG_PREEMPT=y
 # CONFIG_COMPACTION is not set
-# CONFIG_CROSS_MEMORY_ATTACH is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -35,6 +34,7 @@ CONFIG_UNIX_DIAG=y
 CONFIG_NET_KEY=y
 CONFIG_INET=y
 # CONFIG_IPV6 is not set
+CONFIG_DEVTMPFS=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FIRMWARE_IN_KERNEL is not set
@@ -49,7 +49,6 @@ CONFIG_SERIAL_ARC=y
 CONFIG_SERIAL_ARC_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
 # CONFIG_HWMON is not set
-# CONFIG_VGA_CONSOLE is not set
 # CONFIG_HID is not set
 # CONFIG_USB_SUPPORT is not set
 # CONFIG_IOMMU_SUPPORT is not set
@@ -60,4 +59,3 @@ CONFIG_TMPFS=y
 CONFIG_NFS_FS=y
 # CONFIG_ENABLE_WARN_DEPRECATED is not set
 # CONFIG_ENABLE_MUST_CHECK is not set
-CONFIG_XZ_DEC=y
index 31e1d95..646182e 100644 (file)
@@ -33,6 +33,7 @@ CONFIG_UNIX_DIAG=y
 CONFIG_NET_KEY=y
 CONFIG_INET=y
 # CONFIG_IPV6 is not set
+CONFIG_DEVTMPFS=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FIRMWARE_IN_KERNEL is not set
@@ -58,7 +59,6 @@ CONFIG_SERIAL_OF_PLATFORM=y
 # CONFIG_HW_RANDOM is not set
 # CONFIG_HWMON is not set
 CONFIG_FB=y
-# CONFIG_VGA_CONSOLE is not set
 CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_LOGO=y
 # CONFIG_HID is not set
index fcae666..ceca254 100644 (file)
@@ -34,12 +34,12 @@ CONFIG_UNIX_DIAG=y
 CONFIG_NET_KEY=y
 CONFIG_INET=y
 # CONFIG_IPV6 is not set
+CONFIG_DEVTMPFS=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FIRMWARE_IN_KERNEL is not set
 # CONFIG_BLK_DEV is not set
 CONFIG_NETDEVICES=y
-CONFIG_NET_OSCI_LAN=y
 CONFIG_INPUT_EVDEV=y
 # CONFIG_MOUSE_PS2_ALPS is not set
 # CONFIG_MOUSE_PS2_LOGIPS2PP is not set
@@ -58,7 +58,6 @@ CONFIG_SERIAL_OF_PLATFORM=y
 # CONFIG_HW_RANDOM is not set
 # CONFIG_HWMON is not set
 CONFIG_FB=y
-# CONFIG_VGA_CONSOLE is not set
 CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_LOGO=y
 # CONFIG_HID is not set
index b01b659..4b6da90 100644 (file)
@@ -2,6 +2,7 @@ CONFIG_CROSS_COMPILE="arc-linux-"
 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
 # CONFIG_SWAP is not set
 CONFIG_SYSVIPC=y
+# CONFIG_CROSS_MEMORY_ATTACH is not set
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_IKCONFIG=y
@@ -18,15 +19,11 @@ CONFIG_MODULES=y
 # CONFIG_IOSCHED_DEADLINE is not set
 # CONFIG_IOSCHED_CFQ is not set
 CONFIG_ARC_PLAT_SIM=y
-CONFIG_ARC_BOARD_ML509=y
 CONFIG_ISA_ARCV2=y
 CONFIG_SMP=y
-CONFIG_ARC_HAS_LL64=y
-# CONFIG_ARC_HAS_RTSC is not set
 CONFIG_ARC_BUILTIN_DTB_NAME="nsimosci_hs_idu"
 CONFIG_PREEMPT=y
 # CONFIG_COMPACTION is not set
-# CONFIG_CROSS_MEMORY_ATTACH is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_PACKET_DIAG=y
@@ -40,6 +37,7 @@ CONFIG_INET=y
 # CONFIG_INET_LRO is not set
 # CONFIG_IPV6 is not set
 # CONFIG_WIRELESS is not set
+CONFIG_DEVTMPFS=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FIRMWARE_IN_KERNEL is not set
@@ -56,14 +54,11 @@ CONFIG_NETDEVICES=y
 # CONFIG_NET_VENDOR_STMICRO is not set
 # CONFIG_NET_VENDOR_VIA is not set
 # CONFIG_NET_VENDOR_WIZNET is not set
-CONFIG_NET_OSCI_LAN=y
 # CONFIG_WLAN is not set
 CONFIG_INPUT_EVDEV=y
 CONFIG_MOUSE_PS2_TOUCHKIT=y
 # CONFIG_SERIO_SERPORT is not set
-CONFIG_SERIO_LIBPS2=y
 CONFIG_SERIO_ARC_PS2=y
-CONFIG_VT_HW_CONSOLE_BINDING=y
 # CONFIG_LEGACY_PTYS is not set
 # CONFIG_DEVKMEM is not set
 CONFIG_SERIAL_8250=y
@@ -75,9 +70,6 @@ CONFIG_SERIAL_OF_PLATFORM=y
 # CONFIG_HW_RANDOM is not set
 # CONFIG_HWMON is not set
 CONFIG_FB=y
-CONFIG_ARCPGU_RGB888=y
-CONFIG_ARCPGU_DISPTYPE=0
-# CONFIG_VGA_CONSOLE is not set
 CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_LOGO=y
 # CONFIG_HID is not set
index 3b4dc9c..9b342ea 100644 (file)
@@ -3,6 +3,7 @@ CONFIG_CROSS_COMPILE="arc-linux-"
 CONFIG_DEFAULT_HOSTNAME="tb10x"
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
+# CONFIG_CROSS_MEMORY_ATTACH is not set
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_BSD_PROCESS_ACCT=y
 CONFIG_BSD_PROCESS_ACCT_V3=y
@@ -26,12 +27,10 @@ CONFIG_MODULE_UNLOAD=y
 # CONFIG_BLOCK is not set
 CONFIG_ARC_PLAT_TB10X=y
 CONFIG_ARC_CACHE_LINE_SHIFT=5
-CONFIG_ARC_STACK_NONEXEC=y
 CONFIG_HZ=250
 CONFIG_ARC_BUILTIN_DTB_NAME="abilis_tb100_dvk"
 CONFIG_PREEMPT_VOLUNTARY=y
 # CONFIG_COMPACTION is not set
-# CONFIG_CROSS_MEMORY_ATTACH is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
 CONFIG_UNIX=y
@@ -44,8 +43,8 @@ CONFIG_IP_MULTICAST=y
 # CONFIG_INET_DIAG is not set
 # CONFIG_IPV6 is not set
 # CONFIG_WIRELESS is not set
+CONFIG_DEVTMPFS=y
 # CONFIG_FIRMWARE_IN_KERNEL is not set
-CONFIG_PROC_DEVICETREE=y
 CONFIG_NETDEVICES=y
 # CONFIG_NET_CADENCE is not set
 # CONFIG_NET_VENDOR_BROADCOM is not set
@@ -55,9 +54,6 @@ CONFIG_NETDEVICES=y
 # CONFIG_NET_VENDOR_NATSEMI is not set
 # CONFIG_NET_VENDOR_SEEQ is not set
 CONFIG_STMMAC_ETH=y
-CONFIG_STMMAC_DEBUG_FS=y
-CONFIG_STMMAC_DA=y
-CONFIG_STMMAC_CHAINED=y
 # CONFIG_NET_VENDOR_WIZNET is not set
 # CONFIG_WLAN is not set
 # CONFIG_INPUT is not set
@@ -91,7 +87,6 @@ CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
 CONFIG_LEDS_TRIGGER_TRANSIENT=y
 CONFIG_DMADEVICES=y
 CONFIG_DW_DMAC=y
-CONFIG_NET_DMA=y
 CONFIG_ASYNC_TX_DMA=y
 # CONFIG_IOMMU_SUPPORT is not set
 # CONFIG_DNOTIFY is not set
@@ -100,17 +95,16 @@ CONFIG_TMPFS=y
 CONFIG_CONFIGFS_FS=y
 # CONFIG_MISC_FILESYSTEMS is not set
 # CONFIG_NETWORK_FILESYSTEMS is not set
+CONFIG_DEBUG_INFO=y
 # CONFIG_ENABLE_WARN_DEPRECATED is not set
-CONFIG_MAGIC_SYSRQ=y
 CONFIG_STRIP_ASM_SYMS=y
 CONFIG_DEBUG_FS=y
 CONFIG_HEADERS_CHECK=y
 CONFIG_DEBUG_SECTION_MISMATCH=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_MEMORY_INIT=y
+CONFIG_DEBUG_STACKOVERFLOW=y
 CONFIG_DETECT_HUNG_TASK=y
 CONFIG_SCHEDSTATS=y
 CONFIG_TIMER_STATS=y
-CONFIG_DEBUG_INFO=y
-CONFIG_DEBUG_MEMORY_INIT=y
-CONFIG_DEBUG_STACKOVERFLOW=y
-# CONFIG_CRYPTO_ANSI_CPRNG is not set
 # CONFIG_CRYPTO_HW is not set
index f36c047..7359859 100644 (file)
@@ -16,7 +16,7 @@ CONFIG_ARC_PLAT_AXS10X=y
 CONFIG_AXS103=y
 CONFIG_ISA_ARCV2=y
 CONFIG_SMP=y
-# CONFIG_ARC_HAS_GRTC is not set
+# CONFIG_ARC_HAS_GFRC is not set
 CONFIG_ARC_UBOOT_SUPPORT=y
 CONFIG_ARC_BUILTIN_DTB_NAME="vdk_hs38_smp"
 CONFIG_PREEMPT=y
index 7fac7d8..f9f4c6f 100644 (file)
@@ -10,7 +10,8 @@
 #define _ASM_ARC_ARCREGS_H
 
 /* Build Configuration Registers */
-#define ARC_REG_DCCMBASE_BCR   0x61    /* DCCM Base Addr */
+#define ARC_REG_AUX_DCCM       0x18    /* DCCM Base Addr ARCv2 */
+#define ARC_REG_DCCM_BASE_BUILD        0x61    /* DCCM Base Addr ARCompact */
 #define ARC_REG_CRC_BCR                0x62
 #define ARC_REG_VECBASE_BCR    0x68
 #define ARC_REG_PERIBASE_BCR   0x69
 #define ARC_REG_DPFP_BCR       0x6C    /* ARCompact: Dbl Precision FPU */
 #define ARC_REG_FP_V2_BCR      0xc8    /* ARCv2 FPU */
 #define ARC_REG_SLC_BCR                0xce
-#define ARC_REG_DCCM_BCR       0x74    /* DCCM Present + SZ */
+#define ARC_REG_DCCM_BUILD     0x74    /* DCCM size (common) */
 #define ARC_REG_TIMERS_BCR     0x75
 #define ARC_REG_AP_BCR         0x76
-#define ARC_REG_ICCM_BCR       0x78
+#define ARC_REG_ICCM_BUILD     0x78    /* ICCM size (common) */
 #define ARC_REG_XY_MEM_BCR     0x79
 #define ARC_REG_MAC_BCR                0x7a
 #define ARC_REG_MUL_BCR                0x7b
@@ -36,6 +37,7 @@
 #define ARC_REG_IRQ_BCR                0xF3
 #define ARC_REG_SMART_BCR      0xFF
 #define ARC_REG_CLUSTER_BCR    0xcf
+#define ARC_REG_AUX_ICCM       0x208   /* ICCM Base Addr (ARCv2) */
 
 /* status32 Bits Positions */
 #define STATUS_AE_BIT          5       /* Exception active */
@@ -246,7 +248,7 @@ struct bcr_perip {
 #endif
 };
 
-struct bcr_iccm {
+struct bcr_iccm_arcompact {
 #ifdef CONFIG_CPU_BIG_ENDIAN
        unsigned int base:16, pad:5, sz:3, ver:8;
 #else
@@ -254,17 +256,15 @@ struct bcr_iccm {
 #endif
 };
 
-/* DCCM Base Address Register: ARC_REG_DCCMBASE_BCR */
-struct bcr_dccm_base {
+struct bcr_iccm_arcv2 {
 #ifdef CONFIG_CPU_BIG_ENDIAN
-       unsigned int addr:24, ver:8;
+       unsigned int pad:8, sz11:4, sz01:4, sz10:4, sz00:4, ver:8;
 #else
-       unsigned int ver:8, addr:24;
+       unsigned int ver:8, sz00:4, sz10:4, sz01:4, sz11:4, pad:8;
 #endif
 };
 
-/* DCCM RAM Configuration Register: ARC_REG_DCCM_BCR */
-struct bcr_dccm {
+struct bcr_dccm_arcompact {
 #ifdef CONFIG_CPU_BIG_ENDIAN
        unsigned int res:21, sz:3, ver:8;
 #else
@@ -272,6 +272,14 @@ struct bcr_dccm {
 #endif
 };
 
+struct bcr_dccm_arcv2 {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+       unsigned int pad2:12, cyc:3, pad1:1, sz1:4, sz0:4, ver:8;
+#else
+       unsigned int ver:8, sz0:4, sz1:4, pad1:1, cyc:3, pad2:12;
+#endif
+};
+
 /* ARCompact: Both SP and DP FPU BCRs have same format */
 struct bcr_fp_arcompact {
 #ifdef CONFIG_CPU_BIG_ENDIAN
@@ -315,9 +323,9 @@ struct bcr_bpu_arcv2 {
 
 struct bcr_generic {
 #ifdef CONFIG_CPU_BIG_ENDIAN
-       unsigned int pad:24, ver:8;
+       unsigned int info:24, ver:8;
 #else
-       unsigned int ver:8, pad:24;
+       unsigned int ver:8, info:24;
 #endif
 };
 
@@ -349,14 +357,13 @@ struct cpuinfo_arc {
        struct cpuinfo_arc_bpu bpu;
        struct bcr_identity core;
        struct bcr_isa isa;
-       struct bcr_timer timers;
        unsigned int vec_base;
        struct cpuinfo_arc_ccm iccm, dccm;
        struct {
                unsigned int swap:1, norm:1, minmax:1, barrel:1, crc:1, pad1:3,
                             fpu_sp:1, fpu_dp:1, pad2:6,
                             debug:1, ap:1, smart:1, rtt:1, pad3:4,
-                            pad4:8;
+                            timer0:1, timer1:1, rtc:1, gfrc:1, pad4:4;
        } extn;
        struct bcr_mpy extn_mpy;
        struct bcr_extn_xymem extn_xymem;
index 4fd7d62..49014f0 100644 (file)
 #ifdef CONFIG_ISA_ARCOMPACT
 #define TIMER0_IRQ      3
 #define TIMER1_IRQ      4
-#define IPI_IRQ                (NR_CPU_IRQS-1) /* dummy to enable SMP build for up hardware */
 #else
 #define TIMER0_IRQ      16
 #define TIMER1_IRQ      17
-#define IPI_IRQ         19
 #endif
 
 #include <linux/interrupt.h>
index 258b0e5..37c2f75 100644 (file)
@@ -22,6 +22,7 @@
 #define AUX_IRQ_CTRL           0x00E
 #define AUX_IRQ_ACT            0x043   /* Active Intr across all levels */
 #define AUX_IRQ_LVL_PEND       0x200   /* Pending Intr across all levels */
+#define AUX_IRQ_HINT           0x201   /* For generating Soft Interrupts */
 #define AUX_IRQ_PRIORITY       0x206
 #define ICAUSE                 0x40a
 #define AUX_IRQ_SELECT         0x40b
 /* Was Intr taken in User Mode */
 #define AUX_IRQ_ACT_BIT_U      31
 
-/* 0 is highest level, but taken by FIRQs, if present in design */
-#define ARCV2_IRQ_DEF_PRIO             0
+/*
+ * User space should be interruptable even by lowest prio interrupt
+ * Safe even if actual interrupt priorities is fewer or even one
+ */
+#define ARCV2_IRQ_DEF_PRIO     15
 
 /* seed value for status register */
 #define ISA_INIT_STATUS_BITS   (STATUS_IE_MASK | STATUS_AD_MASK | \
@@ -112,6 +116,16 @@ static inline int arch_irqs_disabled(void)
        return arch_irqs_disabled_flags(arch_local_save_flags());
 }
 
+static inline void arc_softirq_trigger(int irq)
+{
+       write_aux_reg(AUX_IRQ_HINT, irq);
+}
+
+static inline void arc_softirq_clear(int irq)
+{
+       write_aux_reg(AUX_IRQ_HINT, 0);
+}
+
 #else
 
 .macro IRQ_DISABLE  scratch
index 46f4e53..847e3bb 100644 (file)
@@ -39,8 +39,8 @@ struct mcip_cmd {
 #define CMD_DEBUG_SET_MASK             0x34
 #define CMD_DEBUG_SET_SELECT           0x36
 
-#define CMD_GRTC_READ_LO               0x42
-#define CMD_GRTC_READ_HI               0x43
+#define CMD_GFRC_READ_LO               0x42
+#define CMD_GFRC_READ_HI               0x43
 
 #define CMD_IDU_ENABLE                 0x71
 #define CMD_IDU_DISABLE                        0x72
index 57af2f0..d426d42 100644 (file)
 #define __S111  PAGE_U_X_W_R
 
 /****************************************************************
- * Page Table Lookup split
+ * 2 tier (PGD:PTE) software page walker
  *
- * We implement 2 tier paging and since this is all software, we are free
- * to customize the span of a PGD / PTE entry to suit us
- *
- *                     32 bit virtual address
+ * [31]                    32 bit virtual address              [0]
  * -------------------------------------------------------
- * | BITS_FOR_PGD    |  BITS_FOR_PTE    |  BITS_IN_PAGE  |
+ * |               | <------------ PGDIR_SHIFT ----------> |
+ * |              |                                     |
+ * | BITS_FOR_PGD  |  BITS_FOR_PTE  | <-- PAGE_SHIFT --> |
  * -------------------------------------------------------
  *       |                  |                |
  *       |                  |                --> off in page frame
- *       |                 |
  *       |                  ---> index into Page Table
- *       |
  *       ----> index into Page Directory
+ *
+ * In a single page size configuration, only PAGE_SHIFT is fixed
+ * So both PGD and PTE sizing can be tweaked
+ *  e.g. 8K page (PAGE_SHIFT 13) can have
+ *  - PGDIR_SHIFT 21  -> 11:8:13 address split
+ *  - PGDIR_SHIFT 24  -> 8:11:13 address split
+ *
+ * If Super Page is configured, PGDIR_SHIFT becomes fixed too,
+ * so the sizing flexibility is gone.
  */
 
-#define BITS_IN_PAGE   PAGE_SHIFT
-
-/* Optimal Sizing of Pg Tbl - based on MMU page size */
-#if defined(CONFIG_ARC_PAGE_SIZE_8K)
-#define BITS_FOR_PTE   8               /* 11:8:13 */
-#elif defined(CONFIG_ARC_PAGE_SIZE_16K)
-#define BITS_FOR_PTE   8               /* 10:8:14 */
-#elif defined(CONFIG_ARC_PAGE_SIZE_4K)
-#define BITS_FOR_PTE   9               /* 11:9:12 */
+#if defined(CONFIG_ARC_HUGEPAGE_16M)
+#define PGDIR_SHIFT    24
+#elif defined(CONFIG_ARC_HUGEPAGE_2M)
+#define PGDIR_SHIFT    21
+#else
+/*
+ * Only Normal page support so "hackable" (see comment above)
+ * Default value provides 11:8:13 (8K), 11:9:12 (4K)
+ */
+#define PGDIR_SHIFT    21
 #endif
 
-#define BITS_FOR_PGD   (32 - BITS_FOR_PTE - BITS_IN_PAGE)
+#define BITS_FOR_PTE   (PGDIR_SHIFT - PAGE_SHIFT)
+#define BITS_FOR_PGD   (32 - PGDIR_SHIFT)
 
-#define PGDIR_SHIFT    (32 - BITS_FOR_PGD)
 #define PGDIR_SIZE     (1UL << PGDIR_SHIFT)    /* vaddr span, not PDG sz */
 #define PGDIR_MASK     (~(PGDIR_SIZE-1))
 
index cbfec79..c126460 100644 (file)
@@ -45,11 +45,12 @@ VECTOR      reserved                ; Reserved slots
 VECTOR handle_interrupt        ; (16) Timer0
 VECTOR handle_interrupt        ; unused (Timer1)
 VECTOR handle_interrupt        ; unused (WDT)
-VECTOR handle_interrupt        ; (19) ICI (inter core interrupt)
-VECTOR handle_interrupt
-VECTOR handle_interrupt
-VECTOR handle_interrupt
-VECTOR handle_interrupt        ; (23) End of fixed IRQs
+VECTOR handle_interrupt        ; (19) Inter core Interrupt (IPI)
+VECTOR handle_interrupt        ; (20) perf Interrupt
+VECTOR handle_interrupt        ; (21) Software Triggered Intr (Self IPI)
+VECTOR handle_interrupt        ; unused
+VECTOR handle_interrupt        ; (23) unused
+# End of fixed IRQs
 
 .rept CONFIG_ARC_NUMBER_OF_INTERRUPTS - 8
        VECTOR  handle_interrupt
@@ -211,7 +212,11 @@ debug_marker_syscall:
 ; (since IRQ NOT allowed in DS in ARCv2, this can only happen if orig
 ; entry was via Exception in DS which got preempted in kernel).
 ;
-; IRQ RTIE won't reliably restore DE bit and/or BTA, needs handling
+; IRQ RTIE won't reliably restore DE bit and/or BTA, needs workaround
+;
+; Solution is return from Intr w/o any delay slot quirks into a kernel trampoline
+; and from pure kernel mode return to delay slot which handles DS bit/BTA correctly
+
 .Lintr_ret_to_delay_slot:
 debug_marker_ds:
 
@@ -222,18 +227,23 @@ debug_marker_ds:
        ld      r2, [sp, PT_ret]
        ld      r3, [sp, PT_status32]
 
+       ; STAT32 for Int return created from scratch
+       ; (No delay dlot, disable Further intr in trampoline)
+
        bic     r0, r3, STATUS_U_MASK|STATUS_DE_MASK|STATUS_IE_MASK|STATUS_L_MASK
        st      r0, [sp, PT_status32]
 
        mov     r1, .Lintr_ret_to_delay_slot_2
        st      r1, [sp, PT_ret]
 
+       ; Orig exception PC/STAT32 safekept @orig_r0 and @event stack slots
        st      r2, [sp, 0]
        st      r3, [sp, 4]
 
        b       .Lisr_ret_fast_path
 
 .Lintr_ret_to_delay_slot_2:
+       ; Trampoline to restore orig exception PC/STAT32/BTA/AUX_USER_SP
        sub     sp, sp, SZ_PT_REGS
        st      r9, [sp, -4]
 
@@ -243,11 +253,19 @@ debug_marker_ds:
        ld      r9, [sp, 4]
        sr      r9, [erstatus]
 
+       ; restore AUX_USER_SP if returning to U mode
+       bbit0   r9, STATUS_U_BIT, 1f
+       ld      r9, [sp, PT_sp]
+       sr      r9, [AUX_USER_SP]
+
+1:
        ld      r9, [sp, 8]
        sr      r9, [erbta]
 
        ld      r9, [sp, -4]
        add     sp, sp, SZ_PT_REGS
+
+       ; return from pure kernel mode to delay slot
        rtie
 
 END(ret_from_exception)
index 0394f9f..9425263 100644 (file)
@@ -14,6 +14,8 @@
 #include <linux/irqchip.h>
 #include <asm/irq.h>
 
+static int irq_prio;
+
 /*
  * Early Hardware specific Interrupt setup
  * -Called very early (start_kernel -> setup_arch -> setup_processor)
@@ -24,6 +26,14 @@ void arc_init_IRQ(void)
 {
        unsigned int tmp;
 
+       struct irq_build {
+#ifdef CONFIG_CPU_BIG_ENDIAN
+               unsigned int pad:3, firq:1, prio:4, exts:8, irqs:8, ver:8;
+#else
+               unsigned int ver:8, irqs:8, exts:8, prio:4, firq:1, pad:3;
+#endif
+       } irq_bcr;
+
        struct aux_irq_ctrl {
 #ifdef CONFIG_CPU_BIG_ENDIAN
                unsigned int res3:18, save_idx_regs:1, res2:1,
@@ -46,28 +56,25 @@ void arc_init_IRQ(void)
 
        WRITE_AUX(AUX_IRQ_CTRL, ictrl);
 
-       /* setup status32, don't enable intr yet as kernel doesn't want */
-       tmp = read_aux_reg(0xa);
-       tmp |= ISA_INIT_STATUS_BITS;
-       tmp &= ~STATUS_IE_MASK;
-       asm volatile("flag %0   \n"::"r"(tmp));
-
        /*
         * ARCv2 core intc provides multiple interrupt priorities (upto 16).
         * Typical builds though have only two levels (0-high, 1-low)
         * Linux by default uses lower prio 1 for most irqs, reserving 0 for
         * NMI style interrupts in future (say perf)
-        *
-        * Read the intc BCR to confirm that Linux default priority is avail
-        * in h/w
-        *
-        * Note:
-        *  IRQ_BCR[27..24] contains N-1 (for N priority levels) and prio level
-        *  is 0 based.
         */
-       tmp = (read_aux_reg(ARC_REG_IRQ_BCR) >> 24 ) & 0xF;
-       if (ARCV2_IRQ_DEF_PRIO > tmp)
-               panic("Linux default irq prio incorrect\n");
+
+       READ_BCR(ARC_REG_IRQ_BCR, irq_bcr);
+
+       irq_prio = irq_bcr.prio;        /* Encoded as N-1 for N levels */
+       pr_info("archs-intc\t: %d priority levels (default %d)%s\n",
+               irq_prio + 1, irq_prio,
+               irq_bcr.firq ? " FIRQ (not used)":"");
+
+       /* setup status32, don't enable intr yet as kernel doesn't want */
+       tmp = read_aux_reg(0xa);
+       tmp |= STATUS_AD_MASK | (irq_prio << 1);
+       tmp &= ~STATUS_IE_MASK;
+       asm volatile("flag %0   \n"::"r"(tmp));
 }
 
 static void arcv2_irq_mask(struct irq_data *data)
@@ -86,7 +93,7 @@ void arcv2_irq_enable(struct irq_data *data)
 {
        /* set default priority */
        write_aux_reg(AUX_IRQ_SELECT, data->irq);
-       write_aux_reg(AUX_IRQ_PRIORITY, ARCV2_IRQ_DEF_PRIO);
+       write_aux_reg(AUX_IRQ_PRIORITY, irq_prio);
 
        /*
         * hw auto enables (linux unmask) all by default
index 06bcedf..224d1c3 100644 (file)
@@ -81,9 +81,6 @@ static int arc_intc_domain_map(struct irq_domain *d, unsigned int irq,
 {
        switch (irq) {
        case TIMER0_IRQ:
-#ifdef CONFIG_SMP
-       case IPI_IRQ:
-#endif
                irq_set_chip_and_handler(irq, &onchip_intc, handle_percpu_irq);
                break;
        default:
index bd237ac..c41c364 100644 (file)
 #include <linux/smp.h>
 #include <linux/irq.h>
 #include <linux/spinlock.h>
+#include <asm/irqflags-arcv2.h>
 #include <asm/mcip.h>
 #include <asm/setup.h>
 
+#define IPI_IRQ                19
+#define SOFTIRQ_IRQ    21
+
 static char smp_cpuinfo_buf[128];
 static int idu_detected;
 
@@ -22,6 +26,7 @@ static DEFINE_RAW_SPINLOCK(mcip_lock);
 static void mcip_setup_per_cpu(int cpu)
 {
        smp_ipi_irq_setup(cpu, IPI_IRQ);
+       smp_ipi_irq_setup(cpu, SOFTIRQ_IRQ);
 }
 
 static void mcip_ipi_send(int cpu)
@@ -29,46 +34,44 @@ static void mcip_ipi_send(int cpu)
        unsigned long flags;
        int ipi_was_pending;
 
+       /* ARConnect can only send IPI to others */
+       if (unlikely(cpu == raw_smp_processor_id())) {
+               arc_softirq_trigger(SOFTIRQ_IRQ);
+               return;
+       }
+
+       raw_spin_lock_irqsave(&mcip_lock, flags);
+
        /*
-        * NOTE: We must spin here if the other cpu hasn't yet
-        * serviced a previous message. This can burn lots
-        * of time, but we MUST follows this protocol or
-        * ipi messages can be lost!!!
-        * Also, we must release the lock in this loop because
-        * the other side may get to this same loop and not
-        * be able to ack -- thus causing deadlock.
+        * If receiver already has a pending interrupt, elide sending this one.
+        * Linux cross core calling works well with concurrent IPIs
+        * coalesced into one
+        * see arch/arc/kernel/smp.c: ipi_send_msg_one()
         */
+       __mcip_cmd(CMD_INTRPT_READ_STATUS, cpu);
+       ipi_was_pending = read_aux_reg(ARC_REG_MCIP_READBACK);
+       if (!ipi_was_pending)
+               __mcip_cmd(CMD_INTRPT_GENERATE_IRQ, cpu);
 
-       do {
-               raw_spin_lock_irqsave(&mcip_lock, flags);
-               __mcip_cmd(CMD_INTRPT_READ_STATUS, cpu);
-               ipi_was_pending = read_aux_reg(ARC_REG_MCIP_READBACK);
-               if (ipi_was_pending == 0)
-                       break; /* break out but keep lock */
-               raw_spin_unlock_irqrestore(&mcip_lock, flags);
-       } while (1);
-
-       __mcip_cmd(CMD_INTRPT_GENERATE_IRQ, cpu);
        raw_spin_unlock_irqrestore(&mcip_lock, flags);
-
-#ifdef CONFIG_ARC_IPI_DBG
-       if (ipi_was_pending)
-               pr_info("IPI ACK delayed from cpu %d\n", cpu);
-#endif
 }
 
 static void mcip_ipi_clear(int irq)
 {
        unsigned int cpu, c;
        unsigned long flags;
-       unsigned int __maybe_unused copy;
+
+       if (unlikely(irq == SOFTIRQ_IRQ)) {
+               arc_softirq_clear(irq);
+               return;
+       }
 
        raw_spin_lock_irqsave(&mcip_lock, flags);
 
        /* Who sent the IPI */
        __mcip_cmd(CMD_INTRPT_CHECK_SOURCE, 0);
 
-       copy = cpu = read_aux_reg(ARC_REG_MCIP_READBACK);       /* 1,2,4,8... */
+       cpu = read_aux_reg(ARC_REG_MCIP_READBACK);      /* 1,2,4,8... */
 
        /*
         * In rare case, multiple concurrent IPIs sent to same target can
@@ -82,12 +85,6 @@ static void mcip_ipi_clear(int irq)
        } while (cpu);
 
        raw_spin_unlock_irqrestore(&mcip_lock, flags);
-
-#ifdef CONFIG_ARC_IPI_DBG
-       if (c != __ffs(copy))
-               pr_info("IPIs from %x coalesced to %x\n",
-                       copy, raw_smp_processor_id());
-#endif
 }
 
 static void mcip_probe_n_setup(void)
@@ -96,13 +93,13 @@ static void mcip_probe_n_setup(void)
 #ifdef CONFIG_CPU_BIG_ENDIAN
                unsigned int pad3:8,
                             idu:1, llm:1, num_cores:6,
-                            iocoh:1,  grtc:1, dbg:1, pad2:1,
+                            iocoh:1,  gfrc:1, dbg:1, pad2:1,
                             msg:1, sem:1, ipi:1, pad:1,
                             ver:8;
 #else
                unsigned int ver:8,
                             pad:1, ipi:1, sem:1, msg:1,
-                            pad2:1, dbg:1, grtc:1, iocoh:1,
+                            pad2:1, dbg:1, gfrc:1, iocoh:1,
                             num_cores:6, llm:1, idu:1,
                             pad3:8;
 #endif
@@ -111,12 +108,13 @@ static void mcip_probe_n_setup(void)
        READ_BCR(ARC_REG_MCIP_BCR, mp);
 
        sprintf(smp_cpuinfo_buf,
-               "Extn [SMP]\t: ARConnect (v%d): %d cores with %s%s%s%s\n",
+               "Extn [SMP]\t: ARConnect (v%d): %d cores with %s%s%s%s%s\n",
                mp.ver, mp.num_cores,
                IS_AVAIL1(mp.ipi, "IPI "),
                IS_AVAIL1(mp.idu, "IDU "),
+               IS_AVAIL1(mp.llm, "LLM "),
                IS_AVAIL1(mp.dbg, "DEBUG "),
-               IS_AVAIL1(mp.grtc, "GRTC"));
+               IS_AVAIL1(mp.gfrc, "GFRC"));
 
        idu_detected = mp.idu;
 
@@ -125,8 +123,8 @@ static void mcip_probe_n_setup(void)
                __mcip_cmd_data(CMD_DEBUG_SET_MASK, 0xf, 0xf);
        }
 
-       if (IS_ENABLED(CONFIG_ARC_HAS_GRTC) && !mp.grtc)
-               panic("kernel trying to use non-existent GRTC\n");
+       if (IS_ENABLED(CONFIG_ARC_HAS_GFRC) && !mp.gfrc)
+               panic("kernel trying to use non-existent GFRC\n");
 }
 
 struct plat_smp_ops plat_smp_ops = {
index e1b8744..cdc821d 100644 (file)
@@ -42,9 +42,57 @@ struct task_struct *_current_task[NR_CPUS];  /* For stack switching */
 
 struct cpuinfo_arc cpuinfo_arc700[NR_CPUS];
 
+static void read_decode_ccm_bcr(struct cpuinfo_arc *cpu)
+{
+       if (is_isa_arcompact()) {
+               struct bcr_iccm_arcompact iccm;
+               struct bcr_dccm_arcompact dccm;
+
+               READ_BCR(ARC_REG_ICCM_BUILD, iccm);
+               if (iccm.ver) {
+                       cpu->iccm.sz = 4096 << iccm.sz; /* 8K to 512K */
+                       cpu->iccm.base_addr = iccm.base << 16;
+               }
+
+               READ_BCR(ARC_REG_DCCM_BUILD, dccm);
+               if (dccm.ver) {
+                       unsigned long base;
+                       cpu->dccm.sz = 2048 << dccm.sz; /* 2K to 256K */
+
+                       base = read_aux_reg(ARC_REG_DCCM_BASE_BUILD);
+                       cpu->dccm.base_addr = base & ~0xF;
+               }
+       } else {
+               struct bcr_iccm_arcv2 iccm;
+               struct bcr_dccm_arcv2 dccm;
+               unsigned long region;
+
+               READ_BCR(ARC_REG_ICCM_BUILD, iccm);
+               if (iccm.ver) {
+                       cpu->iccm.sz = 256 << iccm.sz00;        /* 512B to 16M */
+                       if (iccm.sz00 == 0xF && iccm.sz01 > 0)
+                               cpu->iccm.sz <<= iccm.sz01;
+
+                       region = read_aux_reg(ARC_REG_AUX_ICCM);
+                       cpu->iccm.base_addr = region & 0xF0000000;
+               }
+
+               READ_BCR(ARC_REG_DCCM_BUILD, dccm);
+               if (dccm.ver) {
+                       cpu->dccm.sz = 256 << dccm.sz0;
+                       if (dccm.sz0 == 0xF && dccm.sz1 > 0)
+                               cpu->dccm.sz <<= dccm.sz1;
+
+                       region = read_aux_reg(ARC_REG_AUX_DCCM);
+                       cpu->dccm.base_addr = region & 0xF0000000;
+               }
+       }
+}
+
 static void read_arc_build_cfg_regs(void)
 {
        struct bcr_perip uncached_space;
+       struct bcr_timer timer;
        struct bcr_generic bcr;
        struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
        unsigned long perip_space;
@@ -53,7 +101,11 @@ static void read_arc_build_cfg_regs(void)
        READ_BCR(AUX_IDENTITY, cpu->core);
        READ_BCR(ARC_REG_ISA_CFG_BCR, cpu->isa);
 
-       READ_BCR(ARC_REG_TIMERS_BCR, cpu->timers);
+       READ_BCR(ARC_REG_TIMERS_BCR, timer);
+       cpu->extn.timer0 = timer.t0;
+       cpu->extn.timer1 = timer.t1;
+       cpu->extn.rtc = timer.rtc;
+
        cpu->vec_base = read_aux_reg(AUX_INTR_VEC_BASE);
 
        READ_BCR(ARC_REG_D_UNCACH_BCR, uncached_space);
@@ -71,36 +123,11 @@ static void read_arc_build_cfg_regs(void)
        cpu->extn.swap = read_aux_reg(ARC_REG_SWAP_BCR) ? 1 : 0;        /* 1,3 */
        cpu->extn.crc = read_aux_reg(ARC_REG_CRC_BCR) ? 1 : 0;
        cpu->extn.minmax = read_aux_reg(ARC_REG_MIXMAX_BCR) > 1 ? 1 : 0; /* 2 */
-
-       /* Note that we read the CCM BCRs independent of kernel config
-        * This is to catch the cases where user doesn't know that
-        * CCMs are present in hardware build
-        */
-       {
-               struct bcr_iccm iccm;
-               struct bcr_dccm dccm;
-               struct bcr_dccm_base dccm_base;
-               unsigned int bcr_32bit_val;
-
-               bcr_32bit_val = read_aux_reg(ARC_REG_ICCM_BCR);
-               if (bcr_32bit_val) {
-                       iccm = *((struct bcr_iccm *)&bcr_32bit_val);
-                       cpu->iccm.base_addr = iccm.base << 16;
-                       cpu->iccm.sz = 0x2000 << (iccm.sz - 1);
-               }
-
-               bcr_32bit_val = read_aux_reg(ARC_REG_DCCM_BCR);
-               if (bcr_32bit_val) {
-                       dccm = *((struct bcr_dccm *)&bcr_32bit_val);
-                       cpu->dccm.sz = 0x800 << (dccm.sz);
-
-                       READ_BCR(ARC_REG_DCCMBASE_BCR, dccm_base);
-                       cpu->dccm.base_addr = dccm_base.addr << 8;
-               }
-       }
-
        READ_BCR(ARC_REG_XY_MEM_BCR, cpu->extn_xymem);
 
+       /* Read CCM BCRs for boot reporting even if not enabled in Kconfig */
+       read_decode_ccm_bcr(cpu);
+
        read_decode_mmu_bcr();
        read_decode_cache_bcr();
 
@@ -208,9 +235,9 @@ static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
                       (unsigned int)(arc_get_core_freq() / 10000) % 100);
 
        n += scnprintf(buf + n, len - n, "Timers\t\t: %s%s%s%s\nISA Extn\t: ",
-                      IS_AVAIL1(cpu->timers.t0, "Timer0 "),
-                      IS_AVAIL1(cpu->timers.t1, "Timer1 "),
-                      IS_AVAIL2(cpu->timers.rtc, "64-bit RTC ",
+                      IS_AVAIL1(cpu->extn.timer0, "Timer0 "),
+                      IS_AVAIL1(cpu->extn.timer1, "Timer1 "),
+                      IS_AVAIL2(cpu->extn.rtc, "Local-64-bit-Ctr ",
                                 CONFIG_ARC_HAS_RTC));
 
        n += i = scnprintf(buf + n, len - n, "%s%s%s%s%s",
@@ -232,8 +259,6 @@ static char *arc_cpu_mumbojumbo(int cpu_id, char *buf, int len)
 
                        n += scnprintf(buf + n, len - n, "mpy[opt %d] ", opt);
                }
-               n += scnprintf(buf + n, len - n, "%s",
-                              IS_USED_CFG(CONFIG_ARC_HAS_HW_MPY));
        }
 
        n += scnprintf(buf + n, len - n, "%s%s%s%s%s%s%s%s\n",
@@ -293,13 +318,13 @@ static void arc_chk_core_config(void)
        struct cpuinfo_arc *cpu = &cpuinfo_arc700[smp_processor_id()];
        int fpu_enabled;
 
-       if (!cpu->timers.t0)
+       if (!cpu->extn.timer0)
                panic("Timer0 is not present!\n");
 
-       if (!cpu->timers.t1)
+       if (!cpu->extn.timer1)
                panic("Timer1 is not present!\n");
 
-       if (IS_ENABLED(CONFIG_ARC_HAS_RTC) && !cpu->timers.rtc)
+       if (IS_ENABLED(CONFIG_ARC_HAS_RTC) && !cpu->extn.rtc)
                panic("RTC is not present\n");
 
 #ifdef CONFIG_ARC_HAS_DCCM
@@ -334,6 +359,7 @@ static void arc_chk_core_config(void)
                panic("FPU non-existent, disable CONFIG_ARC_FPU_SAVE_RESTORE\n");
 
        if (is_isa_arcv2() && IS_ENABLED(CONFIG_SMP) && cpu->isa.atomic &&
+           IS_ENABLED(CONFIG_ARC_HAS_LLSC) &&
            !IS_ENABLED(CONFIG_ARC_STAR_9000923308))
                panic("llock/scond livelock workaround missing\n");
 }
index ef6e9e1..424e937 100644 (file)
@@ -336,11 +336,8 @@ irqreturn_t do_IPI(int irq, void *dev_id)
                int rc;
 
                rc = __do_IPI(msg);
-#ifdef CONFIG_ARC_IPI_DBG
-               /* IPI received but no valid @msg */
                if (rc)
                        pr_info("IPI with bogus msg %ld in %ld\n", msg, copy);
-#endif
                pending &= ~(1U << msg);
        } while (pending);
 
index dfad287..156d983 100644 (file)
@@ -62,7 +62,7 @@
 
 /********** Clock Source Device *********/
 
-#ifdef CONFIG_ARC_HAS_GRTC
+#ifdef CONFIG_ARC_HAS_GFRC
 
 static int arc_counter_setup(void)
 {
@@ -83,10 +83,10 @@ static cycle_t arc_counter_read(struct clocksource *cs)
 
        local_irq_save(flags);
 
-       __mcip_cmd(CMD_GRTC_READ_LO, 0);
+       __mcip_cmd(CMD_GFRC_READ_LO, 0);
        stamp.l = read_aux_reg(ARC_REG_MCIP_READBACK);
 
-       __mcip_cmd(CMD_GRTC_READ_HI, 0);
+       __mcip_cmd(CMD_GFRC_READ_HI, 0);
        stamp.h = read_aux_reg(ARC_REG_MCIP_READBACK);
 
        local_irq_restore(flags);
@@ -95,7 +95,7 @@ static cycle_t arc_counter_read(struct clocksource *cs)
 }
 
 static struct clocksource arc_counter = {
-       .name   = "ARConnect GRTC",
+       .name   = "ARConnect GFRC",
        .rating = 400,
        .read   = arc_counter_read,
        .mask   = CLOCKSOURCE_MASK(64),
index 7a6a58e..43788b1 100644 (file)
@@ -195,5 +195,7 @@ CFLAGS_font.o := -Dstatic=
 $(obj)/font.c: $(FONTC)
        $(call cmd,shipped)
 
+AFLAGS_hyp-stub.o := -Wa,-march=armv7-a
+
 $(obj)/hyp-stub.S: $(srctree)/arch/$(SRCARCH)/kernel/hyp-stub.S
        $(call cmd,shipped)
index f3db13d..0cc150b 100644 (file)
        };
 };
 
+
+/include/ "tps65217.dtsi"
+
 &tps {
-       compatible = "ti,tps65217";
        /*
         * Configure pmic to enter OFF-state instead of SLEEP-state ("RTC-only
         * mode") at poweroff.  Most BeagleBone versions do not support RTC-only
        ti,pmic-shutdown-controller;
 
        regulators {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                dcdc1_reg: regulator@0 {
-                       reg = <0>;
                        regulator-name = "vdds_dpr";
                        regulator-always-on;
                };
 
                dcdc2_reg: regulator@1 {
-                       reg = <1>;
                        /* VDD_MPU voltage limits 0.95V - 1.26V with +/-4% tolerance */
                        regulator-name = "vdd_mpu";
                        regulator-min-microvolt = <925000>;
                };
 
                dcdc3_reg: regulator@2 {
-                       reg = <2>;
                        /* VDD_CORE voltage limits 0.95V - 1.1V with +/-4% tolerance */
                        regulator-name = "vdd_core";
                        regulator-min-microvolt = <925000>;
                };
 
                ldo1_reg: regulator@3 {
-                       reg = <3>;
                        regulator-name = "vio,vrtc,vdds";
                        regulator-always-on;
                };
 
                ldo2_reg: regulator@4 {
-                       reg = <4>;
                        regulator-name = "vdd_3v3aux";
                        regulator-always-on;
                };
 
                ldo3_reg: regulator@5 {
-                       reg = <5>;
                        regulator-name = "vdd_1v8";
                        regulator-always-on;
                };
 
                ldo4_reg: regulator@6 {
-                       reg = <6>;
                        regulator-name = "vdd_3v3a";
                        regulator-always-on;
                };
index fda457b..857d989 100644 (file)
 
 };
 
-&tps {
-       compatible = "ti,tps65217";
+/include/ "tps65217.dtsi"
 
+&tps {
        regulators {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                dcdc1_reg: regulator@0 {
-                       reg = <0>;
                        regulator-name = "vdds_dpr";
                        regulator-always-on;
                };
 
                dcdc2_reg: regulator@1 {
-                       reg = <1>;
                        /* VDD_MPU voltage limits 0.95V - 1.26V with +/-4% tolerance */
                        regulator-name = "vdd_mpu";
                        regulator-min-microvolt = <925000>;
                };
 
                dcdc3_reg: regulator@2 {
-                       reg = <2>;
                        /* VDD_CORE voltage limits 0.95V - 1.1V with +/-4% tolerance */
                        regulator-name = "vdd_core";
                        regulator-min-microvolt = <925000>;
                };
 
                ldo1_reg: regulator@3 {
-                       reg = <3>;
                        regulator-name = "vio,vrtc,vdds";
                        regulator-boot-on;
                        regulator-always-on;
                };
 
                ldo2_reg: regulator@4 {
-                       reg = <4>;
                        regulator-name = "vdd_3v3aux";
                        regulator-boot-on;
                        regulator-always-on;
                };
 
                ldo3_reg: regulator@5 {
-                       reg = <5>;
                        regulator-name = "vdd_1v8";
                        regulator-boot-on;
                        regulator-always-on;
                };
 
                ldo4_reg: regulator@6 {
-                       reg = <6>;
                        regulator-name = "vdd_3v3d";
                        regulator-boot-on;
                        regulator-always-on;
index 77559a1..f313999 100644 (file)
        wp-gpios = <&gpio3 18 0>;
 };
 
-&tps {
-       compatible = "ti,tps65217";
+#include "tps65217.dtsi"
 
+&tps {
        regulators {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                dcdc1_reg: regulator@0 {
-                       reg = <0>;
                        /* +1.5V voltage with ±4% tolerance */
                        regulator-min-microvolt = <1450000>;
                        regulator-max-microvolt = <1550000>;
                };
 
                dcdc2_reg: regulator@1 {
-                       reg = <1>;
                        /* VDD_MPU voltage limits 0.95V - 1.1V with ±4% tolerance */
                        regulator-name = "vdd_mpu";
                        regulator-min-microvolt = <915000>;
                };
 
                dcdc3_reg: regulator@2 {
-                       reg = <2>;
                        /* VDD_CORE voltage limits 0.95V - 1.1V with ±4% tolerance */
                        regulator-name = "vdd_core";
                        regulator-min-microvolt = <915000>;
                };
 
                ldo1_reg: regulator@3 {
-                       reg = <3>;
                        /* +1.8V voltage with ±4% tolerance */
                        regulator-min-microvolt = <1750000>;
                        regulator-max-microvolt = <1870000>;
                };
 
                ldo2_reg: regulator@4 {
-                       reg = <4>;
                        /* +3.3V voltage with ±4% tolerance */
                        regulator-min-microvolt = <3175000>;
                        regulator-max-microvolt = <3430000>;
                };
 
                ldo3_reg: regulator@5 {
-                       reg = <5>;
                        /* +1.8V voltage with ±4% tolerance */
                        regulator-min-microvolt = <1750000>;
                        regulator-max-microvolt = <1870000>;
                };
 
                ldo4_reg: regulator@6 {
-                       reg = <6>;
                        /* +3.3V voltage with ±4% tolerance */
                        regulator-min-microvolt = <3175000>;
                        regulator-max-microvolt = <3430000>;
index 471a3a7..8867aaa 100644 (file)
        vin-supply = <&vbat>;
 };
 
-&tps {
-       compatible = "ti,tps65217";
+/include/ "tps65217.dtsi"
 
+&tps {
        backlight {
                isel = <1>; /* ISET1 */
                fdim = <200>; /* TPS65217_BL_FDIM_200HZ */
        };
 
        regulators {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                dcdc1_reg: regulator@0 {
-                       reg = <0>;
                        /* VDD_1V8 system supply */
                        regulator-always-on;
                };
 
                dcdc2_reg: regulator@1 {
-                       reg = <1>;
                        /* VDD_CORE voltage limits 0.95V - 1.26V with +/-4% tolerance */
                        regulator-name = "vdd_core";
                        regulator-min-microvolt = <925000>;
                };
 
                dcdc3_reg: regulator@2 {
-                       reg = <2>;
                        /* VDD_MPU voltage limits 0.95V - 1.1V with +/-4% tolerance */
                        regulator-name = "vdd_mpu";
                        regulator-min-microvolt = <925000>;
                };
 
                ldo1_reg: regulator@3 {
-                       reg = <3>;
                        /* VRTC 1.8V always-on supply */
                        regulator-name = "vrtc,vdds";
                        regulator-always-on;
                };
 
                ldo2_reg: regulator@4 {
-                       reg = <4>;
                        /* 3.3V rail */
                        regulator-name = "vdd_3v3aux";
                        regulator-always-on;
                };
 
                ldo3_reg: regulator@5 {
-                       reg = <5>;
                        /* VDD_3V3A 3.3V rail */
                        regulator-name = "vdd_3v3a";
                        regulator-min-microvolt = <3300000>;
                };
 
                ldo4_reg: regulator@6 {
-                       reg = <6>;
                        /* VDD_3V3B 3.3V rail */
                        regulator-name = "vdd_3v3b";
                        regulator-always-on;
index 1b5b044..865de85 100644 (file)
@@ -46,7 +46,7 @@
                        gpios = <&gpio1 29 GPIO_ACTIVE_HIGH>;
                        linux,code = <KEY_BACK>;
                        debounce-interval = <1000>;
-                       gpio-key,wakeup;
+                       wakeup-source;
                };
 
                front_button {
@@ -54,7 +54,7 @@
                        gpios = <&gpio1 25 GPIO_ACTIVE_HIGH>;
                        linux,code = <KEY_FRONT>;
                        debounce-interval = <1000>;
-                       gpio-key,wakeup;
+                       wakeup-source;
                };
        };
 
index d38edfa..3303c28 100644 (file)
        pinctrl-0 = <&uart4_pins>;
 };
 
+#include "tps65217.dtsi"
+
 &tps {
-       compatible = "ti,tps65217";
        ti,pmic-shutdown-controller;
 
        interrupt-parent = <&intc>;
        interrupts = <7>;       /* NNMI */
 
        regulators {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                dcdc1_reg: regulator@0 {
-                       reg = <0>;
                        /* VDDS_DDR */
                        regulator-min-microvolt = <1500000>;
                        regulator-max-microvolt = <1500000>;
                };
 
                dcdc2_reg: regulator@1 {
-                       reg = <1>;
                        /* VDD_MPU voltage limits 0.95V - 1.26V with +/-4% tolerance */
                        regulator-name = "vdd_mpu";
                        regulator-min-microvolt = <925000>;
                };
 
                dcdc3_reg: regulator@2 {
-                       reg = <2>;
                        /* VDD_CORE voltage limits 0.95V - 1.1V with +/-4% tolerance */
                        regulator-name = "vdd_core";
                        regulator-min-microvolt = <925000>;
                };
 
                ldo1_reg: regulator@3 {
-                       reg = <3>;
                        /* VRTC / VIO / VDDS*/
                        regulator-always-on;
                        regulator-min-microvolt = <1800000>;
                };
 
                ldo2_reg: regulator@4 {
-                       reg = <4>;
                        /* VDD_3V3AUX */
                        regulator-always-on;
                        regulator-min-microvolt = <3300000>;
                };
 
                ldo3_reg: regulator@5 {
-                       reg = <5>;
                        /* VDD_1V8 */
                        regulator-min-microvolt = <1800000>;
                        regulator-max-microvolt = <1800000>;
                };
 
                ldo4_reg: regulator@6 {
-                       reg = <6>;
                        /* VDD_3V3A */
                        regulator-min-microvolt = <3300000>;
                        regulator-max-microvolt = <3300000>;
index 36c0fa6..a0986c6 100644 (file)
 
                sound0_master: simple-audio-card,codec {
                        sound-dai = <&tlv320aic3104>;
+                       assigned-clocks = <&clkoutmux2_clk_mux>;
+                       assigned-clock-parents = <&sys_clk2_dclk_div>;
                        clocks = <&clkout2_clk>;
                };
        };
        pinctrl-names = "default", "sleep";
        pinctrl-0 = <&mcasp3_pins_default>;
        pinctrl-1 = <&mcasp3_pins_sleep>;
+       assigned-clocks = <&mcasp3_ahclkx_mux>;
+       assigned-clock-parents = <&sys_clkin2>;
        status = "okay";
 
        op-mode = <0>;  /* MCASP_IIS_MODE */
index 8d93882..1c06cb7 100644 (file)
                ti,debounce-tol = /bits/ 16 <10>;
                ti,debounce-rep = /bits/ 16 <1>;
 
-               linux,wakeup;
+               wakeup-source;
        };
 };
 
index 23fc670..5c21b23 100644 (file)
@@ -70,8 +70,8 @@
        soc {
                ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xf1000000 0x100000
                          MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
-                         MBUS_ID(0x09, 0x09) 0 0 0xf8100000 0x10000
-                         MBUS_ID(0x09, 0x05) 0 0 0xf8110000 0x10000>;
+                         MBUS_ID(0x09, 0x09) 0 0 0xf1100000 0x10000
+                         MBUS_ID(0x09, 0x05) 0 0 0xf1110000 0x10000>;
 
                pcie-controller {
                        status = "okay";
index f774101..ebe1d26 100644 (file)
@@ -76,8 +76,8 @@
                ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xf1000000 0x100000
                          MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
                          MBUS_ID(0x01, 0x2f) 0 0 0xf0000000 0x1000000
-                         MBUS_ID(0x09, 0x09) 0 0 0xf8100000 0x10000
-                         MBUS_ID(0x09, 0x05) 0 0 0xf8110000 0x10000>;
+                         MBUS_ID(0x09, 0x09) 0 0 0xf1100000 0x10000
+                         MBUS_ID(0x09, 0x05) 0 0 0xf1110000 0x10000>;
 
                devbus-bootcs {
                        status = "okay";
index 4878d73..5730b87 100644 (file)
@@ -95,8 +95,8 @@
                ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xf1000000 0x100000
                          MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
                          MBUS_ID(0x01, 0x2f) 0 0 0xf0000000 0x1000000
-                         MBUS_ID(0x09, 0x09) 0 0 0xf8100000 0x10000
-                         MBUS_ID(0x09, 0x05) 0 0 0xf8110000 0x10000>;
+                         MBUS_ID(0x09, 0x09) 0 0 0xf1100000 0x10000
+                         MBUS_ID(0x09, 0x05) 0 0 0xf1110000 0x10000>;
 
                devbus-bootcs {
                        status = "okay";
index fb9e1bb..8af463f 100644 (file)
@@ -65,8 +65,8 @@
        soc {
                ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xd0000000 0x100000
                        MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
-                       MBUS_ID(0x09, 0x09) 0 0 0xf8100000 0x10000
-                       MBUS_ID(0x09, 0x05) 0 0 0xf8110000 0x10000>;
+                       MBUS_ID(0x09, 0x09) 0 0 0xf1100000 0x10000
+                       MBUS_ID(0x09, 0x05) 0 0 0xf1110000 0x10000>;
 
                pcie-controller {
                        status = "okay";
index 6e9820e..b89e6cf 100644 (file)
@@ -70,8 +70,8 @@
        soc {
                ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xf1000000 0x100000
                          MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
-                         MBUS_ID(0x09, 0x09) 0 0 0xf8100000 0x10000
-                         MBUS_ID(0x09, 0x05) 0 0 0xf8110000 0x10000>;
+                         MBUS_ID(0x09, 0x09) 0 0 0xf1100000 0x10000
+                         MBUS_ID(0x09, 0x05) 0 0 0xf1110000 0x10000>;
 
                pcie-controller {
                        status = "okay";
index 6ab3383..6522b04 100644 (file)
@@ -68,8 +68,8 @@
        soc {
                ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xf1000000 0x100000
                          MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
-                         MBUS_ID(0x09, 0x09) 0 0 0xf8100000 0x10000
-                         MBUS_ID(0x09, 0x05) 0 0 0xf8110000 0x10000>;
+                         MBUS_ID(0x09, 0x09) 0 0 0xf1100000 0x10000
+                         MBUS_ID(0x09, 0x05) 0 0 0xf1110000 0x10000>;
 
                internal-regs {
                        serial@12000 {
index 62175a8..d19f44c 100644 (file)
@@ -64,8 +64,8 @@
        soc {
                ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xd0000000 0x100000
                          MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
-                         MBUS_ID(0x09, 0x09) 0 0 0xf8100000 0x10000
-                         MBUS_ID(0x09, 0x05) 0 0 0xf8110000 0x10000>;
+                         MBUS_ID(0x09, 0x09) 0 0 0xf1100000 0x10000
+                         MBUS_ID(0x09, 0x05) 0 0 0xf1110000 0x10000>;
 
                pcie-controller {
                        status = "okay";
index a5db177..853bd39 100644 (file)
@@ -65,9 +65,9 @@
        soc {
                ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xd0000000 0x100000
                          MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
-                         MBUS_ID(0x01, 0x2f) 0 0 0xf0000000 0x8000000
-                         MBUS_ID(0x09, 0x09) 0 0 0xf8100000 0x10000
-                         MBUS_ID(0x09, 0x05) 0 0 0xf8110000 0x10000>;
+                         MBUS_ID(0x01, 0x2f) 0 0 0xe8000000 0x8000000
+                         MBUS_ID(0x09, 0x09) 0 0 0xf1100000 0x10000
+                         MBUS_ID(0x09, 0x05) 0 0 0xf1110000 0x10000>;
 
                devbus-bootcs {
                        status = "okay";
index 2391b11..d17dab0 100644 (file)
@@ -78,8 +78,8 @@
        soc {
                ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xf1000000 0x100000
                          MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
-                         MBUS_ID(0x09, 0x09) 0 0 0xf8100000 0x10000
-                         MBUS_ID(0x09, 0x05) 0 0 0xf8110000 0x10000>;
+                         MBUS_ID(0x09, 0x09) 0 0 0xf1100000 0x10000
+                         MBUS_ID(0x09, 0x05) 0 0 0xf1110000 0x10000>;
 
                pcie-controller {
                        status = "okay";
index c4d9175..f82aa44 100644 (file)
                               0x48485200 0x2E00>;
                        #address-cells = <1>;
                        #size-cells = <1>;
+
+                       /*
+                        * Do not allow gating of cpsw clock as workaround
+                        * for errata i877. Keeping internal clock disabled
+                        * causes the device switching characteristics
+                        * to degrade over time and eventually fail to meet
+                        * the data manual delay time/skew specs.
+                        */
+                       ti,no-idle;
+
                        /*
                         * rx_thresh_pend
                         * rx_pend
index 4f6ae92..f74d3db 100644 (file)
                                #size-cells = <1>;
                                reg = <0x2100000 0x10000>;
                                ranges = <0 0x2100000 0x10000>;
-                               interrupt-parent = <&intc>;
                                clocks = <&clks IMX6QDL_CLK_CAAM_MEM>,
                                         <&clks IMX6QDL_CLK_CAAM_ACLK>,
                                         <&clks IMX6QDL_CLK_CAAM_IPG>,
index bf4143c..b84af3d 100644 (file)
@@ -14,7 +14,7 @@
 #include "kirkwood-synology.dtsi"
 
 / {
-       model = "Synology DS111";
+       model = "Synology DS112";
        compatible = "synology,ds111", "marvell,kirkwood";
 
        memory {
index 4207882..aae8a7a 100644 (file)
        };
 };
 
+&devbus_bootcs {
+       status = "okay";
+       devbus,keep-config;
+
+       flash@0 {
+               compatible = "jedec-flash";
+               reg = <0 0x40000>;
+               bank-width = <1>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       header@0 {
+                               reg = <0 0x30000>;
+                               read-only;
+                       };
+
+                       uboot@30000 {
+                               reg = <0x30000 0xF000>;
+                               read-only;
+                       };
+
+                       uboot_env@3F000 {
+                               reg = <0x3F000 0x1000>;
+                       };
+               };
+       };
+};
+
 &mdio {
        status = "okay";
 
index 6713b1e..01d239c 100644 (file)
        pinctrl-names = "default";
 
        status = "okay";
-       renesas,enable-gpio = <&gpio5 31 GPIO_ACTIVE_HIGH>;
 };
 
 &usbphy {
index 1afe246..b0c912f 100644 (file)
@@ -90,7 +90,7 @@
 #define PIN_PA14__I2SC1_MCK            PINMUX_PIN(PIN_PA14, 4, 2)
 #define PIN_PA14__FLEXCOM3_IO2         PINMUX_PIN(PIN_PA14, 5, 1)
 #define PIN_PA14__D9                   PINMUX_PIN(PIN_PA14, 6, 2)
-#define PIN_PA15                       14
+#define PIN_PA15                       15
 #define PIN_PA15__GPIO                 PINMUX_PIN(PIN_PA15, 0, 0)
 #define PIN_PA15__SPI0_MOSI            PINMUX_PIN(PIN_PA15, 1, 1)
 #define PIN_PA15__TF1                  PINMUX_PIN(PIN_PA15, 2, 1)
diff --git a/arch/arm/boot/dts/tps65217.dtsi b/arch/arm/boot/dts/tps65217.dtsi
new file mode 100644 (file)
index 0000000..a632724
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.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.
+ */
+
+/*
+ * Integrated Power Management Chip
+ * http://www.ti.com/lit/ds/symlink/tps65217.pdf
+ */
+
+&tps {
+       compatible = "ti,tps65217";
+
+       regulators {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               dcdc1_reg: regulator@0 {
+                       reg = <0>;
+                       regulator-compatible = "dcdc1";
+               };
+
+               dcdc2_reg: regulator@1 {
+                       reg = <1>;
+                       regulator-compatible = "dcdc2";
+               };
+
+               dcdc3_reg: regulator@2 {
+                       reg = <2>;
+                       regulator-compatible = "dcdc3";
+               };
+
+               ldo1_reg: regulator@3 {
+                       reg = <3>;
+                       regulator-compatible = "ldo1";
+               };
+
+               ldo2_reg: regulator@4 {
+                       reg = <4>;
+                       regulator-compatible = "ldo2";
+               };
+
+               ldo3_reg: regulator@5 {
+                       reg = <5>;
+                       regulator-compatible = "ldo3";
+               };
+
+               ldo4_reg: regulator@6 {
+                       reg = <6>;
+                       regulator-compatible = "ldo4";
+               };
+       };
+};
index 2dc6da7..d7ed252 100644 (file)
@@ -16,7 +16,7 @@
  */
 #include <linux/module.h>
 #include <linux/kernel.h>
-
+#include <asm/div64.h>
 #include <asm/hardware/icst.h>
 
 /*
@@ -29,7 +29,11 @@ EXPORT_SYMBOL(icst525_s2div);
 
 unsigned long icst_hz(const struct icst_params *p, struct icst_vco vco)
 {
-       return p->ref * 2 * (vco.v + 8) / ((vco.r + 2) * p->s2div[vco.s]);
+       u64 dividend = p->ref * 2 * (u64)(vco.v + 8);
+       u32 divisor = (vco.r + 2) * p->s2div[vco.s];
+
+       do_div(dividend, divisor);
+       return (unsigned long)dividend;
 }
 
 EXPORT_SYMBOL(icst_hz);
@@ -58,6 +62,7 @@ icst_hz_to_vco(const struct icst_params *p, unsigned long freq)
 
                if (f > p->vco_min && f <= p->vco_max)
                        break;
+               i++;
        } while (i < 8);
 
        if (i >= 8)
index a715174..d18d6b4 100644 (file)
@@ -292,24 +292,23 @@ CONFIG_FB=y
 CONFIG_FIRMWARE_EDID=y
 CONFIG_FB_MODE_HELPERS=y
 CONFIG_FB_TILEBLITTING=y
-CONFIG_OMAP2_DSS=m
-CONFIG_OMAP5_DSS_HDMI=y
-CONFIG_OMAP2_DSS_SDI=y
-CONFIG_OMAP2_DSS_DSI=y
+CONFIG_FB_OMAP5_DSS_HDMI=y
+CONFIG_FB_OMAP2_DSS_SDI=y
+CONFIG_FB_OMAP2_DSS_DSI=y
 CONFIG_FB_OMAP2=m
-CONFIG_DISPLAY_ENCODER_TFP410=m
-CONFIG_DISPLAY_ENCODER_TPD12S015=m
-CONFIG_DISPLAY_CONNECTOR_DVI=m
-CONFIG_DISPLAY_CONNECTOR_HDMI=m
-CONFIG_DISPLAY_CONNECTOR_ANALOG_TV=m
-CONFIG_DISPLAY_PANEL_DPI=m
-CONFIG_DISPLAY_PANEL_DSI_CM=m
-CONFIG_DISPLAY_PANEL_SONY_ACX565AKM=m
-CONFIG_DISPLAY_PANEL_LGPHILIPS_LB035Q02=m
-CONFIG_DISPLAY_PANEL_SHARP_LS037V7DW01=m
-CONFIG_DISPLAY_PANEL_TPO_TD028TTEC1=m
-CONFIG_DISPLAY_PANEL_TPO_TD043MTEA1=m
-CONFIG_DISPLAY_PANEL_NEC_NL8048HL11=m
+CONFIG_FB_OMAP2_ENCODER_TFP410=m
+CONFIG_FB_OMAP2_ENCODER_TPD12S015=m
+CONFIG_FB_OMAP2_CONNECTOR_DVI=m
+CONFIG_FB_OMAP2_CONNECTOR_HDMI=m
+CONFIG_FB_OMAP2_CONNECTOR_ANALOG_TV=m
+CONFIG_FB_OMAP2_PANEL_DPI=m
+CONFIG_FB_OMAP2_PANEL_DSI_CM=m
+CONFIG_FB_OMAP2_PANEL_SONY_ACX565AKM=m
+CONFIG_FB_OMAP2_PANEL_LGPHILIPS_LB035Q02=m
+CONFIG_FB_OMAP2_PANEL_SHARP_LS037V7DW01=m
+CONFIG_FB_OMAP2_PANEL_TPO_TD028TTEC1=m
+CONFIG_FB_OMAP2_PANEL_TPO_TD043MTEA1=m
+CONFIG_FB_OMAP2_PANEL_NEC_NL8048HL11=m
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_LCD_PLATFORM=y
index b445a5d..89a3a3e 100644 (file)
@@ -364,7 +364,7 @@ static struct crypto_alg aes_algs[] = { {
        .cra_blkcipher = {
                .min_keysize    = AES_MIN_KEY_SIZE,
                .max_keysize    = AES_MAX_KEY_SIZE,
-               .ivsize         = AES_BLOCK_SIZE,
+               .ivsize         = 0,
                .setkey         = ce_aes_setkey,
                .encrypt        = ecb_encrypt,
                .decrypt        = ecb_decrypt,
@@ -441,7 +441,7 @@ static struct crypto_alg aes_algs[] = { {
        .cra_ablkcipher = {
                .min_keysize    = AES_MIN_KEY_SIZE,
                .max_keysize    = AES_MAX_KEY_SIZE,
-               .ivsize         = AES_BLOCK_SIZE,
+               .ivsize         = 0,
                .setkey         = ablk_set_key,
                .encrypt        = ablk_encrypt,
                .decrypt        = ablk_decrypt,
index 7da5503..e08d151 100644 (file)
@@ -117,6 +117,7 @@ static inline u32 gic_read_iar(void)
        u32 irqstat;
 
        asm volatile("mrc " __stringify(ICC_IAR1) : "=r" (irqstat));
+       dsb(sy);
        return irqstat;
 }
 
index 0375c8c..9408a99 100644 (file)
@@ -35,14 +35,21 @@ static inline void xen_dma_map_page(struct device *hwdev, struct page *page,
             dma_addr_t dev_addr, unsigned long offset, size_t size,
             enum dma_data_direction dir, struct dma_attrs *attrs)
 {
-       bool local = XEN_PFN_DOWN(dev_addr) == page_to_xen_pfn(page);
+       unsigned long page_pfn = page_to_xen_pfn(page);
+       unsigned long dev_pfn = XEN_PFN_DOWN(dev_addr);
+       unsigned long compound_pages =
+               (1<<compound_order(page)) * XEN_PFN_PER_PAGE;
+       bool local = (page_pfn <= dev_pfn) &&
+               (dev_pfn - page_pfn < compound_pages);
+
        /*
-        * Dom0 is mapped 1:1, while the Linux page can be spanned accross
-        * multiple Xen page, it's not possible to have a mix of local and
-        * foreign Xen page. So if the first xen_pfn == mfn the page is local
-        * otherwise it's a foreign page grant-mapped in dom0. If the page is
-        * local we can safely call the native dma_ops function, otherwise we
-        * call the xen specific function.
+        * Dom0 is mapped 1:1, while the Linux page can span across
+        * multiple Xen pages, it's not possible for it to contain a
+        * mix of local and foreign Xen pages. So if the first xen_pfn
+        * == mfn the page is local otherwise it's a foreign page
+        * grant-mapped in dom0. If the page is local we can safely
+        * call the native dma_ops function, otherwise we call the xen
+        * specific function.
         */
        if (local)
                __generic_dma_ops(hwdev)->map_page(hwdev, page, offset, size, dir, attrs);
index 2c5f160..ad325a8 100644 (file)
@@ -88,6 +88,7 @@ obj-$(CONFIG_DEBUG_LL)        += debug.o
 obj-$(CONFIG_EARLY_PRINTK)     += early_printk.o
 
 obj-$(CONFIG_ARM_VIRT_EXT)     += hyp-stub.o
+AFLAGS_hyp-stub.o              :=-Wa,-march=armv7-a
 ifeq ($(CONFIG_ARM_PSCI),y)
 obj-$(CONFIG_SMP)              += psci_smp.o
 endif
index 5fa69d7..99361f1 100644 (file)
@@ -161,7 +161,7 @@ static int get_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
        u64 val;
 
        val = kvm_arm_timer_get_reg(vcpu, reg->id);
-       return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id));
+       return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id)) ? -EFAULT : 0;
 }
 
 static unsigned long num_core_regs(void)
index 7f33b20..0f6600f 100644 (file)
@@ -206,7 +206,8 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
        run->mmio.is_write      = is_write;
        run->mmio.phys_addr     = fault_ipa;
        run->mmio.len           = len;
-       memcpy(run->mmio.data, data_buf, len);
+       if (is_write)
+               memcpy(run->mmio.data, data_buf, len);
 
        if (!ret) {
                /* We handled the access successfully in the kernel. */
index 8098272..bab814d 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <asm/setup.h>
 #include <asm/mach/arch.h>
+#include <asm/system_info.h>
 
 #include "common.h"
 
@@ -77,12 +78,31 @@ static const char *const n900_boards_compat[] __initconst = {
        NULL,
 };
 
+/* Set system_rev from atags */
+static void __init rx51_set_system_rev(const struct tag *tags)
+{
+       const struct tag *tag;
+
+       if (tags->hdr.tag != ATAG_CORE)
+               return;
+
+       for_each_tag(tag, tags) {
+               if (tag->hdr.tag == ATAG_REVISION) {
+                       system_rev = tag->u.revision.rev;
+                       break;
+               }
+       }
+}
+
 /* Legacy userspace on Nokia N900 needs ATAGS exported in /proc/atags,
  * save them while the data is still not overwritten
  */
 static void __init rx51_reserve(void)
 {
-       save_atags((const struct tag *)(PAGE_OFFSET + 0x100));
+       const struct tag *tags = (const struct tag *)(PAGE_OFFSET + 0x100);
+
+       save_atags(tags);
+       rx51_set_system_rev(tags);
        omap_reserve();
 }
 
index 7b76ce0..8633c70 100644 (file)
@@ -101,10 +101,8 @@ static void omap2_onenand_set_async_mode(void __iomem *onenand_base)
 
 static void set_onenand_cfg(void __iomem *onenand_base)
 {
-       u32 reg;
+       u32 reg = ONENAND_SYS_CFG1_RDY | ONENAND_SYS_CFG1_INT;
 
-       reg = readw(onenand_base + ONENAND_REG_SYS_CFG1);
-       reg &= ~((0x7 << ONENAND_SYS_CFG1_BRL_SHIFT) | (0x7 << 9));
        reg |=  (latency << ONENAND_SYS_CFG1_BRL_SHIFT) |
                ONENAND_SYS_CFG1_BL_16;
        if (onenand_flags & ONENAND_FLAG_SYNCREAD)
@@ -123,6 +121,7 @@ static void set_onenand_cfg(void __iomem *onenand_base)
                reg |= ONENAND_SYS_CFG1_VHF;
        else
                reg &= ~ONENAND_SYS_CFG1_VHF;
+
        writew(reg, onenand_base + ONENAND_REG_SYS_CFG1);
 }
 
@@ -289,6 +288,7 @@ static int omap2_onenand_setup_async(void __iomem *onenand_base)
                }
        }
 
+       onenand_async.sync_write = true;
        omap2_onenand_calc_async_timings(&t);
 
        ret = gpmc_cs_program_settings(gpmc_onenand_data->cs, &onenand_async);
index 0437537..f7ff3b9 100644 (file)
@@ -191,12 +191,22 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct omap_device *od;
+       int err;
 
        switch (event) {
        case BUS_NOTIFY_DEL_DEVICE:
                if (pdev->archdata.od)
                        omap_device_delete(pdev->archdata.od);
                break;
+       case BUS_NOTIFY_UNBOUND_DRIVER:
+               od = to_omap_device(pdev);
+               if (od && (od->_state == OMAP_DEVICE_STATE_ENABLED)) {
+                       dev_info(dev, "enabled after unload, idling\n");
+                       err = omap_device_idle(pdev);
+                       if (err)
+                               dev_err(dev, "failed to idle\n");
+               }
+               break;
        case BUS_NOTIFY_ADD_DEVICE:
                if (pdev->dev.of_node)
                        omap_device_build_from_dt(pdev);
@@ -602,8 +612,10 @@ static int _od_runtime_resume(struct device *dev)
        int ret;
 
        ret = omap_device_enable(pdev);
-       if (ret)
+       if (ret) {
+               dev_err(dev, "use pm_runtime_put_sync_suspend() in driver?\n");
                return ret;
+       }
 
        return pm_generic_runtime_resume(dev);
 }
index e9f65fe..b6d62e4 100644 (file)
@@ -2200,6 +2200,11 @@ static int _enable(struct omap_hwmod *oh)
  */
 static int _idle(struct omap_hwmod *oh)
 {
+       if (oh->flags & HWMOD_NO_IDLE) {
+               oh->_int_flags |= _HWMOD_SKIP_ENABLE;
+               return 0;
+       }
+
        pr_debug("omap_hwmod: %s: idling\n", oh->name);
 
        if (oh->_state != _HWMOD_STATE_ENABLED) {
@@ -2504,6 +2509,8 @@ static int __init _init(struct omap_hwmod *oh, void *data)
                        oh->flags |= HWMOD_INIT_NO_RESET;
                if (of_find_property(np, "ti,no-idle-on-init", NULL))
                        oh->flags |= HWMOD_INIT_NO_IDLE;
+               if (of_find_property(np, "ti,no-idle", NULL))
+                       oh->flags |= HWMOD_NO_IDLE;
        }
 
        oh->_state = _HWMOD_STATE_INITIALIZED;
@@ -2630,7 +2637,7 @@ static void __init _setup_postsetup(struct omap_hwmod *oh)
         * XXX HWMOD_INIT_NO_IDLE does not belong in hwmod data -
         * it should be set by the core code as a runtime flag during startup
         */
-       if ((oh->flags & HWMOD_INIT_NO_IDLE) &&
+       if ((oh->flags & (HWMOD_INIT_NO_IDLE | HWMOD_NO_IDLE)) &&
            (postsetup_state == _HWMOD_STATE_IDLE)) {
                oh->_int_flags |= _HWMOD_SKIP_ENABLE;
                postsetup_state = _HWMOD_STATE_ENABLED;
index 76bce11..7c7a311 100644 (file)
@@ -525,6 +525,8 @@ struct omap_hwmod_omap4_prcm {
  *     or idled.
  * HWMOD_OPT_CLKS_NEEDED: The optional clocks are needed for the module to
  *     operate and they need to be handled at the same time as the main_clk.
+ * HWMOD_NO_IDLE: Do not idle the hwmod at all. Useful to handle certain
+ *     IPs like CPSW on DRA7, where clocks to this module cannot be disabled.
  */
 #define HWMOD_SWSUP_SIDLE                      (1 << 0)
 #define HWMOD_SWSUP_MSTANDBY                   (1 << 1)
@@ -541,6 +543,7 @@ struct omap_hwmod_omap4_prcm {
 #define HWMOD_SWSUP_SIDLE_ACT                  (1 << 12)
 #define HWMOD_RECONFIG_IO_CHAIN                        (1 << 13)
 #define HWMOD_OPT_CLKS_NEEDED                  (1 << 14)
+#define HWMOD_NO_IDLE                          (1 << 15)
 
 /*
  * omap_hwmod._int_flags definitions
index 9cb1121..b3a4ed5 100644 (file)
@@ -4,7 +4,6 @@
 extern void shmobile_init_delay(void);
 extern void shmobile_boot_vector(void);
 extern unsigned long shmobile_boot_fn;
-extern unsigned long shmobile_boot_arg;
 extern unsigned long shmobile_boot_size;
 extern void shmobile_smp_boot(void);
 extern void shmobile_smp_sleep(void);
index fa5248c..5e503d9 100644 (file)
@@ -38,9 +38,3 @@ ENTRY(shmobile_boot_scu)
 
        b       secondary_startup
 ENDPROC(shmobile_boot_scu)
-
-       .text
-       .align  2
-       .globl  shmobile_scu_base
-shmobile_scu_base:
-       .space  4
index 330c1fc..32e0bf6 100644 (file)
@@ -24,7 +24,6 @@
        .arm
        .align  12
 ENTRY(shmobile_boot_vector)
-       ldr     r0, 2f
        ldr     r1, 1f
        bx      r1
 
@@ -34,9 +33,6 @@ ENDPROC(shmobile_boot_vector)
        .globl  shmobile_boot_fn
 shmobile_boot_fn:
 1:     .space  4
-       .globl  shmobile_boot_arg
-shmobile_boot_arg:
-2:     .space  4
        .globl  shmobile_boot_size
 shmobile_boot_size:
        .long   . - shmobile_boot_vector
@@ -46,13 +42,15 @@ shmobile_boot_size:
  */
 
 ENTRY(shmobile_smp_boot)
-                                               @ r0 = MPIDR_HWID_BITMASK
        mrc     p15, 0, r1, c0, c0, 5           @ r1 = MPIDR
-       and     r0, r1, r0                      @ r0 = cpu_logical_map() value
+       and     r0, r1, #0xffffff               @ MPIDR_HWID_BITMASK
+                                               @ r0 = cpu_logical_map() value
        mov     r1, #0                          @ r1 = CPU index
-       adr     r5, 1f                          @ array of per-cpu mpidr values
-       adr     r6, 2f                          @ array of per-cpu functions
-       adr     r7, 3f                          @ array of per-cpu arguments
+       adr     r2, 1f
+       ldmia   r2, {r5, r6, r7}
+       add     r5, r5, r2                      @ array of per-cpu mpidr values
+       add     r6, r6, r2                      @ array of per-cpu functions
+       add     r7, r7, r2                      @ array of per-cpu arguments
 
 shmobile_smp_boot_find_mpidr:
        ldr     r8, [r5, r1, lsl #2]
@@ -80,12 +78,18 @@ ENTRY(shmobile_smp_sleep)
        b       shmobile_smp_boot
 ENDPROC(shmobile_smp_sleep)
 
+       .align  2
+1:     .long   shmobile_smp_mpidr - .
+       .long   shmobile_smp_fn - 1b
+       .long   shmobile_smp_arg - 1b
+
+       .bss
        .globl  shmobile_smp_mpidr
 shmobile_smp_mpidr:
-1:     .space  NR_CPUS * 4
+       .space  NR_CPUS * 4
        .globl  shmobile_smp_fn
 shmobile_smp_fn:
-2:     .space  NR_CPUS * 4
+       .space  NR_CPUS * 4
        .globl  shmobile_smp_arg
 shmobile_smp_arg:
-3:     .space  NR_CPUS * 4
+       .space  NR_CPUS * 4
index 911884f..aba75c8 100644 (file)
@@ -123,7 +123,6 @@ void __init shmobile_smp_apmu_prepare_cpus(unsigned int max_cpus,
 {
        /* install boot code shared by all CPUs */
        shmobile_boot_fn = virt_to_phys(shmobile_smp_boot);
-       shmobile_boot_arg = MPIDR_HWID_BITMASK;
 
        /* perform per-cpu setup */
        apmu_parse_cfg(apmu_init_cpu, apmu_config, num);
index 6466311..081a097 100644 (file)
@@ -17,6 +17,9 @@
 #include <asm/smp_scu.h>
 #include "common.h"
 
+
+void __iomem *shmobile_scu_base;
+
 static int shmobile_smp_scu_notifier_call(struct notifier_block *nfb,
                                          unsigned long action, void *hcpu)
 {
@@ -41,7 +44,6 @@ void __init shmobile_smp_scu_prepare_cpus(unsigned int max_cpus)
 {
        /* install boot code shared by all CPUs */
        shmobile_boot_fn = virt_to_phys(shmobile_smp_boot);
-       shmobile_boot_arg = MPIDR_HWID_BITMASK;
 
        /* enable SCU and cache coherency on booting CPU */
        scu_enable(shmobile_scu_base);
index b854fe2..0b024a9 100644 (file)
@@ -92,8 +92,6 @@ static void __init r8a7779_smp_prepare_cpus(unsigned int max_cpus)
 {
        /* Map the reset vector (in headsmp-scu.S, headsmp.S) */
        __raw_writel(__pa(shmobile_boot_vector), AVECR);
-       shmobile_boot_fn = virt_to_phys(shmobile_boot_scu);
-       shmobile_boot_arg = (unsigned long)shmobile_scu_base;
 
        /* setup r8a7779 specific SCU bits */
        shmobile_scu_base = IOMEM(R8A7779_SCU_BASE);
index 4b4058d..66353ca 100644 (file)
@@ -173,7 +173,7 @@ unsigned long arch_mmap_rnd(void)
 {
        unsigned long rnd;
 
-       rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1);
+       rnd = get_random_long() & ((1UL << mmap_rnd_bits) - 1);
 
        return rnd << PAGE_SHIFT;
 }
index cf30daf..d19b1ad 100644 (file)
@@ -49,6 +49,9 @@ static int change_memory_common(unsigned long addr, int numpages,
                WARN_ON_ONCE(1);
        }
 
+       if (!numpages)
+               return 0;
+
        if (start < MODULES_VADDR || start >= MODULES_END)
                return -EINVAL;
 
index 307237c..b5e3f6d 100644 (file)
@@ -88,7 +88,7 @@ Image: vmlinux
 Image.%: vmlinux
        $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
 
-zinstall install: vmlinux
+zinstall install:
        $(Q)$(MAKE) $(build)=$(boot) $@
 
 %.dtb: scripts
index abcbba2..305c552 100644 (file)
@@ -34,10 +34,10 @@ $(obj)/Image.lzma: $(obj)/Image FORCE
 $(obj)/Image.lzo: $(obj)/Image FORCE
        $(call if_changed,lzo)
 
-install: $(obj)/Image
+install:
        $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
        $(obj)/Image System.map "$(INSTALL_PATH)"
 
-zinstall: $(obj)/Image.gz
+zinstall:
        $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
        $(obj)/Image.gz System.map "$(INSTALL_PATH)"
index 12ed78a..d91e1f0 100644 (file)
 #   $4 - default install path (blank if root directory)
 #
 
+verify () {
+       if [ ! -f "$1" ]; then
+               echo ""                                                   1>&2
+               echo " *** Missing file: $1"                              1>&2
+               echo ' *** You need to run "make" before "make install".' 1>&2
+               echo ""                                                   1>&2
+               exit 1
+       fi
+}
+
+# Make sure the files actually exist
+verify "$2"
+verify "$3"
+
 # User may have a custom install script
 if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
 if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
index 05d9e16..7a3d22a 100644 (file)
@@ -294,7 +294,7 @@ static struct crypto_alg aes_algs[] = { {
        .cra_blkcipher = {
                .min_keysize    = AES_MIN_KEY_SIZE,
                .max_keysize    = AES_MAX_KEY_SIZE,
-               .ivsize         = AES_BLOCK_SIZE,
+               .ivsize         = 0,
                .setkey         = aes_setkey,
                .encrypt        = ecb_encrypt,
                .decrypt        = ecb_decrypt,
@@ -371,7 +371,7 @@ static struct crypto_alg aes_algs[] = { {
        .cra_ablkcipher = {
                .min_keysize    = AES_MIN_KEY_SIZE,
                .max_keysize    = AES_MAX_KEY_SIZE,
-               .ivsize         = AES_BLOCK_SIZE,
+               .ivsize         = 0,
                .setkey         = ablk_set_key,
                .encrypt        = ablk_encrypt,
                .decrypt        = ablk_decrypt,
index 2731d3b..8ec88e5 100644 (file)
@@ -103,6 +103,7 @@ static inline u64 gic_read_iar_common(void)
        u64 irqstat;
 
        asm volatile("mrs_s %0, " __stringify(ICC_IAR1_EL1) : "=r" (irqstat));
+       dsb(sy);
        return irqstat;
 }
 
index 738a95f..d201d4b 100644 (file)
 #define TCR_EL2_MASK   (TCR_EL2_TG0 | TCR_EL2_SH0 | \
                         TCR_EL2_ORGN0 | TCR_EL2_IRGN0 | TCR_EL2_T0SZ)
 
-#define TCR_EL2_FLAGS  (TCR_EL2_RES1 | TCR_EL2_PS_40B)
-
 /* VTCR_EL2 Registers bits */
 #define VTCR_EL2_RES1          (1 << 31)
 #define VTCR_EL2_PS_MASK       (7 << 16)
 #define CPTR_EL2_TCPAC (1 << 31)
 #define CPTR_EL2_TTA   (1 << 20)
 #define CPTR_EL2_TFP   (1 << CPTR_EL2_TFP_SHIFT)
+#define CPTR_EL2_DEFAULT       0x000033ff
 
 /* Hyp Debug Configuration Register bits */
 #define MDCR_EL2_TDRA          (1 << 11)
index 3066328..779a587 100644 (file)
@@ -127,10 +127,14 @@ static inline unsigned long *vcpu_spsr(const struct kvm_vcpu *vcpu)
 
 static inline bool vcpu_mode_priv(const struct kvm_vcpu *vcpu)
 {
-       u32 mode = *vcpu_cpsr(vcpu) & PSR_MODE_MASK;
+       u32 mode;
 
-       if (vcpu_mode_is_32bit(vcpu))
+       if (vcpu_mode_is_32bit(vcpu)) {
+               mode = *vcpu_cpsr(vcpu) & COMPAT_PSR_MODE_MASK;
                return mode > COMPAT_PSR_MODE_USR;
+       }
+
+       mode = *vcpu_cpsr(vcpu) & PSR_MODE_MASK;
 
        return mode != PSR_MODE_EL0t;
 }
index bf464de..819aff5 100644 (file)
@@ -34,7 +34,7 @@
 /*
  * VMALLOC and SPARSEMEM_VMEMMAP ranges.
  *
- * VMEMAP_SIZE: allows the whole VA space to be covered by a struct page array
+ * VMEMAP_SIZE: allows the whole linear region to be covered by a struct page array
  *     (rounded up to PUD_SIZE).
  * VMALLOC_START: beginning of the kernel VA space
  * VMALLOC_END: extends to the available space below vmmemmap, PCI I/O space,
@@ -51,7 +51,9 @@
 
 #define VMALLOC_END            (PAGE_OFFSET - PUD_SIZE - VMEMMAP_SIZE - SZ_64K)
 
-#define vmemmap                        ((struct page *)(VMALLOC_END + SZ_64K))
+#define VMEMMAP_START          (VMALLOC_END + SZ_64K)
+#define vmemmap                        ((struct page *)VMEMMAP_START - \
+                                SECTION_ALIGN_DOWN(memstart_addr >> PAGE_SHIFT))
 
 #define FIRST_USER_ADDRESS     0UL
 
index 8aee3ae..c536c9e 100644 (file)
@@ -226,11 +226,28 @@ static int call_step_hook(struct pt_regs *regs, unsigned int esr)
        return retval;
 }
 
+static void send_user_sigtrap(int si_code)
+{
+       struct pt_regs *regs = current_pt_regs();
+       siginfo_t info = {
+               .si_signo       = SIGTRAP,
+               .si_errno       = 0,
+               .si_code        = si_code,
+               .si_addr        = (void __user *)instruction_pointer(regs),
+       };
+
+       if (WARN_ON(!user_mode(regs)))
+               return;
+
+       if (interrupts_enabled(regs))
+               local_irq_enable();
+
+       force_sig_info(SIGTRAP, &info, current);
+}
+
 static int single_step_handler(unsigned long addr, unsigned int esr,
                               struct pt_regs *regs)
 {
-       siginfo_t info;
-
        /*
         * If we are stepping a pending breakpoint, call the hw_breakpoint
         * handler first.
@@ -239,11 +256,7 @@ static int single_step_handler(unsigned long addr, unsigned int esr,
                return 0;
 
        if (user_mode(regs)) {
-               info.si_signo = SIGTRAP;
-               info.si_errno = 0;
-               info.si_code  = TRAP_HWBKPT;
-               info.si_addr  = (void __user *)instruction_pointer(regs);
-               force_sig_info(SIGTRAP, &info, current);
+               send_user_sigtrap(TRAP_HWBKPT);
 
                /*
                 * ptrace will disable single step unless explicitly
@@ -307,17 +320,8 @@ static int call_break_hook(struct pt_regs *regs, unsigned int esr)
 static int brk_handler(unsigned long addr, unsigned int esr,
                       struct pt_regs *regs)
 {
-       siginfo_t info;
-
        if (user_mode(regs)) {
-               info = (siginfo_t) {
-                       .si_signo = SIGTRAP,
-                       .si_errno = 0,
-                       .si_code  = TRAP_BRKPT,
-                       .si_addr  = (void __user *)instruction_pointer(regs),
-               };
-
-               force_sig_info(SIGTRAP, &info, current);
+               send_user_sigtrap(TRAP_BRKPT);
        } else if (call_break_hook(regs, esr) != DBG_HOOK_HANDLED) {
                pr_warning("Unexpected kernel BRK exception at EL1\n");
                return -EFAULT;
@@ -328,7 +332,6 @@ static int brk_handler(unsigned long addr, unsigned int esr,
 
 int aarch32_break_handler(struct pt_regs *regs)
 {
-       siginfo_t info;
        u32 arm_instr;
        u16 thumb_instr;
        bool bp = false;
@@ -359,14 +362,7 @@ int aarch32_break_handler(struct pt_regs *regs)
        if (!bp)
                return -EFAULT;
 
-       info = (siginfo_t) {
-               .si_signo = SIGTRAP,
-               .si_errno = 0,
-               .si_code  = TRAP_BRKPT,
-               .si_addr  = pc,
-       };
-
-       force_sig_info(SIGTRAP, &info, current);
+       send_user_sigtrap(TRAP_BRKPT);
        return 0;
 }
 
index 999633b..352f7ab 100644 (file)
@@ -89,6 +89,7 @@ __efistub_memcpy              = KALLSYMS_HIDE(__pi_memcpy);
 __efistub_memmove              = KALLSYMS_HIDE(__pi_memmove);
 __efistub_memset               = KALLSYMS_HIDE(__pi_memset);
 __efistub_strlen               = KALLSYMS_HIDE(__pi_strlen);
+__efistub_strnlen              = KALLSYMS_HIDE(__pi_strnlen);
 __efistub_strcmp               = KALLSYMS_HIDE(__pi_strcmp);
 __efistub_strncmp              = KALLSYMS_HIDE(__pi_strncmp);
 __efistub___flush_dcache_area  = KALLSYMS_HIDE(__pi___flush_dcache_area);
index e33fe33..fd10eb6 100644 (file)
@@ -145,6 +145,10 @@ ENTRY(cpu_resume_mmu)
 ENDPROC(cpu_resume_mmu)
        .popsection
 cpu_resume_after_mmu:
+#ifdef CONFIG_KASAN
+       mov     x0, sp
+       bl      kasan_unpoison_remaining_stack
+#endif
        mov     x0, #0                  // return zero on success
        ldp     x19, x20, [sp, #16]
        ldp     x21, x22, [sp, #32]
index 4fad978..d9751a4 100644 (file)
@@ -44,14 +44,13 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
        unsigned long irq_stack_ptr;
 
        /*
-        * Use raw_smp_processor_id() to avoid false-positives from
-        * CONFIG_DEBUG_PREEMPT. get_wchan() calls unwind_frame() on sleeping
-        * task stacks, we can be pre-empted in this case, so
-        * {raw_,}smp_processor_id() may give us the wrong value. Sleeping
-        * tasks can't ever be on an interrupt stack, so regardless of cpu,
-        * the checks will always fail.
+        * Switching between stacks is valid when tracing current and in
+        * non-preemptible context.
         */
-       irq_stack_ptr = IRQ_STACK_PTR(raw_smp_processor_id());
+       if (tsk == current && !preemptible())
+               irq_stack_ptr = IRQ_STACK_PTR(smp_processor_id());
+       else
+               irq_stack_ptr = 0;
 
        low  = frame->sp;
        /* irq stacks are not THREAD_SIZE aligned */
@@ -64,8 +63,8 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
                return -EINVAL;
 
        frame->sp = fp + 0x10;
-       frame->fp = *(unsigned long *)(fp);
-       frame->pc = *(unsigned long *)(fp + 8);
+       frame->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp));
+       frame->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp + 8));
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
        if (tsk && tsk->ret_stack &&
index cbedd72..c539208 100644 (file)
@@ -146,9 +146,18 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
 static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
 {
        struct stackframe frame;
-       unsigned long irq_stack_ptr = IRQ_STACK_PTR(smp_processor_id());
+       unsigned long irq_stack_ptr;
        int skip;
 
+       /*
+        * Switching between stacks is valid when tracing current and in
+        * non-preemptible context.
+        */
+       if (tsk == current && !preemptible())
+               irq_stack_ptr = IRQ_STACK_PTR(smp_processor_id());
+       else
+               irq_stack_ptr = 0;
+
        pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
 
        if (!tsk)
index fcb7788..9e54ad7 100644 (file)
@@ -194,7 +194,7 @@ static int get_timer_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
        u64 val;
 
        val = kvm_arm_timer_get_reg(vcpu, reg->id);
-       return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id));
+       return copy_to_user(uaddr, &val, KVM_REG_SIZE(reg->id)) ? -EFAULT : 0;
 }
 
 /**
index 3e568dc..d073b5a 100644 (file)
@@ -64,7 +64,7 @@ __do_hyp_init:
        mrs     x4, tcr_el1
        ldr     x5, =TCR_EL2_MASK
        and     x4, x4, x5
-       ldr     x5, =TCR_EL2_FLAGS
+       mov     x5, #TCR_EL2_RES1
        orr     x4, x4, x5
 
 #ifndef CONFIG_ARM64_VA_BITS_48
@@ -85,15 +85,17 @@ __do_hyp_init:
        ldr_l   x5, idmap_t0sz
        bfi     x4, x5, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH
 #endif
-       msr     tcr_el2, x4
-
-       ldr     x4, =VTCR_EL2_FLAGS
        /*
         * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in
-        * VTCR_EL2.
+        * TCR_EL2 and VTCR_EL2.
         */
        mrs     x5, ID_AA64MMFR0_EL1
        bfi     x4, x5, #16, #3
+
+       msr     tcr_el2, x4
+
+       ldr     x4, =VTCR_EL2_FLAGS
+       bfi     x4, x5, #16, #3
        /*
         * Read the VMIDBits bits from ID_AA64MMFR1_EL1 and set the VS bit in
         * VTCR_EL2.
index ca8f5a5..f0e7bdf 100644 (file)
@@ -36,7 +36,11 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
        write_sysreg(val, hcr_el2);
        /* Trap on AArch32 cp15 c15 accesses (EL1 or EL0) */
        write_sysreg(1 << 15, hstr_el2);
-       write_sysreg(CPTR_EL2_TTA | CPTR_EL2_TFP, cptr_el2);
+
+       val = CPTR_EL2_DEFAULT;
+       val |= CPTR_EL2_TTA | CPTR_EL2_TFP;
+       write_sysreg(val, cptr_el2);
+
        write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2);
 }
 
@@ -45,7 +49,7 @@ static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu)
        write_sysreg(HCR_RW, hcr_el2);
        write_sysreg(0, hstr_el2);
        write_sysreg(read_sysreg(mdcr_el2) & MDCR_EL2_HPMN_MASK, mdcr_el2);
-       write_sysreg(0, cptr_el2);
+       write_sysreg(CPTR_EL2_DEFAULT, cptr_el2);
 }
 
 static void __hyp_text __activate_vm(struct kvm_vcpu *vcpu)
index 9142e08..5dd2a26 100644 (file)
@@ -149,16 +149,6 @@ void __hyp_text __vgic_v3_restore_state(struct kvm_vcpu *vcpu)
 
        switch (nr_pri_bits) {
        case 7:
-                write_gicreg(cpu_if->vgic_ap1r[3], ICH_AP1R3_EL2);
-                write_gicreg(cpu_if->vgic_ap1r[2], ICH_AP1R2_EL2);
-       case 6:
-                write_gicreg(cpu_if->vgic_ap1r[1], ICH_AP1R1_EL2);
-       default:
-                write_gicreg(cpu_if->vgic_ap1r[0], ICH_AP1R0_EL2);
-       }                                          
-                                                  
-       switch (nr_pri_bits) {
-       case 7:
                 write_gicreg(cpu_if->vgic_ap0r[3], ICH_AP0R3_EL2);
                 write_gicreg(cpu_if->vgic_ap0r[2], ICH_AP0R2_EL2);
        case 6:
@@ -167,6 +157,16 @@ void __hyp_text __vgic_v3_restore_state(struct kvm_vcpu *vcpu)
                 write_gicreg(cpu_if->vgic_ap0r[0], ICH_AP0R0_EL2);
        }
 
+       switch (nr_pri_bits) {
+       case 7:
+                write_gicreg(cpu_if->vgic_ap1r[3], ICH_AP1R3_EL2);
+                write_gicreg(cpu_if->vgic_ap1r[2], ICH_AP1R2_EL2);
+       case 6:
+                write_gicreg(cpu_if->vgic_ap1r[1], ICH_AP1R1_EL2);
+       default:
+                write_gicreg(cpu_if->vgic_ap1r[0], ICH_AP1R0_EL2);
+       }
+
        switch (max_lr_idx) {
        case 15:
                write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(15)], ICH_LR15_EL2);
index 648112e..4d1ac81 100644 (file)
 
 #define PSTATE_FAULT_BITS_64   (PSR_MODE_EL1h | PSR_A_BIT | PSR_F_BIT | \
                                 PSR_I_BIT | PSR_D_BIT)
-#define EL1_EXCEPT_SYNC_OFFSET 0x200
+
+#define CURRENT_EL_SP_EL0_VECTOR       0x0
+#define CURRENT_EL_SP_ELx_VECTOR       0x200
+#define LOWER_EL_AArch64_VECTOR                0x400
+#define LOWER_EL_AArch32_VECTOR                0x600
 
 static void prepare_fault32(struct kvm_vcpu *vcpu, u32 mode, u32 vect_offset)
 {
@@ -97,6 +101,34 @@ static void inject_abt32(struct kvm_vcpu *vcpu, bool is_pabt,
                *fsr = 0x14;
 }
 
+enum exception_type {
+       except_type_sync        = 0,
+       except_type_irq         = 0x80,
+       except_type_fiq         = 0x100,
+       except_type_serror      = 0x180,
+};
+
+static u64 get_except_vector(struct kvm_vcpu *vcpu, enum exception_type type)
+{
+       u64 exc_offset;
+
+       switch (*vcpu_cpsr(vcpu) & (PSR_MODE_MASK | PSR_MODE32_BIT)) {
+       case PSR_MODE_EL1t:
+               exc_offset = CURRENT_EL_SP_EL0_VECTOR;
+               break;
+       case PSR_MODE_EL1h:
+               exc_offset = CURRENT_EL_SP_ELx_VECTOR;
+               break;
+       case PSR_MODE_EL0t:
+               exc_offset = LOWER_EL_AArch64_VECTOR;
+               break;
+       default:
+               exc_offset = LOWER_EL_AArch32_VECTOR;
+       }
+
+       return vcpu_sys_reg(vcpu, VBAR_EL1) + exc_offset + type;
+}
+
 static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr)
 {
        unsigned long cpsr = *vcpu_cpsr(vcpu);
@@ -108,8 +140,8 @@ static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr
        *vcpu_spsr(vcpu) = cpsr;
        *vcpu_elr_el1(vcpu) = *vcpu_pc(vcpu);
 
+       *vcpu_pc(vcpu) = get_except_vector(vcpu, except_type_sync);
        *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64;
-       *vcpu_pc(vcpu) = vcpu_sys_reg(vcpu, VBAR_EL1) + EL1_EXCEPT_SYNC_OFFSET;
 
        vcpu_sys_reg(vcpu, FAR_EL1) = addr;
 
@@ -143,8 +175,8 @@ static void inject_undef64(struct kvm_vcpu *vcpu)
        *vcpu_spsr(vcpu) = cpsr;
        *vcpu_elr_el1(vcpu) = *vcpu_pc(vcpu);
 
+       *vcpu_pc(vcpu) = get_except_vector(vcpu, except_type_sync);
        *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64;
-       *vcpu_pc(vcpu) = vcpu_sys_reg(vcpu, VBAR_EL1) + EL1_EXCEPT_SYNC_OFFSET;
 
        /*
         * Build an unknown exception, depending on the instruction
index eec3598..2e90371 100644 (file)
@@ -1007,10 +1007,9 @@ static int emulate_cp(struct kvm_vcpu *vcpu,
                if (likely(r->access(vcpu, params, r))) {
                        /* Skip instruction, since it was emulated */
                        kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
+                       /* Handled */
+                       return 0;
                }
-
-               /* Handled */
-               return 0;
        }
 
        /* Not handled */
@@ -1043,7 +1042,7 @@ static void unhandled_cp_access(struct kvm_vcpu *vcpu,
 }
 
 /**
- * kvm_handle_cp_64 -- handles a mrrc/mcrr trap on a guest CP15 access
+ * kvm_handle_cp_64 -- handles a mrrc/mcrr trap on a guest CP14/CP15 access
  * @vcpu: The VCPU pointer
  * @run:  The kvm_run struct
  */
@@ -1095,7 +1094,7 @@ out:
 }
 
 /**
- * kvm_handle_cp15_32 -- handles a mrc/mcr trap on a guest CP15 access
+ * kvm_handle_cp_32 -- handles a mrc/mcr trap on a guest CP14/CP15 access
  * @vcpu: The VCPU pointer
  * @run:  The kvm_run struct
  */
index 2ca6657..eae38da 100644 (file)
@@ -168,4 +168,4 @@ CPU_LE( lsr tmp2, tmp2, tmp4 )      /* Shift (tmp1 & 63).  */
 .Lhit_limit:
        mov     len, limit
        ret
-ENDPROC(strnlen)
+ENDPIPROC(strnlen)
index 331c4ca..a6e757c 100644 (file)
@@ -933,6 +933,10 @@ static int __init __iommu_dma_init(void)
                ret = register_iommu_dma_ops_notifier(&platform_bus_type);
        if (!ret)
                ret = register_iommu_dma_ops_notifier(&amba_bustype);
+
+       /* handle devices queued before this arch_initcall */
+       if (!ret)
+               __iommu_attach_notifier(NULL, BUS_NOTIFY_ADD_DEVICE, NULL);
        return ret;
 }
 arch_initcall(__iommu_dma_init);
index 92ddac1..abe2a95 100644 (file)
@@ -371,6 +371,13 @@ static int __kprobes do_translation_fault(unsigned long addr,
        return 0;
 }
 
+static int do_alignment_fault(unsigned long addr, unsigned int esr,
+                             struct pt_regs *regs)
+{
+       do_bad_area(addr, esr, regs);
+       return 0;
+}
+
 /*
  * This abort handler always returns "fault".
  */
@@ -418,7 +425,7 @@ static struct fault_info {
        { do_bad,               SIGBUS,  0,             "synchronous parity error (translation table walk)" },
        { do_bad,               SIGBUS,  0,             "synchronous parity error (translation table walk)" },
        { do_bad,               SIGBUS,  0,             "unknown 32"                    },
-       { do_bad,               SIGBUS,  BUS_ADRALN,    "alignment fault"               },
+       { do_alignment_fault,   SIGBUS,  BUS_ADRALN,    "alignment fault"               },
        { do_bad,               SIGBUS,  0,             "unknown 34"                    },
        { do_bad,               SIGBUS,  0,             "unknown 35"                    },
        { do_bad,               SIGBUS,  0,             "unknown 36"                    },
index 82d607c..da30529 100644 (file)
@@ -306,10 +306,6 @@ static __init int setup_hugepagesz(char *opt)
                hugetlb_add_hstate(PMD_SHIFT - PAGE_SHIFT);
        } else if (ps == PUD_SIZE) {
                hugetlb_add_hstate(PUD_SHIFT - PAGE_SHIFT);
-       } else if (ps == (PAGE_SIZE * CONT_PTES)) {
-               hugetlb_add_hstate(CONT_PTE_SHIFT);
-       } else if (ps == (PMD_SIZE * CONT_PMDS)) {
-               hugetlb_add_hstate((PMD_SHIFT + CONT_PMD_SHIFT) - PAGE_SHIFT);
        } else {
                pr_err("hugepagesz: Unsupported page size %lu K\n", ps >> 10);
                return 0;
@@ -317,13 +313,3 @@ static __init int setup_hugepagesz(char *opt)
        return 1;
 }
 __setup("hugepagesz=", setup_hugepagesz);
-
-#ifdef CONFIG_ARM64_64K_PAGES
-static __init int add_default_hugepagesz(void)
-{
-       if (size_to_hstate(CONT_PTES * PAGE_SIZE) == NULL)
-               hugetlb_add_hstate(CONT_PMD_SHIFT);
-       return 0;
-}
-arch_initcall(add_default_hugepagesz);
-#endif
index f3b061e..7802f21 100644 (file)
@@ -319,8 +319,8 @@ void __init mem_init(void)
 #endif
                  MLG(VMALLOC_START, VMALLOC_END),
 #ifdef CONFIG_SPARSEMEM_VMEMMAP
-                 MLG((unsigned long)vmemmap,
-                     (unsigned long)vmemmap + VMEMMAP_SIZE),
+                 MLG(VMEMMAP_START,
+                     VMEMMAP_START + VMEMMAP_SIZE),
                  MLM((unsigned long)virt_to_page(PAGE_OFFSET),
                      (unsigned long)virt_to_page(high_memory)),
 #endif
index 4c893b5..232f787 100644 (file)
@@ -53,10 +53,10 @@ unsigned long arch_mmap_rnd(void)
 
 #ifdef CONFIG_COMPAT
        if (test_thread_flag(TIF_32BIT))
-               rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_compat_bits) - 1);
+               rnd = get_random_long() & ((1UL << mmap_rnd_compat_bits) - 1);
        else
 #endif
-               rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1);
+               rnd = get_random_long() & ((1UL << mmap_rnd_bits) - 1);
        return rnd << PAGE_SHIFT;
 }
 
index fc96e81..d1fc479 100644 (file)
@@ -108,6 +108,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -266,6 +268,12 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_ATALK=m
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -366,6 +374,7 @@ CONFIG_ARIADNE=y
 # CONFIG_NET_VENDOR_INTEL is not set
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
 CONFIG_HYDRA=y
 CONFIG_APNE=y
 CONFIG_ZORRO8390=y
index 05c904f..9bfe8be 100644 (file)
@@ -106,6 +106,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -264,6 +266,12 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_ATALK=m
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -344,6 +352,7 @@ CONFIG_VETH=m
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
 # CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RENESAS is not set
 # CONFIG_NET_VENDOR_ROCKER is not set
index d572b73..ebdcfae 100644 (file)
@@ -106,6 +106,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -264,6 +266,12 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_ATALK=m
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -353,6 +361,7 @@ CONFIG_ATARILANCE=y
 # CONFIG_NET_VENDOR_INTEL is not set
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
 CONFIG_NE2000=y
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RENESAS is not set
index 11a30c6..8acc65e 100644 (file)
@@ -104,6 +104,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -262,6 +264,12 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_ATALK=m
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -343,6 +351,7 @@ CONFIG_BVME6000_NET=y
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
 # CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RENESAS is not set
 # CONFIG_NET_VENDOR_ROCKER is not set
index 6630a51..0c6a3d5 100644 (file)
@@ -106,6 +106,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -264,6 +266,12 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_ATALK=m
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -345,6 +353,7 @@ CONFIG_HPLANCE=y
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
 # CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RENESAS is not set
 # CONFIG_NET_VENDOR_ROCKER is not set
index 1d90b71..12a8a6c 100644 (file)
@@ -105,6 +105,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -266,6 +268,12 @@ CONFIG_DEV_APPLETALK=m
 CONFIG_IPDDP=m
 CONFIG_IPDDP_ENCAP=y
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -362,6 +370,7 @@ CONFIG_MAC89x0=y
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
 CONFIG_MACSONIC=y
+# CONFIG_NET_VENDOR_NETRONOME is not set
 CONFIG_MAC8390=y
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RENESAS is not set
index 1fd21c1..64ff2dc 100644 (file)
@@ -115,6 +115,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -276,6 +278,12 @@ CONFIG_DEV_APPLETALK=m
 CONFIG_IPDDP=m
 CONFIG_IPDDP_ENCAP=y
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -404,6 +412,7 @@ CONFIG_MVME16x_NET=y
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
 CONFIG_MACSONIC=y
+# CONFIG_NET_VENDOR_NETRONOME is not set
 CONFIG_HYDRA=y
 CONFIG_MAC8390=y
 CONFIG_NE2000=y
index 74e10f7..07fc6ab 100644 (file)
@@ -103,6 +103,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -261,6 +263,12 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_ATALK=m
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -343,6 +351,7 @@ CONFIG_MVME147_NET=y
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
 # CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RENESAS is not set
 # CONFIG_NET_VENDOR_ROCKER is not set
index 7034e71..69903de 100644 (file)
@@ -104,6 +104,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -262,6 +264,12 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_ATALK=m
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -343,6 +351,7 @@ CONFIG_MVME16x_NET=y
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
 # CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RENESAS is not set
 # CONFIG_NET_VENDOR_ROCKER is not set
index f7deb5f..bd84016 100644 (file)
@@ -104,6 +104,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -262,6 +264,12 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_ATALK=m
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -352,6 +360,7 @@ CONFIG_VETH=m
 # CONFIG_NET_VENDOR_INTEL is not set
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
 CONFIG_NE2000=y
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RENESAS is not set
index 0ce79eb..5f9fb3a 100644 (file)
@@ -101,6 +101,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -259,6 +261,12 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_ATALK=m
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -340,6 +348,7 @@ CONFIG_SUN3_82586=y
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
 # CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RENESAS is not set
 # CONFIG_NET_VENDOR_ROCKER is not set
index 4cb787e..5d1c674 100644 (file)
@@ -101,6 +101,8 @@ CONFIG_NFT_NAT=m
 CONFIG_NFT_QUEUE=m
 CONFIG_NFT_REJECT=m
 CONFIG_NFT_COMPAT=m
+CONFIG_NFT_DUP_NETDEV=m
+CONFIG_NFT_FWD_NETDEV=m
 CONFIG_NETFILTER_XT_SET=m
 CONFIG_NETFILTER_XT_TARGET_CHECKSUM=m
 CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
@@ -259,6 +261,12 @@ CONFIG_L2TP=m
 CONFIG_BRIDGE=m
 CONFIG_ATALK=m
 CONFIG_6LOWPAN=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_HOP=m
+CONFIG_6LOWPAN_GHC_UDP=m
+CONFIG_6LOWPAN_GHC_ICMPV6=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_DEST=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG=m
+CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE=m
 CONFIG_DNS_RESOLVER=y
 CONFIG_BATMAN_ADV=m
 CONFIG_BATMAN_ADV_DAT=y
@@ -341,6 +349,7 @@ CONFIG_SUN3LANCE=y
 # CONFIG_NET_VENDOR_MARVELL is not set
 # CONFIG_NET_VENDOR_MICREL is not set
 # CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
 # CONFIG_NET_VENDOR_QUALCOMM is not set
 # CONFIG_NET_VENDOR_RENESAS is not set
 # CONFIG_NET_VENDOR_ROCKER is not set
index f9d96bf..bafaff6 100644 (file)
@@ -4,7 +4,7 @@
 #include <uapi/asm/unistd.h>
 
 
-#define NR_syscalls            376
+#define NR_syscalls            377
 
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
index 36cf129..0ca7296 100644 (file)
 #define __NR_userfaultfd       373
 #define __NR_membarrier                374
 #define __NR_mlock2            375
+#define __NR_copy_file_range   376
 
 #endif /* _UAPI_ASM_M68K_UNISTD_H_ */
index 282cd90..8bb9426 100644 (file)
@@ -396,3 +396,4 @@ ENTRY(sys_call_table)
        .long sys_userfaultfd
        .long sys_membarrier
        .long sys_mlock2                /* 375 */
+       .long sys_copy_file_range
index 57a945e..74a3db9 100644 (file)
@@ -2085,7 +2085,7 @@ config PAGE_SIZE_32KB
 
 config PAGE_SIZE_64KB
        bool "64kB"
-       depends on !CPU_R3000 && !CPU_TX39XX
+       depends on !CPU_R3000 && !CPU_TX39XX && !CPU_R6000
        help
          Using 64kB page size will result in higher performance kernel at
          the price of higher memory consumption.  This option is available on
index 459b9b2..d61b161 100644 (file)
@@ -74,6 +74,7 @@
                timer: timer@10000040 {
                        compatible = "syscon";
                        reg = <0x10000040 0x2c>;
+                       little-endian;
                };
 
                reboot {
index 4fc7ece..1a7efa8 100644 (file)
@@ -98,6 +98,7 @@
                sun_top_ctrl: syscon@404000 {
                        compatible = "brcm,bcm7125-sun-top-ctrl", "syscon";
                        reg = <0x404000 0x60c>;
+                       little-endian;
                };
 
                reboot {
index a3039bb..d4bf52c 100644 (file)
                sun_top_ctrl: syscon@404000 {
                        compatible = "brcm,bcm7346-sun-top-ctrl", "syscon";
                        reg = <0x404000 0x51c>;
+                       little-endian;
                };
 
                reboot {
index 4274ff4..8e25016 100644 (file)
                sun_top_ctrl: syscon@404000 {
                        compatible = "brcm,bcm7358-sun-top-ctrl", "syscon";
                        reg = <0x404000 0x51c>;
+                       little-endian;
                };
 
                reboot {
index 0dcc916..7e5f760 100644 (file)
                sun_top_ctrl: syscon@404000 {
                        compatible = "brcm,bcm7360-sun-top-ctrl", "syscon";
                        reg = <0x404000 0x51c>;
+                       little-endian;
                };
 
                reboot {
index 2f3f9fc..c739ea7 100644 (file)
                sun_top_ctrl: syscon@404000 {
                        compatible = "brcm,bcm7362-sun-top-ctrl", "syscon";
                        reg = <0x404000 0x51c>;
+                       little-endian;
                };
 
                reboot {
index bee221b..5f55d0a 100644 (file)
@@ -99,6 +99,7 @@
                sun_top_ctrl: syscon@404000 {
                        compatible = "brcm,bcm7420-sun-top-ctrl", "syscon";
                        reg = <0x404000 0x60c>;
+                       little-endian;
                };
 
                reboot {
index 571f30f..e24d41a 100644 (file)
                sun_top_ctrl: syscon@404000 {
                        compatible = "brcm,bcm7425-sun-top-ctrl", "syscon";
                        reg = <0x404000 0x51c>;
+                       little-endian;
                };
 
                reboot {
index 614ee21..8b9432c 100644 (file)
                sun_top_ctrl: syscon@404000 {
                        compatible = "brcm,bcm7425-sun-top-ctrl", "syscon";
                        reg = <0x404000 0x51c>;
+                       little-endian;
                };
 
                reboot {
index cefb7a5..e090fc3 100644 (file)
@@ -227,7 +227,7 @@ struct mips_elf_abiflags_v0 {
        int __res = 1;                                                  \
        struct elfhdr *__h = (hdr);                                     \
                                                                        \
-       if (__h->e_machine != EM_MIPS)                                  \
+       if (!mips_elf_check_machine(__h))                               \
                __res = 0;                                              \
        if (__h->e_ident[EI_CLASS] != ELFCLASS32)                       \
                __res = 0;                                              \
@@ -258,7 +258,7 @@ struct mips_elf_abiflags_v0 {
        int __res = 1;                                                  \
        struct elfhdr *__h = (hdr);                                     \
                                                                        \
-       if (__h->e_machine != EM_MIPS)                                  \
+       if (!mips_elf_check_machine(__h))                               \
                __res = 0;                                              \
        if (__h->e_ident[EI_CLASS] != ELFCLASS64)                       \
                __res = 0;                                              \
@@ -285,6 +285,11 @@ struct mips_elf_abiflags_v0 {
 
 #endif /* !defined(ELF_ARCH) */
 
+#define mips_elf_check_machine(x) ((x)->e_machine == EM_MIPS)
+
+#define vmcore_elf32_check_arch mips_elf_check_machine
+#define vmcore_elf64_check_arch mips_elf_check_machine
+
 struct mips_abi;
 
 extern struct mips_abi mips_abi;
index 9cbf383..f06f97b 100644 (file)
@@ -179,6 +179,10 @@ static inline void lose_fpu_inatomic(int save, struct task_struct *tsk)
                if (save)
                        _save_fp(tsk);
                __disable_fpu();
+       } else {
+               /* FPU should not have been left enabled with no owner */
+               WARN(read_c0_status() & ST0_CU1,
+                    "Orphaned FPU left enabled");
        }
        KSTK_STATUS(tsk) &= ~ST0_CU1;
        clear_tsk_thread_flag(tsk, TIF_USEDFPU);
index 8ebd3f5..3ed10a8 100644 (file)
@@ -128,7 +128,8 @@ static inline int octeon_has_feature(enum octeon_feature feature)
        case OCTEON_FEATURE_PCIE:
                return OCTEON_IS_MODEL(OCTEON_CN56XX)
                        || OCTEON_IS_MODEL(OCTEON_CN52XX)
-                       || OCTEON_IS_MODEL(OCTEON_CN6XXX);
+                       || OCTEON_IS_MODEL(OCTEON_CN6XXX)
+                       || OCTEON_IS_MODEL(OCTEON_CN7XXX);
 
        case OCTEON_FEATURE_SRIO:
                return OCTEON_IS_MODEL(OCTEON_CN63XX)
index 3f832c3..041153f 100644 (file)
@@ -45,7 +45,7 @@ extern unsigned int vced_count, vcei_count;
  * User space process size: 2GB. This is hardcoded into a few places,
  * so don't change it unless you know what you are doing.
  */
-#define TASK_SIZE      0x7fff8000UL
+#define TASK_SIZE      0x80000000UL
 #endif
 
 #define STACK_TOP_MAX  TASK_SIZE
index a71da57..eebf395 100644 (file)
                .set    reorder
                .set    noat
                mfc0    a0, CP0_STATUS
-               li      v1, 0xff00
+               li      v1, ST0_CU1 | ST0_IM
                ori     a0, STATMASK
                xori    a0, STATMASK
                mtc0    a0, CP0_STATUS
                ori     a0, STATMASK
                xori    a0, STATMASK
                mtc0    a0, CP0_STATUS
-               li      v1, 0xff00
+               li      v1, ST0_CU1 | ST0_FR | ST0_IM
                and     a0, v1
                LONG_L  v0, PT_STATUS(sp)
                nor     v1, $0, v1
index 6499d93..47bc45a 100644 (file)
@@ -101,10 +101,8 @@ static inline void syscall_get_arguments(struct task_struct *task,
        /* O32 ABI syscall() - Either 64-bit with O32 or 32-bit */
        if ((config_enabled(CONFIG_32BIT) ||
            test_tsk_thread_flag(task, TIF_32BIT_REGS)) &&
-           (regs->regs[2] == __NR_syscall)) {
+           (regs->regs[2] == __NR_syscall))
                i++;
-               n++;
-       }
 
        while (n--)
                ret |= mips_get_syscall_arg(args++, task, regs, i++);
index 90f03a7..3129795 100644 (file)
 #define __NR_userfaultfd               (__NR_Linux + 357)
 #define __NR_membarrier                        (__NR_Linux + 358)
 #define __NR_mlock2                    (__NR_Linux + 359)
+#define __NR_copy_file_range           (__NR_Linux + 360)
 
 /*
  * Offset of the last Linux o32 flavoured syscall
  */
-#define __NR_Linux_syscalls            359
+#define __NR_Linux_syscalls            360
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
 
 #define __NR_O32_Linux                 4000
-#define __NR_O32_Linux_syscalls                359
+#define __NR_O32_Linux_syscalls                360
 
 #if _MIPS_SIM == _MIPS_SIM_ABI64
 
 #define __NR_userfaultfd               (__NR_Linux + 317)
 #define __NR_membarrier                        (__NR_Linux + 318)
 #define __NR_mlock2                    (__NR_Linux + 319)
+#define __NR_copy_file_range           (__NR_Linux + 320)
 
 /*
  * Offset of the last Linux 64-bit flavoured syscall
  */
-#define __NR_Linux_syscalls            319
+#define __NR_Linux_syscalls            320
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
 
 #define __NR_64_Linux                  5000
-#define __NR_64_Linux_syscalls         319
+#define __NR_64_Linux_syscalls         320
 
 #if _MIPS_SIM == _MIPS_SIM_NABI32
 
 #define __NR_userfaultfd               (__NR_Linux + 321)
 #define __NR_membarrier                        (__NR_Linux + 322)
 #define __NR_mlock2                    (__NR_Linux + 323)
+#define __NR_copy_file_range           (__NR_Linux + 324)
 
 /*
  * Offset of the last N32 flavoured syscall
  */
-#define __NR_Linux_syscalls            323
+#define __NR_Linux_syscalls            324
 
 #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
 
 #define __NR_N32_Linux                 6000
-#define __NR_N32_Linux_syscalls                323
+#define __NR_N32_Linux_syscalls                324
 
 #endif /* _UAPI_ASM_UNISTD_H */
index 8c6d76c..d9907e5 100644 (file)
@@ -270,7 +270,7 @@ uint32_t jz_gpio_port_get_value(int port, uint32_t mask)
 }
 EXPORT_SYMBOL(jz_gpio_port_get_value);
 
-#define IRQ_TO_BIT(irq) BIT(irq_to_gpio(irq) & 0x1f)
+#define IRQ_TO_BIT(irq) BIT((irq - JZ4740_IRQ_GPIO(0)) & 0x1f)
 
 static void jz_gpio_check_trigger_both(struct jz_gpio_chip *chip, unsigned int irq)
 {
index 1188e00..1b992c6 100644 (file)
@@ -35,7 +35,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
        int __res = 1;                                                  \
        struct elfhdr *__h = (hdr);                                     \
                                                                        \
-       if (__h->e_machine != EM_MIPS)                                  \
+       if (!mips_elf_check_machine(__h))                               \
                __res = 0;                                              \
        if (__h->e_ident[EI_CLASS] != ELFCLASS32)                       \
                __res = 0;                                              \
index 9287678..abd3aff 100644 (file)
@@ -47,7 +47,7 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
        int __res = 1;                                                  \
        struct elfhdr *__h = (hdr);                                     \
                                                                        \
-       if (__h->e_machine != EM_MIPS)                                  \
+       if (!mips_elf_check_machine(__h))                               \
                __res = 0;                                              \
        if (__h->e_ident[EI_CLASS] != ELFCLASS32)                       \
                __res = 0;                                              \
index f2975d4..eddd5fd 100644 (file)
@@ -65,12 +65,10 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
        status = regs->cp0_status & ~(ST0_CU0|ST0_CU1|ST0_FR|KU_MASK);
        status |= KU_USER;
        regs->cp0_status = status;
+       lose_fpu(0);
+       clear_thread_flag(TIF_MSA_CTX_LIVE);
        clear_used_math();
-       clear_fpu_owner();
        init_dsp();
-       clear_thread_flag(TIF_USEDMSA);
-       clear_thread_flag(TIF_MSA_CTX_LIVE);
-       disable_msa();
        regs->cp0_epc = pc;
        regs->regs[29] = sp;
 }
index 5ce3b74..b4ac637 100644 (file)
@@ -125,7 +125,7 @@ LEAF(_restore_fp_context)
        END(_restore_fp_context)
        .set    reorder
 
-       .type   fault@function
+       .type   fault@function
        .ent    fault
 fault: li      v0, -EFAULT
        jr      ra
index f09546e..17732f8 100644 (file)
@@ -358,7 +358,7 @@ LEAF(_restore_msa_all_upper)
 
        .set    reorder
 
-       .type   fault@function
+       .type   fault@function
        .ent    fault
 fault: li      v0, -EFAULT                             # failure
        jr      ra
index 2d23c83..a563174 100644 (file)
@@ -595,3 +595,4 @@ EXPORT(sys_call_table)
        PTR     sys_userfaultfd
        PTR     sys_membarrier
        PTR     sys_mlock2
+       PTR     sys_copy_file_range             /* 4360 */
index deac633..2b2dc14 100644 (file)
@@ -433,4 +433,5 @@ EXPORT(sys_call_table)
        PTR     sys_userfaultfd
        PTR     sys_membarrier
        PTR     sys_mlock2
+       PTR     sys_copy_file_range             /* 5320 */
        .size   sys_call_table,.-sys_call_table
index 5a69eb4..2bf5c85 100644 (file)
@@ -423,4 +423,5 @@ EXPORT(sysn32_call_table)
        PTR     sys_userfaultfd
        PTR     sys_membarrier
        PTR     sys_mlock2
+       PTR     sys_copy_file_range
        .size   sysn32_call_table,.-sysn32_call_table
index e4b6d7c..c5b759e 100644 (file)
@@ -578,4 +578,5 @@ EXPORT(sys32_call_table)
        PTR     sys_userfaultfd
        PTR     sys_membarrier
        PTR     sys_mlock2
+       PTR     sys_copy_file_range             /* 4360 */
        .size   sys32_call_table,.-sys32_call_table
index 569a7d5..5fdaf8b 100644 (file)
@@ -782,6 +782,7 @@ static inline void prefill_possible_map(void) {}
 void __init setup_arch(char **cmdline_p)
 {
        cpu_probe();
+       mips_cm_probe();
        prom_init();
 
        setup_early_fdc_console();
index bafcb7a..bf14da9 100644 (file)
@@ -663,7 +663,7 @@ static int simulate_rdhwr_normal(struct pt_regs *regs, unsigned int opcode)
        return -1;
 }
 
-static int simulate_rdhwr_mm(struct pt_regs *regs, unsigned short opcode)
+static int simulate_rdhwr_mm(struct pt_regs *regs, unsigned int opcode)
 {
        if ((opcode & MM_POOL32A_FUNC) == MM_RDHWR) {
                int rd = (opcode & MM_RS) >> 16;
@@ -690,15 +690,15 @@ static int simulate_sync(struct pt_regs *regs, unsigned int opcode)
 asmlinkage void do_ov(struct pt_regs *regs)
 {
        enum ctx_state prev_state;
-       siginfo_t info;
+       siginfo_t info = {
+               .si_signo = SIGFPE,
+               .si_code = FPE_INTOVF,
+               .si_addr = (void __user *)regs->cp0_epc,
+       };
 
        prev_state = exception_enter();
        die_if_kernel("Integer overflow", regs);
 
-       info.si_code = FPE_INTOVF;
-       info.si_signo = SIGFPE;
-       info.si_errno = 0;
-       info.si_addr = (void __user *) regs->cp0_epc;
        force_sig_info(SIGFPE, &info, current);
        exception_exit(prev_state);
 }
@@ -874,7 +874,7 @@ out:
 void do_trap_or_bp(struct pt_regs *regs, unsigned int code,
        const char *str)
 {
-       siginfo_t info;
+       siginfo_t info = { 0 };
        char b[40];
 
 #ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
@@ -903,7 +903,6 @@ void do_trap_or_bp(struct pt_regs *regs, unsigned int code,
                else
                        info.si_code = FPE_INTOVF;
                info.si_signo = SIGFPE;
-               info.si_errno = 0;
                info.si_addr = (void __user *) regs->cp0_epc;
                force_sig_info(SIGFPE, &info, current);
                break;
@@ -1119,11 +1118,12 @@ no_r2_instr:
        if (get_isa16_mode(regs->cp0_epc)) {
                unsigned short mmop[2] = { 0 };
 
-               if (unlikely(get_user(mmop[0], epc) < 0))
+               if (unlikely(get_user(mmop[0], (u16 __user *)epc + 0) < 0))
                        status = SIGSEGV;
-               if (unlikely(get_user(mmop[1], epc) < 0))
+               if (unlikely(get_user(mmop[1], (u16 __user *)epc + 1) < 0))
                        status = SIGSEGV;
-               opcode = (mmop[0] << 16) | mmop[1];
+               opcode = mmop[0];
+               opcode = (opcode << 16) | mmop[1];
 
                if (status < 0)
                        status = simulate_rdhwr_mm(regs, opcode);
@@ -1369,26 +1369,12 @@ asmlinkage void do_cpu(struct pt_regs *regs)
                if (unlikely(compute_return_epc(regs) < 0))
                        break;
 
-               if (get_isa16_mode(regs->cp0_epc)) {
-                       unsigned short mmop[2] = { 0 };
-
-                       if (unlikely(get_user(mmop[0], epc) < 0))
-                               status = SIGSEGV;
-                       if (unlikely(get_user(mmop[1], epc) < 0))
-                               status = SIGSEGV;
-                       opcode = (mmop[0] << 16) | mmop[1];
-
-                       if (status < 0)
-                               status = simulate_rdhwr_mm(regs, opcode);
-               } else {
+               if (!get_isa16_mode(regs->cp0_epc)) {
                        if (unlikely(get_user(opcode, epc) < 0))
                                status = SIGSEGV;
 
                        if (!cpu_has_llsc && status < 0)
                                status = simulate_llsc(regs, opcode);
-
-                       if (status < 0)
-                               status = simulate_rdhwr_normal(regs, opcode);
                }
 
                if (status < 0)
index 8bc3977..3110447 100644 (file)
@@ -702,7 +702,7 @@ static int kvm_mips_get_reg(struct kvm_vcpu *vcpu,
        } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) {
                void __user *uaddr = (void __user *)(long)reg->addr;
 
-               return copy_to_user(uaddr, vs, 16);
+               return copy_to_user(uaddr, vs, 16) ? -EFAULT : 0;
        } else {
                return -EINVAL;
        }
@@ -732,7 +732,7 @@ static int kvm_mips_set_reg(struct kvm_vcpu *vcpu,
        } else if ((reg->id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U128) {
                void __user *uaddr = (void __user *)(long)reg->addr;
 
-               return copy_from_user(vs, uaddr, 16);
+               return copy_from_user(vs, uaddr, 16) ? -EFAULT : 0;
        } else {
                return -EINVAL;
        }
index 5c81fdd..3530376 100644 (file)
@@ -146,7 +146,7 @@ unsigned long arch_mmap_rnd(void)
 {
        unsigned long rnd;
 
-       rnd = (unsigned long)get_random_int();
+       rnd = get_random_long();
        rnd <<= PAGE_SHIFT;
        if (TASK_IS_32BIT_ADDR)
                rnd &= 0xfffffful;
@@ -174,7 +174,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
 
 static inline unsigned long brk_rnd(void)
 {
-       unsigned long rnd = get_random_int();
+       unsigned long rnd = get_random_long();
 
        rnd = rnd << PAGE_SHIFT;
        /* 8MB for 32bit, 256MB for 64bit */
index 3bd0597..91dec32 100644 (file)
@@ -164,11 +164,13 @@ static int __init mips_sc_probe_cm3(void)
 
        sets = cfg & CM_GCR_L2_CONFIG_SET_SIZE_MSK;
        sets >>= CM_GCR_L2_CONFIG_SET_SIZE_SHF;
-       c->scache.sets = 64 << sets;
+       if (sets)
+               c->scache.sets = 64 << sets;
 
        line_sz = cfg & CM_GCR_L2_CONFIG_LINE_SIZE_MSK;
        line_sz >>= CM_GCR_L2_CONFIG_LINE_SIZE_SHF;
-       c->scache.linesz = 2 << line_sz;
+       if (line_sz)
+               c->scache.linesz = 2 << line_sz;
 
        assoc = cfg & CM_GCR_L2_CONFIG_ASSOC_MSK;
        assoc >>= CM_GCR_L2_CONFIG_ASSOC_SHF;
@@ -176,13 +178,12 @@ static int __init mips_sc_probe_cm3(void)
        c->scache.waysize = c->scache.sets * c->scache.linesz;
        c->scache.waybit = __ffs(c->scache.waysize);
 
-       c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
+       if (c->scache.linesz) {
+               c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
+               return 1;
+       }
 
-       return 1;
-}
-
-void __weak platform_early_l2_init(void)
-{
+       return 0;
 }
 
 static inline int __init mips_sc_probe(void)
@@ -194,12 +195,6 @@ static inline int __init mips_sc_probe(void)
        /* Mark as not present until probe completed */
        c->scache.flags |= MIPS_CACHE_NOT_PRESENT;
 
-       /*
-        * Do we need some platform specific probing before
-        * we configure L2?
-        */
-       platform_early_l2_init();
-
        if (mips_cm_revision() >= CM_REV_CM3)
                return mips_sc_probe_cm3();
 
index 571148c..dc2c521 100644 (file)
@@ -293,7 +293,6 @@ mips_pci_controller:
        console_config();
 #endif
        /* Early detection of CMP support */
-       mips_cm_probe();
        mips_cpc_probe();
 
        if (!register_cps_smp_ops())
@@ -304,10 +303,3 @@ mips_pci_controller:
                return;
        register_up_smp_ops();
 }
-
-void platform_early_l2_init(void)
-{
-       /* L2 configuration lives in the CM3 */
-       if (mips_cm_revision() >= CM_REV_CM3)
-               mips_cm_probe();
-}
index a009ee4..1ae932c 100644 (file)
@@ -297,12 +297,12 @@ static int mt7620_pci_probe(struct platform_device *pdev)
                return PTR_ERR(rstpcie0);
 
        bridge_base = devm_ioremap_resource(&pdev->dev, bridge_res);
-       if (!bridge_base)
-               return -ENOMEM;
+       if (IS_ERR(bridge_base))
+               return PTR_ERR(bridge_base);
 
        pcie_base = devm_ioremap_resource(&pdev->dev, pcie_res);
-       if (!pcie_base)
-               return -ENOMEM;
+       if (IS_ERR(pcie_base))
+               return PTR_ERR(pcie_base);
 
        iomem_resource.start = 0;
        iomem_resource.end = ~0;
index f84ff12..6d8276c 100644 (file)
@@ -33,7 +33,7 @@
  * floppy accesses go through the track buffer.
  */
 #define _CROSS_64KB(a,s,vdma) \
-(!vdma && ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64))
+(!(vdma) && ((unsigned long)(a)/K_64 != ((unsigned long)(a) + (s) - 1) / K_64))
 
 #define CROSS_64KB(a,s) _CROSS_64KB(a,s,use_virtual_dma & 1)
 
index 35bdccb..b75039f 100644 (file)
 #define __NR_membarrier                (__NR_Linux + 343)
 #define __NR_userfaultfd       (__NR_Linux + 344)
 #define __NR_mlock2            (__NR_Linux + 345)
+#define __NR_copy_file_range   (__NR_Linux + 346)
 
-#define __NR_Linux_syscalls    (__NR_mlock2 + 1)
+#define __NR_Linux_syscalls    (__NR_copy_file_range + 1)
 
 
 #define __IGNORE_select                /* newselect */
index 9585c81..ce0b2b4 100644 (file)
@@ -269,14 +269,19 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 
 long do_syscall_trace_enter(struct pt_regs *regs)
 {
-       long ret = 0;
-
        /* Do the secure computing check first. */
        secure_computing_strict(regs->gr[20]);
 
        if (test_thread_flag(TIF_SYSCALL_TRACE) &&
-           tracehook_report_syscall_entry(regs))
-               ret = -1L;
+           tracehook_report_syscall_entry(regs)) {
+               /*
+                * Tracing decided this syscall should not happen or the
+                * debugger stored an invalid system call number. Skip
+                * the system call and the system call restart handling.
+                */
+               regs->gr[20] = -1UL;
+               goto out;
+       }
 
 #ifdef CONFIG_64BIT
        if (!is_compat_task())
@@ -290,7 +295,8 @@ long do_syscall_trace_enter(struct pt_regs *regs)
                        regs->gr[24] & 0xffffffff,
                        regs->gr[23] & 0xffffffff);
 
-       return ret ? : regs->gr[20];
+out:
+       return regs->gr[20];
 }
 
 void do_syscall_trace_exit(struct pt_regs *regs)
index 3fbd725..fbafa0d 100644 (file)
@@ -343,7 +343,7 @@ tracesys_next:
 #endif
 
        comiclr,>>=     __NR_Linux_syscalls, %r20, %r0
-       b,n     .Lsyscall_nosys
+       b,n     .Ltracesys_nosys
 
        LDREGX  %r20(%r19), %r19
 
@@ -359,6 +359,9 @@ tracesys_next:
        be      0(%sr7,%r19)
        ldo     R%tracesys_exit(%r2),%r2
 
+.Ltracesys_nosys:
+       ldo     -ENOSYS(%r0),%r28               /* set errno */
+
        /* Do *not* call this function on the gateway page, because it
        makes a direct call to syscall_trace. */
        
index d4ffcfb..585d50f 100644 (file)
        ENTRY_SAME(membarrier)
        ENTRY_SAME(userfaultfd)
        ENTRY_SAME(mlock2)              /* 345 */
+       ENTRY_SAME(copy_file_range)
 
 
 .ifne (. - 90b) - (__NR_Linux_syscalls * (91b - 90b))
index e4824fd..9faa18c 100644 (file)
@@ -557,7 +557,7 @@ choice
 
 config PPC_4K_PAGES
        bool "4k page size"
-       select HAVE_ARCH_SOFT_DIRTY if CHECKPOINT_RESTORE && PPC_BOOK3S
+       select HAVE_ARCH_SOFT_DIRTY if PPC_BOOK3S_64
 
 config PPC_16K_PAGES
        bool "16k page size"
@@ -566,7 +566,7 @@ config PPC_16K_PAGES
 config PPC_64K_PAGES
        bool "64k page size"
        depends on !PPC_FSL_BOOK3E && (44x || PPC_STD_MMU_64 || PPC_BOOK3E_64)
-       select HAVE_ARCH_SOFT_DIRTY if CHECKPOINT_RESTORE && PPC_BOOK3S
+       select HAVE_ARCH_SOFT_DIRTY if PPC_BOOK3S_64
 
 config PPC_256K_PAGES
        bool "256k page size"
index 8d1c41d..ac07a30 100644 (file)
@@ -281,6 +281,10 @@ extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
 extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
                            pmd_t *pmdp);
 
+#define __HAVE_ARCH_PMDP_HUGE_SPLIT_PREPARE
+extern void pmdp_huge_split_prepare(struct vm_area_struct *vma,
+                                   unsigned long address, pmd_t *pmdp);
+
 #define pmd_move_must_withdraw pmd_move_must_withdraw
 struct spinlock;
 static inline int pmd_move_must_withdraw(struct spinlock *new_pmd_ptl,
index c5eb86f..867c39b 100644 (file)
@@ -81,6 +81,7 @@ struct pci_dn;
 #define EEH_PE_KEEP            (1 << 8)        /* Keep PE on hotplug   */
 #define EEH_PE_CFG_RESTRICTED  (1 << 9)        /* Block config on error */
 #define EEH_PE_REMOVED         (1 << 10)       /* Removed permanently  */
+#define EEH_PE_PRI_BUS         (1 << 11)       /* Cached primary bus   */
 
 struct eeh_pe {
        int type;                       /* PE type: PHB/Bus/Device      */
index 8e86b48..32e36b1 100644 (file)
@@ -57,12 +57,14 @@ DEFINE_EVENT(ppc64_interrupt_class, timer_interrupt_exit,
 extern void hcall_tracepoint_regfunc(void);
 extern void hcall_tracepoint_unregfunc(void);
 
-TRACE_EVENT_FN(hcall_entry,
+TRACE_EVENT_FN_COND(hcall_entry,
 
        TP_PROTO(unsigned long opcode, unsigned long *args),
 
        TP_ARGS(opcode, args),
 
+       TP_CONDITION(cpu_online(raw_smp_processor_id())),
+
        TP_STRUCT__entry(
                __field(unsigned long, opcode)
        ),
@@ -76,13 +78,15 @@ TRACE_EVENT_FN(hcall_entry,
        hcall_tracepoint_regfunc, hcall_tracepoint_unregfunc
 );
 
-TRACE_EVENT_FN(hcall_exit,
+TRACE_EVENT_FN_COND(hcall_exit,
 
        TP_PROTO(unsigned long opcode, unsigned long retval,
                unsigned long *retbuf),
 
        TP_ARGS(opcode, retval, retbuf),
 
+       TP_CONDITION(cpu_online(raw_smp_processor_id())),
+
        TP_STRUCT__entry(
                __field(unsigned long, opcode)
                __field(unsigned long, retval)
index 9387421..650cfb3 100644 (file)
@@ -418,8 +418,7 @@ static void *eeh_rmv_device(void *data, void *userdata)
                eeh_pcid_put(dev);
                if (driver->err_handler &&
                    driver->err_handler->error_detected &&
-                   driver->err_handler->slot_reset &&
-                   driver->err_handler->resume)
+                   driver->err_handler->slot_reset)
                        return NULL;
        }
 
@@ -564,6 +563,7 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)
         */
        eeh_pe_state_mark(pe, EEH_PE_KEEP);
        if (bus) {
+               eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
                pci_lock_rescan_remove();
                pcibios_remove_pci_devices(bus);
                pci_unlock_rescan_remove();
@@ -803,6 +803,7 @@ perm_error:
         * the their PCI config any more.
         */
        if (frozen_bus) {
+               eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
                eeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED);
 
                pci_lock_rescan_remove();
@@ -886,6 +887,7 @@ static void eeh_handle_special_event(void)
                                        continue;
 
                                /* Notify all devices to be down */
+                               eeh_pe_state_clear(pe, EEH_PE_PRI_BUS);
                                bus = eeh_pe_bus_get(phb_pe);
                                eeh_pe_dev_traverse(pe,
                                        eeh_report_failure, NULL);
index ca9e537..98f8180 100644 (file)
@@ -928,7 +928,7 @@ struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe)
                bus = pe->phb->bus;
        } else if (pe->type & EEH_PE_BUS ||
                   pe->type & EEH_PE_DEVICE) {
-               if (pe->bus) {
+               if (pe->state & EEH_PE_PRI_BUS) {
                        bus = pe->bus;
                        goto out;
                }
index 05e804c..aec9a1b 100644 (file)
@@ -109,8 +109,9 @@ void arch_unregister_hw_breakpoint(struct perf_event *bp)
         * If the breakpoint is unregistered between a hw_breakpoint_handler()
         * and the single_step_dabr_instruction(), then cleanup the breakpoint
         * restoration variables to prevent dangling pointers.
+        * FIXME, this should not be using bp->ctx at all! Sayeth peterz.
         */
-       if (bp->ctx && bp->ctx->task)
+       if (bp->ctx && bp->ctx->task && bp->ctx->task != ((void *)-1L))
                bp->ctx->task->thread.last_hit_ubp = NULL;
 }
 
index ac64ffd..08b7a40 100644 (file)
@@ -340,7 +340,7 @@ static void dedotify(Elf64_Sym *syms, unsigned int numsyms, char *strtab)
                        if (name[0] == '.') {
                                if (strcmp(name+1, "TOC.") == 0)
                                        syms[i].st_shndx = SHN_ABS;
-                               memmove(name, name+1, strlen(name));
+                               syms[i].st_name++;
                        }
                }
        }
index dccc87e..3c5736e 100644 (file)
@@ -1768,9 +1768,9 @@ static inline unsigned long brk_rnd(void)
 
        /* 8MB for 32bit, 1GB for 64bit */
        if (is_32bit_task())
-               rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
+               rnd = (get_random_long() % (1UL<<(23-PAGE_SHIFT)));
        else
-               rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
+               rnd = (get_random_long() % (1UL<<(30-PAGE_SHIFT)));
 
        return rnd << PAGE_SHIFT;
 }
index 6ee26de..25ae2c9 100644 (file)
@@ -1370,6 +1370,20 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_207S)
        std     r6, VCPU_ACOP(r9)
        stw     r7, VCPU_GUEST_PID(r9)
        std     r8, VCPU_WORT(r9)
+       /*
+        * Restore various registers to 0, where non-zero values
+        * set by the guest could disrupt the host.
+        */
+       li      r0, 0
+       mtspr   SPRN_IAMR, r0
+       mtspr   SPRN_CIABR, r0
+       mtspr   SPRN_DAWRX, r0
+       mtspr   SPRN_TCSCR, r0
+       mtspr   SPRN_WORT, r0
+       /* Set MMCRS to 1<<31 to freeze and disable the SPMC counters */
+       li      r0, 1
+       sldi    r0, r0, 31
+       mtspr   SPRN_MMCRS, r0
 8:
 
        /* Save and reset AMR and UAMOR before turning on the MMU */
index 0762c1e..edb0991 100644 (file)
@@ -111,7 +111,13 @@ int __hash_page_4K(unsigned long ea, unsigned long access, unsigned long vsid,
         */
        if (!(old_pte & _PAGE_COMBO)) {
                flush_hash_page(vpn, rpte, MMU_PAGE_64K, ssize, flags);
-               old_pte &= ~_PAGE_HASHPTE | _PAGE_F_GIX | _PAGE_F_SECOND;
+               /*
+                * clear the old slot details from the old and new pte.
+                * On hash insert failure we use old pte value and we don't
+                * want slot information there if we have a insert failure.
+                */
+               old_pte &= ~(_PAGE_HASHPTE | _PAGE_F_GIX | _PAGE_F_SECOND);
+               new_pte &= ~(_PAGE_HASHPTE | _PAGE_F_GIX | _PAGE_F_SECOND);
                goto htab_insert_hpte;
        }
        /*
index 49b152b..eb2accd 100644 (file)
@@ -78,9 +78,19 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid,
                 * base page size. This is because demote_segment won't flush
                 * hash page table entries.
                 */
-               if ((old_pmd & _PAGE_HASHPTE) && !(old_pmd & _PAGE_COMBO))
+               if ((old_pmd & _PAGE_HASHPTE) && !(old_pmd & _PAGE_COMBO)) {
                        flush_hash_hugepage(vsid, ea, pmdp, MMU_PAGE_64K,
                                            ssize, flags);
+                       /*
+                        * With THP, we also clear the slot information with
+                        * respect to all the 64K hash pte mapping the 16MB
+                        * page. They are all invalid now. This make sure we
+                        * don't find the slot valid when we fault with 4k
+                        * base page size.
+                        *
+                        */
+                       memset(hpte_slot_array, 0, PTE_FRAG_SIZE);
+               }
        }
 
        valid = hpte_valid(hpte_slot_array, index);
index 7e6d088..83a8be7 100644 (file)
@@ -8,6 +8,8 @@
 #include <linux/mm.h>
 #include <linux/hugetlb.h>
 
+#include <asm/mmu.h>
+
 #ifdef CONFIG_PPC_FSL_BOOK3E
 #ifdef CONFIG_PPC64
 static inline int tlb1_next(void)
@@ -60,6 +62,14 @@ static inline void book3e_tlb_lock(void)
        unsigned long tmp;
        int token = smp_processor_id() + 1;
 
+       /*
+        * Besides being unnecessary in the absence of SMT, this
+        * check prevents trying to do lbarx/stbcx. on e5500 which
+        * doesn't implement either feature.
+        */
+       if (!cpu_has_feature(CPU_FTR_SMT))
+               return;
+
        asm volatile("1: lbarx %0, 0, %1;"
                     "cmpwi %0, 0;"
                     "bne 2f;"
@@ -80,6 +90,9 @@ static inline void book3e_tlb_unlock(void)
 {
        struct paca_struct *paca = get_paca();
 
+       if (!cpu_has_feature(CPU_FTR_SMT))
+               return;
+
        isync();
        paca->tcd_ptr->lock = 0;
 }
index 0f0502e..4087705 100644 (file)
@@ -59,9 +59,9 @@ unsigned long arch_mmap_rnd(void)
 
        /* 8MB for 32bit, 1GB for 64bit */
        if (is_32bit_task())
-               rnd = (unsigned long)get_random_int() % (1<<(23-PAGE_SHIFT));
+               rnd = get_random_long() % (1<<(23-PAGE_SHIFT));
        else
-               rnd = (unsigned long)get_random_int() % (1<<(30-PAGE_SHIFT));
+               rnd = get_random_long() % (1UL<<(30-PAGE_SHIFT));
 
        return rnd << PAGE_SHIFT;
 }
index 3124a20..cdf2123 100644 (file)
@@ -646,6 +646,28 @@ pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp)
        return pgtable;
 }
 
+void pmdp_huge_split_prepare(struct vm_area_struct *vma,
+                            unsigned long address, pmd_t *pmdp)
+{
+       VM_BUG_ON(address & ~HPAGE_PMD_MASK);
+       VM_BUG_ON(REGION_ID(address) != USER_REGION_ID);
+
+       /*
+        * We can't mark the pmd none here, because that will cause a race
+        * against exit_mmap. We need to continue mark pmd TRANS HUGE, while
+        * we spilt, but at the same time we wan't rest of the ppc64 code
+        * not to insert hash pte on this, because we will be modifying
+        * the deposited pgtable in the caller of this function. Hence
+        * clear the _PAGE_USER so that we move the fault handling to
+        * higher level function and that will serialize against ptl.
+        * We need to flush existing hash pte entries here even though,
+        * the translation is still valid, because we will withdraw
+        * pgtable_t after this.
+        */
+       pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_USER, 0);
+}
+
+
 /*
  * set a new huge pmd. We should not be called for updating
  * an existing pmd entry. That should go via pmd_hugepage_update.
@@ -663,10 +685,20 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr,
        return set_pte_at(mm, addr, pmdp_ptep(pmdp), pmd_pte(pmd));
 }
 
+/*
+ * We use this to invalidate a pmdp entry before switching from a
+ * hugepte to regular pmd entry.
+ */
 void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
                     pmd_t *pmdp)
 {
        pmd_hugepage_update(vma->vm_mm, address, pmdp, _PAGE_PRESENT, 0);
+
+       /*
+        * This ensures that generic code that rely on IRQ disabling
+        * to prevent a parallel THP split work as expected.
+        */
+       kick_all_cpus_sync();
 }
 
 /*
index 5f152b9..87f47e5 100644 (file)
@@ -444,9 +444,12 @@ static void *pnv_eeh_probe(struct pci_dn *pdn, void *data)
         * PCI devices of the PE are expected to be removed prior
         * to PE reset.
         */
-       if (!edev->pe->bus)
+       if (!(edev->pe->state & EEH_PE_PRI_BUS)) {
                edev->pe->bus = pci_find_bus(hose->global_number,
                                             pdn->busno);
+               if (edev->pe->bus)
+                       edev->pe->state |= EEH_PE_PRI_BUS;
+       }
 
        /*
         * Enable EEH explicitly so that we will do EEH check
index 573ae19..f90dc04 100644 (file)
@@ -3180,6 +3180,7 @@ static void pnv_pci_ioda_shutdown(struct pci_controller *hose)
 
 static const struct pci_controller_ops pnv_pci_ioda_controller_ops = {
        .dma_dev_setup = pnv_pci_dma_dev_setup,
+       .dma_bus_setup = pnv_pci_dma_bus_setup,
 #ifdef CONFIG_PCI_MSI
        .setup_msi_irqs = pnv_setup_msi_irqs,
        .teardown_msi_irqs = pnv_teardown_msi_irqs,
index 2f55c86..b1ef84a 100644 (file)
@@ -599,6 +599,9 @@ int pnv_tce_build(struct iommu_table *tbl, long index, long npages,
        u64 rpn = __pa(uaddr) >> tbl->it_page_shift;
        long i;
 
+       if (proto_tce & TCE_PCI_WRITE)
+               proto_tce |= TCE_PCI_READ;
+
        for (i = 0; i < npages; i++) {
                unsigned long newtce = proto_tce |
                        ((rpn + i) << tbl->it_page_shift);
@@ -620,6 +623,9 @@ int pnv_tce_xchg(struct iommu_table *tbl, long index,
 
        BUG_ON(*hpa & ~IOMMU_PAGE_MASK(tbl));
 
+       if (newtce & TCE_PCI_WRITE)
+               newtce |= TCE_PCI_READ;
+
        oldtce = xchg(pnv_tce(tbl, idx), cpu_to_be64(newtce));
        *hpa = be64_to_cpu(oldtce) & ~(TCE_PCI_READ | TCE_PCI_WRITE);
        *direction = iommu_tce_direction(oldtce);
@@ -760,6 +766,26 @@ void pnv_pci_dma_dev_setup(struct pci_dev *pdev)
                phb->dma_dev_setup(phb, pdev);
 }
 
+void pnv_pci_dma_bus_setup(struct pci_bus *bus)
+{
+       struct pci_controller *hose = bus->sysdata;
+       struct pnv_phb *phb = hose->private_data;
+       struct pnv_ioda_pe *pe;
+
+       list_for_each_entry(pe, &phb->ioda.pe_list, list) {
+               if (!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL)))
+                       continue;
+
+               if (!pe->pbus)
+                       continue;
+
+               if (bus->number == ((pe->rid >> 8) & 0xFF)) {
+                       pe->pbus = bus;
+                       break;
+               }
+       }
+}
+
 void pnv_pci_shutdown(void)
 {
        struct pci_controller *hose;
index 7f56313..00691a9 100644 (file)
@@ -242,6 +242,7 @@ extern void pnv_pci_reset_secondary_bus(struct pci_dev *dev);
 extern int pnv_eeh_phb_reset(struct pci_controller *hose, int option);
 
 extern void pnv_pci_dma_dev_setup(struct pci_dev *pdev);
+extern void pnv_pci_dma_bus_setup(struct pci_bus *bus);
 extern int pnv_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type);
 extern void pnv_teardown_msi_irqs(struct pci_dev *pdev);
 
index ea91ddf..629c908 100644 (file)
@@ -40,6 +40,7 @@ static inline void convert_fp_to_vx(__vector128 *vxrs, freg_t *fprs)
 static inline void fpregs_store(_s390_fp_regs *fpregs, struct fpu *fpu)
 {
        fpregs->pad = 0;
+       fpregs->fpc = fpu->fpc;
        if (MACHINE_HAS_VX)
                convert_vx_to_fp((freg_t *)&fpregs->fprs, fpu->vxrs);
        else
@@ -49,6 +50,7 @@ static inline void fpregs_store(_s390_fp_regs *fpregs, struct fpu *fpu)
 
 static inline void fpregs_load(_s390_fp_regs *fpregs, struct fpu *fpu)
 {
+       fpu->fpc = fpregs->fpc;
        if (MACHINE_HAS_VX)
                convert_fp_to_vx(fpu->vxrs, (freg_t *)&fpregs->fprs);
        else
index 7aa7991..a52b6cc 100644 (file)
@@ -37,7 +37,7 @@ static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip)
        regs->psw.addr = ip;
 }
 #else
-#error Live patching support is disabled; check CONFIG_LIVEPATCH
+#error Include linux/livepatch.h, not asm/livepatch.h
 #endif
 
 #endif
index fb1b93e..e485817 100644 (file)
 static inline int init_new_context(struct task_struct *tsk,
                                   struct mm_struct *mm)
 {
+       spin_lock_init(&mm->context.list_lock);
+       INIT_LIST_HEAD(&mm->context.pgtable_list);
+       INIT_LIST_HEAD(&mm->context.gmap_list);
        cpumask_clear(&mm->context.cpu_attach_mask);
        atomic_set(&mm->context.attach_count, 0);
        mm->context.flush_mm = 0;
-       mm->context.asce_bits = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS;
-       mm->context.asce_bits |= _ASCE_TYPE_REGION3;
 #ifdef CONFIG_PGSTE
        mm->context.alloc_pgste = page_table_allocate_pgste;
        mm->context.has_pgste = 0;
        mm->context.use_skey = 0;
 #endif
-       mm->context.asce_limit = STACK_TOP_MAX;
+       if (mm->context.asce_limit == 0) {
+               /* context created by exec, set asce limit to 4TB */
+               mm->context.asce_bits = _ASCE_TABLE_LENGTH |
+                       _ASCE_USER_BITS | _ASCE_TYPE_REGION3;
+               mm->context.asce_limit = STACK_TOP_MAX;
+       } else if (mm->context.asce_limit == (1UL << 31)) {
+               mm_inc_nr_pmds(mm);
+       }
        crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm));
        return 0;
 }
@@ -111,8 +119,6 @@ static inline void activate_mm(struct mm_struct *prev,
 static inline void arch_dup_mmap(struct mm_struct *oldmm,
                                 struct mm_struct *mm)
 {
-       if (oldmm->context.asce_limit < mm->context.asce_limit)
-               crst_table_downgrade(mm, oldmm->context.asce_limit);
 }
 
 static inline void arch_exit_mmap(struct mm_struct *mm)
index 7b7858f..d7cc79f 100644 (file)
@@ -100,12 +100,26 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
 
 static inline pgd_t *pgd_alloc(struct mm_struct *mm)
 {
-       spin_lock_init(&mm->context.list_lock);
-       INIT_LIST_HEAD(&mm->context.pgtable_list);
-       INIT_LIST_HEAD(&mm->context.gmap_list);
-       return (pgd_t *) crst_table_alloc(mm);
+       unsigned long *table = crst_table_alloc(mm);
+
+       if (!table)
+               return NULL;
+       if (mm->context.asce_limit == (1UL << 31)) {
+               /* Forking a compat process with 2 page table levels */
+               if (!pgtable_pmd_page_ctor(virt_to_page(table))) {
+                       crst_table_free(mm, table);
+                       return NULL;
+               }
+       }
+       return (pgd_t *) table;
+}
+
+static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
+{
+       if (mm->context.asce_limit == (1UL << 31))
+               pgtable_pmd_page_dtor(virt_to_page(pgd));
+       crst_table_free(mm, (unsigned long *) pgd);
 }
-#define pgd_free(mm, pgd) crst_table_free(mm, (unsigned long *) pgd)
 
 static inline void pmd_populate(struct mm_struct *mm,
                                pmd_t *pmd, pgtable_t pte)
index 66c9441..4af6037 100644 (file)
@@ -271,7 +271,7 @@ static int restore_sigregs_ext32(struct pt_regs *regs,
 
        /* Restore high gprs from signal stack */
        if (__copy_from_user(&gprs_high, &sregs_ext->gprs_high,
-                            sizeof(&sregs_ext->gprs_high)))
+                            sizeof(sregs_ext->gprs_high)))
                return -EFAULT;
        for (i = 0; i < NUM_GPRS; i++)
                *(__u32 *)&regs->gprs[i] = gprs_high[i];
index c5febe8..03c2b46 100644 (file)
@@ -16,7 +16,7 @@
 
 __HEAD
 ENTRY(startup_continue)
-       tm      __LC_STFLE_FAC_LIST+6,0x80      # LPP available ?
+       tm      __LC_STFLE_FAC_LIST+5,0x80      # LPP available ?
        jz      0f
        xc      __LC_LPP+1(7,0),__LC_LPP+1      # clear lpp and current_pid
        mvi     __LC_LPP,0x80                   #   and set LPP_MAGIC
index cfcba2d..0943b11 100644 (file)
@@ -260,12 +260,13 @@ static unsigned long __store_trace(struct perf_callchain_entry *entry,
 void perf_callchain_kernel(struct perf_callchain_entry *entry,
                           struct pt_regs *regs)
 {
-       unsigned long head;
+       unsigned long head, frame_size;
        struct stack_frame *head_sf;
 
        if (user_mode(regs))
                return;
 
+       frame_size = STACK_FRAME_OVERHEAD + sizeof(struct pt_regs);
        head = regs->gprs[15];
        head_sf = (struct stack_frame *) head;
 
@@ -273,8 +274,9 @@ void perf_callchain_kernel(struct perf_callchain_entry *entry,
                return;
 
        head = head_sf->back_chain;
-       head = __store_trace(entry, head, S390_lowcore.async_stack - ASYNC_SIZE,
-                            S390_lowcore.async_stack);
+       head = __store_trace(entry, head,
+                            S390_lowcore.async_stack + frame_size - ASYNC_SIZE,
+                            S390_lowcore.async_stack + frame_size);
 
        __store_trace(entry, head, S390_lowcore.thread_info,
                      S390_lowcore.thread_info + THREAD_SIZE);
index 5acba3c..8f64ebd 100644 (file)
@@ -59,26 +59,32 @@ static unsigned long save_context_stack(struct stack_trace *trace,
        }
 }
 
-void save_stack_trace(struct stack_trace *trace)
+static void __save_stack_trace(struct stack_trace *trace, unsigned long sp)
 {
-       register unsigned long sp asm ("15");
-       unsigned long orig_sp, new_sp;
+       unsigned long new_sp, frame_size;
 
-       orig_sp = sp;
-       new_sp = save_context_stack(trace, orig_sp,
-                                   S390_lowcore.panic_stack - PAGE_SIZE,
-                                   S390_lowcore.panic_stack, 1);
-       if (new_sp != orig_sp)
-               return;
+       frame_size = STACK_FRAME_OVERHEAD + sizeof(struct pt_regs);
+       new_sp = save_context_stack(trace, sp,
+                       S390_lowcore.panic_stack + frame_size - PAGE_SIZE,
+                       S390_lowcore.panic_stack + frame_size, 1);
        new_sp = save_context_stack(trace, new_sp,
-                                   S390_lowcore.async_stack - ASYNC_SIZE,
-                                   S390_lowcore.async_stack, 1);
-       if (new_sp != orig_sp)
-               return;
+                       S390_lowcore.async_stack + frame_size - ASYNC_SIZE,
+                       S390_lowcore.async_stack + frame_size, 1);
        save_context_stack(trace, new_sp,
                           S390_lowcore.thread_info,
                           S390_lowcore.thread_info + THREAD_SIZE, 1);
 }
+
+void save_stack_trace(struct stack_trace *trace)
+{
+       register unsigned long r15 asm ("15");
+       unsigned long sp;
+
+       sp = r15;
+       __save_stack_trace(trace, sp);
+       if (trace->nr_entries < trace->max_entries)
+               trace->entries[trace->nr_entries++] = ULONG_MAX;
+}
 EXPORT_SYMBOL_GPL(save_stack_trace);
 
 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
@@ -86,6 +92,10 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
        unsigned long sp, low, high;
 
        sp = tsk->thread.ksp;
+       if (tsk == current) {
+               /* Get current stack pointer. */
+               asm volatile("la %0,0(15)" : "=a" (sp));
+       }
        low = (unsigned long) task_stack_page(tsk);
        high = (unsigned long) task_pt_regs(tsk);
        save_context_stack(trace, sp, low, high, 0);
@@ -93,3 +103,14 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
                trace->entries[trace->nr_entries++] = ULONG_MAX;
 }
 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
+
+void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
+{
+       unsigned long sp;
+
+       sp = kernel_stack_pointer(regs);
+       __save_stack_trace(trace, sp);
+       if (trace->nr_entries < trace->max_entries)
+               trace->entries[trace->nr_entries++] = ULONG_MAX;
+}
+EXPORT_SYMBOL_GPL(save_stack_trace_regs);
index 21a5df9..dde7654 100644 (file)
@@ -18,6 +18,9 @@ void trace_s390_diagnose_norecursion(int diag_nr)
        unsigned long flags;
        unsigned int *depth;
 
+       /* Avoid lockdep recursion. */
+       if (IS_ENABLED(CONFIG_LOCKDEP))
+               return;
        local_irq_save(flags);
        depth = this_cpu_ptr(&diagnose_trace_depth);
        if (*depth == 0) {
index 4af21c7..03dfe9c 100644 (file)
@@ -2381,7 +2381,7 @@ int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long gpa)
 
        /* manually convert vector registers if necessary */
        if (MACHINE_HAS_VX) {
-               convert_vx_to_fp(fprs, current->thread.fpu.vxrs);
+               convert_vx_to_fp(fprs, (__vector128 *) vcpu->run->s.regs.vrs);
                rc = write_guest_abs(vcpu, gpa + __LC_FPREGS_SAVE_AREA,
                                     fprs, 128);
        } else {
index fec59c0..792f9c6 100644 (file)
@@ -93,15 +93,19 @@ static int __memcpy_real(void *dest, void *src, size_t count)
  */
 int memcpy_real(void *dest, void *src, size_t count)
 {
+       int irqs_disabled, rc;
        unsigned long flags;
-       int rc;
 
        if (!count)
                return 0;
-       local_irq_save(flags);
-       __arch_local_irq_stnsm(0xfbUL);
+       flags = __arch_local_irq_stnsm(0xf8UL);
+       irqs_disabled = arch_irqs_disabled_flags(flags);
+       if (!irqs_disabled)
+               trace_hardirqs_off();
        rc = __memcpy_real(dest, src, count);
-       local_irq_restore(flags);
+       if (!irqs_disabled)
+               trace_hardirqs_on();
+       __arch_local_irq_ssm(flags);
        return rc;
 }
 
index fe0bfe3..1884e17 100644 (file)
@@ -54,12 +54,13 @@ __show_trace(unsigned int *depth, unsigned long sp,
 
 void s390_backtrace(struct pt_regs * const regs, unsigned int depth)
 {
-       unsigned long head;
+       unsigned long head, frame_size;
        struct stack_frame* head_sf;
 
        if (user_mode(regs))
                return;
 
+       frame_size = STACK_FRAME_OVERHEAD + sizeof(struct pt_regs);
        head = regs->gprs[15];
        head_sf = (struct stack_frame*)head;
 
@@ -68,8 +69,9 @@ void s390_backtrace(struct pt_regs * const regs, unsigned int depth)
 
        head = head_sf->back_chain;
 
-       head = __show_trace(&depth, head, S390_lowcore.async_stack - ASYNC_SIZE,
-                           S390_lowcore.async_stack);
+       head = __show_trace(&depth, head,
+                           S390_lowcore.async_stack + frame_size - ASYNC_SIZE,
+                           S390_lowcore.async_stack + frame_size);
 
        __show_trace(&depth, head, S390_lowcore.thread_info,
                     S390_lowcore.thread_info + THREAD_SIZE);
index eaee146..8496a07 100644 (file)
@@ -24,7 +24,13 @@ LDFLAGS        := -m elf32_sparc
 export BITS    := 32
 UTS_MACHINE    := sparc
 
+# We are adding -Wa,-Av8 to KBUILD_CFLAGS to deal with a specs bug in some
+# versions of gcc.  Some gcc versions won't pass -Av8 to binutils when you
+# give -mcpu=v8.  This silently worked with older bintutils versions but
+# does not any more.
 KBUILD_CFLAGS  += -m32 -mcpu=v8 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
+KBUILD_CFLAGS  += -Wa,-Av8
+
 KBUILD_AFLAGS  += -m32 -Wa,-Av8
 
 else
index 1c26d44..b6de8b1 100644 (file)
 #define __NR_listen            354
 #define __NR_setsockopt                355
 #define __NR_mlock2            356
+#define __NR_copy_file_range   357
 
-#define NR_syscalls            357
+#define NR_syscalls            358
 
 /* Bitmask values returned from kern_features system call.  */
 #define KERN_FEATURE_MIXED_MODE_STACK  0x00000001
index 33c02b1..a83707c 100644 (file)
@@ -948,7 +948,24 @@ linux_syscall_trace:
        cmp     %o0, 0
        bne     3f
         mov    -ENOSYS, %o0
+
+       /* Syscall tracing can modify the registers.  */
+       ld      [%sp + STACKFRAME_SZ + PT_G1], %g1
+       sethi   %hi(sys_call_table), %l7
+       ld      [%sp + STACKFRAME_SZ + PT_I0], %i0
+       or      %l7, %lo(sys_call_table), %l7
+       ld      [%sp + STACKFRAME_SZ + PT_I1], %i1
+       ld      [%sp + STACKFRAME_SZ + PT_I2], %i2
+       ld      [%sp + STACKFRAME_SZ + PT_I3], %i3
+       ld      [%sp + STACKFRAME_SZ + PT_I4], %i4
+       ld      [%sp + STACKFRAME_SZ + PT_I5], %i5
+       cmp     %g1, NR_syscalls
+       bgeu    3f
+        mov    -ENOSYS, %o0
+
+       sll     %g1, 2, %l4
        mov     %i0, %o0
+       ld      [%l7 + %l4], %l7
        mov     %i1, %o1
        mov     %i2, %o2
        mov     %i3, %o3
index afbaba5..d127130 100644 (file)
@@ -338,8 +338,9 @@ ENTRY(sun4v_mach_set_watchdog)
        mov     %o1, %o4
        mov     HV_FAST_MACH_SET_WATCHDOG, %o5
        ta      HV_FAST_TRAP
+       brnz,a,pn %o4, 0f
        stx     %o1, [%o4]
-       retl
+0:     retl
         nop
 ENDPROC(sun4v_mach_set_watchdog)
 
index d88beff..39aaec1 100644 (file)
@@ -52,7 +52,7 @@ asmlinkage void sparc64_set_context(struct pt_regs *regs)
        unsigned char fenab;
        int err;
 
-       flush_user_windows();
+       synchronize_user_stack();
        if (get_thread_wsaved()                                 ||
            (((unsigned long)ucp) & (sizeof(unsigned long)-1))  ||
            (!__access_ok(ucp, sizeof(*ucp))))
index a92d5d2..9e034f2 100644 (file)
@@ -37,6 +37,7 @@ EXPORT_SYMBOL(sun4v_niagara_getperf);
 EXPORT_SYMBOL(sun4v_niagara_setperf);
 EXPORT_SYMBOL(sun4v_niagara2_getperf);
 EXPORT_SYMBOL(sun4v_niagara2_setperf);
+EXPORT_SYMBOL(sun4v_mach_set_watchdog);
 
 /* from hweight.S */
 EXPORT_SYMBOL(__arch_hweight8);
index c690c8e..b489e97 100644 (file)
@@ -264,7 +264,7 @@ static unsigned long mmap_rnd(void)
        unsigned long rnd = 0UL;
 
        if (current->flags & PF_RANDOMIZE) {
-               unsigned long val = get_random_int();
+               unsigned long val = get_random_long();
                if (test_thread_flag(TIF_32BIT))
                        rnd = (val % (1UL << (23UL-PAGE_SHIFT)));
                else
index bb00089..c4a1b5c 100644 (file)
@@ -158,7 +158,25 @@ linux_syscall_trace32:
         add    %sp, PTREGS_OFF, %o0
        brnz,pn %o0, 3f
         mov    -ENOSYS, %o0
+
+       /* Syscall tracing can modify the registers.  */
+       ldx     [%sp + PTREGS_OFF + PT_V9_G1], %g1
+       sethi   %hi(sys_call_table32), %l7
+       ldx     [%sp + PTREGS_OFF + PT_V9_I0], %i0
+       or      %l7, %lo(sys_call_table32), %l7
+       ldx     [%sp + PTREGS_OFF + PT_V9_I1], %i1
+       ldx     [%sp + PTREGS_OFF + PT_V9_I2], %i2
+       ldx     [%sp + PTREGS_OFF + PT_V9_I3], %i3
+       ldx     [%sp + PTREGS_OFF + PT_V9_I4], %i4
+       ldx     [%sp + PTREGS_OFF + PT_V9_I5], %i5
+
+       cmp     %g1, NR_syscalls
+       bgeu,pn %xcc, 3f
+        mov    -ENOSYS, %o0
+
+       sll     %g1, 2, %l4
        srl     %i0, 0, %o0
+       lduw    [%l7 + %l4], %l7
        srl     %i4, 0, %o4
        srl     %i1, 0, %o1
        srl     %i2, 0, %o2
@@ -170,7 +188,25 @@ linux_syscall_trace:
         add    %sp, PTREGS_OFF, %o0
        brnz,pn %o0, 3f
         mov    -ENOSYS, %o0
+
+       /* Syscall tracing can modify the registers.  */
+       ldx     [%sp + PTREGS_OFF + PT_V9_G1], %g1
+       sethi   %hi(sys_call_table64), %l7
+       ldx     [%sp + PTREGS_OFF + PT_V9_I0], %i0
+       or      %l7, %lo(sys_call_table64), %l7
+       ldx     [%sp + PTREGS_OFF + PT_V9_I1], %i1
+       ldx     [%sp + PTREGS_OFF + PT_V9_I2], %i2
+       ldx     [%sp + PTREGS_OFF + PT_V9_I3], %i3
+       ldx     [%sp + PTREGS_OFF + PT_V9_I4], %i4
+       ldx     [%sp + PTREGS_OFF + PT_V9_I5], %i5
+
+       cmp     %g1, NR_syscalls
+       bgeu,pn %xcc, 3f
+        mov    -ENOSYS, %o0
+
+       sll     %g1, 2, %l4
        mov     %i0, %o0
+       lduw    [%l7 + %l4], %l7
        mov     %i1, %o1
        mov     %i2, %o2
        mov     %i3, %o3
index e663b6c..6c3dd6c 100644 (file)
@@ -88,4 +88,4 @@ sys_call_table:
 /*340*/        .long sys_ni_syscall, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
 /*345*/        .long sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
 /*350*/        .long sys_execveat, sys_membarrier, sys_userfaultfd, sys_bind, sys_listen
-/*355*/        .long sys_setsockopt, sys_mlock2
+/*355*/        .long sys_setsockopt, sys_mlock2, sys_copy_file_range
index 1557121..12b524c 100644 (file)
@@ -89,7 +89,7 @@ sys_call_table32:
 /*340*/        .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
        .word sys32_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
 /*350*/        .word sys32_execveat, sys_membarrier, sys_userfaultfd, sys_bind, sys_listen
-       .word compat_sys_setsockopt, sys_mlock2
+       .word compat_sys_setsockopt, sys_mlock2, sys_copy_file_range
 
 #endif /* CONFIG_COMPAT */
 
@@ -170,4 +170,4 @@ sys_call_table:
 /*340*/        .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr
        .word sys_renameat2, sys_seccomp, sys_getrandom, sys_memfd_create, sys_bpf
 /*350*/        .word sys64_execveat, sys_membarrier, sys_userfaultfd, sys_bind, sys_listen
-       .word sys_setsockopt, sys_mlock2
+       .word sys_setsockopt, sys_mlock2, sys_copy_file_range
index 9bdf67a..b60a9f8 100644 (file)
@@ -12,6 +12,7 @@
 #include <skas.h>
 
 void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
 
 static void kill_off_processes(void)
 {
index fc8be0e..57acbd6 100644 (file)
@@ -69,7 +69,7 @@ void do_signal(struct pt_regs *regs)
        struct ksignal ksig;
        int handled_sig = 0;
 
-       if (get_signal(&ksig)) {
+       while (get_signal(&ksig)) {
                handled_sig = 1;
                /* Whee!  Actually deliver the signal.  */
                handle_signal(&ksig, regs);
index 9af2e63..c46662f 100644 (file)
@@ -475,6 +475,7 @@ config X86_UV
        depends on X86_64
        depends on X86_EXTENDED_PLATFORM
        depends on NUMA
+       depends on EFI
        depends on X86_X2APIC
        depends on PCI
        ---help---
@@ -777,8 +778,8 @@ config HPET_TIMER
          HPET is the next generation timer replacing legacy 8254s.
          The HPET provides a stable time base on SMP
          systems, unlike the TSC, but it is more expensive to access,
-         as it is off-chip.  You can find the HPET spec at
-         <http://www.intel.com/hardwaredesign/hpetspec_1.pdf>.
+         as it is off-chip.  The interface used is documented
+         in the HPET spec, revision 1.
 
          You can safely choose Y here.  However, HPET will only be
          activated if the platform and the BIOS support this feature.
index 77d8c51..bb3e376 100644 (file)
@@ -294,6 +294,7 @@ sysenter_past_esp:
        pushl   $__USER_DS              /* pt_regs->ss */
        pushl   %ebp                    /* pt_regs->sp (stashed in bp) */
        pushfl                          /* pt_regs->flags (except IF = 0) */
+       ASM_CLAC                        /* Clear AC after saving FLAGS */
        orl     $X86_EFLAGS_IF, (%esp)  /* Fix IF */
        pushl   $__USER_CS              /* pt_regs->cs */
        pushl   $0                      /* pt_regs->ip = 0 (placeholder) */
index ff1c6d6..3c990ee 100644 (file)
@@ -261,6 +261,7 @@ ENTRY(entry_INT80_compat)
         * Interrupts are off on entry.
         */
        PARAVIRT_ADJUST_EXCEPTION_FRAME
+       ASM_CLAC                        /* Do this early to minimize exposure */
        SWAPGS
 
        /*
index 19c099a..e795f52 100644 (file)
@@ -41,7 +41,7 @@ static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip)
        regs->ip = ip;
 }
 #else
-#error Live patching support is disabled; check CONFIG_LIVEPATCH
+#error Include linux/livepatch.h, not asm/livepatch.h
 #endif
 
 #endif /* _ASM_X86_LIVEPATCH_H */
index 46873fb..d08eacd 100644 (file)
@@ -93,6 +93,8 @@ extern raw_spinlock_t pci_config_lock;
 extern int (*pcibios_enable_irq)(struct pci_dev *dev);
 extern void (*pcibios_disable_irq)(struct pci_dev *dev);
 
+extern bool mp_should_keep_irq(struct device *dev);
+
 struct pci_raw_ops {
        int (*read)(unsigned int domain, unsigned int bus, unsigned int devfn,
                                                int reg, int len, u32 *val);
index 2d5a50c..20c11d1 100644 (file)
@@ -766,7 +766,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
  * Return saved PC of a blocked thread.
  * What is this good for? it will be always the scheduler or ret_from_fork.
  */
-#define thread_saved_pc(t)     (*(unsigned long *)((t)->thread.sp - 8))
+#define thread_saved_pc(t)     READ_ONCE_NOCHECK(*(unsigned long *)((t)->thread.sp - 8))
 
 #define task_pt_regs(tsk)      ((struct pt_regs *)(tsk)->thread.sp0 - 1)
 extern unsigned long KSTK_ESP(struct task_struct *task);
index f5dcb52..3fe0eac 100644 (file)
@@ -48,20 +48,28 @@ __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
 
                switch (n) {
                case 1:
+                       __uaccess_begin();
                        __put_user_size(*(u8 *)from, (u8 __user *)to,
                                        1, ret, 1);
+                       __uaccess_end();
                        return ret;
                case 2:
+                       __uaccess_begin();
                        __put_user_size(*(u16 *)from, (u16 __user *)to,
                                        2, ret, 2);
+                       __uaccess_end();
                        return ret;
                case 4:
+                       __uaccess_begin();
                        __put_user_size(*(u32 *)from, (u32 __user *)to,
                                        4, ret, 4);
+                       __uaccess_end();
                        return ret;
                case 8:
+                       __uaccess_begin();
                        __put_user_size(*(u64 *)from, (u64 __user *)to,
                                        8, ret, 8);
+                       __uaccess_end();
                        return ret;
                }
        }
@@ -103,13 +111,19 @@ __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
 
                switch (n) {
                case 1:
+                       __uaccess_begin();
                        __get_user_size(*(u8 *)to, from, 1, ret, 1);
+                       __uaccess_end();
                        return ret;
                case 2:
+                       __uaccess_begin();
                        __get_user_size(*(u16 *)to, from, 2, ret, 2);
+                       __uaccess_end();
                        return ret;
                case 4:
+                       __uaccess_begin();
                        __get_user_size(*(u32 *)to, from, 4, ret, 4);
+                       __uaccess_end();
                        return ret;
                }
        }
@@ -148,13 +162,19 @@ __copy_from_user(void *to, const void __user *from, unsigned long n)
 
                switch (n) {
                case 1:
+                       __uaccess_begin();
                        __get_user_size(*(u8 *)to, from, 1, ret, 1);
+                       __uaccess_end();
                        return ret;
                case 2:
+                       __uaccess_begin();
                        __get_user_size(*(u16 *)to, from, 2, ret, 2);
+                       __uaccess_end();
                        return ret;
                case 4:
+                       __uaccess_begin();
                        __get_user_size(*(u32 *)to, from, 4, ret, 4);
+                       __uaccess_end();
                        return ret;
                }
        }
@@ -170,13 +190,19 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
 
                switch (n) {
                case 1:
+                       __uaccess_begin();
                        __get_user_size(*(u8 *)to, from, 1, ret, 1);
+                       __uaccess_end();
                        return ret;
                case 2:
+                       __uaccess_begin();
                        __get_user_size(*(u16 *)to, from, 2, ret, 2);
+                       __uaccess_end();
                        return ret;
                case 4:
+                       __uaccess_begin();
                        __get_user_size(*(u32 *)to, from, 4, ret, 4);
+                       __uaccess_end();
                        return ret;
                }
        }
index 968d57d..f320ee3 100644 (file)
@@ -57,7 +57,7 @@ static inline int xen_pci_frontend_enable_msi(struct pci_dev *dev,
 {
        if (xen_pci_frontend && xen_pci_frontend->enable_msi)
                return xen_pci_frontend->enable_msi(dev, vectors);
-       return -ENODEV;
+       return -ENOSYS;
 }
 static inline void xen_pci_frontend_disable_msi(struct pci_dev *dev)
 {
@@ -69,7 +69,7 @@ static inline int xen_pci_frontend_enable_msix(struct pci_dev *dev,
 {
        if (xen_pci_frontend && xen_pci_frontend->enable_msix)
                return xen_pci_frontend->enable_msix(dev, vectors, nvec);
-       return -ENODEV;
+       return -ENOSYS;
 }
 static inline void xen_pci_frontend_disable_msix(struct pci_dev *dev)
 {
index d1daead..adb3eaf 100644 (file)
@@ -16,6 +16,7 @@
 #include <asm/cacheflush.h>
 #include <asm/realmode.h>
 
+#include <linux/ftrace.h>
 #include "../../realmode/rm/wakeup.h"
 #include "sleep.h"
 
@@ -107,7 +108,13 @@ int x86_acpi_suspend_lowlevel(void)
        saved_magic = 0x123456789abcdef0L;
 #endif /* CONFIG_64BIT */
 
+       /*
+        * Pause/unpause graph tracing around do_suspend_lowlevel as it has
+        * inconsistent call/return info after it jumps to the wakeup vector.
+        */
+       pause_graph_tracing();
        do_suspend_lowlevel();
+       unpause_graph_tracing();
        return 0;
 }
 
index 4974274..8836fc9 100644 (file)
@@ -323,6 +323,8 @@ static int amd_uncore_cpu_up_prepare(unsigned int cpu)
        return 0;
 
 fail:
+       if (amd_uncore_nb)
+               *per_cpu_ptr(amd_uncore_nb, cpu) = NULL;
        kfree(uncore_nb);
        return -ENOMEM;
 }
index 1505587..b9b09fe 100644 (file)
@@ -650,10 +650,10 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
        u16 sel;
 
        la = seg_base(ctxt, addr.seg) + addr.ea;
-       *linear = la;
        *max_size = 0;
        switch (mode) {
        case X86EMUL_MODE_PROT64:
+               *linear = la;
                if (is_noncanonical_address(la))
                        goto bad;
 
@@ -662,6 +662,7 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
                        goto bad;
                break;
        default:
+               *linear = la = (u32)la;
                usable = ctxt->ops->get_segment(ctxt, &sel, &desc, NULL,
                                                addr.seg);
                if (!usable)
@@ -689,7 +690,6 @@ static __always_inline int __linearize(struct x86_emulate_ctxt *ctxt,
                        if (size > *max_size)
                                goto bad;
                }
-               la &= (u32)-1;
                break;
        }
        if (insn_aligned(ctxt, size) && ((la & (size - 1)) != 0))
index 95a955d..1e7a49b 100644 (file)
@@ -3721,13 +3721,15 @@ static void reset_rsvds_bits_mask_ept(struct kvm_vcpu *vcpu,
 void
 reset_shadow_zero_bits_mask(struct kvm_vcpu *vcpu, struct kvm_mmu *context)
 {
+       bool uses_nx = context->nx || context->base_role.smep_andnot_wp;
+
        /*
         * Passing "true" to the last argument is okay; it adds a check
         * on bit 8 of the SPTEs which KVM doesn't use anyway.
         */
        __reset_rsvds_bits_mask(vcpu, &context->shadow_zero_check,
                                boot_cpu_data.x86_phys_bits,
-                               context->shadow_root_level, context->nx,
+                               context->shadow_root_level, uses_nx,
                                guest_cpuid_has_gbpages(vcpu), is_pse(vcpu),
                                true);
 }
index 6c9fed9..2ce4f05 100644 (file)
@@ -249,7 +249,7 @@ static int FNAME(update_accessed_dirty_bits)(struct kvm_vcpu *vcpu,
                        return ret;
 
                kvm_vcpu_mark_page_dirty(vcpu, table_gfn);
-               walker->ptes[level] = pte;
+               walker->ptes[level - 1] = pte;
        }
        return 0;
 }
index e2951b6..9bd8f44 100644 (file)
@@ -596,6 +596,8 @@ struct vcpu_vmx {
        /* Support for PML */
 #define PML_ENTITY_NUM         512
        struct page *pml_pg;
+
+       u64 current_tsc_ratio;
 };
 
 enum segment_cache_field {
@@ -1811,6 +1813,13 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
                        return;
                }
                break;
+       case MSR_IA32_PEBS_ENABLE:
+               /* PEBS needs a quiescent period after being disabled (to write
+                * a record).  Disabling PEBS through VMX MSR swapping doesn't
+                * provide that period, so a CPU could write host's record into
+                * guest's memory.
+                */
+               wrmsrl(MSR_IA32_PEBS_ENABLE, 0);
        }
 
        for (i = 0; i < m->nr; ++i)
@@ -1848,26 +1857,31 @@ static void reload_tss(void)
 
 static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset)
 {
-       u64 guest_efer;
-       u64 ignore_bits;
+       u64 guest_efer = vmx->vcpu.arch.efer;
+       u64 ignore_bits = 0;
 
-       guest_efer = vmx->vcpu.arch.efer;
+       if (!enable_ept) {
+               /*
+                * NX is needed to handle CR0.WP=1, CR4.SMEP=1.  Testing
+                * host CPUID is more efficient than testing guest CPUID
+                * or CR4.  Host SMEP is anyway a requirement for guest SMEP.
+                */
+               if (boot_cpu_has(X86_FEATURE_SMEP))
+                       guest_efer |= EFER_NX;
+               else if (!(guest_efer & EFER_NX))
+                       ignore_bits |= EFER_NX;
+       }
 
        /*
-        * NX is emulated; LMA and LME handled by hardware; SCE meaningless
-        * outside long mode
+        * LMA and LME handled by hardware; SCE meaningless outside long mode.
         */
-       ignore_bits = EFER_NX | EFER_SCE;
+       ignore_bits |= EFER_SCE;
 #ifdef CONFIG_X86_64
        ignore_bits |= EFER_LMA | EFER_LME;
        /* SCE is meaningful only in long mode on Intel */
        if (guest_efer & EFER_LMA)
                ignore_bits &= ~(u64)EFER_SCE;
 #endif
-       guest_efer &= ~ignore_bits;
-       guest_efer |= host_efer & ignore_bits;
-       vmx->guest_msrs[efer_offset].data = guest_efer;
-       vmx->guest_msrs[efer_offset].mask = ~ignore_bits;
 
        clear_atomic_switch_msr(vmx, MSR_EFER);
 
@@ -1878,16 +1892,21 @@ static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset)
         */
        if (cpu_has_load_ia32_efer ||
            (enable_ept && ((vmx->vcpu.arch.efer ^ host_efer) & EFER_NX))) {
-               guest_efer = vmx->vcpu.arch.efer;
                if (!(guest_efer & EFER_LMA))
                        guest_efer &= ~EFER_LME;
                if (guest_efer != host_efer)
                        add_atomic_switch_msr(vmx, MSR_EFER,
                                              guest_efer, host_efer);
                return false;
-       }
+       } else {
+               guest_efer &= ~ignore_bits;
+               guest_efer |= host_efer & ignore_bits;
 
-       return true;
+               vmx->guest_msrs[efer_offset].data = guest_efer;
+               vmx->guest_msrs[efer_offset].mask = ~ignore_bits;
+
+               return true;
+       }
 }
 
 static unsigned long segment_base(u16 selector)
@@ -2127,14 +2146,16 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
                rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
                vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
 
-               /* Setup TSC multiplier */
-               if (cpu_has_vmx_tsc_scaling())
-                       vmcs_write64(TSC_MULTIPLIER,
-                                    vcpu->arch.tsc_scaling_ratio);
-
                vmx->loaded_vmcs->cpu = cpu;
        }
 
+       /* Setup TSC multiplier */
+       if (kvm_has_tsc_control &&
+           vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio) {
+               vmx->current_tsc_ratio = vcpu->arch.tsc_scaling_ratio;
+               vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio);
+       }
+
        vmx_vcpu_pi_load(vcpu, cpu);
 }
 
index 4244c2b..eaf6ee8 100644 (file)
@@ -6618,12 +6618,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
         * KVM_DEBUGREG_WONT_EXIT again.
         */
        if (unlikely(vcpu->arch.switch_db_regs & KVM_DEBUGREG_WONT_EXIT)) {
-               int i;
-
                WARN_ON(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP);
                kvm_x86_ops->sync_dirty_debug_regs(vcpu);
-               for (i = 0; i < KVM_NR_DB_REGS; i++)
-                       vcpu->arch.eff_db[i] = vcpu->arch.db[i];
+               kvm_update_dr0123(vcpu);
+               kvm_update_dr6(vcpu);
+               kvm_update_dr7(vcpu);
+               vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_RELOAD;
        }
 
        /*
index 982ce34..27f89c7 100644 (file)
@@ -232,17 +232,31 @@ ENDPROC(copy_user_enhanced_fast_string)
 
 /*
  * copy_user_nocache - Uncached memory copy with exception handling
- * This will force destination/source out of cache for more performance.
+ * This will force destination out of cache for more performance.
+ *
+ * Note: Cached memory copy is used when destination or size is not
+ * naturally aligned. That is:
+ *  - Require 8-byte alignment when size is 8 bytes or larger.
+ *  - Require 4-byte alignment when size is 4 bytes.
  */
 ENTRY(__copy_user_nocache)
        ASM_STAC
+
+       /* If size is less than 8 bytes, go to 4-byte copy */
        cmpl $8,%edx
-       jb 20f          /* less then 8 bytes, go to byte copy loop */
+       jb .L_4b_nocache_copy_entry
+
+       /* If destination is not 8-byte aligned, "cache" copy to align it */
        ALIGN_DESTINATION
+
+       /* Set 4x8-byte copy count and remainder */
        movl %edx,%ecx
        andl $63,%edx
        shrl $6,%ecx
-       jz 17f
+       jz .L_8b_nocache_copy_entry     /* jump if count is 0 */
+
+       /* Perform 4x8-byte nocache loop-copy */
+.L_4x8b_nocache_copy_loop:
 1:     movq (%rsi),%r8
 2:     movq 1*8(%rsi),%r9
 3:     movq 2*8(%rsi),%r10
@@ -262,60 +276,106 @@ ENTRY(__copy_user_nocache)
        leaq 64(%rsi),%rsi
        leaq 64(%rdi),%rdi
        decl %ecx
-       jnz 1b
-17:    movl %edx,%ecx
+       jnz .L_4x8b_nocache_copy_loop
+
+       /* Set 8-byte copy count and remainder */
+.L_8b_nocache_copy_entry:
+       movl %edx,%ecx
        andl $7,%edx
        shrl $3,%ecx
-       jz 20f
-18:    movq (%rsi),%r8
-19:    movnti %r8,(%rdi)
+       jz .L_4b_nocache_copy_entry     /* jump if count is 0 */
+
+       /* Perform 8-byte nocache loop-copy */
+.L_8b_nocache_copy_loop:
+20:    movq (%rsi),%r8
+21:    movnti %r8,(%rdi)
        leaq 8(%rsi),%rsi
        leaq 8(%rdi),%rdi
        decl %ecx
-       jnz 18b
-20:    andl %edx,%edx
-       jz 23f
+       jnz .L_8b_nocache_copy_loop
+
+       /* If no byte left, we're done */
+.L_4b_nocache_copy_entry:
+       andl %edx,%edx
+       jz .L_finish_copy
+
+       /* If destination is not 4-byte aligned, go to byte copy: */
+       movl %edi,%ecx
+       andl $3,%ecx
+       jnz .L_1b_cache_copy_entry
+
+       /* Set 4-byte copy count (1 or 0) and remainder */
        movl %edx,%ecx
-21:    movb (%rsi),%al
-22:    movb %al,(%rdi)
+       andl $3,%edx
+       shrl $2,%ecx
+       jz .L_1b_cache_copy_entry       /* jump if count is 0 */
+
+       /* Perform 4-byte nocache copy: */
+30:    movl (%rsi),%r8d
+31:    movnti %r8d,(%rdi)
+       leaq 4(%rsi),%rsi
+       leaq 4(%rdi),%rdi
+
+       /* If no bytes left, we're done: */
+       andl %edx,%edx
+       jz .L_finish_copy
+
+       /* Perform byte "cache" loop-copy for the remainder */
+.L_1b_cache_copy_entry:
+       movl %edx,%ecx
+.L_1b_cache_copy_loop:
+40:    movb (%rsi),%al
+41:    movb %al,(%rdi)
        incq %rsi
        incq %rdi
        decl %ecx
-       jnz 21b
-23:    xorl %eax,%eax
+       jnz .L_1b_cache_copy_loop
+
+       /* Finished copying; fence the prior stores */
+.L_finish_copy:
+       xorl %eax,%eax
        ASM_CLAC
        sfence
        ret
 
        .section .fixup,"ax"
-30:    shll $6,%ecx
+.L_fixup_4x8b_copy:
+       shll $6,%ecx
        addl %ecx,%edx
-       jmp 60f
-40:    lea (%rdx,%rcx,8),%rdx
-       jmp 60f
-50:    movl %ecx,%edx
-60:    sfence
+       jmp .L_fixup_handle_tail
+.L_fixup_8b_copy:
+       lea (%rdx,%rcx,8),%rdx
+       jmp .L_fixup_handle_tail
+.L_fixup_4b_copy:
+       lea (%rdx,%rcx,4),%rdx
+       jmp .L_fixup_handle_tail
+.L_fixup_1b_copy:
+       movl %ecx,%edx
+.L_fixup_handle_tail:
+       sfence
        jmp copy_user_handle_tail
        .previous
 
-       _ASM_EXTABLE(1b,30b)
-       _ASM_EXTABLE(2b,30b)
-       _ASM_EXTABLE(3b,30b)
-       _ASM_EXTABLE(4b,30b)
-       _ASM_EXTABLE(5b,30b)
-       _ASM_EXTABLE(6b,30b)
-       _ASM_EXTABLE(7b,30b)
-       _ASM_EXTABLE(8b,30b)
-       _ASM_EXTABLE(9b,30b)
-       _ASM_EXTABLE(10b,30b)
-       _ASM_EXTABLE(11b,30b)
-       _ASM_EXTABLE(12b,30b)
-       _ASM_EXTABLE(13b,30b)
-       _ASM_EXTABLE(14b,30b)
-       _ASM_EXTABLE(15b,30b)
-       _ASM_EXTABLE(16b,30b)
-       _ASM_EXTABLE(18b,40b)
-       _ASM_EXTABLE(19b,40b)
-       _ASM_EXTABLE(21b,50b)
-       _ASM_EXTABLE(22b,50b)
+       _ASM_EXTABLE(1b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(2b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(3b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(4b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(5b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(6b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(7b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(8b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(9b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(10b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(11b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(12b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(13b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(14b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(15b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(16b,.L_fixup_4x8b_copy)
+       _ASM_EXTABLE(20b,.L_fixup_8b_copy)
+       _ASM_EXTABLE(21b,.L_fixup_8b_copy)
+       _ASM_EXTABLE(30b,.L_fixup_4b_copy)
+       _ASM_EXTABLE(31b,.L_fixup_4b_copy)
+       _ASM_EXTABLE(40b,.L_fixup_1b_copy)
+       _ASM_EXTABLE(41b,.L_fixup_1b_copy)
 ENDPROC(__copy_user_nocache)
index eef44d9..e830c71 100644 (file)
@@ -287,6 +287,9 @@ static noinline int vmalloc_fault(unsigned long address)
        if (!pmd_k)
                return -1;
 
+       if (pmd_huge(*pmd_k))
+               return 0;
+
        pte_k = pte_offset_kernel(pmd_k, address);
        if (!pte_present(*pte_k))
                return -1;
@@ -360,8 +363,6 @@ void vmalloc_sync_all(void)
  * 64-bit:
  *
  *   Handle a fault on the vmalloc area
- *
- * This assumes no large pages in there.
  */
 static noinline int vmalloc_fault(unsigned long address)
 {
@@ -403,17 +404,23 @@ static noinline int vmalloc_fault(unsigned long address)
        if (pud_none(*pud_ref))
                return -1;
 
-       if (pud_none(*pud) || pud_page_vaddr(*pud) != pud_page_vaddr(*pud_ref))
+       if (pud_none(*pud) || pud_pfn(*pud) != pud_pfn(*pud_ref))
                BUG();
 
+       if (pud_huge(*pud))
+               return 0;
+
        pmd = pmd_offset(pud, address);
        pmd_ref = pmd_offset(pud_ref, address);
        if (pmd_none(*pmd_ref))
                return -1;
 
-       if (pmd_none(*pmd) || pmd_page(*pmd) != pmd_page(*pmd_ref))
+       if (pmd_none(*pmd) || pmd_pfn(*pmd) != pmd_pfn(*pmd_ref))
                BUG();
 
+       if (pmd_huge(*pmd))
+               return 0;
+
        pte_ref = pte_offset_kernel(pmd_ref, address);
        if (!pte_present(*pte_ref))
                return -1;
index 6d5eb59..d8a798d 100644 (file)
@@ -102,7 +102,6 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
                        return 0;
                }
 
-               page = pte_page(pte);
                if (pte_devmap(pte)) {
                        pgmap = get_dev_pagemap(pte_pfn(pte), pgmap);
                        if (unlikely(!pgmap)) {
@@ -115,6 +114,7 @@ static noinline int gup_pte_range(pmd_t pmd, unsigned long addr,
                        return 0;
                }
                VM_BUG_ON(!pfn_valid(pte_pfn(pte)));
+               page = pte_page(pte);
                get_page(page);
                put_dev_pagemap(pgmap);
                SetPageReferenced(page);
index 96bd1e2..72bb52f 100644 (file)
@@ -71,12 +71,12 @@ unsigned long arch_mmap_rnd(void)
 
        if (mmap_is_ia32())
 #ifdef CONFIG_COMPAT
-               rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_compat_bits) - 1);
+               rnd = get_random_long() & ((1UL << mmap_rnd_compat_bits) - 1);
 #else
-               rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1);
+               rnd = get_random_long() & ((1UL << mmap_rnd_bits) - 1);
 #endif
        else
-               rnd = (unsigned long)get_random_int() & ((1 << mmap_rnd_bits) - 1);
+               rnd = get_random_long() & ((1UL << mmap_rnd_bits) - 1);
 
        return rnd << PAGE_SHIFT;
 }
index b2fd67d..ef05755 100644 (file)
@@ -123,7 +123,7 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
                break;
        }
 
-       if (regno > nr_registers) {
+       if (regno >= nr_registers) {
                WARN_ONCE(1, "decoded an instruction with an invalid register");
                return -EINVAL;
        }
index c3b3f65..d04f809 100644 (file)
@@ -469,7 +469,7 @@ static void __init numa_clear_kernel_node_hotplug(void)
 {
        int i, nid;
        nodemask_t numa_kernel_nodes = NODE_MASK_NONE;
-       unsigned long start, end;
+       phys_addr_t start, end;
        struct memblock_region *r;
 
        /*
index 2440814..9cf96d8 100644 (file)
@@ -419,24 +419,30 @@ pmd_t *lookup_pmd_address(unsigned long address)
 phys_addr_t slow_virt_to_phys(void *__virt_addr)
 {
        unsigned long virt_addr = (unsigned long)__virt_addr;
-       unsigned long phys_addr, offset;
+       phys_addr_t phys_addr;
+       unsigned long offset;
        enum pg_level level;
        pte_t *pte;
 
        pte = lookup_address(virt_addr, &level);
        BUG_ON(!pte);
 
+       /*
+        * pXX_pfn() returns unsigned long, which must be cast to phys_addr_t
+        * before being left-shifted PAGE_SHIFT bits -- this trick is to
+        * make 32-PAE kernel work correctly.
+        */
        switch (level) {
        case PG_LEVEL_1G:
-               phys_addr = pud_pfn(*(pud_t *)pte) << PAGE_SHIFT;
+               phys_addr = (phys_addr_t)pud_pfn(*(pud_t *)pte) << PAGE_SHIFT;
                offset = virt_addr & ~PUD_PAGE_MASK;
                break;
        case PG_LEVEL_2M:
-               phys_addr = pmd_pfn(*(pmd_t *)pte) << PAGE_SHIFT;
+               phys_addr = (phys_addr_t)pmd_pfn(*(pmd_t *)pte) << PAGE_SHIFT;
                offset = virt_addr & ~PMD_PAGE_MASK;
                break;
        default:
-               phys_addr = pte_pfn(*pte) << PAGE_SHIFT;
+               phys_addr = (phys_addr_t)pte_pfn(*pte) << PAGE_SHIFT;
                offset = virt_addr & ~PAGE_MASK;
        }
 
index 2879efc..d34b511 100644 (file)
@@ -711,28 +711,22 @@ int pcibios_add_device(struct pci_dev *dev)
        return 0;
 }
 
-int pcibios_alloc_irq(struct pci_dev *dev)
+int pcibios_enable_device(struct pci_dev *dev, int mask)
 {
-       /*
-        * If the PCI device was already claimed by core code and has
-        * MSI enabled, probing of the pcibios IRQ will overwrite
-        * dev->irq.  So bail out if MSI is already enabled.
-        */
-       if (pci_dev_msi_enabled(dev))
-               return -EBUSY;
+       int err;
 
-       return pcibios_enable_irq(dev);
-}
+       if ((err = pci_enable_resources(dev, mask)) < 0)
+               return err;
 
-void pcibios_free_irq(struct pci_dev *dev)
-{
-       if (pcibios_disable_irq)
-               pcibios_disable_irq(dev);
+       if (!pci_dev_msi_enabled(dev))
+               return pcibios_enable_irq(dev);
+       return 0;
 }
 
-int pcibios_enable_device(struct pci_dev *dev, int mask)
+void pcibios_disable_device (struct pci_dev *dev)
 {
-       return pci_enable_resources(dev, mask);
+       if (!pci_dev_msi_enabled(dev) && pcibios_disable_irq)
+               pcibios_disable_irq(dev);
 }
 
 int pci_ext_cfg_avail(void)
index 0d24e7c..8b93e63 100644 (file)
@@ -215,7 +215,7 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
        int polarity;
        int ret;
 
-       if (pci_has_managed_irq(dev))
+       if (dev->irq_managed && dev->irq > 0)
                return 0;
 
        switch (intel_mid_identify_cpu()) {
@@ -256,13 +256,10 @@ static int intel_mid_pci_irq_enable(struct pci_dev *dev)
 
 static void intel_mid_pci_irq_disable(struct pci_dev *dev)
 {
-       if (pci_has_managed_irq(dev)) {
+       if (!mp_should_keep_irq(&dev->dev) && dev->irq_managed &&
+           dev->irq > 0) {
                mp_unmap_irq(dev->irq);
                dev->irq_managed = 0;
-               /*
-                * Don't reset dev->irq here, otherwise
-                * intel_mid_pci_irq_enable() will fail on next call.
-                */
        }
 }
 
index 32e7034..9bd1154 100644 (file)
@@ -1202,7 +1202,7 @@ static int pirq_enable_irq(struct pci_dev *dev)
                        struct pci_dev *temp_dev;
                        int irq;
 
-                       if (pci_has_managed_irq(dev))
+                       if (dev->irq_managed && dev->irq > 0)
                                return 0;
 
                        irq = IO_APIC_get_PCI_irq_vector(dev->bus->number,
@@ -1230,7 +1230,8 @@ static int pirq_enable_irq(struct pci_dev *dev)
                        }
                        dev = temp_dev;
                        if (irq >= 0) {
-                               pci_set_managed_irq(dev, irq);
+                               dev->irq_managed = 1;
+                               dev->irq = irq;
                                dev_info(&dev->dev, "PCI->APIC IRQ transform: "
                                         "INT %c -> IRQ %d\n", 'A' + pin - 1, irq);
                                return 0;
@@ -1256,10 +1257,24 @@ static int pirq_enable_irq(struct pci_dev *dev)
        return 0;
 }
 
+bool mp_should_keep_irq(struct device *dev)
+{
+       if (dev->power.is_prepared)
+               return true;
+#ifdef CONFIG_PM
+       if (dev->power.runtime_status == RPM_SUSPENDING)
+               return true;
+#endif
+
+       return false;
+}
+
 static void pirq_disable_irq(struct pci_dev *dev)
 {
-       if (io_apic_assign_pci_irqs && pci_has_managed_irq(dev)) {
+       if (io_apic_assign_pci_irqs && !mp_should_keep_irq(&dev->dev) &&
+           dev->irq_managed && dev->irq) {
                mp_unmap_irq(dev->irq);
-               pci_reset_managed_irq(dev);
+               dev->irq = 0;
+               dev->irq_managed = 0;
        }
 }
index ff31ab4..beac4df 100644 (file)
@@ -196,7 +196,10 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
        return 0;
 
 error:
-       dev_err(&dev->dev, "Xen PCI frontend has not registered MSI/MSI-X support!\n");
+       if (ret == -ENOSYS)
+               dev_err(&dev->dev, "Xen PCI frontend has not registered MSI/MSI-X support!\n");
+       else if (ret)
+               dev_err(&dev->dev, "Xen PCI frontend error: %d!\n", ret);
 free:
        kfree(v);
        return ret;
index c61b6c3..bfadcd0 100644 (file)
@@ -592,14 +592,14 @@ static void __init imr_fixup_memmap(struct imr_device *idev)
        end = (unsigned long)__end_rodata - 1;
 
        /*
-        * Setup a locked IMR around the physical extent of the kernel
+        * Setup an unlocked IMR around the physical extent of the kernel
         * from the beginning of the .text secton to the end of the
         * .rodata section as one physically contiguous block.
         *
         * We don't round up @size since it is already PAGE_SIZE aligned.
         * See vmlinux.lds.S for details.
         */
-       ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, true);
+       ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, false);
        if (ret < 0) {
                pr_err("unable to setup IMR for kernel: %zu KiB (%lx - %lx)\n",
                        size / 1024, start, end);
index 8502ad3..5adb6a2 100644 (file)
@@ -109,7 +109,7 @@ unsigned long os_get_top_address(void)
                exit(1);
        }
 
-       printf("0x%x\n", bottom << UM_KERN_PAGE_SHIFT);
+       printf("0x%lx\n", bottom << UM_KERN_PAGE_SHIFT);
        printf("Locating the top of the address space ... ");
        fflush(stdout);
 
@@ -134,7 +134,7 @@ out:
                exit(1);
        }
        top <<= UM_KERN_PAGE_SHIFT;
-       printf("0x%x\n", top);
+       printf("0x%lx\n", top);
 
        return top;
 }
index 161491d..0363cd7 100644 (file)
@@ -88,6 +88,19 @@ config BLK_DEV_INTEGRITY
        T10/SCSI Data Integrity Field or the T13/ATA External Path
        Protection.  If in doubt, say N.
 
+config BLK_DEV_DAX
+       bool "Block device DAX support"
+       depends on FS_DAX
+       depends on BROKEN
+       help
+         When DAX support is available (CONFIG_FS_DAX) raw block
+         devices can also support direct userspace access to the
+         storage capacity via MMAP(2) similar to a file on a
+         DAX-enabled filesystem.  However, the DAX I/O-path disables
+         some standard I/O-statistics, and the MMAP(2) path has some
+         operational differences due to bypassing the page
+         cache.  If in doubt, say N.
+
 config BLK_DEV_THROTTLING
        bool "Block layer bio throttling support"
        depends on BLK_CGROUP=y
index dbabd48..cf75915 100644 (file)
@@ -874,7 +874,7 @@ int submit_bio_wait(int rw, struct bio *bio)
        bio->bi_private = &ret;
        bio->bi_end_io = submit_bio_wait_endio;
        submit_bio(rw, bio);
-       wait_for_completion(&ret.event);
+       wait_for_completion_io(&ret.event);
 
        return ret.error;
 }
@@ -1090,9 +1090,12 @@ int bio_uncopy_user(struct bio *bio)
        if (!bio_flagged(bio, BIO_NULL_MAPPED)) {
                /*
                 * if we're in a workqueue, the request is orphaned, so
-                * don't copy into a random user address space, just free.
+                * don't copy into a random user address space, just free
+                * and return -EINTR so user space doesn't expect any data.
                 */
-               if (current->mm && bio_data_dir(bio) == READ)
+               if (!current->mm)
+                       ret = -EINTR;
+               else if (bio_data_dir(bio) == READ)
                        ret = bio_copy_to_iter(bio, bmd->iter);
                if (bmd->is_our_pages)
                        bio_free_pages(bio);
index 5a37188..66e6f1a 100644 (file)
@@ -788,6 +788,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 {
        struct gendisk *disk;
        struct blkcg_gq *blkg;
+       struct module *owner;
        unsigned int major, minor;
        int key_len, part, ret;
        char *body;
@@ -804,7 +805,9 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
        if (!disk)
                return -ENODEV;
        if (part) {
+               owner = disk->fops->owner;
                put_disk(disk);
+               module_put(owner);
                return -ENODEV;
        }
 
@@ -820,7 +823,9 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
                ret = PTR_ERR(blkg);
                rcu_read_unlock();
                spin_unlock_irq(disk->queue->queue_lock);
+               owner = disk->fops->owner;
                put_disk(disk);
+               module_put(owner);
                /*
                 * If queue was bypassing, we should retry.  Do so after a
                 * short msleep().  It isn't strictly necessary but queue
@@ -851,9 +856,13 @@ EXPORT_SYMBOL_GPL(blkg_conf_prep);
 void blkg_conf_finish(struct blkg_conf_ctx *ctx)
        __releases(ctx->disk->queue->queue_lock) __releases(rcu)
 {
+       struct module *owner;
+
        spin_unlock_irq(ctx->disk->queue->queue_lock);
        rcu_read_unlock();
+       owner = ctx->disk->fops->owner;
        put_disk(ctx->disk);
+       module_put(owner);
 }
 EXPORT_SYMBOL_GPL(blkg_conf_finish);
 
index ab51685..b83d297 100644 (file)
@@ -2455,14 +2455,16 @@ struct request *blk_peek_request(struct request_queue *q)
 
                        rq = NULL;
                        break;
-               } else if (ret == BLKPREP_KILL) {
+               } else if (ret == BLKPREP_KILL || ret == BLKPREP_INVALID) {
+                       int err = (ret == BLKPREP_INVALID) ? -EREMOTEIO : -EIO;
+
                        rq->cmd_flags |= REQ_QUIET;
                        /*
                         * Mark this request as started so we don't trigger
                         * any debug logic in the end I/O path.
                         */
                        blk_start_request(rq);
-                       __blk_end_request_all(rq, -EIO);
+                       __blk_end_request_all(rq, err);
                } else {
                        printk(KERN_ERR "%s: bad return=%d\n", __func__, ret);
                        break;
index f565e11..a54f054 100644 (file)
@@ -57,6 +57,49 @@ static int __blk_rq_unmap_user(struct bio *bio)
        return ret;
 }
 
+static int __blk_rq_map_user_iov(struct request *rq,
+               struct rq_map_data *map_data, struct iov_iter *iter,
+               gfp_t gfp_mask, bool copy)
+{
+       struct request_queue *q = rq->q;
+       struct bio *bio, *orig_bio;
+       int ret;
+
+       if (copy)
+               bio = bio_copy_user_iov(q, map_data, iter, gfp_mask);
+       else
+               bio = bio_map_user_iov(q, iter, gfp_mask);
+
+       if (IS_ERR(bio))
+               return PTR_ERR(bio);
+
+       if (map_data && map_data->null_mapped)
+               bio_set_flag(bio, BIO_NULL_MAPPED);
+
+       iov_iter_advance(iter, bio->bi_iter.bi_size);
+       if (map_data)
+               map_data->offset += bio->bi_iter.bi_size;
+
+       orig_bio = bio;
+       blk_queue_bounce(q, &bio);
+
+       /*
+        * We link the bounce buffer in and could have to traverse it
+        * later so we have to get a ref to prevent it from being freed
+        */
+       bio_get(bio);
+
+       ret = blk_rq_append_bio(q, rq, bio);
+       if (ret) {
+               bio_endio(bio);
+               __blk_rq_unmap_user(orig_bio);
+               bio_put(bio);
+               return ret;
+       }
+
+       return 0;
+}
+
 /**
  * blk_rq_map_user_iov - map user data to a request, for REQ_TYPE_BLOCK_PC usage
  * @q:         request queue where request should be inserted
@@ -82,10 +125,11 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
                        struct rq_map_data *map_data,
                        const struct iov_iter *iter, gfp_t gfp_mask)
 {
-       struct bio *bio;
-       int unaligned = 0;
-       struct iov_iter i;
        struct iovec iov, prv = {.iov_base = NULL, .iov_len = 0};
+       bool copy = (q->dma_pad_mask & iter->count) || map_data;
+       struct bio *bio = NULL;
+       struct iov_iter i;
+       int ret;
 
        if (!iter || !iter->count)
                return -EINVAL;
@@ -101,42 +145,29 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
                 */
                if ((uaddr & queue_dma_alignment(q)) ||
                    iovec_gap_to_prv(q, &prv, &iov))
-                       unaligned = 1;
+                       copy = true;
 
                prv.iov_base = iov.iov_base;
                prv.iov_len = iov.iov_len;
        }
 
-       if (unaligned || (q->dma_pad_mask & iter->count) || map_data)
-               bio = bio_copy_user_iov(q, map_data, iter, gfp_mask);
-       else
-               bio = bio_map_user_iov(q, iter, gfp_mask);
-
-       if (IS_ERR(bio))
-               return PTR_ERR(bio);
-
-       if (map_data && map_data->null_mapped)
-               bio_set_flag(bio, BIO_NULL_MAPPED);
-
-       if (bio->bi_iter.bi_size != iter->count) {
-               /*
-                * Grab an extra reference to this bio, as bio_unmap_user()
-                * expects to be able to drop it twice as it happens on the
-                * normal IO completion path
-                */
-               bio_get(bio);
-               bio_endio(bio);
-               __blk_rq_unmap_user(bio);
-               return -EINVAL;
-       }
+       i = *iter;
+       do {
+               ret =__blk_rq_map_user_iov(rq, map_data, &i, gfp_mask, copy);
+               if (ret)
+                       goto unmap_rq;
+               if (!bio)
+                       bio = rq->bio;
+       } while (iov_iter_count(&i));
 
        if (!bio_flagged(bio, BIO_USER_MAPPED))
                rq->cmd_flags |= REQ_COPY_USER;
-
-       blk_queue_bounce(q, &bio);
-       bio_get(bio);
-       blk_rq_bio_prep(q, rq, bio);
        return 0;
+
+unmap_rq:
+       __blk_rq_unmap_user(bio);
+       rq->bio = NULL;
+       return -EINVAL;
 }
 EXPORT_SYMBOL(blk_rq_map_user_iov);
 
index 888a7fe..2613531 100644 (file)
@@ -304,7 +304,6 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
                                   struct bio *nxt)
 {
        struct bio_vec end_bv = { NULL }, nxt_bv;
-       struct bvec_iter iter;
 
        if (!blk_queue_cluster(q))
                return 0;
@@ -316,11 +315,8 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
        if (!bio_has_data(bio))
                return 1;
 
-       bio_for_each_segment(end_bv, bio, iter)
-               if (end_bv.bv_len == iter.bi_size)
-                       break;
-
-       nxt_bv = bio_iovec(nxt);
+       bio_get_last_bvec(bio, &end_bv);
+       bio_get_first_bvec(nxt, &nxt_bv);
 
        if (!BIOVEC_PHYS_MERGEABLE(&end_bv, &nxt_bv))
                return 0;
index 4c0622f..56c0a72 100644 (file)
@@ -599,8 +599,10 @@ static void blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,
                 * If a request wasn't started before the queue was
                 * marked dying, kill it here or it'll go unnoticed.
                 */
-               if (unlikely(blk_queue_dying(rq->q)))
-                       blk_mq_complete_request(rq, -EIO);
+               if (unlikely(blk_queue_dying(rq->q))) {
+                       rq->errors = -EIO;
+                       blk_mq_end_request(rq, rq->errors);
+               }
                return;
        }
 
index dd49735..c7bb666 100644 (file)
@@ -91,8 +91,8 @@ void blk_set_default_limits(struct queue_limits *lim)
        lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
        lim->virt_boundary_mask = 0;
        lim->max_segment_size = BLK_MAX_SEGMENT_SIZE;
-       lim->max_sectors = lim->max_dev_sectors = lim->max_hw_sectors =
-               BLK_SAFE_MAX_SECTORS;
+       lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
+       lim->max_dev_sectors = 0;
        lim->chunk_sectors = 0;
        lim->max_write_same_sectors = 0;
        lim->max_discard_sectors = 0;
index e140cc4..dd93763 100644 (file)
@@ -147,10 +147,9 @@ static ssize_t queue_discard_granularity_show(struct request_queue *q, char *pag
 
 static ssize_t queue_discard_max_hw_show(struct request_queue *q, char *page)
 {
-       unsigned long long val;
 
-       val = q->limits.max_hw_discard_sectors << 9;
-       return sprintf(page, "%llu\n", val);
+       return sprintf(page, "%llu\n",
+               (unsigned long long)q->limits.max_hw_discard_sectors << 9);
 }
 
 static ssize_t queue_discard_max_show(struct request_queue *q, char *page)
index a753df2..d0dd788 100644 (file)
@@ -39,7 +39,6 @@ struct deadline_data {
         */
        struct request *next_rq[2];
        unsigned int batching;          /* number of sequential requests made */
-       sector_t last_sector;           /* head position */
        unsigned int starved;           /* times reads have starved writes */
 
        /*
@@ -210,8 +209,6 @@ deadline_move_request(struct deadline_data *dd, struct request *rq)
        dd->next_rq[WRITE] = NULL;
        dd->next_rq[data_dir] = deadline_latter_request(rq);
 
-       dd->last_sector = rq_end_sector(rq);
-
        /*
         * take it off the sort and fifo list, move
         * to dispatch queue
index 38c1aa8..28556fc 100644 (file)
@@ -65,18 +65,10 @@ struct skcipher_async_req {
        struct skcipher_async_rsgl first_sgl;
        struct list_head list;
        struct scatterlist *tsg;
-       char iv[];
+       atomic_t *inflight;
+       struct skcipher_request req;
 };
 
-#define GET_SREQ(areq, ctx) (struct skcipher_async_req *)((char *)areq + \
-       crypto_skcipher_reqsize(crypto_skcipher_reqtfm(&ctx->req)))
-
-#define GET_REQ_SIZE(ctx) \
-       crypto_skcipher_reqsize(crypto_skcipher_reqtfm(&ctx->req))
-
-#define GET_IV_SIZE(ctx) \
-       crypto_skcipher_ivsize(crypto_skcipher_reqtfm(&ctx->req))
-
 #define MAX_SGL_ENTS ((4096 - sizeof(struct skcipher_sg_list)) / \
                      sizeof(struct scatterlist) - 1)
 
@@ -102,15 +94,12 @@ static void skcipher_free_async_sgls(struct skcipher_async_req *sreq)
 
 static void skcipher_async_cb(struct crypto_async_request *req, int err)
 {
-       struct sock *sk = req->data;
-       struct alg_sock *ask = alg_sk(sk);
-       struct skcipher_ctx *ctx = ask->private;
-       struct skcipher_async_req *sreq = GET_SREQ(req, ctx);
+       struct skcipher_async_req *sreq = req->data;
        struct kiocb *iocb = sreq->iocb;
 
-       atomic_dec(&ctx->inflight);
+       atomic_dec(sreq->inflight);
        skcipher_free_async_sgls(sreq);
-       kfree(req);
+       kzfree(sreq);
        iocb->ki_complete(iocb, err, err);
 }
 
@@ -306,8 +295,11 @@ static int skcipher_sendmsg(struct socket *sock, struct msghdr *msg,
 {
        struct sock *sk = sock->sk;
        struct alg_sock *ask = alg_sk(sk);
+       struct sock *psk = ask->parent;
+       struct alg_sock *pask = alg_sk(psk);
        struct skcipher_ctx *ctx = ask->private;
-       struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(&ctx->req);
+       struct skcipher_tfm *skc = pask->private;
+       struct crypto_skcipher *tfm = skc->skcipher;
        unsigned ivsize = crypto_skcipher_ivsize(tfm);
        struct skcipher_sg_list *sgl;
        struct af_alg_control con = {};
@@ -509,37 +501,43 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg,
 {
        struct sock *sk = sock->sk;
        struct alg_sock *ask = alg_sk(sk);
+       struct sock *psk = ask->parent;
+       struct alg_sock *pask = alg_sk(psk);
        struct skcipher_ctx *ctx = ask->private;
+       struct skcipher_tfm *skc = pask->private;
+       struct crypto_skcipher *tfm = skc->skcipher;
        struct skcipher_sg_list *sgl;
        struct scatterlist *sg;
        struct skcipher_async_req *sreq;
        struct skcipher_request *req;
        struct skcipher_async_rsgl *last_rsgl = NULL;
-       unsigned int txbufs = 0, len = 0, tx_nents = skcipher_all_sg_nents(ctx);
-       unsigned int reqlen = sizeof(struct skcipher_async_req) +
-                               GET_REQ_SIZE(ctx) + GET_IV_SIZE(ctx);
+       unsigned int txbufs = 0, len = 0, tx_nents;
+       unsigned int reqsize = crypto_skcipher_reqsize(tfm);
+       unsigned int ivsize = crypto_skcipher_ivsize(tfm);
        int err = -ENOMEM;
        bool mark = false;
+       char *iv;
 
-       lock_sock(sk);
-       req = kmalloc(reqlen, GFP_KERNEL);
-       if (unlikely(!req))
-               goto unlock;
+       sreq = kzalloc(sizeof(*sreq) + reqsize + ivsize, GFP_KERNEL);
+       if (unlikely(!sreq))
+               goto out;
 
-       sreq = GET_SREQ(req, ctx);
+       req = &sreq->req;
+       iv = (char *)(req + 1) + reqsize;
        sreq->iocb = msg->msg_iocb;
-       memset(&sreq->first_sgl, '\0', sizeof(struct skcipher_async_rsgl));
        INIT_LIST_HEAD(&sreq->list);
+       sreq->inflight = &ctx->inflight;
+
+       lock_sock(sk);
+       tx_nents = skcipher_all_sg_nents(ctx);
        sreq->tsg = kcalloc(tx_nents, sizeof(*sg), GFP_KERNEL);
-       if (unlikely(!sreq->tsg)) {
-               kfree(req);
+       if (unlikely(!sreq->tsg))
                goto unlock;
-       }
        sg_init_table(sreq->tsg, tx_nents);
-       memcpy(sreq->iv, ctx->iv, GET_IV_SIZE(ctx));
-       skcipher_request_set_tfm(req, crypto_skcipher_reqtfm(&ctx->req));
-       skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
-                                     skcipher_async_cb, sk);
+       memcpy(iv, ctx->iv, ivsize);
+       skcipher_request_set_tfm(req, tfm);
+       skcipher_request_set_callback(req, CRYPTO_TFM_REQ_MAY_SLEEP,
+                                     skcipher_async_cb, sreq);
 
        while (iov_iter_count(&msg->msg_iter)) {
                struct skcipher_async_rsgl *rsgl;
@@ -615,20 +613,22 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg,
                sg_mark_end(sreq->tsg + txbufs - 1);
 
        skcipher_request_set_crypt(req, sreq->tsg, sreq->first_sgl.sgl.sg,
-                                  len, sreq->iv);
+                                  len, iv);
        err = ctx->enc ? crypto_skcipher_encrypt(req) :
                         crypto_skcipher_decrypt(req);
        if (err == -EINPROGRESS) {
                atomic_inc(&ctx->inflight);
                err = -EIOCBQUEUED;
+               sreq = NULL;
                goto unlock;
        }
 free:
        skcipher_free_async_sgls(sreq);
-       kfree(req);
 unlock:
        skcipher_wmem_wakeup(sk);
        release_sock(sk);
+       kzfree(sreq);
+out:
        return err;
 }
 
@@ -637,9 +637,12 @@ static int skcipher_recvmsg_sync(struct socket *sock, struct msghdr *msg,
 {
        struct sock *sk = sock->sk;
        struct alg_sock *ask = alg_sk(sk);
+       struct sock *psk = ask->parent;
+       struct alg_sock *pask = alg_sk(psk);
        struct skcipher_ctx *ctx = ask->private;
-       unsigned bs = crypto_skcipher_blocksize(crypto_skcipher_reqtfm(
-               &ctx->req));
+       struct skcipher_tfm *skc = pask->private;
+       struct crypto_skcipher *tfm = skc->skcipher;
+       unsigned bs = crypto_skcipher_blocksize(tfm);
        struct skcipher_sg_list *sgl;
        struct scatterlist *sg;
        int err = -EAGAIN;
@@ -947,7 +950,8 @@ static int skcipher_accept_parent_nokey(void *private, struct sock *sk)
        ask->private = ctx;
 
        skcipher_request_set_tfm(&ctx->req, skcipher);
-       skcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_BACKLOG,
+       skcipher_request_set_callback(&ctx->req, CRYPTO_TFM_REQ_MAY_SLEEP |
+                                                CRYPTO_TFM_REQ_MAY_BACKLOG,
                                      af_alg_complete, &ctx->completion);
 
        sk->sk_destruct = skcipher_sock_destruct;
index 237f379..43fe85f 100644 (file)
@@ -499,6 +499,7 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
                if (link->dump == NULL)
                        return -EINVAL;
 
+               down_read(&crypto_alg_sem);
                list_for_each_entry(alg, &crypto_alg_list, cra_list)
                        dump_alloc += CRYPTO_REPORT_MAXSIZE;
 
@@ -508,8 +509,11 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
                                .done = link->done,
                                .min_dump_alloc = dump_alloc,
                        };
-                       return netlink_dump_start(crypto_nlsk, skb, nlh, &c);
+                       err = netlink_dump_start(crypto_nlsk, skb, nlh, &c);
                }
+               up_read(&crypto_alg_sem);
+
+               return err;
        }
 
        err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX,
index 3052185..d48cbed 100644 (file)
@@ -269,8 +269,7 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
         */
        if (ACPI_SUCCESS(status) &&
            possible_method_call && (node->type == ACPI_TYPE_METHOD)) {
-               if (GET_CURRENT_ARG_TYPE(walk_state->arg_types) ==
-                   ARGP_SUPERNAME) {
+               if (walk_state->opcode == AML_UNLOAD_OP) {
                        /*
                         * acpi_ps_get_next_namestring has increased the AML pointer,
                         * so we need to restore the saved AML pointer for method call.
@@ -697,7 +696,7 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
  *
  * PARAMETERS:  walk_state          - Current state
  *              parser_state        - Current parser state object
- *              arg_type            - The parser argument type (ARGP_*)
+ *              arg_type            - The argument type (AML_*_ARG)
  *              return_arg          - Where the next arg is returned
  *
  * RETURN:      Status, and an op object containing the next argument.
@@ -817,9 +816,9 @@ acpi_ps_get_next_arg(struct acpi_walk_state *walk_state,
                                return_ACPI_STATUS(AE_NO_MEMORY);
                        }
 
-                       /* super_name allows argument to be a method call */
+                       /* To support super_name arg of Unload */
 
-                       if (arg_type == ARGP_SUPERNAME) {
+                       if (walk_state->opcode == AML_UNLOAD_OP) {
                                status =
                                    acpi_ps_get_next_namepath(walk_state,
                                                              parser_state, arg,
index ad6d8c6..35947ac 100644 (file)
@@ -469,37 +469,16 @@ static void nfit_mem_find_spa_bdw(struct acpi_nfit_desc *acpi_desc,
        nfit_mem->bdw = NULL;
 }
 
-static int nfit_mem_add(struct acpi_nfit_desc *acpi_desc,
+static void nfit_mem_init_bdw(struct acpi_nfit_desc *acpi_desc,
                struct nfit_mem *nfit_mem, struct acpi_nfit_system_address *spa)
 {
        u16 dcr = __to_nfit_memdev(nfit_mem)->region_index;
        struct nfit_memdev *nfit_memdev;
        struct nfit_flush *nfit_flush;
-       struct nfit_dcr *nfit_dcr;
        struct nfit_bdw *nfit_bdw;
        struct nfit_idt *nfit_idt;
        u16 idt_idx, range_index;
 
-       list_for_each_entry(nfit_dcr, &acpi_desc->dcrs, list) {
-               if (nfit_dcr->dcr->region_index != dcr)
-                       continue;
-               nfit_mem->dcr = nfit_dcr->dcr;
-               break;
-       }
-
-       if (!nfit_mem->dcr) {
-               dev_dbg(acpi_desc->dev, "SPA %d missing:%s%s\n",
-                               spa->range_index, __to_nfit_memdev(nfit_mem)
-                               ? "" : " MEMDEV", nfit_mem->dcr ? "" : " DCR");
-               return -ENODEV;
-       }
-
-       /*
-        * We've found enough to create an nvdimm, optionally
-        * find an associated BDW
-        */
-       list_add(&nfit_mem->list, &acpi_desc->dimms);
-
        list_for_each_entry(nfit_bdw, &acpi_desc->bdws, list) {
                if (nfit_bdw->bdw->region_index != dcr)
                        continue;
@@ -508,12 +487,12 @@ static int nfit_mem_add(struct acpi_nfit_desc *acpi_desc,
        }
 
        if (!nfit_mem->bdw)
-               return 0;
+               return;
 
        nfit_mem_find_spa_bdw(acpi_desc, nfit_mem);
 
        if (!nfit_mem->spa_bdw)
-               return 0;
+               return;
 
        range_index = nfit_mem->spa_bdw->range_index;
        list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {
@@ -538,8 +517,6 @@ static int nfit_mem_add(struct acpi_nfit_desc *acpi_desc,
                }
                break;
        }
-
-       return 0;
 }
 
 static int nfit_mem_dcr_init(struct acpi_nfit_desc *acpi_desc,
@@ -548,7 +525,6 @@ static int nfit_mem_dcr_init(struct acpi_nfit_desc *acpi_desc,
        struct nfit_mem *nfit_mem, *found;
        struct nfit_memdev *nfit_memdev;
        int type = nfit_spa_type(spa);
-       u16 dcr;
 
        switch (type) {
        case NFIT_SPA_DCR:
@@ -559,14 +535,18 @@ static int nfit_mem_dcr_init(struct acpi_nfit_desc *acpi_desc,
        }
 
        list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {
-               int rc;
+               struct nfit_dcr *nfit_dcr;
+               u32 device_handle;
+               u16 dcr;
 
                if (nfit_memdev->memdev->range_index != spa->range_index)
                        continue;
                found = NULL;
                dcr = nfit_memdev->memdev->region_index;
+               device_handle = nfit_memdev->memdev->device_handle;
                list_for_each_entry(nfit_mem, &acpi_desc->dimms, list)
-                       if (__to_nfit_memdev(nfit_mem)->region_index == dcr) {
+                       if (__to_nfit_memdev(nfit_mem)->device_handle
+                                       == device_handle) {
                                found = nfit_mem;
                                break;
                        }
@@ -579,6 +559,31 @@ static int nfit_mem_dcr_init(struct acpi_nfit_desc *acpi_desc,
                        if (!nfit_mem)
                                return -ENOMEM;
                        INIT_LIST_HEAD(&nfit_mem->list);
+                       list_add(&nfit_mem->list, &acpi_desc->dimms);
+               }
+
+               list_for_each_entry(nfit_dcr, &acpi_desc->dcrs, list) {
+                       if (nfit_dcr->dcr->region_index != dcr)
+                               continue;
+                       /*
+                        * Record the control region for the dimm.  For
+                        * the ACPI 6.1 case, where there are separate
+                        * control regions for the pmem vs blk
+                        * interfaces, be sure to record the extended
+                        * blk details.
+                        */
+                       if (!nfit_mem->dcr)
+                               nfit_mem->dcr = nfit_dcr->dcr;
+                       else if (nfit_mem->dcr->windows == 0
+                                       && nfit_dcr->dcr->windows)
+                               nfit_mem->dcr = nfit_dcr->dcr;
+                       break;
+               }
+
+               if (dcr && !nfit_mem->dcr) {
+                       dev_err(acpi_desc->dev, "SPA %d missing DCR %d\n",
+                                       spa->range_index, dcr);
+                       return -ENODEV;
                }
 
                if (type == NFIT_SPA_DCR) {
@@ -595,6 +600,7 @@ static int nfit_mem_dcr_init(struct acpi_nfit_desc *acpi_desc,
                                nfit_mem->idt_dcr = nfit_idt->idt;
                                break;
                        }
+                       nfit_mem_init_bdw(acpi_desc, nfit_mem, spa);
                } else {
                        /*
                         * A single dimm may belong to multiple SPA-PM
@@ -603,13 +609,6 @@ static int nfit_mem_dcr_init(struct acpi_nfit_desc *acpi_desc,
                         */
                        nfit_mem->memdev_pmem = nfit_memdev->memdev;
                }
-
-               if (found)
-                       continue;
-
-               rc = nfit_mem_add(acpi_desc, nfit_mem, spa);
-               if (rc)
-                       return rc;
        }
 
        return 0;
@@ -1504,9 +1503,7 @@ static int ars_do_start(struct nvdimm_bus_descriptor *nd_desc,
                case 1:
                        /* ARS unsupported, but we should never get here */
                        return 0;
-               case 2:
-                       return -EINVAL;
-               case 3:
+               case 6:
                        /* ARS is in progress */
                        msleep(1000);
                        break;
@@ -1517,13 +1514,13 @@ static int ars_do_start(struct nvdimm_bus_descriptor *nd_desc,
 }
 
 static int ars_get_status(struct nvdimm_bus_descriptor *nd_desc,
-               struct nd_cmd_ars_status *cmd)
+               struct nd_cmd_ars_status *cmd, u32 size)
 {
        int rc;
 
        while (1) {
                rc = nd_desc->ndctl(nd_desc, NULL, ND_CMD_ARS_STATUS, cmd,
-                       sizeof(*cmd));
+                       size);
                if (rc || cmd->status & 0xffff)
                        return -ENXIO;
 
@@ -1538,6 +1535,8 @@ static int ars_get_status(struct nvdimm_bus_descriptor *nd_desc,
                case 2:
                        /* No ARS performed for the current boot */
                        return 0;
+               case 3:
+                       /* TODO: error list overflow support */
                default:
                        return -ENXIO;
                }
@@ -1581,6 +1580,7 @@ static int acpi_nfit_find_poison(struct acpi_nfit_desc *acpi_desc,
        struct nd_cmd_ars_start *ars_start = NULL;
        struct nd_cmd_ars_cap *ars_cap = NULL;
        u64 start, len, cur, remaining;
+       u32 ars_status_size;
        int rc;
 
        ars_cap = kzalloc(sizeof(*ars_cap), GFP_KERNEL);
@@ -1590,14 +1590,21 @@ static int acpi_nfit_find_poison(struct acpi_nfit_desc *acpi_desc,
        start = ndr_desc->res->start;
        len = ndr_desc->res->end - ndr_desc->res->start + 1;
 
+       /*
+        * If ARS is unimplemented, unsupported, or if the 'Persistent Memory
+        * Scrub' flag in extended status is not set, skip this but continue
+        * initialization
+        */
        rc = ars_get_cap(nd_desc, ars_cap, start, len);
+       if (rc == -ENOTTY) {
+               dev_dbg(acpi_desc->dev,
+                       "Address Range Scrub is not implemented, won't create an error list\n");
+               rc = 0;
+               goto out;
+       }
        if (rc)
                goto out;
 
-       /*
-        * If ARS is unsupported, or if the 'Persistent Memory Scrub' flag in
-        * extended status is not set, skip this but continue initialization
-        */
        if ((ars_cap->status & 0xffff) ||
                !(ars_cap->status >> 16 & ND_ARS_PERSISTENT)) {
                dev_warn(acpi_desc->dev,
@@ -1610,14 +1617,14 @@ static int acpi_nfit_find_poison(struct acpi_nfit_desc *acpi_desc,
         * Check if a full-range ARS has been run. If so, use those results
         * without having to start a new ARS.
         */
-       ars_status = kzalloc(ars_cap->max_ars_out + sizeof(*ars_status),
-                       GFP_KERNEL);
+       ars_status_size = ars_cap->max_ars_out;
+       ars_status = kzalloc(ars_status_size, GFP_KERNEL);
        if (!ars_status) {
                rc = -ENOMEM;
                goto out;
        }
 
-       rc = ars_get_status(nd_desc, ars_status);
+       rc = ars_get_status(nd_desc, ars_status, ars_status_size);
        if (rc)
                goto out;
 
@@ -1647,7 +1654,7 @@ static int acpi_nfit_find_poison(struct acpi_nfit_desc *acpi_desc,
                if (rc)
                        goto out;
 
-               rc = ars_get_status(nd_desc, ars_status);
+               rc = ars_get_status(nd_desc, ars_status, ars_status_size);
                if (rc)
                        goto out;
 
index d30184c..c8e169e 100644 (file)
@@ -406,7 +406,7 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
                return 0;
        }
 
-       if (pci_has_managed_irq(dev))
+       if (dev->irq_managed && dev->irq > 0)
                return 0;
 
        entry = acpi_pci_irq_lookup(dev, pin);
@@ -451,7 +451,8 @@ int acpi_pci_irq_enable(struct pci_dev *dev)
                kfree(entry);
                return rc;
        }
-       pci_set_managed_irq(dev, rc);
+       dev->irq = rc;
+       dev->irq_managed = 1;
 
        if (link)
                snprintf(link_desc, sizeof(link_desc), " -> Link[%s]", link);
@@ -474,9 +475,17 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
        u8 pin;
 
        pin = dev->pin;
-       if (!pin || !pci_has_managed_irq(dev))
+       if (!pin || !dev->irq_managed || dev->irq <= 0)
                return;
 
+       /* Keep IOAPIC pin configuration when suspending */
+       if (dev->dev.power.is_prepared)
+               return;
+#ifdef CONFIG_PM
+       if (dev->dev.power.runtime_status == RPM_SUSPENDING)
+               return;
+#endif
+
        entry = acpi_pci_irq_lookup(dev, pin);
        if (!entry)
                return;
@@ -496,6 +505,6 @@ void acpi_pci_irq_disable(struct pci_dev *dev)
        dev_dbg(&dev->dev, "PCI INT %c disabled\n", pin_name(pin));
        if (gsi >= 0) {
                acpi_unregister_gsi(gsi);
-               pci_reset_managed_irq(dev);
+               dev->irq_managed = 0;
        }
 }
index fa28635..ededa90 100644 (file)
@@ -4,7 +4,6 @@
  *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
  *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
  *  Copyright (C) 2002       Dominik Brodowski <devel@brodo.de>
- *  Copyright (c) 2015, The Linux Foundation. All rights reserved.
  *
  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  *
@@ -438,6 +437,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
  * enabled system.
  */
 
+#define ACPI_MAX_IRQS          256
 #define ACPI_MAX_ISA_IRQ       16
 
 #define PIRQ_PENALTY_PCI_AVAILABLE     (0)
@@ -447,7 +447,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
 #define PIRQ_PENALTY_ISA_USED          (16*16*16*16*16)
 #define PIRQ_PENALTY_ISA_ALWAYS                (16*16*16*16*16*16)
 
-static int acpi_irq_isa_penalty[ACPI_MAX_ISA_IRQ] = {
+static int acpi_irq_penalty[ACPI_MAX_IRQS] = {
        PIRQ_PENALTY_ISA_ALWAYS,        /* IRQ0 timer */
        PIRQ_PENALTY_ISA_ALWAYS,        /* IRQ1 keyboard */
        PIRQ_PENALTY_ISA_ALWAYS,        /* IRQ2 cascade */
@@ -464,68 +464,9 @@ static int acpi_irq_isa_penalty[ACPI_MAX_ISA_IRQ] = {
        PIRQ_PENALTY_ISA_USED,          /* IRQ13 fpe, sometimes */
        PIRQ_PENALTY_ISA_USED,          /* IRQ14 ide0 */
        PIRQ_PENALTY_ISA_USED,          /* IRQ15 ide1 */
+       /* >IRQ15 */
 };
 
-struct irq_penalty_info {
-       int irq;
-       int penalty;
-       struct list_head node;
-};
-
-static LIST_HEAD(acpi_irq_penalty_list);
-
-static int acpi_irq_get_penalty(int irq)
-{
-       struct irq_penalty_info *irq_info;
-
-       if (irq < ACPI_MAX_ISA_IRQ)
-               return acpi_irq_isa_penalty[irq];
-
-       list_for_each_entry(irq_info, &acpi_irq_penalty_list, node) {
-               if (irq_info->irq == irq)
-                       return irq_info->penalty;
-       }
-
-       return 0;
-}
-
-static int acpi_irq_set_penalty(int irq, int new_penalty)
-{
-       struct irq_penalty_info *irq_info;
-
-       /* see if this is a ISA IRQ */
-       if (irq < ACPI_MAX_ISA_IRQ) {
-               acpi_irq_isa_penalty[irq] = new_penalty;
-               return 0;
-       }
-
-       /* next, try to locate from the dynamic list */
-       list_for_each_entry(irq_info, &acpi_irq_penalty_list, node) {
-               if (irq_info->irq == irq) {
-                       irq_info->penalty  = new_penalty;
-                       return 0;
-               }
-       }
-
-       /* nope, let's allocate a slot for this IRQ */
-       irq_info = kzalloc(sizeof(*irq_info), GFP_KERNEL);
-       if (!irq_info)
-               return -ENOMEM;
-
-       irq_info->irq = irq;
-       irq_info->penalty = new_penalty;
-       list_add_tail(&irq_info->node, &acpi_irq_penalty_list);
-
-       return 0;
-}
-
-static void acpi_irq_add_penalty(int irq, int penalty)
-{
-       int curpen = acpi_irq_get_penalty(irq);
-
-       acpi_irq_set_penalty(irq, curpen + penalty);
-}
-
 int __init acpi_irq_penalty_init(void)
 {
        struct acpi_pci_link *link;
@@ -546,16 +487,15 @@ int __init acpi_irq_penalty_init(void)
                            link->irq.possible_count;
 
                        for (i = 0; i < link->irq.possible_count; i++) {
-                               if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ) {
-                                       int irqpos = link->irq.possible[i];
-
-                                       acpi_irq_add_penalty(irqpos, penalty);
-                               }
+                               if (link->irq.possible[i] < ACPI_MAX_ISA_IRQ)
+                                       acpi_irq_penalty[link->irq.
+                                                        possible[i]] +=
+                                           penalty;
                        }
 
                } else if (link->irq.active) {
-                       acpi_irq_add_penalty(link->irq.active,
-                                            PIRQ_PENALTY_PCI_POSSIBLE);
+                       acpi_irq_penalty[link->irq.active] +=
+                           PIRQ_PENALTY_PCI_POSSIBLE;
                }
        }
 
@@ -607,12 +547,12 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
                 * the use of IRQs 9, 10, 11, and >15.
                 */
                for (i = (link->irq.possible_count - 1); i >= 0; i--) {
-                       if (acpi_irq_get_penalty(irq) >
-                           acpi_irq_get_penalty(link->irq.possible[i]))
+                       if (acpi_irq_penalty[irq] >
+                           acpi_irq_penalty[link->irq.possible[i]])
                                irq = link->irq.possible[i];
                }
        }
-       if (acpi_irq_get_penalty(irq) >= PIRQ_PENALTY_ISA_ALWAYS) {
+       if (acpi_irq_penalty[irq] >= PIRQ_PENALTY_ISA_ALWAYS) {
                printk(KERN_ERR PREFIX "No IRQ available for %s [%s]. "
                            "Try pci=noacpi or acpi=off\n",
                            acpi_device_name(link->device),
@@ -628,8 +568,7 @@ static int acpi_pci_link_allocate(struct acpi_pci_link *link)
                            acpi_device_bid(link->device));
                return -ENODEV;
        } else {
-               acpi_irq_add_penalty(link->irq.active, PIRQ_PENALTY_PCI_USING);
-
+               acpi_irq_penalty[link->irq.active] += PIRQ_PENALTY_PCI_USING;
                printk(KERN_WARNING PREFIX "%s [%s] enabled at IRQ %d\n",
                       acpi_device_name(link->device),
                       acpi_device_bid(link->device), link->irq.active);
@@ -839,7 +778,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)
 }
 
 /*
- * modify penalty from cmdline
+ * modify acpi_irq_penalty[] from cmdline
  */
 static int __init acpi_irq_penalty_update(char *str, int used)
 {
@@ -857,10 +796,13 @@ static int __init acpi_irq_penalty_update(char *str, int used)
                if (irq < 0)
                        continue;
 
+               if (irq >= ARRAY_SIZE(acpi_irq_penalty))
+                       continue;
+
                if (used)
-                       acpi_irq_add_penalty(irq, PIRQ_PENALTY_ISA_USED);
+                       acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
                else
-                       acpi_irq_set_penalty(irq, PIRQ_PENALTY_PCI_AVAILABLE);
+                       acpi_irq_penalty[irq] = PIRQ_PENALTY_PCI_AVAILABLE;
 
                if (retval != 2)        /* no next number */
                        break;
@@ -877,15 +819,18 @@ static int __init acpi_irq_penalty_update(char *str, int used)
  */
 void acpi_penalize_isa_irq(int irq, int active)
 {
-       if (irq >= 0)
-               acpi_irq_add_penalty(irq, active ?
-                       PIRQ_PENALTY_ISA_USED : PIRQ_PENALTY_PCI_USING);
+       if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
+               if (active)
+                       acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_USED;
+               else
+                       acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
+       }
 }
 
 bool acpi_isa_irq_available(int irq)
 {
-       return irq >= 0 &&
-               (acpi_irq_get_penalty(irq) < PIRQ_PENALTY_ISA_ALWAYS);
+       return irq >= 0 && (irq >= ARRAY_SIZE(acpi_irq_penalty) ||
+                           acpi_irq_penalty[irq] < PIRQ_PENALTY_ISA_ALWAYS);
 }
 
 /*
@@ -895,18 +840,13 @@ bool acpi_isa_irq_available(int irq)
  */
 void acpi_penalize_sci_irq(int irq, int trigger, int polarity)
 {
-       int penalty;
-
-       if (irq < 0)
-               return;
-
-       if (trigger != ACPI_MADT_TRIGGER_LEVEL ||
-           polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
-               penalty = PIRQ_PENALTY_ISA_ALWAYS;
-       else
-               penalty = PIRQ_PENALTY_PCI_USING;
-
-       acpi_irq_add_penalty(irq, penalty);
+       if (irq >= 0 && irq < ARRAY_SIZE(acpi_irq_penalty)) {
+               if (trigger != ACPI_MADT_TRIGGER_LEVEL ||
+                   polarity != ACPI_MADT_POLARITY_ACTIVE_LOW)
+                       acpi_irq_penalty[irq] += PIRQ_PENALTY_ISA_ALWAYS;
+               else
+                       acpi_irq_penalty[irq] += PIRQ_PENALTY_PCI_USING;
+       }
 }
 
 /*
index a39e85f..7d00b7a 100644 (file)
@@ -2074,7 +2074,7 @@ static int binder_thread_write(struct binder_proc *proc,
                        if (get_user(cookie, (binder_uintptr_t __user *)ptr))
                                return -EFAULT;
 
-                       ptr += sizeof(void *);
+                       ptr += sizeof(cookie);
                        list_for_each_entry(w, &proc->delivered_death, entry) {
                                struct binder_ref_death *tmp_death = container_of(w, struct binder_ref_death, work);
 
index 594fcab..146dc0b 100644 (file)
@@ -264,6 +264,26 @@ static const struct pci_device_id ahci_pci_tbl[] = {
        { PCI_VDEVICE(INTEL, 0x3b2b), board_ahci }, /* PCH RAID */
        { PCI_VDEVICE(INTEL, 0x3b2c), board_ahci }, /* PCH RAID */
        { PCI_VDEVICE(INTEL, 0x3b2f), board_ahci }, /* PCH AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b0), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b1), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b2), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b3), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b4), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b5), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b6), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19b7), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19bE), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19bF), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19c0), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19c1), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19c2), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19c3), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19c4), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19c5), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19c6), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19c7), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19cE), board_ahci }, /* DNV AHCI */
+       { PCI_VDEVICE(INTEL, 0x19cF), board_ahci }, /* DNV AHCI */
        { PCI_VDEVICE(INTEL, 0x1c02), board_ahci }, /* CPT AHCI */
        { PCI_VDEVICE(INTEL, 0x1c03), board_ahci }, /* CPT AHCI */
        { PCI_VDEVICE(INTEL, 0x1c04), board_ahci }, /* CPT RAID */
@@ -347,15 +367,21 @@ static const struct pci_device_id ahci_pci_tbl[] = {
        { PCI_VDEVICE(INTEL, 0xa107), board_ahci }, /* Sunrise Point-H RAID */
        { PCI_VDEVICE(INTEL, 0xa10f), board_ahci }, /* Sunrise Point-H RAID */
        { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Lewisburg AHCI*/
        { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Lewisburg RAID*/
        { PCI_VDEVICE(INTEL, 0xa182), board_ahci }, /* Lewisburg AHCI*/
        { PCI_VDEVICE(INTEL, 0xa184), board_ahci }, /* Lewisburg RAID*/
        { PCI_VDEVICE(INTEL, 0xa186), board_ahci }, /* Lewisburg RAID*/
        { PCI_VDEVICE(INTEL, 0xa18e), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0xa1d2), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0xa1d6), board_ahci }, /* Lewisburg RAID*/
        { PCI_VDEVICE(INTEL, 0xa202), board_ahci }, /* Lewisburg AHCI*/
        { PCI_VDEVICE(INTEL, 0xa204), board_ahci }, /* Lewisburg RAID*/
        { PCI_VDEVICE(INTEL, 0xa206), board_ahci }, /* Lewisburg RAID*/
        { PCI_VDEVICE(INTEL, 0xa20e), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0xa252), board_ahci }, /* Lewisburg RAID*/
+       { PCI_VDEVICE(INTEL, 0xa256), board_ahci }, /* Lewisburg RAID*/
 
        /* JMicron 360/1/3/5/6, match class to avoid IDE function */
        { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
@@ -1305,6 +1331,44 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)
 {}
 #endif
 
+#ifdef CONFIG_ARM64
+/*
+ * Due to ERRATA#22536, ThunderX needs to handle HOST_IRQ_STAT differently.
+ * Workaround is to make sure all pending IRQs are served before leaving
+ * handler.
+ */
+static irqreturn_t ahci_thunderx_irq_handler(int irq, void *dev_instance)
+{
+       struct ata_host *host = dev_instance;
+       struct ahci_host_priv *hpriv;
+       unsigned int rc = 0;
+       void __iomem *mmio;
+       u32 irq_stat, irq_masked;
+       unsigned int handled = 1;
+
+       VPRINTK("ENTER\n");
+       hpriv = host->private_data;
+       mmio = hpriv->mmio;
+       irq_stat = readl(mmio + HOST_IRQ_STAT);
+       if (!irq_stat)
+               return IRQ_NONE;
+
+       do {
+               irq_masked = irq_stat & hpriv->port_map;
+               spin_lock(&host->lock);
+               rc = ahci_handle_port_intr(host, irq_masked);
+               if (!rc)
+                       handled = 0;
+               writel(irq_stat, mmio + HOST_IRQ_STAT);
+               irq_stat = readl(mmio + HOST_IRQ_STAT);
+               spin_unlock(&host->lock);
+       } while (irq_stat);
+       VPRINTK("EXIT\n");
+
+       return IRQ_RETVAL(handled);
+}
+#endif
+
 /*
  * ahci_init_msix() - optionally enable per-port MSI-X otherwise defer
  * to single msi.
@@ -1540,6 +1604,11 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (ahci_broken_devslp(pdev))
                hpriv->flags |= AHCI_HFLAG_NO_DEVSLP;
 
+#ifdef CONFIG_ARM64
+       if (pdev->vendor == 0x177d && pdev->device == 0xa01c)
+               hpriv->irq_handler = ahci_thunderx_irq_handler;
+#endif
+
        /* save initial config */
        ahci_pci_save_initial_config(pdev, hpriv);
 
index a4faa43..167ba7e 100644 (file)
@@ -240,8 +240,7 @@ enum {
                                                        error-handling stage) */
        AHCI_HFLAG_NO_DEVSLP            = (1 << 17), /* no device sleep */
        AHCI_HFLAG_NO_FBS               = (1 << 18), /* no FBS */
-       AHCI_HFLAG_EDGE_IRQ             = (1 << 19), /* HOST_IRQ_STAT behaves as
-                                                       Edge Triggered */
+
 #ifdef CONFIG_PCI_MSI
        AHCI_HFLAG_MULTI_MSI            = (1 << 20), /* multiple PCI MSIs */
        AHCI_HFLAG_MULTI_MSIX           = (1 << 21), /* per-port MSI-X */
@@ -250,6 +249,7 @@ enum {
        AHCI_HFLAG_MULTI_MSI            = 0,
        AHCI_HFLAG_MULTI_MSIX           = 0,
 #endif
+       AHCI_HFLAG_WAKE_BEFORE_STOP     = (1 << 22), /* wake before DMA stop */
 
        /* ap->flags bits */
 
@@ -360,6 +360,7 @@ struct ahci_host_priv {
         * be overridden anytime before the host is activated.
         */
        void                    (*start_engine)(struct ata_port *ap);
+       irqreturn_t             (*irq_handler)(int irq, void *dev_instance);
 };
 
 #ifdef CONFIG_PCI_MSI
@@ -423,6 +424,7 @@ int ahci_reset_em(struct ata_host *host);
 void ahci_print_info(struct ata_host *host, const char *scc_s);
 int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht);
 void ahci_error_handler(struct ata_port *ap);
+u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked);
 
 static inline void __iomem *__ahci_port_base(struct ata_host *host,
                                             unsigned int port_no)
index b36cae2..e87bcec 100644 (file)
@@ -317,6 +317,7 @@ static int brcm_ahci_probe(struct platform_device *pdev)
        if (IS_ERR(hpriv))
                return PTR_ERR(hpriv);
        hpriv->plat_data = priv;
+       hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP;
 
        brcm_sata_alpm_init(hpriv);
 
index e2c6d9e..8e3f7fa 100644 (file)
@@ -548,6 +548,88 @@ softreset_retry:
        return rc;
 }
 
+/**
+ * xgene_ahci_handle_broken_edge_irq - Handle the broken irq.
+ * @ata_host: Host that recieved the irq
+ * @irq_masked: HOST_IRQ_STAT value
+ *
+ * For hardware with broken edge trigger latch
+ * the HOST_IRQ_STAT register misses the edge interrupt
+ * when clearing of HOST_IRQ_STAT register and hardware
+ * reporting the PORT_IRQ_STAT register at the
+ * same clock cycle.
+ * As such, the algorithm below outlines the workaround.
+ *
+ * 1. Read HOST_IRQ_STAT register and save the state.
+ * 2. Clear the HOST_IRQ_STAT register.
+ * 3. Read back the HOST_IRQ_STAT register.
+ * 4. If HOST_IRQ_STAT register equals to zero, then
+ *    traverse the rest of port's PORT_IRQ_STAT register
+ *    to check if an interrupt is triggered at that point else
+ *    go to step 6.
+ * 5. If PORT_IRQ_STAT register of rest ports is not equal to zero
+ *    then update the state of HOST_IRQ_STAT saved in step 1.
+ * 6. Handle port interrupts.
+ * 7. Exit
+ */
+static int xgene_ahci_handle_broken_edge_irq(struct ata_host *host,
+                                            u32 irq_masked)
+{
+       struct ahci_host_priv *hpriv = host->private_data;
+       void __iomem *port_mmio;
+       int i;
+
+       if (!readl(hpriv->mmio + HOST_IRQ_STAT)) {
+               for (i = 0; i < host->n_ports; i++) {
+                       if (irq_masked & (1 << i))
+                               continue;
+
+                       port_mmio = ahci_port_base(host->ports[i]);
+                       if (readl(port_mmio + PORT_IRQ_STAT))
+                               irq_masked |= (1 << i);
+               }
+       }
+
+       return ahci_handle_port_intr(host, irq_masked);
+}
+
+static irqreturn_t xgene_ahci_irq_intr(int irq, void *dev_instance)
+{
+       struct ata_host *host = dev_instance;
+       struct ahci_host_priv *hpriv;
+       unsigned int rc = 0;
+       void __iomem *mmio;
+       u32 irq_stat, irq_masked;
+
+       VPRINTK("ENTER\n");
+
+       hpriv = host->private_data;
+       mmio = hpriv->mmio;
+
+       /* sigh.  0xffffffff is a valid return from h/w */
+       irq_stat = readl(mmio + HOST_IRQ_STAT);
+       if (!irq_stat)
+               return IRQ_NONE;
+
+       irq_masked = irq_stat & hpriv->port_map;
+
+       spin_lock(&host->lock);
+
+       /*
+        * HOST_IRQ_STAT behaves as edge triggered latch meaning that
+        * it should be cleared before all the port events are cleared.
+        */
+       writel(irq_stat, mmio + HOST_IRQ_STAT);
+
+       rc = xgene_ahci_handle_broken_edge_irq(host, irq_masked);
+
+       spin_unlock(&host->lock);
+
+       VPRINTK("EXIT\n");
+
+       return IRQ_RETVAL(rc);
+}
+
 static struct ata_port_operations xgene_ahci_v1_ops = {
        .inherits = &ahci_ops,
        .host_stop = xgene_ahci_host_stop,
@@ -779,7 +861,8 @@ skip_clk_phy:
                hpriv->flags = AHCI_HFLAG_NO_NCQ;
                break;
        case XGENE_AHCI_V2:
-               hpriv->flags |= AHCI_HFLAG_YES_FBS | AHCI_HFLAG_EDGE_IRQ;
+               hpriv->flags |= AHCI_HFLAG_YES_FBS;
+               hpriv->irq_handler = xgene_ahci_irq_intr;
                break;
        default:
                break;
index d61740e..85ea514 100644 (file)
@@ -113,6 +113,7 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
                                    const char *buf, size_t size);
 static ssize_t ahci_show_em_supported(struct device *dev,
                                      struct device_attribute *attr, char *buf);
+static irqreturn_t ahci_single_level_irq_intr(int irq, void *dev_instance);
 
 static DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL);
 static DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL);
@@ -496,8 +497,8 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
                }
        }
 
-       /* fabricate port_map from cap.nr_ports */
-       if (!port_map) {
+       /* fabricate port_map from cap.nr_ports for < AHCI 1.3 */
+       if (!port_map && vers < 0x10300) {
                port_map = (1 << ahci_nr_ports(cap)) - 1;
                dev_warn(dev, "forcing PORTS_IMPL to 0x%x\n", port_map);
 
@@ -512,6 +513,9 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
 
        if (!hpriv->start_engine)
                hpriv->start_engine = ahci_start_engine;
+
+       if (!hpriv->irq_handler)
+               hpriv->irq_handler = ahci_single_level_irq_intr;
 }
 EXPORT_SYMBOL_GPL(ahci_save_initial_config);
 
@@ -593,8 +597,22 @@ EXPORT_SYMBOL_GPL(ahci_start_engine);
 int ahci_stop_engine(struct ata_port *ap)
 {
        void __iomem *port_mmio = ahci_port_base(ap);
+       struct ahci_host_priv *hpriv = ap->host->private_data;
        u32 tmp;
 
+       /*
+        * On some controllers, stopping a port's DMA engine while the port
+        * is in ALPM state (partial or slumber) results in failures on
+        * subsequent DMA engine starts.  For those controllers, put the
+        * port back in active state before stopping its DMA engine.
+        */
+       if ((hpriv->flags & AHCI_HFLAG_WAKE_BEFORE_STOP) &&
+           (ap->link.lpm_policy > ATA_LPM_MAX_POWER) &&
+           ahci_set_lpm(&ap->link, ATA_LPM_MAX_POWER, ATA_LPM_WAKE_ONLY)) {
+               dev_err(ap->host->dev, "Failed to wake up port before engine stop\n");
+               return -EIO;
+       }
+
        tmp = readl(port_mmio + PORT_CMD);
 
        /* check if the HBA is idle */
@@ -689,6 +707,9 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
        void __iomem *port_mmio = ahci_port_base(ap);
 
        if (policy != ATA_LPM_MAX_POWER) {
+               /* wakeup flag only applies to the max power policy */
+               hints &= ~ATA_LPM_WAKE_ONLY;
+
                /*
                 * Disable interrupts on Phy Ready. This keeps us from
                 * getting woken up due to spurious phy ready
@@ -704,7 +725,8 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
                u32 cmd = readl(port_mmio + PORT_CMD);
 
                if (policy == ATA_LPM_MAX_POWER || !(hints & ATA_LPM_HIPM)) {
-                       cmd &= ~(PORT_CMD_ASP | PORT_CMD_ALPE);
+                       if (!(hints & ATA_LPM_WAKE_ONLY))
+                               cmd &= ~(PORT_CMD_ASP | PORT_CMD_ALPE);
                        cmd |= PORT_CMD_ICC_ACTIVE;
 
                        writel(cmd, port_mmio + PORT_CMD);
@@ -712,6 +734,9 @@ static int ahci_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
 
                        /* wait 10ms to be sure we've come out of LPM state */
                        ata_msleep(ap, 10);
+
+                       if (hints & ATA_LPM_WAKE_ONLY)
+                               return 0;
                } else {
                        cmd |= PORT_CMD_ALPE;
                        if (policy == ATA_LPM_MIN_POWER)
@@ -1143,8 +1168,7 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
 
        /* mark esata ports */
        tmp = readl(port_mmio + PORT_CMD);
-       if ((tmp & PORT_CMD_HPCP) ||
-           ((tmp & PORT_CMD_ESP) && (hpriv->cap & HOST_CAP_SXS)))
+       if ((tmp & PORT_CMD_ESP) && (hpriv->cap & HOST_CAP_SXS))
                ap->pflags |= ATA_PFLAG_EXTERNAL;
 }
 
@@ -1825,7 +1849,7 @@ static irqreturn_t ahci_multi_irqs_intr_hard(int irq, void *dev_instance)
        return IRQ_HANDLED;
 }
 
-static u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked)
+u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked)
 {
        unsigned int i, handled = 0;
 
@@ -1851,43 +1875,7 @@ static u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked)
 
        return handled;
 }
-
-static irqreturn_t ahci_single_edge_irq_intr(int irq, void *dev_instance)
-{
-       struct ata_host *host = dev_instance;
-       struct ahci_host_priv *hpriv;
-       unsigned int rc = 0;
-       void __iomem *mmio;
-       u32 irq_stat, irq_masked;
-
-       VPRINTK("ENTER\n");
-
-       hpriv = host->private_data;
-       mmio = hpriv->mmio;
-
-       /* sigh.  0xffffffff is a valid return from h/w */
-       irq_stat = readl(mmio + HOST_IRQ_STAT);
-       if (!irq_stat)
-               return IRQ_NONE;
-
-       irq_masked = irq_stat & hpriv->port_map;
-
-       spin_lock(&host->lock);
-
-       /*
-        * HOST_IRQ_STAT behaves as edge triggered latch meaning that
-        * it should be cleared before all the port events are cleared.
-        */
-       writel(irq_stat, mmio + HOST_IRQ_STAT);
-
-       rc = ahci_handle_port_intr(host, irq_masked);
-
-       spin_unlock(&host->lock);
-
-       VPRINTK("EXIT\n");
-
-       return IRQ_RETVAL(rc);
-}
+EXPORT_SYMBOL_GPL(ahci_handle_port_intr);
 
 static irqreturn_t ahci_single_level_irq_intr(int irq, void *dev_instance)
 {
@@ -2514,14 +2502,18 @@ int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht)
        int irq = hpriv->irq;
        int rc;
 
-       if (hpriv->flags & (AHCI_HFLAG_MULTI_MSI | AHCI_HFLAG_MULTI_MSIX))
+       if (hpriv->flags & (AHCI_HFLAG_MULTI_MSI | AHCI_HFLAG_MULTI_MSIX)) {
+               if (hpriv->irq_handler)
+                       dev_warn(host->dev, "both AHCI_HFLAG_MULTI_MSI flag set \
+                                and custom irq handler implemented\n");
+
                rc = ahci_host_activate_multi_irqs(host, sht);
-       else if (hpriv->flags & AHCI_HFLAG_EDGE_IRQ)
-               rc = ata_host_activate(host, irq, ahci_single_edge_irq_intr,
-                                      IRQF_SHARED, sht);
-       else
-               rc = ata_host_activate(host, irq, ahci_single_level_irq_intr,
+       } else {
+               rc = ata_host_activate(host, irq, hpriv->irq_handler,
                                       IRQF_SHARED, sht);
+       }
+
+
        return rc;
 }
 EXPORT_SYMBOL_GPL(ahci_host_activate);
index cbb7471..55e257c 100644 (file)
@@ -4125,6 +4125,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
        { "SAMSUNG CD-ROM SN-124", "N001",      ATA_HORKAGE_NODMA },
        { "Seagate STT20000A", NULL,            ATA_HORKAGE_NODMA },
        { " 2GB ATA Flash Disk", "ADMA428M",    ATA_HORKAGE_NODMA },
+       { "VRFDFC22048UCHC-TE*", NULL,          ATA_HORKAGE_NODMA },
        /* Odd clown on sil3726/4726 PMPs */
        { "Config  Disk",       NULL,           ATA_HORKAGE_DISABLE },
 
index 7e959f9..e417e1a 100644 (file)
@@ -675,19 +675,18 @@ static int ata_ioc32(struct ata_port *ap)
 int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *scsidev,
                     int cmd, void __user *arg)
 {
-       int val = -EINVAL, rc = -EINVAL;
+       unsigned long val;
+       int rc = -EINVAL;
        unsigned long flags;
 
        switch (cmd) {
-       case ATA_IOC_GET_IO32:
+       case HDIO_GET_32BIT:
                spin_lock_irqsave(ap->lock, flags);
                val = ata_ioc32(ap);
                spin_unlock_irqrestore(ap->lock, flags);
-               if (copy_to_user(arg, &val, 1))
-                       return -EFAULT;
-               return 0;
+               return put_user(val, (unsigned long __user *)arg);
 
-       case ATA_IOC_SET_IO32:
+       case HDIO_SET_32BIT:
                val = (unsigned long) arg;
                rc = 0;
                spin_lock_irqsave(ap->lock, flags);
index cdf6215..051b615 100644 (file)
@@ -997,12 +997,9 @@ static inline int ata_hsm_ok_in_wq(struct ata_port *ap,
 static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
 {
        struct ata_port *ap = qc->ap;
-       unsigned long flags;
 
        if (ap->ops->error_handler) {
                if (in_wq) {
-                       spin_lock_irqsave(ap->lock, flags);
-
                        /* EH might have kicked in while host lock is
                         * released.
                         */
@@ -1014,8 +1011,6 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
                                } else
                                        ata_port_freeze(ap);
                        }
-
-                       spin_unlock_irqrestore(ap->lock, flags);
                } else {
                        if (likely(!(qc->err_mask & AC_ERR_HSM)))
                                ata_qc_complete(qc);
@@ -1024,10 +1019,8 @@ static void ata_hsm_qc_complete(struct ata_queued_cmd *qc, int in_wq)
                }
        } else {
                if (in_wq) {
-                       spin_lock_irqsave(ap->lock, flags);
                        ata_sff_irq_on(ap);
                        ata_qc_complete(qc);
-                       spin_unlock_irqrestore(ap->lock, flags);
                } else
                        ata_qc_complete(qc);
        }
@@ -1048,9 +1041,10 @@ int ata_sff_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc,
 {
        struct ata_link *link = qc->dev->link;
        struct ata_eh_info *ehi = &link->eh_info;
-       unsigned long flags = 0;
        int poll_next;
 
+       lockdep_assert_held(ap->lock);
+
        WARN_ON_ONCE((qc->flags & ATA_QCFLAG_ACTIVE) == 0);
 
        /* Make sure ata_sff_qc_issue() does not throw things
@@ -1112,14 +1106,6 @@ fsm_start:
                        }
                }
 
-               /* Send the CDB (atapi) or the first data block (ata pio out).
-                * During the state transition, interrupt handler shouldn't
-                * be invoked before the data transfer is complete and
-                * hsm_task_state is changed. Hence, the following locking.
-                */
-               if (in_wq)
-                       spin_lock_irqsave(ap->lock, flags);
-
                if (qc->tf.protocol == ATA_PROT_PIO) {
                        /* PIO data out protocol.
                         * send first data block.
@@ -1135,9 +1121,6 @@ fsm_start:
                        /* send CDB */
                        atapi_send_cdb(ap, qc);
 
-               if (in_wq)
-                       spin_unlock_irqrestore(ap->lock, flags);
-
                /* if polling, ata_sff_pio_task() handles the rest.
                 * otherwise, interrupt handler takes over from here.
                 */
@@ -1296,7 +1279,8 @@ fsm_start:
                break;
        default:
                poll_next = 0;
-               BUG();
+               WARN(true, "ata%d: SFF host state machine in invalid state %d",
+                    ap->print_id, ap->hsm_task_state);
        }
 
        return poll_next;
@@ -1361,12 +1345,14 @@ static void ata_sff_pio_task(struct work_struct *work)
        u8 status;
        int poll_next;
 
+       spin_lock_irq(ap->lock);
+
        BUG_ON(ap->sff_pio_task_link == NULL);
        /* qc can be NULL if timeout occurred */
        qc = ata_qc_from_tag(ap, link->active_tag);
        if (!qc) {
                ap->sff_pio_task_link = NULL;
-               return;
+               goto out_unlock;
        }
 
 fsm_start:
@@ -1381,11 +1367,14 @@ fsm_start:
         */
        status = ata_sff_busy_wait(ap, ATA_BUSY, 5);
        if (status & ATA_BUSY) {
+               spin_unlock_irq(ap->lock);
                ata_msleep(ap, 2);
+               spin_lock_irq(ap->lock);
+
                status = ata_sff_busy_wait(ap, ATA_BUSY, 10);
                if (status & ATA_BUSY) {
                        ata_sff_queue_pio_task(link, ATA_SHORT_PAUSE);
-                       return;
+                       goto out_unlock;
                }
        }
 
@@ -1402,6 +1391,8 @@ fsm_start:
         */
        if (poll_next)
                goto fsm_start;
+out_unlock:
+       spin_unlock_irq(ap->lock);
 }
 
 /**
index 12fe0f3..c8b6a78 100644 (file)
@@ -32,6 +32,8 @@
 #include <linux/libata.h>
 #include <scsi/scsi_host.h>
 
+#include <asm/mach-rc32434/rb.h>
+
 #define DRV_NAME       "pata-rb532-cf"
 #define DRV_VERSION    "0.1.0"
 #define DRV_DESC       "PATA driver for RouterBOARD 532 Compact Flash"
@@ -107,6 +109,7 @@ static int rb532_pata_driver_probe(struct platform_device *pdev)
        int gpio;
        struct resource *res;
        struct ata_host *ah;
+       struct cf_device *pdata;
        struct rb532_cf_info *info;
        int ret;
 
@@ -122,7 +125,13 @@ static int rb532_pata_driver_probe(struct platform_device *pdev)
                return -ENOENT;
        }
 
-       gpio = irq_to_gpio(irq);
+       pdata = dev_get_platdata(&pdev->dev);
+       if (!pdata) {
+               dev_err(&pdev->dev, "no platform data specified\n");
+               return -EINVAL;
+       }
+
+       gpio = pdata->gpio_pin;
        if (gpio < 0) {
                dev_err(&pdev->dev, "no GPIO found for irq%d\n", irq);
                return -ENOENT;
index 89f5cf6..04a1582 100644 (file)
@@ -206,6 +206,8 @@ static void component_match_release(struct device *master,
                if (mc->release)
                        mc->release(master, mc->data);
        }
+
+       kfree(match->compare);
 }
 
 static void devm_component_match_release(struct device *dev, void *res)
@@ -221,14 +223,14 @@ static int component_match_realloc(struct device *dev,
        if (match->alloc == num)
                return 0;
 
-       new = devm_kmalloc_array(dev, num, sizeof(*new), GFP_KERNEL);
+       new = kmalloc_array(num, sizeof(*new), GFP_KERNEL);
        if (!new)
                return -ENOMEM;
 
        if (match->compare) {
                memcpy(new, match->compare, sizeof(*new) *
                                            min(match->num, num));
-               devm_kfree(dev, match->compare);
+               kfree(match->compare);
        }
        match->compare = new;
        match->alloc = num;
@@ -283,6 +285,24 @@ void component_match_add_release(struct device *master,
 }
 EXPORT_SYMBOL(component_match_add_release);
 
+static void free_master(struct master *master)
+{
+       struct component_match *match = master->match;
+       int i;
+
+       list_del(&master->node);
+
+       if (match) {
+               for (i = 0; i < match->num; i++) {
+                       struct component *c = match->compare[i].component;
+                       if (c)
+                               c->master = NULL;
+               }
+       }
+
+       kfree(master);
+}
+
 int component_master_add_with_match(struct device *dev,
        const struct component_master_ops *ops,
        struct component_match *match)
@@ -309,11 +329,9 @@ int component_master_add_with_match(struct device *dev,
 
        ret = try_to_bring_up_master(master, NULL);
 
-       if (ret < 0) {
-               /* Delete off the list if we weren't successful */
-               list_del(&master->node);
-               kfree(master);
-       }
+       if (ret < 0)
+               free_master(master);
+
        mutex_unlock(&component_mutex);
 
        return ret < 0 ? ret : 0;
@@ -324,25 +342,12 @@ void component_master_del(struct device *dev,
        const struct component_master_ops *ops)
 {
        struct master *master;
-       int i;
 
        mutex_lock(&component_mutex);
        master = __master_find(dev, ops);
        if (master) {
-               struct component_match *match = master->match;
-
                take_down_master(master);
-
-               list_del(&master->node);
-
-               if (match) {
-                       for (i = 0; i < match->num; i++) {
-                               struct component *c = match->compare[i].component;
-                               if (c)
-                                       c->master = NULL;
-                       }
-               }
-               kfree(master);
+               free_master(master);
        }
        mutex_unlock(&component_mutex);
 }
@@ -486,6 +491,8 @@ int component_add(struct device *dev, const struct component_ops *ops)
 
        ret = try_to_bring_up_masters(component);
        if (ret < 0) {
+               if (component->master)
+                       remove_component(component->master, component);
                list_del(&component->node);
 
                kfree(component);
index c359351..a163f2c 100644 (file)
@@ -218,7 +218,7 @@ bool fwnode_property_present(struct fwnode_handle *fwnode, const char *propname)
        bool ret;
 
        ret = __fwnode_property_present(fwnode, propname);
-       if (ret == false && fwnode && fwnode->secondary)
+       if (ret == false && fwnode && !IS_ERR_OR_NULL(fwnode->secondary))
                ret = __fwnode_property_present(fwnode->secondary, propname);
        return ret;
 }
@@ -423,7 +423,7 @@ EXPORT_SYMBOL_GPL(device_property_match_string);
        int _ret_;                                                                      \
        _ret_ = FWNODE_PROP_READ(_fwnode_, _propname_, _type_, _proptype_,              \
                                 _val_, _nval_);                                        \
-       if (_ret_ == -EINVAL && _fwnode_ && _fwnode_->secondary)                        \
+       if (_ret_ == -EINVAL && _fwnode_ && !IS_ERR_OR_NULL(_fwnode_->secondary))       \
                _ret_ = FWNODE_PROP_READ(_fwnode_->secondary, _propname_, _type_,       \
                                _proptype_, _val_, _nval_);                             \
        _ret_;                                                                          \
@@ -593,7 +593,7 @@ int fwnode_property_read_string_array(struct fwnode_handle *fwnode,
        int ret;
 
        ret = __fwnode_property_read_string_array(fwnode, propname, val, nval);
-       if (ret == -EINVAL && fwnode && fwnode->secondary)
+       if (ret == -EINVAL && fwnode && !IS_ERR_OR_NULL(fwnode->secondary))
                ret = __fwnode_property_read_string_array(fwnode->secondary,
                                                          propname, val, nval);
        return ret;
@@ -621,7 +621,7 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode,
        int ret;
 
        ret = __fwnode_property_read_string(fwnode, propname, val);
-       if (ret == -EINVAL && fwnode && fwnode->secondary)
+       if (ret == -EINVAL && fwnode && !IS_ERR_OR_NULL(fwnode->secondary))
                ret = __fwnode_property_read_string(fwnode->secondary,
                                                    propname, val);
        return ret;
index 8812bfb..eea5156 100644 (file)
@@ -133,17 +133,17 @@ static int regmap_mmio_gather_write(void *context,
        while (val_size) {
                switch (ctx->val_bytes) {
                case 1:
-                       __raw_writeb(*(u8 *)val, ctx->regs + offset);
+                       writeb(*(u8 *)val, ctx->regs + offset);
                        break;
                case 2:
-                       __raw_writew(*(u16 *)val, ctx->regs + offset);
+                       writew(*(u16 *)val, ctx->regs + offset);
                        break;
                case 4:
-                       __raw_writel(*(u32 *)val, ctx->regs + offset);
+                       writel(*(u32 *)val, ctx->regs + offset);
                        break;
 #ifdef CONFIG_64BIT
                case 8:
-                       __raw_writeq(*(u64 *)val, ctx->regs + offset);
+                       writeq(*(u64 *)val, ctx->regs + offset);
                        break;
 #endif
                default:
@@ -193,17 +193,17 @@ static int regmap_mmio_read(void *context,
        while (val_size) {
                switch (ctx->val_bytes) {
                case 1:
-                       *(u8 *)val = __raw_readb(ctx->regs + offset);
+                       *(u8 *)val = readb(ctx->regs + offset);
                        break;
                case 2:
-                       *(u16 *)val = __raw_readw(ctx->regs + offset);
+                       *(u16 *)val = readw(ctx->regs + offset);
                        break;
                case 4:
-                       *(u32 *)val = __raw_readl(ctx->regs + offset);
+                       *(u32 *)val = readl(ctx->regs + offset);
                        break;
 #ifdef CONFIG_64BIT
                case 8:
-                       *(u64 *)val = __raw_readq(ctx->regs + offset);
+                       *(u64 *)val = readq(ctx->regs + offset);
                        break;
 #endif
                default:
index 9e25120..84708a5 100644 (file)
@@ -866,7 +866,7 @@ static void set_fdc(int drive)
 }
 
 /* locks the driver */
-static int lock_fdc(int drive, bool interruptible)
+static int lock_fdc(int drive)
 {
        if (WARN(atomic_read(&usage_count) == 0,
                 "Trying to lock fdc while usage count=0\n"))
@@ -2173,7 +2173,7 @@ static int do_format(int drive, struct format_descr *tmp_format_req)
 {
        int ret;
 
-       if (lock_fdc(drive, true))
+       if (lock_fdc(drive))
                return -EINTR;
 
        set_floppy(drive);
@@ -2960,7 +2960,7 @@ static int user_reset_fdc(int drive, int arg, bool interruptible)
 {
        int ret;
 
-       if (lock_fdc(drive, interruptible))
+       if (lock_fdc(drive))
                return -EINTR;
 
        if (arg == FD_RESET_ALWAYS)
@@ -3243,7 +3243,7 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g,
                if (!capable(CAP_SYS_ADMIN))
                        return -EPERM;
                mutex_lock(&open_lock);
-               if (lock_fdc(drive, true)) {
+               if (lock_fdc(drive)) {
                        mutex_unlock(&open_lock);
                        return -EINTR;
                }
@@ -3263,7 +3263,7 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g,
        } else {
                int oldStretch;
 
-               if (lock_fdc(drive, true))
+               if (lock_fdc(drive))
                        return -EINTR;
                if (cmd != FDDEFPRM) {
                        /* notice a disk change immediately, else
@@ -3349,7 +3349,7 @@ static int get_floppy_geometry(int drive, int type, struct floppy_struct **g)
        if (type)
                *g = &floppy_type[type];
        else {
-               if (lock_fdc(drive, false))
+               if (lock_fdc(drive))
                        return -EINTR;
                if (poll_drive(false, 0) == -EINTR)
                        return -EINTR;
@@ -3433,7 +3433,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
                if (UDRS->fd_ref != 1)
                        /* somebody else has this drive open */
                        return -EBUSY;
-               if (lock_fdc(drive, true))
+               if (lock_fdc(drive))
                        return -EINTR;
 
                /* do the actual eject. Fails on
@@ -3445,7 +3445,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
                process_fd_request();
                return ret;
        case FDCLRPRM:
-               if (lock_fdc(drive, true))
+               if (lock_fdc(drive))
                        return -EINTR;
                current_type[drive] = NULL;
                floppy_sizes[drive] = MAX_DISK_SIZE << 1;
@@ -3467,7 +3467,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
                UDP->flags &= ~FTD_MSG;
                return 0;
        case FDFMTBEG:
-               if (lock_fdc(drive, true))
+               if (lock_fdc(drive))
                        return -EINTR;
                if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
                        return -EINTR;
@@ -3484,7 +3484,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
                return do_format(drive, &inparam.f);
        case FDFMTEND:
        case FDFLUSH:
-               if (lock_fdc(drive, true))
+               if (lock_fdc(drive))
                        return -EINTR;
                return invalidate_drive(bdev);
        case FDSETEMSGTRESH:
@@ -3507,7 +3507,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
                outparam = UDP;
                break;
        case FDPOLLDRVSTAT:
-               if (lock_fdc(drive, true))
+               if (lock_fdc(drive))
                        return -EINTR;
                if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
                        return -EINTR;
@@ -3530,7 +3530,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
        case FDRAWCMD:
                if (type)
                        return -EINVAL;
-               if (lock_fdc(drive, true))
+               if (lock_fdc(drive))
                        return -EINTR;
                set_floppy(drive);
                i = raw_cmd_ioctl(cmd, (void __user *)param);
@@ -3539,7 +3539,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
                process_fd_request();
                return i;
        case FDTWADDLE:
-               if (lock_fdc(drive, true))
+               if (lock_fdc(drive))
                        return -EINTR;
                twaddle();
                process_fd_request();
@@ -3663,6 +3663,11 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
 
        opened_bdev[drive] = bdev;
 
+       if (!(mode & (FMODE_READ|FMODE_WRITE))) {
+               res = -EINVAL;
+               goto out;
+       }
+
        res = -ENXIO;
 
        if (!floppy_track_buffer) {
@@ -3706,21 +3711,20 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
        if (UFDCS->rawcmd == 1)
                UFDCS->rawcmd = 2;
 
-       if (!(mode & FMODE_NDELAY)) {
-               if (mode & (FMODE_READ|FMODE_WRITE)) {
-                       UDRS->last_checked = 0;
-                       clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
-                       check_disk_change(bdev);
-                       if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))
-                               goto out;
-                       if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
-                               goto out;
-               }
-               res = -EROFS;
-               if ((mode & FMODE_WRITE) &&
-                   !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags))
-                       goto out;
-       }
+       UDRS->last_checked = 0;
+       clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags);
+       check_disk_change(bdev);
+       if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags))
+               goto out;
+       if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags))
+               goto out;
+
+       res = -EROFS;
+
+       if ((mode & FMODE_WRITE) &&
+                       !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags))
+               goto out;
+
        mutex_unlock(&open_lock);
        mutex_unlock(&floppy_mutex);
        return 0;
@@ -3748,7 +3752,8 @@ static unsigned int floppy_check_events(struct gendisk *disk,
                return DISK_EVENT_MEDIA_CHANGE;
 
        if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) {
-               lock_fdc(drive, false);
+               if (lock_fdc(drive))
+                       return -EINTR;
                poll_drive(false, 0);
                process_fd_request();
        }
@@ -3847,7 +3852,9 @@ static int floppy_revalidate(struct gendisk *disk)
                         "VFS: revalidate called on non-open device.\n"))
                        return -EFAULT;
 
-               lock_fdc(drive, false);
+               res = lock_fdc(drive);
+               if (res)
+                       return res;
                cf = (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) ||
                      test_bit(FD_VERIFY_BIT, &UDRS->flags));
                if (!(cf || test_bit(drive, &fake_change) || drive_no_geom(drive))) {
index 8ba1e97..64a7b59 100644 (file)
@@ -478,7 +478,7 @@ static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id)
        id->ver_id = 0x1;
        id->vmnt = 0;
        id->cgrps = 1;
-       id->cap = 0x3;
+       id->cap = 0x2;
        id->dom = 0x1;
 
        id->ppaf.blk_offset = 0;
@@ -707,9 +707,7 @@ static int null_add_dev(void)
        queue_flag_set_unlocked(QUEUE_FLAG_NONROT, nullb->q);
        queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, nullb->q);
 
-
        mutex_lock(&lock);
-       list_add_tail(&nullb->list, &nullb_list);
        nullb->index = nullb_indexes++;
        mutex_unlock(&lock);
 
@@ -743,6 +741,10 @@ static int null_add_dev(void)
        strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
 
        add_disk(disk);
+
+       mutex_lock(&lock);
+       list_add_tail(&nullb->list, &nullb_list);
+       mutex_unlock(&lock);
 done:
        return 0;
 
index 8a8dc91..83eb9e6 100644 (file)
@@ -1873,6 +1873,43 @@ again:
        return err;
 }
 
+static int negotiate_mq(struct blkfront_info *info)
+{
+       unsigned int backend_max_queues = 0;
+       int err;
+       unsigned int i;
+
+       BUG_ON(info->nr_rings);
+
+       /* Check if backend supports multiple queues. */
+       err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
+                          "multi-queue-max-queues", "%u", &backend_max_queues);
+       if (err < 0)
+               backend_max_queues = 1;
+
+       info->nr_rings = min(backend_max_queues, xen_blkif_max_queues);
+       /* We need at least one ring. */
+       if (!info->nr_rings)
+               info->nr_rings = 1;
+
+       info->rinfo = kzalloc(sizeof(struct blkfront_ring_info) * info->nr_rings, GFP_KERNEL);
+       if (!info->rinfo) {
+               xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure");
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < info->nr_rings; i++) {
+               struct blkfront_ring_info *rinfo;
+
+               rinfo = &info->rinfo[i];
+               INIT_LIST_HEAD(&rinfo->indirect_pages);
+               INIT_LIST_HEAD(&rinfo->grants);
+               rinfo->dev_info = info;
+               INIT_WORK(&rinfo->work, blkif_restart_queue);
+               spin_lock_init(&rinfo->ring_lock);
+       }
+       return 0;
+}
 /**
  * Entry point to this code when a new device is created.  Allocate the basic
  * structures and the ring buffer for communication with the backend, and
@@ -1883,9 +1920,7 @@ static int blkfront_probe(struct xenbus_device *dev,
                          const struct xenbus_device_id *id)
 {
        int err, vdevice;
-       unsigned int r_index;
        struct blkfront_info *info;
-       unsigned int backend_max_queues = 0;
 
        /* FIXME: Use dynamic device id if this is not set. */
        err = xenbus_scanf(XBT_NIL, dev->nodename,
@@ -1936,33 +1971,10 @@ static int blkfront_probe(struct xenbus_device *dev,
        }
 
        info->xbdev = dev;
-       /* Check if backend supports multiple queues. */
-       err = xenbus_scanf(XBT_NIL, info->xbdev->otherend,
-                          "multi-queue-max-queues", "%u", &backend_max_queues);
-       if (err < 0)
-               backend_max_queues = 1;
-
-       info->nr_rings = min(backend_max_queues, xen_blkif_max_queues);
-       /* We need at least one ring. */
-       if (!info->nr_rings)
-               info->nr_rings = 1;
-
-       info->rinfo = kzalloc(sizeof(struct blkfront_ring_info) * info->nr_rings, GFP_KERNEL);
-       if (!info->rinfo) {
-               xenbus_dev_fatal(dev, -ENOMEM, "allocating ring_info structure");
+       err = negotiate_mq(info);
+       if (err) {
                kfree(info);
-               return -ENOMEM;
-       }
-
-       for (r_index = 0; r_index < info->nr_rings; r_index++) {
-               struct blkfront_ring_info *rinfo;
-
-               rinfo = &info->rinfo[r_index];
-               INIT_LIST_HEAD(&rinfo->indirect_pages);
-               INIT_LIST_HEAD(&rinfo->grants);
-               rinfo->dev_info = info;
-               INIT_WORK(&rinfo->work, blkif_restart_queue);
-               spin_lock_init(&rinfo->ring_lock);
+               return err;
        }
 
        mutex_init(&info->mutex);
@@ -2123,12 +2135,16 @@ static int blkif_recover(struct blkfront_info *info)
 static int blkfront_resume(struct xenbus_device *dev)
 {
        struct blkfront_info *info = dev_get_drvdata(&dev->dev);
-       int err;
+       int err = 0;
 
        dev_dbg(&dev->dev, "blkfront_resume: %s\n", dev->nodename);
 
        blkif_free(info, info->connected == BLKIF_STATE_CONNECTED);
 
+       err = negotiate_mq(info);
+       if (err)
+               return err;
+
        err = talk_to_blkback(dev, info);
 
        /*
index 1341a94..aef87fd 100644 (file)
@@ -555,8 +555,10 @@ static unsigned int intel_gtt_mappable_entries(void)
 static void intel_gtt_teardown_scratch_page(void)
 {
        set_pages_wb(intel_private.scratch_page, 1);
-       pci_unmap_page(intel_private.pcidev, intel_private.scratch_page_dma,
-                      PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
+       if (intel_private.needs_dmar)
+               pci_unmap_page(intel_private.pcidev,
+                              intel_private.scratch_page_dma,
+                              PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
        __free_page(intel_private.scratch_page);
 }
 
@@ -1346,16 +1348,6 @@ int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
 {
        int i, mask;
 
-       /*
-        * Can be called from the fake agp driver but also directly from
-        * drm/i915.ko. Hence we need to check whether everything is set up
-        * already.
-        */
-       if (intel_private.driver) {
-               intel_private.refcount++;
-               return 1;
-       }
-
        for (i = 0; intel_gtt_chipsets[i].name != NULL; i++) {
                if (gpu_pdev) {
                        if (gpu_pdev->device ==
@@ -1376,16 +1368,26 @@ int intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev,
        if (!intel_private.driver)
                return 0;
 
-       intel_private.refcount++;
-
 #if IS_ENABLED(CONFIG_AGP_INTEL)
        if (bridge) {
+               if (INTEL_GTT_GEN > 1)
+                       return 0;
+
                bridge->driver = &intel_fake_agp_driver;
                bridge->dev_private_data = &intel_private;
                bridge->dev = bridge_pdev;
        }
 #endif
 
+
+       /*
+        * Can be called from the fake agp driver but also directly from
+        * drm/i915.ko. Hence we need to check whether everything is set up
+        * already.
+        */
+       if (intel_private.refcount++)
+               return 1;
+
        intel_private.bridge_dev = pci_dev_get(bridge_pdev);
 
        dev_info(&bridge_pdev->dev, "Intel %s Chipset\n", intel_gtt_chipsets[i].name);
@@ -1430,6 +1432,8 @@ void intel_gmch_remove(void)
        if (--intel_private.refcount)
                return;
 
+       if (intel_private.scratch_page)
+               intel_gtt_teardown_scratch_page();
        if (intel_private.pcidev)
                pci_dev_put(intel_private.pcidev);
        if (intel_private.bridge_dev)
index 240b6cf..be54e53 100644 (file)
@@ -42,7 +42,7 @@
 /*
  * The High Precision Event Timer driver.
  * This driver is closely modelled after the rtc.c driver.
- * http://www.intel.com/hardwaredesign/hpetspec_1.pdf
+ * See HPET spec revision 1.
  */
 #define        HPET_USER_FREQ  (64)
 #define        HPET_DRIFT      (500)
index d0da5d8..b583e53 100644 (file)
@@ -1819,6 +1819,28 @@ unsigned int get_random_int(void)
 EXPORT_SYMBOL(get_random_int);
 
 /*
+ * Same as get_random_int(), but returns unsigned long.
+ */
+unsigned long get_random_long(void)
+{
+       __u32 *hash;
+       unsigned long ret;
+
+       if (arch_get_random_long(&ret))
+               return ret;
+
+       hash = get_cpu_var(get_random_int_hash);
+
+       hash[0] += current->pid + jiffies + random_get_entropy();
+       md5_transform(hash, random_int_secret);
+       ret = *(unsigned long *)hash;
+       put_cpu_var(get_random_int_hash);
+
+       return ret;
+}
+EXPORT_SYMBOL(get_random_long);
+
+/*
  * randomize_range() returns a start address such that
  *
  *    [...... <range> .....]
index b038e36..bae4be6 100644 (file)
@@ -43,7 +43,7 @@ obj-$(CONFIG_COMMON_CLK_SI514)                += clk-si514.o
 obj-$(CONFIG_COMMON_CLK_SI570)         += clk-si570.o
 obj-$(CONFIG_COMMON_CLK_CDCE925)       += clk-cdce925.o
 obj-$(CONFIG_ARCH_STM32)               += clk-stm32f4.o
-obj-$(CONFIG_ARCH_TANGOX)              += clk-tango4.o
+obj-$(CONFIG_ARCH_TANGO              += clk-tango4.o
 obj-$(CONFIG_CLK_TWL6040)              += clk-twl6040.o
 obj-$(CONFIG_ARCH_U300)                        += clk-u300.o
 obj-$(CONFIG_ARCH_VT8500)              += clk-vt8500.o
index 19fed65..7b09a26 100644 (file)
@@ -289,7 +289,7 @@ static void __init of_gpio_clk_setup(struct device_node *node,
 
        num_parents = of_clk_get_parent_count(node);
        if (num_parents < 0)
-               return;
+               num_parents = 0;
 
        data = kzalloc(sizeof(*data), GFP_KERNEL);
        if (!data)
index cd0f272..89e9ca7 100644 (file)
@@ -299,7 +299,7 @@ static int scpi_clocks_probe(struct platform_device *pdev)
        /* Add the virtual cpufreq device */
        cpufreq_dev = platform_device_register_simple("scpi-cpufreq",
                                                      -1, NULL, 0);
-       if (!cpufreq_dev)
+       if (IS_ERR(cpufreq_dev))
                pr_warn("unable to register cpufreq device");
 
        return 0;
index d5c5bfa..3e0b52d 100644 (file)
@@ -247,7 +247,7 @@ static struct clk_onecell_data dove_divider_data = {
 
 void __init dove_divider_clk_init(struct device_node *np)
 {
-       void *base;
+       void __iomem *base;
 
        base = of_iomap(np, 0);
        if (WARN_ON(!base))
index cf73e53..070037a 100644 (file)
@@ -3587,7 +3587,6 @@ static const struct regmap_config gcc_apq8084_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x1fc0,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc gcc_apq8084_desc = {
index b692ae8..dd5402b 100644 (file)
@@ -3005,7 +3005,6 @@ static const struct regmap_config gcc_ipq806x_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x3e40,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc gcc_ipq806x_desc = {
index f6a2b14..ad41303 100644 (file)
@@ -2702,7 +2702,6 @@ static const struct regmap_config gcc_msm8660_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x363c,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc gcc_msm8660_desc = {
index e3bf09d..8cc9b28 100644 (file)
@@ -3336,7 +3336,6 @@ static const struct regmap_config gcc_msm8916_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x80000,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc gcc_msm8916_desc = {
index f31111e..983dd7d 100644 (file)
@@ -3468,7 +3468,6 @@ static const struct regmap_config gcc_msm8960_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x3660,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct regmap_config gcc_apq8064_regmap_config = {
@@ -3477,7 +3476,6 @@ static const struct regmap_config gcc_apq8064_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x3880,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc gcc_msm8960_desc = {
index df164d6..335952d 100644 (file)
@@ -2680,7 +2680,6 @@ static const struct regmap_config gcc_msm8974_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x1fc0,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc gcc_msm8974_desc = {
index 62e79fa..db3998e 100644 (file)
@@ -419,7 +419,6 @@ static const struct regmap_config lcc_ipq806x_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0xfc,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc lcc_ipq806x_desc = {
index bf95bb0..4fcf9d1 100644 (file)
@@ -524,7 +524,6 @@ static const struct regmap_config lcc_msm8960_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0xfc,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc lcc_msm8960_desc = {
index 1e703fd..30777f9 100644 (file)
@@ -3368,7 +3368,6 @@ static const struct regmap_config mmcc_apq8084_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x5104,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc mmcc_apq8084_desc = {
index d73a048..00e3619 100644 (file)
@@ -3029,7 +3029,6 @@ static const struct regmap_config mmcc_msm8960_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x334,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct regmap_config mmcc_apq8064_regmap_config = {
@@ -3038,7 +3037,6 @@ static const struct regmap_config mmcc_apq8064_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x350,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc mmcc_msm8960_desc = {
index bbe28ed..9d790bc 100644 (file)
@@ -2594,7 +2594,6 @@ static const struct regmap_config mmcc_msm8974_regmap_config = {
        .val_bits       = 32,
        .max_register   = 0x5104,
        .fast_io        = true,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static const struct qcom_cc_desc mmcc_msm8974_desc = {
index ebce980..bc7fbac 100644 (file)
@@ -133,7 +133,7 @@ PNAME(mux_spdif_p)  = { "spdif_src", "spdif_frac", "xin12m" };
 PNAME(mux_uart0_p)     = { "uart0_src", "uart0_frac", "xin24m" };
 PNAME(mux_uart1_p)     = { "uart1_src", "uart1_frac", "xin24m" };
 PNAME(mux_uart2_p)     = { "uart2_src", "uart2_frac", "xin24m" };
-PNAME(mux_mac_p)       = { "mac_pll_src", "ext_gmac" };
+PNAME(mux_mac_p)       = { "mac_pll_src", "rmii_clkin" };
 PNAME(mux_dclk_p)      = { "dclk_lcdc", "dclk_cru" };
 
 static struct rockchip_pll_clock rk3036_pll_clks[] __initdata = {
@@ -224,16 +224,16 @@ static struct rockchip_clk_branch rk3036_clk_branches[] __initdata = {
                        RK2928_CLKGATE_CON(2), 2, GFLAGS),
 
        COMPOSITE_NODIV(SCLK_TIMER0, "sclk_timer0", mux_timer_p, CLK_IGNORE_UNUSED,
-                       RK2928_CLKSEL_CON(2), 4, 1, DFLAGS,
+                       RK2928_CLKSEL_CON(2), 4, 1, MFLAGS,
                        RK2928_CLKGATE_CON(1), 0, GFLAGS),
        COMPOSITE_NODIV(SCLK_TIMER1, "sclk_timer1", mux_timer_p, CLK_IGNORE_UNUSED,
-                       RK2928_CLKSEL_CON(2), 5, 1, DFLAGS,
+                       RK2928_CLKSEL_CON(2), 5, 1, MFLAGS,
                        RK2928_CLKGATE_CON(1), 1, GFLAGS),
        COMPOSITE_NODIV(SCLK_TIMER2, "sclk_timer2", mux_timer_p, CLK_IGNORE_UNUSED,
-                       RK2928_CLKSEL_CON(2), 6, 1, DFLAGS,
+                       RK2928_CLKSEL_CON(2), 6, 1, MFLAGS,
                        RK2928_CLKGATE_CON(2), 4, GFLAGS),
        COMPOSITE_NODIV(SCLK_TIMER3, "sclk_timer3", mux_timer_p, CLK_IGNORE_UNUSED,
-                       RK2928_CLKSEL_CON(2), 7, 1, DFLAGS,
+                       RK2928_CLKSEL_CON(2), 7, 1, MFLAGS,
                        RK2928_CLKGATE_CON(2), 5, GFLAGS),
 
        MUX(0, "uart_pll_clk", mux_pll_src_apll_dpll_gpll_usb480m_p, 0,
@@ -242,11 +242,11 @@ static struct rockchip_clk_branch rk3036_clk_branches[] __initdata = {
                        RK2928_CLKSEL_CON(13), 0, 7, DFLAGS,
                        RK2928_CLKGATE_CON(1), 8, GFLAGS),
        COMPOSITE_NOMUX(0, "uart1_src", "uart_pll_clk", 0,
-                       RK2928_CLKSEL_CON(13), 0, 7, DFLAGS,
-                       RK2928_CLKGATE_CON(1), 8, GFLAGS),
+                       RK2928_CLKSEL_CON(14), 0, 7, DFLAGS,
+                       RK2928_CLKGATE_CON(1), 10, GFLAGS),
        COMPOSITE_NOMUX(0, "uart2_src", "uart_pll_clk", 0,
-                       RK2928_CLKSEL_CON(13), 0, 7, DFLAGS,
-                       RK2928_CLKGATE_CON(1), 8, GFLAGS),
+                       RK2928_CLKSEL_CON(15), 0, 7, DFLAGS,
+                       RK2928_CLKGATE_CON(1), 12, GFLAGS),
        COMPOSITE_FRACMUX(0, "uart0_frac", "uart0_src", CLK_SET_RATE_PARENT,
                        RK2928_CLKSEL_CON(17), 0,
                        RK2928_CLKGATE_CON(1), 9, GFLAGS,
@@ -279,13 +279,13 @@ static struct rockchip_clk_branch rk3036_clk_branches[] __initdata = {
                        RK2928_CLKGATE_CON(3), 2, GFLAGS),
 
        COMPOSITE_NODIV(0, "sclk_sdmmc_src", mux_mmc_src_p, 0,
-                       RK2928_CLKSEL_CON(12), 8, 2, DFLAGS,
+                       RK2928_CLKSEL_CON(12), 8, 2, MFLAGS,
                        RK2928_CLKGATE_CON(2), 11, GFLAGS),
        DIV(SCLK_SDMMC, "sclk_sdmmc", "sclk_sdmmc_src", 0,
                        RK2928_CLKSEL_CON(11), 0, 7, DFLAGS),
 
        COMPOSITE_NODIV(0, "sclk_sdio_src", mux_mmc_src_p, 0,
-                       RK2928_CLKSEL_CON(12), 10, 2, DFLAGS,
+                       RK2928_CLKSEL_CON(12), 10, 2, MFLAGS,
                        RK2928_CLKGATE_CON(2), 13, GFLAGS),
        DIV(SCLK_SDIO, "sclk_sdio", "sclk_sdio_src", 0,
                        RK2928_CLKSEL_CON(11), 8, 7, DFLAGS),
@@ -344,12 +344,12 @@ static struct rockchip_clk_branch rk3036_clk_branches[] __initdata = {
                        RK2928_CLKGATE_CON(10), 5, GFLAGS),
 
        COMPOSITE_NOGATE(0, "mac_pll_src", mux_pll_src_3plls_p, 0,
-                       RK2928_CLKSEL_CON(21), 0, 2, MFLAGS, 4, 5, DFLAGS),
+                       RK2928_CLKSEL_CON(21), 0, 2, MFLAGS, 9, 5, DFLAGS),
        MUX(SCLK_MACREF, "mac_clk_ref", mux_mac_p, CLK_SET_RATE_PARENT,
                        RK2928_CLKSEL_CON(21), 3, 1, MFLAGS),
 
        COMPOSITE_NOMUX(SCLK_MAC, "mac_clk", "mac_clk_ref", 0,
-                       RK2928_CLKSEL_CON(21), 9, 5, DFLAGS,
+                       RK2928_CLKSEL_CON(21), 4, 5, DFLAGS,
                        RK2928_CLKGATE_CON(2), 6, GFLAGS),
 
        MUX(SCLK_HDMI, "dclk_hdmi", mux_dclk_p, 0,
index be0ede5..21f3ea9 100644 (file)
@@ -780,13 +780,13 @@ static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = {
        GATE(PCLK_TSADC, "pclk_tsadc", "pclk_peri", 0, RK3368_CLKGATE_CON(20), 0, GFLAGS),
 
        /* pclk_pd_alive gates */
-       GATE(PCLK_TIMER1, "pclk_timer1", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(14), 8, GFLAGS),
-       GATE(PCLK_TIMER0, "pclk_timer0", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(14), 7, GFLAGS),
-       GATE(0, "pclk_alive_niu", "pclk_pd_alive", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(14), 12, GFLAGS),
-       GATE(PCLK_GRF, "pclk_grf", "pclk_pd_alive", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(14), 11, GFLAGS),
-       GATE(PCLK_GPIO3, "pclk_gpio3", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(14), 3, GFLAGS),
-       GATE(PCLK_GPIO2, "pclk_gpio2", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(14), 2, GFLAGS),
-       GATE(PCLK_GPIO1, "pclk_gpio1", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(14), 1, GFLAGS),
+       GATE(PCLK_TIMER1, "pclk_timer1", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(22), 13, GFLAGS),
+       GATE(PCLK_TIMER0, "pclk_timer0", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(22), 12, GFLAGS),
+       GATE(0, "pclk_alive_niu", "pclk_pd_alive", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(22), 9, GFLAGS),
+       GATE(PCLK_GRF, "pclk_grf", "pclk_pd_alive", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(22), 8, GFLAGS),
+       GATE(PCLK_GPIO3, "pclk_gpio3", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(22), 3, GFLAGS),
+       GATE(PCLK_GPIO2, "pclk_gpio2", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(22), 2, GFLAGS),
+       GATE(PCLK_GPIO1, "pclk_gpio1", "pclk_pd_alive", 0, RK3368_CLKGATE_CON(22), 1, GFLAGS),
 
        /*
         * pclk_vio gates
@@ -796,12 +796,12 @@ static struct rockchip_clk_branch rk3368_clk_branches[] __initdata = {
        GATE(0, "pclk_dphytx", "hclk_vio", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(14), 8, GFLAGS),
 
        /* pclk_pd_pmu gates */
-       GATE(PCLK_PMUGRF, "pclk_pmugrf", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(17), 0, GFLAGS),
-       GATE(PCLK_GPIO0, "pclk_gpio0", "pclk_pd_pmu", 0, RK3368_CLKGATE_CON(17), 4, GFLAGS),
-       GATE(PCLK_SGRF, "pclk_sgrf", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(17), 3, GFLAGS),
-       GATE(0, "pclk_pmu_noc", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(17), 2, GFLAGS),
-       GATE(0, "pclk_intmem1", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(17), 1, GFLAGS),
-       GATE(PCLK_PMU, "pclk_pmu", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(17), 2, GFLAGS),
+       GATE(PCLK_PMUGRF, "pclk_pmugrf", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(23), 5, GFLAGS),
+       GATE(PCLK_GPIO0, "pclk_gpio0", "pclk_pd_pmu", 0, RK3368_CLKGATE_CON(23), 4, GFLAGS),
+       GATE(PCLK_SGRF, "pclk_sgrf", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(23), 3, GFLAGS),
+       GATE(0, "pclk_pmu_noc", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(23), 2, GFLAGS),
+       GATE(0, "pclk_intmem1", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(23), 1, GFLAGS),
+       GATE(PCLK_PMU, "pclk_pmu", "pclk_pd_pmu", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(23), 0, GFLAGS),
 
        /* timer gates */
        GATE(0, "sclk_timer15", "xin24m", CLK_IGNORE_UNUSED, RK3368_CLKGATE_CON(24), 11, GFLAGS),
index e1fe8f3..74e7544 100644 (file)
@@ -450,8 +450,10 @@ static int load_timings_from_dt(struct tegra_clk_emc *tegra,
                struct emc_timing *timing = tegra->timings + (i++);
 
                err = load_one_timing_from_dt(tegra, timing, child);
-               if (err)
+               if (err) {
+                       of_node_put(child);
                        return err;
+               }
 
                timing->ram_code = ram_code;
        }
@@ -499,9 +501,9 @@ struct clk *tegra_clk_register_emc(void __iomem *base, struct device_node *np,
                 * fuses until the apbmisc driver is loaded.
                 */
                err = load_timings_from_dt(tegra, node, node_ram_code);
+               of_node_put(node);
                if (err)
                        return ERR_PTR(err);
-               of_node_put(node);
                break;
        }
 
index 19ce073..62ea381 100644 (file)
@@ -11,6 +11,7 @@ enum clk_id {
        tegra_clk_afi,
        tegra_clk_amx,
        tegra_clk_amx1,
+       tegra_clk_apb2ape,
        tegra_clk_apbdma,
        tegra_clk_apbif,
        tegra_clk_ape,
index a534bfa..6ac3f84 100644 (file)
 #define PLLE_SS_DISABLE (PLLE_SS_CNTL_BYPASS_SS | PLLE_SS_CNTL_INTERP_RESET |\
                                PLLE_SS_CNTL_SSC_BYP)
 #define PLLE_SS_MAX_MASK 0x1ff
-#define PLLE_SS_MAX_VAL 0x25
+#define PLLE_SS_MAX_VAL_TEGRA114 0x25
+#define PLLE_SS_MAX_VAL_TEGRA210 0x21
 #define PLLE_SS_INC_MASK (0xff << 16)
 #define PLLE_SS_INC_VAL (0x1 << 16)
 #define PLLE_SS_INCINTRV_MASK (0x3f << 24)
-#define PLLE_SS_INCINTRV_VAL (0x20 << 24)
+#define PLLE_SS_INCINTRV_VAL_TEGRA114 (0x20 << 24)
+#define PLLE_SS_INCINTRV_VAL_TEGRA210 (0x23 << 24)
 #define PLLE_SS_COEFFICIENTS_MASK \
        (PLLE_SS_MAX_MASK | PLLE_SS_INC_MASK | PLLE_SS_INCINTRV_MASK)
-#define PLLE_SS_COEFFICIENTS_VAL \
-       (PLLE_SS_MAX_VAL | PLLE_SS_INC_VAL | PLLE_SS_INCINTRV_VAL)
+#define PLLE_SS_COEFFICIENTS_VAL_TEGRA114 \
+       (PLLE_SS_MAX_VAL_TEGRA114 | PLLE_SS_INC_VAL |\
+        PLLE_SS_INCINTRV_VAL_TEGRA114)
+#define PLLE_SS_COEFFICIENTS_VAL_TEGRA210 \
+       (PLLE_SS_MAX_VAL_TEGRA210 | PLLE_SS_INC_VAL |\
+        PLLE_SS_INCINTRV_VAL_TEGRA210)
 
 #define PLLE_AUX_PLLP_SEL      BIT(2)
 #define PLLE_AUX_USE_LOCKDET   BIT(3)
@@ -880,7 +886,7 @@ static int clk_plle_training(struct tegra_clk_pll *pll)
 static int clk_plle_enable(struct clk_hw *hw)
 {
        struct tegra_clk_pll *pll = to_clk_pll(hw);
-       unsigned long input_rate = clk_get_rate(clk_get_parent(hw->clk));
+       unsigned long input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
        struct tegra_clk_pll_freq_table sel;
        u32 val;
        int err;
@@ -1378,7 +1384,7 @@ static int clk_plle_tegra114_enable(struct clk_hw *hw)
        u32 val;
        int ret;
        unsigned long flags = 0;
-       unsigned long input_rate = clk_get_rate(clk_get_parent(hw->clk));
+       unsigned long input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
 
        if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate))
                return -EINVAL;
@@ -1401,7 +1407,7 @@ static int clk_plle_tegra114_enable(struct clk_hw *hw)
        val |= PLLE_MISC_IDDQ_SW_CTRL;
        val &= ~PLLE_MISC_IDDQ_SW_VALUE;
        val |= PLLE_MISC_PLLE_PTS;
-       val |= PLLE_MISC_VREG_BG_CTRL_MASK | PLLE_MISC_VREG_CTRL_MASK;
+       val &= ~(PLLE_MISC_VREG_BG_CTRL_MASK | PLLE_MISC_VREG_CTRL_MASK);
        pll_writel_misc(val, pll);
        udelay(5);
 
@@ -1428,7 +1434,7 @@ static int clk_plle_tegra114_enable(struct clk_hw *hw)
        val = pll_readl(PLLE_SS_CTRL, pll);
        val &= ~(PLLE_SS_CNTL_CENTER | PLLE_SS_CNTL_INVERT);
        val &= ~PLLE_SS_COEFFICIENTS_MASK;
-       val |= PLLE_SS_COEFFICIENTS_VAL;
+       val |= PLLE_SS_COEFFICIENTS_VAL_TEGRA114;
        pll_writel(val, PLLE_SS_CTRL, pll);
        val &= ~(PLLE_SS_CNTL_SSC_BYP | PLLE_SS_CNTL_BYPASS_SS);
        pll_writel(val, PLLE_SS_CTRL, pll);
@@ -2012,9 +2018,9 @@ static int clk_plle_tegra210_enable(struct clk_hw *hw)
        struct tegra_clk_pll *pll = to_clk_pll(hw);
        struct tegra_clk_pll_freq_table sel;
        u32 val;
-       int ret;
+       int ret = 0;
        unsigned long flags = 0;
-       unsigned long input_rate = clk_get_rate(clk_get_parent(hw->clk));
+       unsigned long input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
 
        if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate))
                return -EINVAL;
@@ -2022,22 +2028,20 @@ static int clk_plle_tegra210_enable(struct clk_hw *hw)
        if (pll->lock)
                spin_lock_irqsave(pll->lock, flags);
 
+       val = pll_readl(pll->params->aux_reg, pll);
+       if (val & PLLE_AUX_SEQ_ENABLE)
+               goto out;
+
        val = pll_readl_base(pll);
        val &= ~BIT(30); /* Disable lock override */
        pll_writel_base(val, pll);
 
-       val = pll_readl(pll->params->aux_reg, pll);
-       val |= PLLE_AUX_ENABLE_SWCTL;
-       val &= ~PLLE_AUX_SEQ_ENABLE;
-       pll_writel(val, pll->params->aux_reg, pll);
-       udelay(1);
-
        val = pll_readl_misc(pll);
        val |= PLLE_MISC_LOCK_ENABLE;
        val |= PLLE_MISC_IDDQ_SW_CTRL;
        val &= ~PLLE_MISC_IDDQ_SW_VALUE;
        val |= PLLE_MISC_PLLE_PTS;
-       val |= PLLE_MISC_VREG_BG_CTRL_MASK | PLLE_MISC_VREG_CTRL_MASK;
+       val &= ~(PLLE_MISC_VREG_BG_CTRL_MASK | PLLE_MISC_VREG_CTRL_MASK);
        pll_writel_misc(val, pll);
        udelay(5);
 
@@ -2067,7 +2071,7 @@ static int clk_plle_tegra210_enable(struct clk_hw *hw)
        val = pll_readl(PLLE_SS_CTRL, pll);
        val &= ~(PLLE_SS_CNTL_CENTER | PLLE_SS_CNTL_INVERT);
        val &= ~PLLE_SS_COEFFICIENTS_MASK;
-       val |= PLLE_SS_COEFFICIENTS_VAL;
+       val |= PLLE_SS_COEFFICIENTS_VAL_TEGRA210;
        pll_writel(val, PLLE_SS_CTRL, pll);
        val &= ~(PLLE_SS_CNTL_SSC_BYP | PLLE_SS_CNTL_BYPASS_SS);
        pll_writel(val, PLLE_SS_CTRL, pll);
@@ -2104,15 +2108,25 @@ static void clk_plle_tegra210_disable(struct clk_hw *hw)
        if (pll->lock)
                spin_lock_irqsave(pll->lock, flags);
 
+       /* If PLLE HW sequencer is enabled, SW should not disable PLLE */
+       val = pll_readl(pll->params->aux_reg, pll);
+       if (val & PLLE_AUX_SEQ_ENABLE)
+               goto out;
+
        val = pll_readl_base(pll);
        val &= ~PLLE_BASE_ENABLE;
        pll_writel_base(val, pll);
 
+       val = pll_readl(pll->params->aux_reg, pll);
+       val |= PLLE_AUX_ENABLE_SWCTL | PLLE_AUX_SS_SWCTL;
+       pll_writel(val, pll->params->aux_reg, pll);
+
        val = pll_readl_misc(pll);
        val |= PLLE_MISC_IDDQ_SW_CTRL | PLLE_MISC_IDDQ_SW_VALUE;
        pll_writel_misc(val, pll);
        udelay(1);
 
+out:
        if (pll->lock)
                spin_unlock_irqrestore(pll->lock, flags);
 }
index 6ad381a..ea2b9cb 100644 (file)
@@ -773,7 +773,7 @@ static struct tegra_periph_init_data periph_clks[] = {
        XUSB("xusb_dev_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_DEV_SRC, 95, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_dev_src),
        XUSB("xusb_dev_src", mux_clkm_pllp_pllre, CLK_SOURCE_XUSB_DEV_SRC, 95, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_dev_src_8),
        MUX8("dbgapb", mux_pllp_clkm_2, CLK_SOURCE_DBGAPB, 185, TEGRA_PERIPH_NO_RESET, tegra_clk_dbgapb),
-       MUX8("msenc", mux_pllc2_c_c3_pllp_plla1_clkm, CLK_SOURCE_NVENC, 219, 0, tegra_clk_nvenc),
+       MUX8("nvenc", mux_pllc2_c_c3_pllp_plla1_clkm, CLK_SOURCE_NVENC, 219, 0, tegra_clk_nvenc),
        MUX8("nvdec", mux_pllc2_c_c3_pllp_plla1_clkm, CLK_SOURCE_NVDEC, 194, 0, tegra_clk_nvdec),
        MUX8("nvjpg", mux_pllc2_c_c3_pllp_plla1_clkm, CLK_SOURCE_NVJPG, 195, 0, tegra_clk_nvjpg),
        MUX8("ape", mux_plla_pllc4_out0_pllc_pllc4_out1_pllp_pllc4_out2_clkm, CLK_SOURCE_APE, 198, TEGRA_PERIPH_ON_APB, tegra_clk_ape),
@@ -782,7 +782,7 @@ static struct tegra_periph_init_data periph_clks[] = {
        NODIV("sor1", mux_clkm_sor1_brick_sor1_src, CLK_SOURCE_SOR1, 15, MASK(1), 183, 0, tegra_clk_sor1, &sor1_lock),
        MUX8("sdmmc_legacy", mux_pllp_out3_clkm_pllp_pllc4, CLK_SOURCE_SDMMC_LEGACY, 193, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_sdmmc_legacy),
        MUX8("qspi", mux_pllp_pllc_pllc_out1_pllc4_out2_pllc4_out1_clkm_pllc4_out0, CLK_SOURCE_QSPI, 211, TEGRA_PERIPH_ON_APB, tegra_clk_qspi),
-       MUX("vii2c", mux_pllp_pllc_clkm, CLK_SOURCE_VI_I2C, 208, TEGRA_PERIPH_ON_APB, tegra_clk_vi_i2c),
+       I2C("vii2c", mux_pllp_pllc_clkm, CLK_SOURCE_VI_I2C, 208, tegra_clk_vi_i2c),
        MUX("mipibif", mux_pllp_clkm, CLK_SOURCE_MIPIBIF, 173, TEGRA_PERIPH_ON_APB, tegra_clk_mipibif),
        MUX("uartape", mux_pllp_pllc_clkm, CLK_SOURCE_UARTAPE, 212, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_uartape),
        MUX8("tsecb", mux_pllp_pllc2_c_c3_clkm, CLK_SOURCE_TSECB, 206, 0, tegra_clk_tsecb),
@@ -829,6 +829,7 @@ static struct tegra_periph_init_data gate_clks[] = {
        GATE("xusb_gate", "osc", 143, 0, tegra_clk_xusb_gate, 0),
        GATE("pll_p_out_cpu", "pll_p", 223, 0, tegra_clk_pll_p_out_cpu, 0),
        GATE("pll_p_out_adsp", "pll_p", 187, 0, tegra_clk_pll_p_out_adsp, 0),
+       GATE("apb2ape", "clk_m", 107, 0, tegra_clk_apb2ape, 0),
 };
 
 static struct tegra_periph_init_data div_clks[] = {
index 4559a20..474de0f 100644 (file)
@@ -67,7 +67,7 @@ static const char *cclk_lp_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
                                         "pll_p", "pll_p_out4", "unused",
                                         "unused", "pll_x", "pll_x_out0" };
 
-const struct tegra_super_gen_info tegra_super_gen_info_gen4 = {
+static const struct tegra_super_gen_info tegra_super_gen_info_gen4 = {
        .gen = gen4,
        .sclk_parents = sclk_parents,
        .cclk_g_parents = cclk_g_parents,
@@ -93,7 +93,7 @@ static const char *cclk_lp_parents_gen5[] = { "clk_m", "unused", "clk_32k", "unu
                                        "unused", "unused", "unused", "unused",
                                        "dfllCPU_out" };
 
-const struct tegra_super_gen_info tegra_super_gen_info_gen5 = {
+static const struct tegra_super_gen_info tegra_super_gen_info_gen5 = {
        .gen = gen5,
        .sclk_parents = sclk_parents_gen5,
        .cclk_g_parents = cclk_g_parents_gen5,
@@ -171,7 +171,7 @@ static void __init tegra_sclk_init(void __iomem *clk_base,
        *dt_clk = clk;
 }
 
-void __init tegra_super_clk_init(void __iomem *clk_base,
+static void __init tegra_super_clk_init(void __iomem *clk_base,
                                void __iomem *pmc_base,
                                struct tegra_clk *tegra_clks,
                                struct tegra_clk_pll_params *params,
index 58514c4..637041f 100644 (file)
@@ -59,8 +59,8 @@
 #define PLLC3_MISC3 0x50c
 
 #define PLLM_BASE 0x90
-#define PLLM_MISC0 0x9c
 #define PLLM_MISC1 0x98
+#define PLLM_MISC2 0x9c
 #define PLLP_BASE 0xa0
 #define PLLP_MISC0 0xac
 #define PLLP_MISC1 0x680
@@ -99,7 +99,7 @@
 #define PLLC4_MISC0 0x5a8
 #define PLLC4_OUT 0x5e4
 #define PLLMB_BASE 0x5e8
-#define PLLMB_MISC0 0x5ec
+#define PLLMB_MISC1 0x5ec
 #define PLLA1_BASE 0x6a4
 #define PLLA1_MISC0 0x6a8
 #define PLLA1_MISC1 0x6ac
@@ -243,7 +243,8 @@ static unsigned long tegra210_input_freq[] = {
 };
 
 static const char *mux_pllmcp_clkm[] = {
-       "pll_m", "pll_c", "pll_p", "clk_m", "pll_m_ud", "pll_c2", "pll_c3",
+       "pll_m", "pll_c", "pll_p", "clk_m", "pll_m_ud", "pll_mb", "pll_mb",
+       "pll_p",
 };
 #define mux_pllmcp_clkm_idx NULL
 
@@ -367,12 +368,12 @@ static const char *mux_pllmcp_clkm[] = {
 /* PLLMB */
 #define PLLMB_BASE_LOCK                        (1 << 27)
 
-#define PLLMB_MISC0_LOCK_OVERRIDE      (1 << 18)
-#define PLLMB_MISC0_IDDQ               (1 << 17)
-#define PLLMB_MISC0_LOCK_ENABLE                (1 << 16)
+#define PLLMB_MISC1_LOCK_OVERRIDE      (1 << 18)
+#define PLLMB_MISC1_IDDQ               (1 << 17)
+#define PLLMB_MISC1_LOCK_ENABLE                (1 << 16)
 
-#define PLLMB_MISC0_DEFAULT_VALUE      0x00030000
-#define PLLMB_MISC0_WRITE_MASK         0x0007ffff
+#define PLLMB_MISC1_DEFAULT_VALUE      0x00030000
+#define PLLMB_MISC1_WRITE_MASK         0x0007ffff
 
 /* PLLP */
 #define PLLP_BASE_OVERRIDE             (1 << 28)
@@ -457,7 +458,8 @@ static void pllcx_check_defaults(struct tegra_clk_pll_params *params)
                        PLLCX_MISC3_WRITE_MASK);
 }
 
-void tegra210_pllcx_set_defaults(const char *name, struct tegra_clk_pll *pllcx)
+static void tegra210_pllcx_set_defaults(const char *name,
+                                       struct tegra_clk_pll *pllcx)
 {
        pllcx->params->defaults_set = true;
 
@@ -482,22 +484,22 @@ void tegra210_pllcx_set_defaults(const char *name, struct tegra_clk_pll *pllcx)
        udelay(1);
 }
 
-void _pllc_set_defaults(struct tegra_clk_pll *pllcx)
+static void _pllc_set_defaults(struct tegra_clk_pll *pllcx)
 {
        tegra210_pllcx_set_defaults("PLL_C", pllcx);
 }
 
-void _pllc2_set_defaults(struct tegra_clk_pll *pllcx)
+static void _pllc2_set_defaults(struct tegra_clk_pll *pllcx)
 {
        tegra210_pllcx_set_defaults("PLL_C2", pllcx);
 }
 
-void _pllc3_set_defaults(struct tegra_clk_pll *pllcx)
+static void _pllc3_set_defaults(struct tegra_clk_pll *pllcx)
 {
        tegra210_pllcx_set_defaults("PLL_C3", pllcx);
 }
 
-void _plla1_set_defaults(struct tegra_clk_pll *pllcx)
+static void _plla1_set_defaults(struct tegra_clk_pll *pllcx)
 {
        tegra210_pllcx_set_defaults("PLL_A1", pllcx);
 }
@@ -507,7 +509,7 @@ void _plla1_set_defaults(struct tegra_clk_pll *pllcx)
  * PLL with dynamic ramp and fractional SDM. Dynamic ramp is not used.
  * Fractional SDM is allowed to provide exact audio rates.
  */
-void tegra210_plla_set_defaults(struct tegra_clk_pll *plla)
+static void tegra210_plla_set_defaults(struct tegra_clk_pll *plla)
 {
        u32 mask;
        u32 val = readl_relaxed(clk_base + plla->params->base_reg);
@@ -559,7 +561,7 @@ void tegra210_plla_set_defaults(struct tegra_clk_pll *plla)
  * PLLD
  * PLL with fractional SDM.
  */
-void tegra210_plld_set_defaults(struct tegra_clk_pll *plld)
+static void tegra210_plld_set_defaults(struct tegra_clk_pll *plld)
 {
        u32 val;
        u32 mask = 0xffff;
@@ -698,7 +700,7 @@ static void plldss_defaults(const char *pll_name, struct tegra_clk_pll *plldss,
        udelay(1);
 }
 
-void tegra210_plld2_set_defaults(struct tegra_clk_pll *plld2)
+static void tegra210_plld2_set_defaults(struct tegra_clk_pll *plld2)
 {
        plldss_defaults("PLL_D2", plld2, PLLD2_MISC0_DEFAULT_VALUE,
                        PLLD2_MISC1_CFG_DEFAULT_VALUE,
@@ -706,7 +708,7 @@ void tegra210_plld2_set_defaults(struct tegra_clk_pll *plld2)
                        PLLD2_MISC3_CTRL2_DEFAULT_VALUE);
 }
 
-void tegra210_plldp_set_defaults(struct tegra_clk_pll *plldp)
+static void tegra210_plldp_set_defaults(struct tegra_clk_pll *plldp)
 {
        plldss_defaults("PLL_DP", plldp, PLLDP_MISC0_DEFAULT_VALUE,
                        PLLDP_MISC1_CFG_DEFAULT_VALUE,
@@ -719,7 +721,7 @@ void tegra210_plldp_set_defaults(struct tegra_clk_pll *plldp)
  * Base and misc0 layout is the same as PLLD2/PLLDP, but no SDM/SSC support.
  * VCO is exposed to the clock tree via fixed 1/3 and 1/5 dividers.
  */
-void tegra210_pllc4_set_defaults(struct tegra_clk_pll *pllc4)
+static void tegra210_pllc4_set_defaults(struct tegra_clk_pll *pllc4)
 {
        plldss_defaults("PLL_C4", pllc4, PLLC4_MISC0_DEFAULT_VALUE, 0, 0, 0);
 }
@@ -728,7 +730,7 @@ void tegra210_pllc4_set_defaults(struct tegra_clk_pll *pllc4)
  * PLLRE
  * VCO is exposed to the clock tree directly along with post-divider output
  */
-void tegra210_pllre_set_defaults(struct tegra_clk_pll *pllre)
+static void tegra210_pllre_set_defaults(struct tegra_clk_pll *pllre)
 {
        u32 mask;
        u32 val = readl_relaxed(clk_base + pllre->params->base_reg);
@@ -780,13 +782,13 @@ static void pllx_get_dyn_steps(struct clk_hw *hw, u32 *step_a, u32 *step_b)
 {
        unsigned long input_rate;
 
-       if (!IS_ERR_OR_NULL(hw->clk)) {
+       /* cf rate */
+       if (!IS_ERR_OR_NULL(hw->clk))
                input_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
-               /* cf rate */
-               input_rate /= tegra_pll_get_fixed_mdiv(hw, input_rate);
-       } else {
+       else
                input_rate = 38400000;
-       }
+
+       input_rate /= tegra_pll_get_fixed_mdiv(hw, input_rate);
 
        switch (input_rate) {
        case 12000000:
@@ -841,7 +843,7 @@ static void pllx_check_defaults(struct tegra_clk_pll *pll)
                        PLLX_MISC5_WRITE_MASK);
 }
 
-void tegra210_pllx_set_defaults(struct tegra_clk_pll *pllx)
+static void tegra210_pllx_set_defaults(struct tegra_clk_pll *pllx)
 {
        u32 val;
        u32 step_a, step_b;
@@ -901,7 +903,7 @@ void tegra210_pllx_set_defaults(struct tegra_clk_pll *pllx)
 }
 
 /* PLLMB */
-void tegra210_pllmb_set_defaults(struct tegra_clk_pll *pllmb)
+static void tegra210_pllmb_set_defaults(struct tegra_clk_pll *pllmb)
 {
        u32 mask, val = readl_relaxed(clk_base + pllmb->params->base_reg);
 
@@ -914,15 +916,15 @@ void tegra210_pllmb_set_defaults(struct tegra_clk_pll *pllmb)
                 * PLL is ON: check if defaults already set, then set those
                 * that can be updated in flight.
                 */
-               val = PLLMB_MISC0_DEFAULT_VALUE & (~PLLMB_MISC0_IDDQ);
-               mask = PLLMB_MISC0_LOCK_ENABLE | PLLMB_MISC0_LOCK_OVERRIDE;
+               val = PLLMB_MISC1_DEFAULT_VALUE & (~PLLMB_MISC1_IDDQ);
+               mask = PLLMB_MISC1_LOCK_ENABLE | PLLMB_MISC1_LOCK_OVERRIDE;
                _pll_misc_chk_default(clk_base, pllmb->params, 0, val,
-                               ~mask & PLLMB_MISC0_WRITE_MASK);
+                               ~mask & PLLMB_MISC1_WRITE_MASK);
 
                /* Enable lock detect */
                val = readl_relaxed(clk_base + pllmb->params->ext_misc_reg[0]);
                val &= ~mask;
-               val |= PLLMB_MISC0_DEFAULT_VALUE & mask;
+               val |= PLLMB_MISC1_DEFAULT_VALUE & mask;
                writel_relaxed(val, clk_base + pllmb->params->ext_misc_reg[0]);
                udelay(1);
 
@@ -930,7 +932,7 @@ void tegra210_pllmb_set_defaults(struct tegra_clk_pll *pllmb)
        }
 
        /* set IDDQ, enable lock detect */
-       writel_relaxed(PLLMB_MISC0_DEFAULT_VALUE,
+       writel_relaxed(PLLMB_MISC1_DEFAULT_VALUE,
                        clk_base + pllmb->params->ext_misc_reg[0]);
        udelay(1);
 }
@@ -960,7 +962,7 @@ static void pllp_check_defaults(struct tegra_clk_pll *pll, bool enabled)
                        ~mask & PLLP_MISC1_WRITE_MASK);
 }
 
-void tegra210_pllp_set_defaults(struct tegra_clk_pll *pllp)
+static void tegra210_pllp_set_defaults(struct tegra_clk_pll *pllp)
 {
        u32 mask;
        u32 val = readl_relaxed(clk_base + pllp->params->base_reg);
@@ -1022,7 +1024,7 @@ static void pllu_check_defaults(struct tegra_clk_pll *pll, bool hw_control)
                        ~mask & PLLU_MISC1_WRITE_MASK);
 }
 
-void tegra210_pllu_set_defaults(struct tegra_clk_pll *pllu)
+static void tegra210_pllu_set_defaults(struct tegra_clk_pll *pllu)
 {
        u32 val = readl_relaxed(clk_base + pllu->params->base_reg);
 
@@ -1212,8 +1214,9 @@ static void tegra210_clk_pll_set_gain(struct tegra_clk_pll_freq_table *cfg)
        cfg->m *= PLL_SDM_COEFF;
 }
 
-unsigned long tegra210_clk_adjust_vco_min(struct tegra_clk_pll_params *params,
-                                         unsigned long parent_rate)
+static unsigned long
+tegra210_clk_adjust_vco_min(struct tegra_clk_pll_params *params,
+                           unsigned long parent_rate)
 {
        unsigned long vco_min = params->vco_min;
 
@@ -1386,7 +1389,7 @@ static struct tegra_clk_pll_params pll_c_params = {
        .mdiv_default = 3,
        .div_nmp = &pllc_nmp,
        .freq_table = pll_cx_freq_table,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
+       .flags = TEGRA_PLL_USE_LOCK,
        .set_defaults = _pllc_set_defaults,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
 };
@@ -1425,7 +1428,7 @@ static struct tegra_clk_pll_params pll_c2_params = {
        .ext_misc_reg[2] = PLLC2_MISC2,
        .ext_misc_reg[3] = PLLC2_MISC3,
        .freq_table = pll_cx_freq_table,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
+       .flags = TEGRA_PLL_USE_LOCK,
        .set_defaults = _pllc2_set_defaults,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
 };
@@ -1455,7 +1458,7 @@ static struct tegra_clk_pll_params pll_c3_params = {
        .ext_misc_reg[2] = PLLC3_MISC2,
        .ext_misc_reg[3] = PLLC3_MISC3,
        .freq_table = pll_cx_freq_table,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
+       .flags = TEGRA_PLL_USE_LOCK,
        .set_defaults = _pllc3_set_defaults,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
 };
@@ -1505,7 +1508,6 @@ static struct tegra_clk_pll_params pll_c4_vco_params = {
        .base_reg = PLLC4_BASE,
        .misc_reg = PLLC4_MISC0,
        .lock_mask = PLL_BASE_LOCK,
-       .lock_enable_bit_idx = PLLSS_MISC_LOCK_ENABLE,
        .lock_delay = 300,
        .max_p = PLL_QLIN_PDIV_MAX,
        .ext_misc_reg[0] = PLLC4_MISC0,
@@ -1517,8 +1519,7 @@ static struct tegra_clk_pll_params pll_c4_vco_params = {
        .div_nmp = &pllss_nmp,
        .freq_table = pll_c4_vco_freq_table,
        .set_defaults = tegra210_pllc4_set_defaults,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE |
-                TEGRA_PLL_VCO_OUT,
+       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
 };
 
@@ -1559,15 +1560,15 @@ static struct tegra_clk_pll_params pll_m_params = {
        .vco_min = 800000000,
        .vco_max = 1866000000,
        .base_reg = PLLM_BASE,
-       .misc_reg = PLLM_MISC1,
+       .misc_reg = PLLM_MISC2,
        .lock_mask = PLL_BASE_LOCK,
        .lock_enable_bit_idx = PLLM_MISC_LOCK_ENABLE,
        .lock_delay = 300,
-       .iddq_reg = PLLM_MISC0,
+       .iddq_reg = PLLM_MISC2,
        .iddq_bit_idx = PLLM_IDDQ_BIT,
        .max_p = PLL_QLIN_PDIV_MAX,
-       .ext_misc_reg[0] = PLLM_MISC0,
-       .ext_misc_reg[0] = PLLM_MISC1,
+       .ext_misc_reg[0] = PLLM_MISC2,
+       .ext_misc_reg[1] = PLLM_MISC1,
        .round_p_to_pdiv = pll_qlin_p_to_pdiv,
        .pdiv_tohw = pll_qlin_pdiv_to_hw,
        .div_nmp = &pllm_nmp,
@@ -1586,19 +1587,18 @@ static struct tegra_clk_pll_params pll_mb_params = {
        .vco_min = 800000000,
        .vco_max = 1866000000,
        .base_reg = PLLMB_BASE,
-       .misc_reg = PLLMB_MISC0,
+       .misc_reg = PLLMB_MISC1,
        .lock_mask = PLL_BASE_LOCK,
-       .lock_enable_bit_idx = PLLMB_MISC_LOCK_ENABLE,
        .lock_delay = 300,
-       .iddq_reg = PLLMB_MISC0,
+       .iddq_reg = PLLMB_MISC1,
        .iddq_bit_idx = PLLMB_IDDQ_BIT,
        .max_p = PLL_QLIN_PDIV_MAX,
-       .ext_misc_reg[0] = PLLMB_MISC0,
+       .ext_misc_reg[0] = PLLMB_MISC1,
        .round_p_to_pdiv = pll_qlin_p_to_pdiv,
        .pdiv_tohw = pll_qlin_pdiv_to_hw,
        .div_nmp = &pllm_nmp,
        .freq_table = pll_m_freq_table,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
+       .flags = TEGRA_PLL_USE_LOCK,
        .set_defaults = tegra210_pllmb_set_defaults,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
 };
@@ -1671,7 +1671,6 @@ static struct tegra_clk_pll_params pll_re_vco_params = {
        .base_reg = PLLRE_BASE,
        .misc_reg = PLLRE_MISC0,
        .lock_mask = PLLRE_MISC_LOCK,
-       .lock_enable_bit_idx = PLLRE_MISC_LOCK_ENABLE,
        .lock_delay = 300,
        .max_p = PLL_QLIN_PDIV_MAX,
        .ext_misc_reg[0] = PLLRE_MISC0,
@@ -1681,8 +1680,7 @@ static struct tegra_clk_pll_params pll_re_vco_params = {
        .pdiv_tohw = pll_qlin_pdiv_to_hw,
        .div_nmp = &pllre_nmp,
        .freq_table = pll_re_vco_freq_table,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_LOCK_MISC |
-                TEGRA_PLL_HAS_LOCK_ENABLE | TEGRA_PLL_VCO_OUT,
+       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_LOCK_MISC | TEGRA_PLL_VCO_OUT,
        .set_defaults = tegra210_pllre_set_defaults,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
 };
@@ -1712,7 +1710,6 @@ static struct tegra_clk_pll_params pll_p_params = {
        .base_reg = PLLP_BASE,
        .misc_reg = PLLP_MISC0,
        .lock_mask = PLL_BASE_LOCK,
-       .lock_enable_bit_idx = PLLP_MISC_LOCK_ENABLE,
        .lock_delay = 300,
        .iddq_reg = PLLP_MISC0,
        .iddq_bit_idx = PLLXP_IDDQ_BIT,
@@ -1721,8 +1718,7 @@ static struct tegra_clk_pll_params pll_p_params = {
        .div_nmp = &pllp_nmp,
        .freq_table = pll_p_freq_table,
        .fixed_rate = 408000000,
-       .flags = TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK |
-                TEGRA_PLL_HAS_LOCK_ENABLE | TEGRA_PLL_VCO_OUT,
+       .flags = TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT,
        .set_defaults = tegra210_pllp_set_defaults,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
 };
@@ -1750,7 +1746,7 @@ static struct tegra_clk_pll_params pll_a1_params = {
        .ext_misc_reg[2] = PLLA1_MISC2,
        .ext_misc_reg[3] = PLLA1_MISC3,
        .freq_table = pll_cx_freq_table,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
+       .flags = TEGRA_PLL_USE_LOCK,
        .set_defaults = _plla1_set_defaults,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
 };
@@ -1787,7 +1783,6 @@ static struct tegra_clk_pll_params pll_a_params = {
        .base_reg = PLLA_BASE,
        .misc_reg = PLLA_MISC0,
        .lock_mask = PLL_BASE_LOCK,
-       .lock_enable_bit_idx = PLLA_MISC_LOCK_ENABLE,
        .lock_delay = 300,
        .round_p_to_pdiv = pll_qlin_p_to_pdiv,
        .pdiv_tohw = pll_qlin_pdiv_to_hw,
@@ -1802,8 +1797,7 @@ static struct tegra_clk_pll_params pll_a_params = {
        .ext_misc_reg[1] = PLLA_MISC1,
        .ext_misc_reg[2] = PLLA_MISC2,
        .freq_table = pll_a_freq_table,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_MDIV_NEW |
-                TEGRA_PLL_HAS_LOCK_ENABLE,
+       .flags = TEGRA_PLL_USE_LOCK | TEGRA_MDIV_NEW,
        .set_defaults = tegra210_plla_set_defaults,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
        .set_gain = tegra210_clk_pll_set_gain,
@@ -1836,7 +1830,6 @@ static struct tegra_clk_pll_params pll_d_params = {
        .base_reg = PLLD_BASE,
        .misc_reg = PLLD_MISC0,
        .lock_mask = PLL_BASE_LOCK,
-       .lock_enable_bit_idx = PLLD_MISC_LOCK_ENABLE,
        .lock_delay = 1000,
        .iddq_reg = PLLD_MISC0,
        .iddq_bit_idx = PLLD_IDDQ_BIT,
@@ -1850,7 +1843,7 @@ static struct tegra_clk_pll_params pll_d_params = {
        .ext_misc_reg[0] = PLLD_MISC0,
        .ext_misc_reg[1] = PLLD_MISC1,
        .freq_table = pll_d_freq_table,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
+       .flags = TEGRA_PLL_USE_LOCK,
        .mdiv_default = 1,
        .set_defaults = tegra210_plld_set_defaults,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
@@ -1876,7 +1869,6 @@ static struct tegra_clk_pll_params pll_d2_params = {
        .base_reg = PLLD2_BASE,
        .misc_reg = PLLD2_MISC0,
        .lock_mask = PLL_BASE_LOCK,
-       .lock_enable_bit_idx = PLLSS_MISC_LOCK_ENABLE,
        .lock_delay = 300,
        .iddq_reg = PLLD2_BASE,
        .iddq_bit_idx = PLLSS_IDDQ_BIT,
@@ -1897,7 +1889,7 @@ static struct tegra_clk_pll_params pll_d2_params = {
        .mdiv_default = 1,
        .freq_table = tegra210_pll_d2_freq_table,
        .set_defaults = tegra210_plld2_set_defaults,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
+       .flags = TEGRA_PLL_USE_LOCK,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
        .set_gain = tegra210_clk_pll_set_gain,
        .adjust_vco = tegra210_clk_adjust_vco_min,
@@ -1920,7 +1912,6 @@ static struct tegra_clk_pll_params pll_dp_params = {
        .base_reg = PLLDP_BASE,
        .misc_reg = PLLDP_MISC,
        .lock_mask = PLL_BASE_LOCK,
-       .lock_enable_bit_idx = PLLSS_MISC_LOCK_ENABLE,
        .lock_delay = 300,
        .iddq_reg = PLLDP_BASE,
        .iddq_bit_idx = PLLSS_IDDQ_BIT,
@@ -1941,7 +1932,7 @@ static struct tegra_clk_pll_params pll_dp_params = {
        .mdiv_default = 1,
        .freq_table = pll_dp_freq_table,
        .set_defaults = tegra210_plldp_set_defaults,
-       .flags = TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE,
+       .flags = TEGRA_PLL_USE_LOCK,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
        .set_gain = tegra210_clk_pll_set_gain,
        .adjust_vco = tegra210_clk_adjust_vco_min,
@@ -1973,7 +1964,6 @@ static struct tegra_clk_pll_params pll_u_vco_params = {
        .base_reg = PLLU_BASE,
        .misc_reg = PLLU_MISC0,
        .lock_mask = PLL_BASE_LOCK,
-       .lock_enable_bit_idx = PLLU_MISC_LOCK_ENABLE,
        .lock_delay = 1000,
        .iddq_reg = PLLU_MISC0,
        .iddq_bit_idx = PLLU_IDDQ_BIT,
@@ -1983,8 +1973,7 @@ static struct tegra_clk_pll_params pll_u_vco_params = {
        .pdiv_tohw = pll_qlin_pdiv_to_hw,
        .div_nmp = &pllu_nmp,
        .freq_table = pll_u_freq_table,
-       .flags = TEGRA_PLLU | TEGRA_PLL_USE_LOCK | TEGRA_PLL_HAS_LOCK_ENABLE |
-                TEGRA_PLL_VCO_OUT,
+       .flags = TEGRA_PLLU | TEGRA_PLL_USE_LOCK | TEGRA_PLL_VCO_OUT,
        .set_defaults = tegra210_pllu_set_defaults,
        .calc_rate = tegra210_pll_fixed_mdiv_cfg,
 };
@@ -2218,6 +2207,7 @@ static struct tegra_clk tegra210_clks[tegra_clk_max] __initdata = {
        [tegra_clk_pll_c4_out1] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT1, .present = true },
        [tegra_clk_pll_c4_out2] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT2, .present = true },
        [tegra_clk_pll_c4_out3] = { .dt_id = TEGRA210_CLK_PLL_C4_OUT3, .present = true },
+       [tegra_clk_apb2ape] = { .dt_id = TEGRA210_CLK_APB2APE, .present = true },
 };
 
 static struct tegra_devclk devclks[] __initdata = {
@@ -2519,7 +2509,7 @@ static void __init tegra210_pll_init(void __iomem *clk_base,
 
        /* PLLU_VCO */
        val = readl(clk_base + pll_u_vco_params.base_reg);
-       val &= ~BIT(24); /* disable PLLU_OVERRIDE */
+       val &= ~PLLU_BASE_OVERRIDE; /* disable PLLU_OVERRIDE */
        writel(val, clk_base + pll_u_vco_params.base_reg);
 
        clk = tegra_clk_register_pllre("pll_u_vco", "pll_ref", clk_base, pmc,
@@ -2738,8 +2728,6 @@ static struct tegra_clk_init_table init_table[] __initdata = {
        { TEGRA210_CLK_DFLL_REF, TEGRA210_CLK_PLL_P, 51000000, 1 },
        { TEGRA210_CLK_SBC4, TEGRA210_CLK_PLL_P, 12000000, 1 },
        { TEGRA210_CLK_PLL_RE_VCO, TEGRA210_CLK_CLK_MAX, 672000000, 1 },
-       { TEGRA210_CLK_PLL_U_OUT1, TEGRA210_CLK_CLK_MAX, 48000000, 1 },
-       { TEGRA210_CLK_PLL_U_OUT2, TEGRA210_CLK_CLK_MAX, 60000000, 1 },
        { TEGRA210_CLK_XUSB_GATE, TEGRA210_CLK_CLK_MAX, 0, 1 },
        { TEGRA210_CLK_XUSB_SS_SRC, TEGRA210_CLK_PLL_U_480M, 120000000, 0 },
        { TEGRA210_CLK_XUSB_FS_SRC, TEGRA210_CLK_PLL_U_48M, 48000000, 0 },
index 1c30038..cc73929 100644 (file)
@@ -460,7 +460,8 @@ int omap3_noncore_dpll_enable(struct clk_hw *hw)
 
        parent = clk_hw_get_parent(hw);
 
-       if (clk_hw_get_rate(hw) == clk_get_rate(dd->clk_bypass)) {
+       if (clk_hw_get_rate(hw) ==
+           clk_hw_get_rate(__clk_get_hw(dd->clk_bypass))) {
                WARN_ON(parent != __clk_get_hw(dd->clk_bypass));
                r = _omap3_noncore_dpll_bypass(clk);
        } else {
index e62f8cb..3bca438 100644 (file)
@@ -78,6 +78,9 @@ static int vco_set(struct clk_icst *icst, struct icst_vco vco)
        ret = regmap_read(icst->map, icst->vcoreg_off, &val);
        if (ret)
                return ret;
+
+       /* Mask the 18 bits used by the VCO */
+       val &= ~0x7ffff;
        val |= vco.v | (vco.r << 9) | (vco.s << 16);
 
        /* This magic unlocks the VCO so it can be controlled */
index 659879a..f935110 100644 (file)
@@ -296,6 +296,7 @@ endif
 config QORIQ_CPUFREQ
        tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
        depends on OF && COMMON_CLK && (PPC_E500MC || ARM)
+       depends on !CPU_THERMAL || THERMAL
        select CLK_QORIQ
        help
          This adds the CPUFreq driver support for Freescale QorIQ SoCs
index 0031069..14b1f93 100644 (file)
@@ -84,10 +84,10 @@ config ARM_KIRKWOOD_CPUFREQ
          SoCs.
 
 config ARM_MT8173_CPUFREQ
-       bool "Mediatek MT8173 CPUFreq support"
+       tristate "Mediatek MT8173 CPUFreq support"
        depends on ARCH_MEDIATEK && REGULATOR
        depends on ARM64 || (ARM_CPU_TOPOLOGY && COMPILE_TEST)
-       depends on !CPU_THERMAL || THERMAL=y
+       depends on !CPU_THERMAL || THERMAL
        select PM_OPP
        help
          This adds the CPUFreq driver support for Mediatek MT8173 SoC.
index 1efba34..2058e6d 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/cpu_cooling.h>
 #include <linux/cpufreq.h>
 #include <linux/cpumask.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_opp.h>
index 20de861..8bf9914 100644 (file)
@@ -782,7 +782,7 @@ static void atmel_sha_finish_req(struct ahash_request *req, int err)
        dd->flags &= ~(SHA_FLAGS_BUSY | SHA_FLAGS_FINAL | SHA_FLAGS_CPU |
                        SHA_FLAGS_DMA_READY | SHA_FLAGS_OUTPUT_READY);
 
-       clk_disable_unprepare(dd->iclk);
+       clk_disable(dd->iclk);
 
        if (req->base.complete)
                req->base.complete(&req->base, err);
@@ -795,7 +795,7 @@ static int atmel_sha_hw_init(struct atmel_sha_dev *dd)
 {
        int err;
 
-       err = clk_prepare_enable(dd->iclk);
+       err = clk_enable(dd->iclk);
        if (err)
                return err;
 
@@ -822,7 +822,7 @@ static void atmel_sha_hw_version_init(struct atmel_sha_dev *dd)
        dev_info(dd->dev,
                        "version: 0x%x\n", dd->hw_version);
 
-       clk_disable_unprepare(dd->iclk);
+       clk_disable(dd->iclk);
 }
 
 static int atmel_sha_handle_queue(struct atmel_sha_dev *dd,
@@ -1410,6 +1410,10 @@ static int atmel_sha_probe(struct platform_device *pdev)
                goto res_err;
        }
 
+       err = clk_prepare(sha_dd->iclk);
+       if (err)
+               goto res_err;
+
        atmel_sha_hw_version_init(sha_dd);
 
        atmel_sha_get_cap(sha_dd);
@@ -1421,12 +1425,12 @@ static int atmel_sha_probe(struct platform_device *pdev)
                        if (IS_ERR(pdata)) {
                                dev_err(&pdev->dev, "platform data not available\n");
                                err = PTR_ERR(pdata);
-                               goto res_err;
+                               goto iclk_unprepare;
                        }
                }
                if (!pdata->dma_slave) {
                        err = -ENXIO;
-                       goto res_err;
+                       goto iclk_unprepare;
                }
                err = atmel_sha_dma_init(sha_dd, pdata);
                if (err)
@@ -1457,6 +1461,8 @@ err_algs:
        if (sha_dd->caps.has_dma)
                atmel_sha_dma_cleanup(sha_dd);
 err_sha_dma:
+iclk_unprepare:
+       clk_unprepare(sha_dd->iclk);
 res_err:
        tasklet_kill(&sha_dd->done_task);
 sha_dd_err:
@@ -1483,12 +1489,7 @@ static int atmel_sha_remove(struct platform_device *pdev)
        if (sha_dd->caps.has_dma)
                atmel_sha_dma_cleanup(sha_dd);
 
-       iounmap(sha_dd->io_base);
-
-       clk_put(sha_dd->iclk);
-
-       if (sha_dd->irq >= 0)
-               free_irq(sha_dd->irq, sha_dd);
+       clk_unprepare(sha_dd->iclk);
 
        return 0;
 }
index 0643e33..c0656e7 100644 (file)
@@ -306,7 +306,7 @@ static int mv_cesa_dev_dma_init(struct mv_cesa_dev *cesa)
                return -ENOMEM;
 
        dma->padding_pool = dmam_pool_create("cesa_padding", dev, 72, 1, 0);
-       if (!dma->cache_pool)
+       if (!dma->padding_pool)
                return -ENOMEM;
 
        cesa->dma = dma;
index 848b93e..fe9dce0 100644 (file)
@@ -500,6 +500,8 @@ static int tegra_devfreq_target(struct device *dev, unsigned long *freq,
        clk_set_min_rate(tegra->emc_clock, rate);
        clk_set_rate(tegra->emc_clock, 0);
 
+       *freq = rate;
+
        return 0;
 }
 
index 64f5d1b..8e304b1 100644 (file)
 #define AT_XDMAC_MAX_CHAN      0x20
 #define AT_XDMAC_MAX_CSIZE     16      /* 16 data */
 #define AT_XDMAC_MAX_DWIDTH    8       /* 64 bits */
+#define AT_XDMAC_RESIDUE_MAX_RETRIES   5
 
 #define AT_XDMAC_DMA_BUSWIDTHS\
        (BIT(DMA_SLAVE_BUSWIDTH_UNDEFINED) |\
@@ -1395,8 +1396,8 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
        struct at_xdmac_desc    *desc, *_desc;
        struct list_head        *descs_list;
        enum dma_status         ret;
-       int                     residue;
-       u32                     cur_nda, mask, value;
+       int                     residue, retry;
+       u32                     cur_nda, check_nda, cur_ubc, mask, value;
        u8                      dwidth = 0;
        unsigned long           flags;
 
@@ -1433,7 +1434,42 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
                        cpu_relax();
        }
 
+       /*
+        * When processing the residue, we need to read two registers but we
+        * can't do it in an atomic way. AT_XDMAC_CNDA is used to find where
+        * we stand in the descriptor list and AT_XDMAC_CUBC is used
+        * to know how many data are remaining for the current descriptor.
+        * Since the dma channel is not paused to not loose data, between the
+        * AT_XDMAC_CNDA and AT_XDMAC_CUBC read, we may have change of
+        * descriptor.
+        * For that reason, after reading AT_XDMAC_CUBC, we check if we are
+        * still using the same descriptor by reading a second time
+        * AT_XDMAC_CNDA. If AT_XDMAC_CNDA has changed, it means we have to
+        * read again AT_XDMAC_CUBC.
+        * Memory barriers are used to ensure the read order of the registers.
+        * A max number of retries is set because unlikely it can never ends if
+        * we are transferring a lot of data with small buffers.
+        */
        cur_nda = at_xdmac_chan_read(atchan, AT_XDMAC_CNDA) & 0xfffffffc;
+       rmb();
+       cur_ubc = at_xdmac_chan_read(atchan, AT_XDMAC_CUBC);
+       for (retry = 0; retry < AT_XDMAC_RESIDUE_MAX_RETRIES; retry++) {
+               rmb();
+               check_nda = at_xdmac_chan_read(atchan, AT_XDMAC_CNDA) & 0xfffffffc;
+
+               if (likely(cur_nda == check_nda))
+                       break;
+
+               cur_nda = check_nda;
+               rmb();
+               cur_ubc = at_xdmac_chan_read(atchan, AT_XDMAC_CUBC);
+       }
+
+       if (unlikely(retry >= AT_XDMAC_RESIDUE_MAX_RETRIES)) {
+               ret = DMA_ERROR;
+               goto spin_unlock;
+       }
+
        /*
         * Remove size of all microblocks already transferred and the current
         * one. Then add the remaining size to transfer of the current
@@ -1446,7 +1482,7 @@ at_xdmac_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
                if ((desc->lld.mbr_nda & 0xfffffffc) == cur_nda)
                        break;
        }
-       residue += at_xdmac_chan_read(atchan, AT_XDMAC_CUBC) << dwidth;
+       residue += cur_ubc << dwidth;
 
        dma_set_residue(txstate, residue);
 
index e893318..5ad0ec1 100644 (file)
@@ -156,7 +156,6 @@ static void dwc_initialize(struct dw_dma_chan *dwc)
 
        /* Enable interrupts */
        channel_set_bit(dw, MASK.XFER, dwc->mask);
-       channel_set_bit(dw, MASK.BLOCK, dwc->mask);
        channel_set_bit(dw, MASK.ERROR, dwc->mask);
 
        dwc->initialized = true;
@@ -588,6 +587,9 @@ static void dwc_handle_cyclic(struct dw_dma *dw, struct dw_dma_chan *dwc,
 
                spin_unlock_irqrestore(&dwc->lock, flags);
        }
+
+       /* Re-enable interrupts */
+       channel_set_bit(dw, MASK.BLOCK, dwc->mask);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -618,11 +620,8 @@ static void dw_dma_tasklet(unsigned long data)
                        dwc_scan_descriptors(dw, dwc);
        }
 
-       /*
-        * Re-enable interrupts.
-        */
+       /* Re-enable interrupts */
        channel_set_bit(dw, MASK.XFER, dw->all_chan_mask);
-       channel_set_bit(dw, MASK.BLOCK, dw->all_chan_mask);
        channel_set_bit(dw, MASK.ERROR, dw->all_chan_mask);
 }
 
@@ -1261,6 +1260,7 @@ static void dwc_free_chan_resources(struct dma_chan *chan)
 int dw_dma_cyclic_start(struct dma_chan *chan)
 {
        struct dw_dma_chan      *dwc = to_dw_dma_chan(chan);
+       struct dw_dma           *dw = to_dw_dma(chan->device);
        unsigned long           flags;
 
        if (!test_bit(DW_DMA_IS_CYCLIC, &dwc->flags)) {
@@ -1269,7 +1269,12 @@ int dw_dma_cyclic_start(struct dma_chan *chan)
        }
 
        spin_lock_irqsave(&dwc->lock, flags);
+
+       /* Enable interrupts to perform cyclic transfer */
+       channel_set_bit(dw, MASK.BLOCK, dwc->mask);
+
        dwc_dostart(dwc, dwc->cdesc->desc[0]);
+
        spin_unlock_irqrestore(&dwc->lock, flags);
 
        return 0;
index 4c30fdd..358f968 100644 (file)
@@ -108,6 +108,10 @@ static const struct pci_device_id dw_pci_id_table[] = {
 
        /* Haswell */
        { PCI_VDEVICE(INTEL, 0x9c60) },
+
+       /* Broadwell */
+       { PCI_VDEVICE(INTEL, 0x9ce0) },
+
        { }
 };
 MODULE_DEVICE_TABLE(pci, dw_pci_id_table);
index d92d655..e3d7fcb 100644 (file)
 #define GET_NUM_REGN(x)                ((x & 0x300000) >> 20) /* bits 20-21 */
 #define CHMAP_EXIST            BIT(24)
 
+/* CCSTAT register */
+#define EDMA_CCSTAT_ACTV       BIT(4)
+
 /*
  * Max of 20 segments per channel to conserve PaRAM slots
  * Also note that MAX_NR_SG should be atleast the no.of periods
@@ -1680,9 +1683,20 @@ static void edma_issue_pending(struct dma_chan *chan)
        spin_unlock_irqrestore(&echan->vchan.lock, flags);
 }
 
+/*
+ * This limit exists to avoid a possible infinite loop when waiting for proof
+ * that a particular transfer is completed. This limit can be hit if there
+ * are large bursts to/from slow devices or the CPU is never able to catch
+ * the DMA hardware idle. On an AM335x transfering 48 bytes from the UART
+ * RX-FIFO, as many as 55 loops have been seen.
+ */
+#define EDMA_MAX_TR_WAIT_LOOPS 1000
+
 static u32 edma_residue(struct edma_desc *edesc)
 {
        bool dst = edesc->direction == DMA_DEV_TO_MEM;
+       int loop_count = EDMA_MAX_TR_WAIT_LOOPS;
+       struct edma_chan *echan = edesc->echan;
        struct edma_pset *pset = edesc->pset;
        dma_addr_t done, pos;
        int i;
@@ -1691,7 +1705,32 @@ static u32 edma_residue(struct edma_desc *edesc)
         * We always read the dst/src position from the first RamPar
         * pset. That's the one which is active now.
         */
-       pos = edma_get_position(edesc->echan->ecc, edesc->echan->slot[0], dst);
+       pos = edma_get_position(echan->ecc, echan->slot[0], dst);
+
+       /*
+        * "pos" may represent a transfer request that is still being
+        * processed by the EDMACC or EDMATC. We will busy wait until
+        * any one of the situations occurs:
+        *   1. the DMA hardware is idle
+        *   2. a new transfer request is setup
+        *   3. we hit the loop limit
+        */
+       while (edma_read(echan->ecc, EDMA_CCSTAT) & EDMA_CCSTAT_ACTV) {
+               /* check if a new transfer request is setup */
+               if (edma_get_position(echan->ecc,
+                                     echan->slot[0], dst) != pos) {
+                       break;
+               }
+
+               if (!--loop_count) {
+                       dev_dbg_ratelimited(echan->vchan.chan.device->dev,
+                               "%s: timeout waiting for PaRAM update\n",
+                               __func__);
+                       break;
+               }
+
+               cpu_relax();
+       }
 
        /*
         * Cyclic is simple. Just subtract pset[0].addr from pos.
index 2209f75..aac85c3 100644 (file)
@@ -522,6 +522,8 @@ static dma_cookie_t fsldma_run_tx_complete_actions(struct fsldma_chan *chan,
                        chan_dbg(chan, "LD %p callback\n", desc);
                        txd->callback(txd->callback_param);
                }
+
+               dma_descriptor_unmap(txd);
        }
 
        /* Run any dependencies */
index 1d5df2e..21539d5 100644 (file)
@@ -861,32 +861,42 @@ void ioat_timer_event(unsigned long data)
                        return;
        }
 
+       spin_lock_bh(&ioat_chan->cleanup_lock);
+
+       /* handle the no-actives case */
+       if (!ioat_ring_active(ioat_chan)) {
+               spin_lock_bh(&ioat_chan->prep_lock);
+               check_active(ioat_chan);
+               spin_unlock_bh(&ioat_chan->prep_lock);
+               spin_unlock_bh(&ioat_chan->cleanup_lock);
+               return;
+       }
+
        /* if we haven't made progress and we have already
         * acknowledged a pending completion once, then be more
         * forceful with a restart
         */
-       spin_lock_bh(&ioat_chan->cleanup_lock);
        if (ioat_cleanup_preamble(ioat_chan, &phys_complete))
                __cleanup(ioat_chan, phys_complete);
        else if (test_bit(IOAT_COMPLETION_ACK, &ioat_chan->state)) {
+               u32 chanerr;
+
+               chanerr = readl(ioat_chan->reg_base + IOAT_CHANERR_OFFSET);
+               dev_warn(to_dev(ioat_chan), "Restarting channel...\n");
+               dev_warn(to_dev(ioat_chan), "CHANSTS: %#Lx CHANERR: %#x\n",
+                        status, chanerr);
+               dev_warn(to_dev(ioat_chan), "Active descriptors: %d\n",
+                        ioat_ring_active(ioat_chan));
+
                spin_lock_bh(&ioat_chan->prep_lock);
                ioat_restart_channel(ioat_chan);
                spin_unlock_bh(&ioat_chan->prep_lock);
                spin_unlock_bh(&ioat_chan->cleanup_lock);
                return;
-       } else {
+       } else
                set_bit(IOAT_COMPLETION_ACK, &ioat_chan->state);
-               mod_timer(&ioat_chan->timer, jiffies + COMPLETION_TIMEOUT);
-       }
-
 
-       if (ioat_ring_active(ioat_chan))
-               mod_timer(&ioat_chan->timer, jiffies + COMPLETION_TIMEOUT);
-       else {
-               spin_lock_bh(&ioat_chan->prep_lock);
-               check_active(ioat_chan);
-               spin_unlock_bh(&ioat_chan->prep_lock);
-       }
+       mod_timer(&ioat_chan->timer, jiffies + COMPLETION_TIMEOUT);
        spin_unlock_bh(&ioat_chan->cleanup_lock);
 }
 
index f2a0310..debca82 100644 (file)
@@ -583,6 +583,8 @@ static void set_updater_desc(struct pxad_desc_sw *sw_desc,
                (PXA_DCMD_LENGTH & sizeof(u32));
        if (flags & DMA_PREP_INTERRUPT)
                updater->dcmd |= PXA_DCMD_ENDIRQEN;
+       if (sw_desc->cyclic)
+               sw_desc->hw_desc[sw_desc->nb_desc - 2]->ddadr = sw_desc->first;
 }
 
 static bool is_desc_completed(struct virt_dma_desc *vd)
@@ -673,6 +675,10 @@ static irqreturn_t pxad_chan_handler(int irq, void *dev_id)
                dev_dbg(&chan->vc.chan.dev->device,
                        "%s(): checking txd %p[%x]: completed=%d\n",
                        __func__, vd, vd->tx.cookie, is_desc_completed(vd));
+               if (to_pxad_sw_desc(vd)->cyclic) {
+                       vchan_cyclic_callback(vd);
+                       break;
+               }
                if (is_desc_completed(vd)) {
                        list_del(&vd->node);
                        vchan_cookie_complete(vd);
@@ -1080,7 +1086,7 @@ pxad_prep_dma_cyclic(struct dma_chan *dchan,
                return NULL;
 
        pxad_get_config(chan, dir, &dcmd, &dsadr, &dtadr);
-       dcmd |= PXA_DCMD_ENDIRQEN | (PXA_DCMD_LENGTH | period_len);
+       dcmd |= PXA_DCMD_ENDIRQEN | (PXA_DCMD_LENGTH & period_len);
        dev_dbg(&chan->vc.chan.dev->device,
                "%s(): buf_addr=0x%lx len=%zu period=%zu dir=%d flags=%lx\n",
                __func__, (unsigned long)buf_addr, len, period_len, dir, flags);
index e438ee5..f5c6b97 100644 (file)
@@ -1574,7 +1574,7 @@ static int knl_get_dimm_capacity(struct sbridge_pvt *pvt, u64 *mc_sizes)
                                for (cha = 0; cha < KNL_MAX_CHAS; cha++) {
                                        if (knl_get_mc_route(target,
                                                mc_route_reg[cha]) == channel
-                                               && participants[channel]) {
+                                               && !participants[channel]) {
                                                participant_count++;
                                                participants[channel] = 1;
                                                break;
index 756eca8..10e6774 100644 (file)
@@ -221,7 +221,7 @@ sanity_check(struct efi_variable *var, efi_char16_t *name, efi_guid_t vendor,
        }
 
        if ((attributes & ~EFI_VARIABLE_MASK) != 0 ||
-           efivar_validate(name, data, size) == false) {
+           efivar_validate(vendor, name, data, size) == false) {
                printk(KERN_ERR "efivars: Malformed variable content\n");
                return -EINVAL;
        }
@@ -447,7 +447,8 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj,
        }
 
        if ((attributes & ~EFI_VARIABLE_MASK) != 0 ||
-           efivar_validate(name, data, size) == false) {
+           efivar_validate(new_var->VendorGuid, name, data,
+                           size) == false) {
                printk(KERN_ERR "efivars: Malformed variable content\n");
                return -EINVAL;
        }
@@ -540,38 +541,30 @@ static ssize_t efivar_delete(struct file *filp, struct kobject *kobj,
 static int
 efivar_create_sysfs_entry(struct efivar_entry *new_var)
 {
-       int i, short_name_size;
+       int short_name_size;
        char *short_name;
-       unsigned long variable_name_size;
-       efi_char16_t *variable_name;
+       unsigned long utf8_name_size;
+       efi_char16_t *variable_name = new_var->var.VariableName;
        int ret;
 
-       variable_name = new_var->var.VariableName;
-       variable_name_size = ucs2_strlen(variable_name) * sizeof(efi_char16_t);
-
        /*
-        * Length of the variable bytes in ASCII, plus the '-' separator,
+        * Length of the variable bytes in UTF8, plus the '-' separator,
         * plus the GUID, plus trailing NUL
         */
-       short_name_size = variable_name_size / sizeof(efi_char16_t)
-                               + 1 + EFI_VARIABLE_GUID_LEN + 1;
-
-       short_name = kzalloc(short_name_size, GFP_KERNEL);
+       utf8_name_size = ucs2_utf8size(variable_name);
+       short_name_size = utf8_name_size + 1 + EFI_VARIABLE_GUID_LEN + 1;
 
+       short_name = kmalloc(short_name_size, GFP_KERNEL);
        if (!short_name)
                return -ENOMEM;
 
-       /* Convert Unicode to normal chars (assume top bits are 0),
-          ala UTF-8 */
-       for (i=0; i < (int)(variable_name_size / sizeof(efi_char16_t)); i++) {
-               short_name[i] = variable_name[i] & 0xFF;
-       }
+       ucs2_as_utf8(short_name, variable_name, short_name_size);
+
        /* This is ugly, but necessary to separate one vendor's
           private variables from another's.         */
-
-       *(short_name + strlen(short_name)) = '-';
+       short_name[utf8_name_size] = '-';
        efi_guid_to_str(&new_var->var.VendorGuid,
-                        short_name + strlen(short_name));
+                        short_name + utf8_name_size + 1);
 
        new_var->kobj.kset = efivars_kset;
 
index 70a0fb1..7f2ea21 100644 (file)
@@ -165,67 +165,133 @@ validate_ascii_string(efi_char16_t *var_name, int match, u8 *buffer,
 }
 
 struct variable_validate {
+       efi_guid_t vendor;
        char *name;
        bool (*validate)(efi_char16_t *var_name, int match, u8 *data,
                         unsigned long len);
 };
 
+/*
+ * This is the list of variables we need to validate, as well as the
+ * whitelist for what we think is safe not to default to immutable.
+ *
+ * If it has a validate() method that's not NULL, it'll go into the
+ * validation routine.  If not, it is assumed valid, but still used for
+ * whitelisting.
+ *
+ * Note that it's sorted by {vendor,name}, but globbed names must come after
+ * any other name with the same prefix.
+ */
 static const struct variable_validate variable_validate[] = {
-       { "BootNext", validate_uint16 },
-       { "BootOrder", validate_boot_order },
-       { "DriverOrder", validate_boot_order },
-       { "Boot*", validate_load_option },
-       { "Driver*", validate_load_option },
-       { "ConIn", validate_device_path },
-       { "ConInDev", validate_device_path },
-       { "ConOut", validate_device_path },
-       { "ConOutDev", validate_device_path },
-       { "ErrOut", validate_device_path },
-       { "ErrOutDev", validate_device_path },
-       { "Timeout", validate_uint16 },
-       { "Lang", validate_ascii_string },
-       { "PlatformLang", validate_ascii_string },
-       { "", NULL },
+       { EFI_GLOBAL_VARIABLE_GUID, "BootNext", validate_uint16 },
+       { EFI_GLOBAL_VARIABLE_GUID, "BootOrder", validate_boot_order },
+       { EFI_GLOBAL_VARIABLE_GUID, "Boot*", validate_load_option },
+       { EFI_GLOBAL_VARIABLE_GUID, "DriverOrder", validate_boot_order },
+       { EFI_GLOBAL_VARIABLE_GUID, "Driver*", validate_load_option },
+       { EFI_GLOBAL_VARIABLE_GUID, "ConIn", validate_device_path },
+       { EFI_GLOBAL_VARIABLE_GUID, "ConInDev", validate_device_path },
+       { EFI_GLOBAL_VARIABLE_GUID, "ConOut", validate_device_path },
+       { EFI_GLOBAL_VARIABLE_GUID, "ConOutDev", validate_device_path },
+       { EFI_GLOBAL_VARIABLE_GUID, "ErrOut", validate_device_path },
+       { EFI_GLOBAL_VARIABLE_GUID, "ErrOutDev", validate_device_path },
+       { EFI_GLOBAL_VARIABLE_GUID, "Lang", validate_ascii_string },
+       { EFI_GLOBAL_VARIABLE_GUID, "OsIndications", NULL },
+       { EFI_GLOBAL_VARIABLE_GUID, "PlatformLang", validate_ascii_string },
+       { EFI_GLOBAL_VARIABLE_GUID, "Timeout", validate_uint16 },
+       { LINUX_EFI_CRASH_GUID, "*", NULL },
+       { NULL_GUID, "", NULL },
 };
 
+static bool
+variable_matches(const char *var_name, size_t len, const char *match_name,
+                int *match)
+{
+       for (*match = 0; ; (*match)++) {
+               char c = match_name[*match];
+               char u = var_name[*match];
+
+               /* Wildcard in the matching name means we've matched */
+               if (c == '*')
+                       return true;
+
+               /* Case sensitive match */
+               if (!c && *match == len)
+                       return true;
+
+               if (c != u)
+                       return false;
+
+               if (!c)
+                       return true;
+       }
+       return true;
+}
+
 bool
-efivar_validate(efi_char16_t *var_name, u8 *data, unsigned long len)
+efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data,
+               unsigned long data_size)
 {
        int i;
-       u16 *unicode_name = var_name;
+       unsigned long utf8_size;
+       u8 *utf8_name;
 
-       for (i = 0; variable_validate[i].validate != NULL; i++) {
-               const char *name = variable_validate[i].name;
-               int match;
+       utf8_size = ucs2_utf8size(var_name);
+       utf8_name = kmalloc(utf8_size + 1, GFP_KERNEL);
+       if (!utf8_name)
+               return false;
 
-               for (match = 0; ; match++) {
-                       char c = name[match];
-                       u16 u = unicode_name[match];
+       ucs2_as_utf8(utf8_name, var_name, utf8_size);
+       utf8_name[utf8_size] = '\0';
 
-                       /* All special variables are plain ascii */
-                       if (u > 127)
-                               return true;
+       for (i = 0; variable_validate[i].name[0] != '\0'; i++) {
+               const char *name = variable_validate[i].name;
+               int match = 0;
 
-                       /* Wildcard in the matching name means we've matched */
-                       if (c == '*')
-                               return variable_validate[i].validate(var_name,
-                                                            match, data, len);
+               if (efi_guidcmp(vendor, variable_validate[i].vendor))
+                       continue;
 
-                       /* Case sensitive match */
-                       if (c != u)
+               if (variable_matches(utf8_name, utf8_size+1, name, &match)) {
+                       if (variable_validate[i].validate == NULL)
                                break;
-
-                       /* Reached the end of the string while matching */
-                       if (!c)
-                               return variable_validate[i].validate(var_name,
-                                                            match, data, len);
+                       kfree(utf8_name);
+                       return variable_validate[i].validate(var_name, match,
+                                                            data, data_size);
                }
        }
-
+       kfree(utf8_name);
        return true;
 }
 EXPORT_SYMBOL_GPL(efivar_validate);
 
+bool
+efivar_variable_is_removable(efi_guid_t vendor, const char *var_name,
+                            size_t len)
+{
+       int i;
+       bool found = false;
+       int match = 0;
+
+       /*
+        * Check if our variable is in the validated variables list
+        */
+       for (i = 0; variable_validate[i].name[0] != '\0'; i++) {
+               if (efi_guidcmp(variable_validate[i].vendor, vendor))
+                       continue;
+
+               if (variable_matches(var_name, len,
+                                    variable_validate[i].name, &match)) {
+                       found = true;
+                       break;
+               }
+       }
+
+       /*
+        * If it's in our list, it is removable.
+        */
+       return found;
+}
+EXPORT_SYMBOL_GPL(efivar_variable_is_removable);
+
 static efi_status_t
 check_var_size(u32 attributes, unsigned long size)
 {
@@ -852,7 +918,7 @@ int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
 
        *set = false;
 
-       if (efivar_validate(name, data, *size) == false)
+       if (efivar_validate(*vendor, name, data, *size) == false)
                return -EINVAL;
 
        /*
index 2aeaebd..3f87a03 100644 (file)
@@ -312,8 +312,8 @@ static int altera_gpio_probe(struct platform_device *pdev)
                handle_simple_irq, IRQ_TYPE_NONE);
 
        if (ret) {
-               dev_info(&pdev->dev, "could not add irqchip\n");
-               return ret;
+               dev_err(&pdev->dev, "could not add irqchip\n");
+               goto teardown;
        }
 
        gpiochip_set_chained_irqchip(&altera_gc->mmchip.gc,
@@ -326,6 +326,7 @@ static int altera_gpio_probe(struct platform_device *pdev)
 skip_irq:
        return 0;
 teardown:
+       of_mm_gpiochip_remove(&altera_gc->mmchip);
        pr_err("%s: registration failed with status %d\n",
                node->full_name, ret);
 
index ec58f42..cd007a6 100644 (file)
@@ -195,7 +195,7 @@ static int davinci_gpio_of_xlate(struct gpio_chip *gc,
 static int davinci_gpio_probe(struct platform_device *pdev)
 {
        int i, base;
-       unsigned ngpio;
+       unsigned ngpio, nbank;
        struct davinci_gpio_controller *chips;
        struct davinci_gpio_platform_data *pdata;
        struct davinci_gpio_regs __iomem *regs;
@@ -224,8 +224,9 @@ static int davinci_gpio_probe(struct platform_device *pdev)
        if (WARN_ON(ARCH_NR_GPIOS < ngpio))
                ngpio = ARCH_NR_GPIOS;
 
+       nbank = DIV_ROUND_UP(ngpio, 32);
        chips = devm_kzalloc(dev,
-                            ngpio * sizeof(struct davinci_gpio_controller),
+                            nbank * sizeof(struct davinci_gpio_controller),
                             GFP_KERNEL);
        if (!chips)
                return -ENOMEM;
@@ -511,7 +512,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
                        return irq;
                }
 
-               irq_domain = irq_domain_add_legacy(NULL, ngpio, irq, 0,
+               irq_domain = irq_domain_add_legacy(dev->of_node, ngpio, irq, 0,
                                                        &davinci_gpio_irq_ops,
                                                        chips);
                if (!irq_domain) {
index cf41440..d9ab0cd 100644 (file)
@@ -196,6 +196,44 @@ static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on)
        return 0;
 }
 
+static void gpio_rcar_irq_bus_lock(struct irq_data *d)
+{
+       struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+       struct gpio_rcar_priv *p = gpiochip_get_data(gc);
+
+       pm_runtime_get_sync(&p->pdev->dev);
+}
+
+static void gpio_rcar_irq_bus_sync_unlock(struct irq_data *d)
+{
+       struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+       struct gpio_rcar_priv *p = gpiochip_get_data(gc);
+
+       pm_runtime_put(&p->pdev->dev);
+}
+
+
+static int gpio_rcar_irq_request_resources(struct irq_data *d)
+{
+       struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+       struct gpio_rcar_priv *p = gpiochip_get_data(gc);
+       int error;
+
+       error = pm_runtime_get_sync(&p->pdev->dev);
+       if (error < 0)
+               return error;
+
+       return 0;
+}
+
+static void gpio_rcar_irq_release_resources(struct irq_data *d)
+{
+       struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+       struct gpio_rcar_priv *p = gpiochip_get_data(gc);
+
+       pm_runtime_put(&p->pdev->dev);
+}
+
 static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id)
 {
        struct gpio_rcar_priv *p = dev_id;
@@ -450,6 +488,10 @@ static int gpio_rcar_probe(struct platform_device *pdev)
        irq_chip->irq_unmask = gpio_rcar_irq_enable;
        irq_chip->irq_set_type = gpio_rcar_irq_set_type;
        irq_chip->irq_set_wake = gpio_rcar_irq_set_wake;
+       irq_chip->irq_bus_lock = gpio_rcar_irq_bus_lock;
+       irq_chip->irq_bus_sync_unlock = gpio_rcar_irq_bus_sync_unlock;
+       irq_chip->irq_request_resources = gpio_rcar_irq_request_resources;
+       irq_chip->irq_release_resources = gpio_rcar_irq_release_resources;
        irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND;
 
        ret = gpiochip_add_data(gpio_chip, p);
index 9a03d56..a80c8ce 100644 (file)
@@ -85,6 +85,8 @@ extern int amdgpu_vm_debug;
 extern int amdgpu_sched_jobs;
 extern int amdgpu_sched_hw_submission;
 extern int amdgpu_powerplay;
+extern unsigned amdgpu_pcie_gen_cap;
+extern unsigned amdgpu_pcie_lane_cap;
 
 #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS         3000
 #define AMDGPU_MAX_USEC_TIMEOUT                        100000  /* 100 ms */
@@ -127,47 +129,6 @@ extern int amdgpu_powerplay;
 #define AMDGPU_RESET_VCE                       (1 << 13)
 #define AMDGPU_RESET_VCE1                      (1 << 14)
 
-/* CG block flags */
-#define AMDGPU_CG_BLOCK_GFX                    (1 << 0)
-#define AMDGPU_CG_BLOCK_MC                     (1 << 1)
-#define AMDGPU_CG_BLOCK_SDMA                   (1 << 2)
-#define AMDGPU_CG_BLOCK_UVD                    (1 << 3)
-#define AMDGPU_CG_BLOCK_VCE                    (1 << 4)
-#define AMDGPU_CG_BLOCK_HDP                    (1 << 5)
-#define AMDGPU_CG_BLOCK_BIF                    (1 << 6)
-
-/* CG flags */
-#define AMDGPU_CG_SUPPORT_GFX_MGCG             (1 << 0)
-#define AMDGPU_CG_SUPPORT_GFX_MGLS             (1 << 1)
-#define AMDGPU_CG_SUPPORT_GFX_CGCG             (1 << 2)
-#define AMDGPU_CG_SUPPORT_GFX_CGLS             (1 << 3)
-#define AMDGPU_CG_SUPPORT_GFX_CGTS             (1 << 4)
-#define AMDGPU_CG_SUPPORT_GFX_CGTS_LS          (1 << 5)
-#define AMDGPU_CG_SUPPORT_GFX_CP_LS            (1 << 6)
-#define AMDGPU_CG_SUPPORT_GFX_RLC_LS           (1 << 7)
-#define AMDGPU_CG_SUPPORT_MC_LS                        (1 << 8)
-#define AMDGPU_CG_SUPPORT_MC_MGCG              (1 << 9)
-#define AMDGPU_CG_SUPPORT_SDMA_LS              (1 << 10)
-#define AMDGPU_CG_SUPPORT_SDMA_MGCG            (1 << 11)
-#define AMDGPU_CG_SUPPORT_BIF_LS               (1 << 12)
-#define AMDGPU_CG_SUPPORT_UVD_MGCG             (1 << 13)
-#define AMDGPU_CG_SUPPORT_VCE_MGCG             (1 << 14)
-#define AMDGPU_CG_SUPPORT_HDP_LS               (1 << 15)
-#define AMDGPU_CG_SUPPORT_HDP_MGCG             (1 << 16)
-
-/* PG flags */
-#define AMDGPU_PG_SUPPORT_GFX_PG               (1 << 0)
-#define AMDGPU_PG_SUPPORT_GFX_SMG              (1 << 1)
-#define AMDGPU_PG_SUPPORT_GFX_DMG              (1 << 2)
-#define AMDGPU_PG_SUPPORT_UVD                  (1 << 3)
-#define AMDGPU_PG_SUPPORT_VCE                  (1 << 4)
-#define AMDGPU_PG_SUPPORT_CP                   (1 << 5)
-#define AMDGPU_PG_SUPPORT_GDS                  (1 << 6)
-#define AMDGPU_PG_SUPPORT_RLC_SMU_HS           (1 << 7)
-#define AMDGPU_PG_SUPPORT_SDMA                 (1 << 8)
-#define AMDGPU_PG_SUPPORT_ACP                  (1 << 9)
-#define AMDGPU_PG_SUPPORT_SAMU                 (1 << 10)
-
 /* GFX current status */
 #define AMDGPU_GFX_NORMAL_MODE                 0x00000000L
 #define AMDGPU_GFX_SAFE_MODE                   0x00000001L
@@ -591,8 +552,6 @@ struct amdgpu_sa_manager {
        uint32_t                align;
 };
 
-struct amdgpu_sa_bo;
-
 /* sub-allocation buffer */
 struct amdgpu_sa_bo {
        struct list_head                olist;
@@ -2368,6 +2327,7 @@ bool amdgpu_ttm_bo_is_amdgpu_bo(struct ttm_buffer_object *bo);
 int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages);
 int amdgpu_ttm_tt_set_userptr(struct ttm_tt *ttm, uint64_t addr,
                                     uint32_t flags);
+bool amdgpu_ttm_tt_has_userptr(struct ttm_tt *ttm);
 struct mm_struct *amdgpu_ttm_tt_get_usermm(struct ttm_tt *ttm);
 bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start,
                                  unsigned long end);
index 84d68d6..32809f7 100644 (file)
@@ -30,25 +30,38 @@ const struct kfd2kgd_calls *kfd2kgd;
 const struct kgd2kfd_calls *kgd2kfd;
 bool (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);
 
-bool amdgpu_amdkfd_init(void)
+int amdgpu_amdkfd_init(void)
 {
+       int ret;
+
 #if defined(CONFIG_HSA_AMD_MODULE)
-       bool (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);
+       int (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);
 
        kgd2kfd_init_p = symbol_request(kgd2kfd_init);
 
        if (kgd2kfd_init_p == NULL)
-               return false;
+               return -ENOENT;
+
+       ret = kgd2kfd_init_p(KFD_INTERFACE_VERSION, &kgd2kfd);
+       if (ret) {
+               symbol_put(kgd2kfd_init);
+               kgd2kfd = NULL;
+       }
+
+#elif defined(CONFIG_HSA_AMD)
+       ret = kgd2kfd_init(KFD_INTERFACE_VERSION, &kgd2kfd);
+       if (ret)
+               kgd2kfd = NULL;
+
+#else
+       ret = -ENOENT;
 #endif
-       return true;
+
+       return ret;
 }
 
 bool amdgpu_amdkfd_load_interface(struct amdgpu_device *rdev)
 {
-#if defined(CONFIG_HSA_AMD_MODULE)
-       bool (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);
-#endif
-
        switch (rdev->asic_type) {
 #ifdef CONFIG_DRM_AMDGPU_CIK
        case CHIP_KAVERI:
@@ -62,35 +75,7 @@ bool amdgpu_amdkfd_load_interface(struct amdgpu_device *rdev)
                return false;
        }
 
-#if defined(CONFIG_HSA_AMD_MODULE)
-       kgd2kfd_init_p = symbol_request(kgd2kfd_init);
-
-       if (kgd2kfd_init_p == NULL) {
-               kfd2kgd = NULL;
-               return false;
-       }
-
-       if (!kgd2kfd_init_p(KFD_INTERFACE_VERSION, &kgd2kfd)) {
-               symbol_put(kgd2kfd_init);
-               kfd2kgd = NULL;
-               kgd2kfd = NULL;
-
-               return false;
-       }
-
        return true;
-#elif defined(CONFIG_HSA_AMD)
-       if (!kgd2kfd_init(KFD_INTERFACE_VERSION, &kgd2kfd)) {
-               kfd2kgd = NULL;
-               kgd2kfd = NULL;
-               return false;
-       }
-
-       return true;
-#else
-       kfd2kgd = NULL;
-       return false;
-#endif
 }
 
 void amdgpu_amdkfd_fini(void)
index a8be765..de530f6 100644 (file)
@@ -36,7 +36,7 @@ struct kgd_mem {
        void *cpu_ptr;
 };
 
-bool amdgpu_amdkfd_init(void);
+int amdgpu_amdkfd_init(void);
 void amdgpu_amdkfd_fini(void);
 
 bool amdgpu_amdkfd_load_interface(struct amdgpu_device *rdev);
index a081dda..7a4b101 100644 (file)
@@ -795,6 +795,12 @@ static int amdgpu_cgs_query_system_info(void *cgs_device,
        case CGS_SYSTEM_INFO_PCIE_MLW:
                sys_info->value = adev->pm.pcie_mlw_mask;
                break;
+       case CGS_SYSTEM_INFO_CG_FLAGS:
+               sys_info->value = adev->cg_flags;
+               break;
+       case CGS_SYSTEM_INFO_PG_FLAGS:
+               sys_info->value = adev->pg_flags;
+               break;
        default:
                return -ENODEV;
        }
index 89c3dd6..119cdc2 100644 (file)
@@ -77,7 +77,7 @@ void amdgpu_connector_hotplug(struct drm_connector *connector)
                        } else if (amdgpu_atombios_dp_needs_link_train(amdgpu_connector)) {
                                /* Don't try to start link training before we
                                 * have the dpcd */
-                               if (!amdgpu_atombios_dp_get_dpcd(amdgpu_connector))
+                               if (amdgpu_atombios_dp_get_dpcd(amdgpu_connector))
                                        return;
 
                                /* set it to OFF so that drm_helper_connector_dpms()
index 462fec0..6121174 100644 (file)
@@ -1768,15 +1768,20 @@ int amdgpu_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
        }
 
        /* post card */
-       amdgpu_atom_asic_init(adev->mode_info.atom_context);
+       if (!amdgpu_card_posted(adev))
+               amdgpu_atom_asic_init(adev->mode_info.atom_context);
 
        r = amdgpu_resume(adev);
+       if (r)
+               DRM_ERROR("amdgpu_resume failed (%d).\n", r);
 
        amdgpu_fence_driver_resume(adev);
 
-       r = amdgpu_ib_ring_tests(adev);
-       if (r)
-               DRM_ERROR("ib ring test failed (%d).\n", r);
+       if (resume) {
+               r = amdgpu_ib_ring_tests(adev);
+               if (r)
+                       DRM_ERROR("ib ring test failed (%d).\n", r);
+       }
 
        r = amdgpu_late_init(adev);
        if (r)
@@ -1909,80 +1914,97 @@ retry:
        return r;
 }
 
+#define AMDGPU_DEFAULT_PCIE_GEN_MASK 0x30007  /* gen: chipset 1/2, asic 1/2/3 */
+#define AMDGPU_DEFAULT_PCIE_MLW_MASK 0x2f0000 /* 1/2/4/8/16 lanes */
+
 void amdgpu_get_pcie_info(struct amdgpu_device *adev)
 {
        u32 mask;
        int ret;
 
-       if (pci_is_root_bus(adev->pdev->bus))
-               return;
+       if (amdgpu_pcie_gen_cap)
+               adev->pm.pcie_gen_mask = amdgpu_pcie_gen_cap;
 
-       if (amdgpu_pcie_gen2 == 0)
-               return;
+       if (amdgpu_pcie_lane_cap)
+               adev->pm.pcie_mlw_mask = amdgpu_pcie_lane_cap;
 
-       if (adev->flags & AMD_IS_APU)
+       /* covers APUs as well */
+       if (pci_is_root_bus(adev->pdev->bus)) {
+               if (adev->pm.pcie_gen_mask == 0)
+                       adev->pm.pcie_gen_mask = AMDGPU_DEFAULT_PCIE_GEN_MASK;
+               if (adev->pm.pcie_mlw_mask == 0)
+                       adev->pm.pcie_mlw_mask = AMDGPU_DEFAULT_PCIE_MLW_MASK;
                return;
+       }
 
-       ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask);
-       if (!ret) {
-               adev->pm.pcie_gen_mask = (CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN1 |
-                                         CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN2 |
-                                         CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN3);
-
-               if (mask & DRM_PCIE_SPEED_25)
-                       adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1;
-               if (mask & DRM_PCIE_SPEED_50)
-                       adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2;
-               if (mask & DRM_PCIE_SPEED_80)
-                       adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3;
-       }
-       ret = drm_pcie_get_max_link_width(adev->ddev, &mask);
-       if (!ret) {
-               switch (mask) {
-               case 32:
-                       adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X32 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
-                       break;
-               case 16:
-                       adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
-                       break;
-               case 12:
-                       adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
-                       break;
-               case 8:
-                       adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
-                       break;
-               case 4:
-                       adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
-                       break;
-               case 2:
-                       adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
-                                                 CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
-                       break;
-               case 1:
-                       adev->pm.pcie_mlw_mask = CAIL_PCIE_LINK_WIDTH_SUPPORT_X1;
-                       break;
-               default:
-                       break;
+       if (adev->pm.pcie_gen_mask == 0) {
+               ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask);
+               if (!ret) {
+                       adev->pm.pcie_gen_mask = (CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN1 |
+                                                 CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN2 |
+                                                 CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN3);
+
+                       if (mask & DRM_PCIE_SPEED_25)
+                               adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1;
+                       if (mask & DRM_PCIE_SPEED_50)
+                               adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2;
+                       if (mask & DRM_PCIE_SPEED_80)
+                               adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3;
+               } else {
+                       adev->pm.pcie_gen_mask = AMDGPU_DEFAULT_PCIE_GEN_MASK;
+               }
+       }
+       if (adev->pm.pcie_mlw_mask == 0) {
+               ret = drm_pcie_get_max_link_width(adev->ddev, &mask);
+               if (!ret) {
+                       switch (mask) {
+                       case 32:
+                               adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X32 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
+                               break;
+                       case 16:
+                               adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
+                               break;
+                       case 12:
+                               adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
+                               break;
+                       case 8:
+                               adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
+                               break;
+                       case 4:
+                               adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
+                               break;
+                       case 2:
+                               adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
+                                                         CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
+                               break;
+                       case 1:
+                               adev->pm.pcie_mlw_mask = CAIL_PCIE_LINK_WIDTH_SUPPORT_X1;
+                               break;
+                       default:
+                               break;
+                       }
+               } else {
+                       adev->pm.pcie_mlw_mask = AMDGPU_DEFAULT_PCIE_MLW_MASK;
                }
        }
 }
index 2cb53c2..f0ed974 100644 (file)
@@ -70,8 +70,8 @@ static void amdgpu_flip_work_func(struct work_struct *__work)
 
        struct drm_crtc *crtc = &amdgpuCrtc->base;
        unsigned long flags;
-       unsigned i;
-       int vpos, hpos, stat, min_udelay;
+       unsigned i, repcnt = 4;
+       int vpos, hpos, stat, min_udelay = 0;
        struct drm_vblank_crtc *vblank = &crtc->dev->vblank[work->crtc_id];
 
        if (amdgpu_flip_handle_fence(work, &work->excl))
@@ -97,7 +97,7 @@ static void amdgpu_flip_work_func(struct work_struct *__work)
         * In practice this won't execute very often unless on very fast
         * machines because the time window for this to happen is very small.
         */
-       for (;;) {
+       while (amdgpuCrtc->enabled && --repcnt) {
                /* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank
                 * start in hpos, and to the "fudged earlier" vblank start in
                 * vpos.
@@ -113,12 +113,24 @@ static void amdgpu_flip_work_func(struct work_struct *__work)
                        break;
 
                /* Sleep at least until estimated real start of hw vblank */
-               spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
                min_udelay = (-hpos + 1) * max(vblank->linedur_ns / 1000, 5);
+               if (min_udelay > vblank->framedur_ns / 2000) {
+                       /* Don't wait ridiculously long - something is wrong */
+                       repcnt = 0;
+                       break;
+               }
+               spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
                usleep_range(min_udelay, 2 * min_udelay);
                spin_lock_irqsave(&crtc->dev->event_lock, flags);
        };
 
+       if (!repcnt)
+               DRM_DEBUG_DRIVER("Delay problem on crtc %d: min_udelay %d, "
+                                "framedur %d, linedur %d, stat %d, vpos %d, "
+                                "hpos %d\n", work->crtc_id, min_udelay,
+                                vblank->framedur_ns / 1000,
+                                vblank->linedur_ns / 1000, stat, vpos, hpos);
+
        /* set the flip status */
        amdgpuCrtc->pflip_status = AMDGPU_FLIP_SUBMITTED;
        spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
index 875333b..f1e17d6 100644 (file)
@@ -80,6 +80,8 @@ int amdgpu_exp_hw_support = 0;
 int amdgpu_sched_jobs = 32;
 int amdgpu_sched_hw_submission = 2;
 int amdgpu_powerplay = -1;
+unsigned amdgpu_pcie_gen_cap = 0;
+unsigned amdgpu_pcie_lane_cap = 0;
 
 MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
 module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
@@ -158,6 +160,12 @@ MODULE_PARM_DESC(powerplay, "Powerplay component (1 = enable, 0 = disable, -1 =
 module_param_named(powerplay, amdgpu_powerplay, int, 0444);
 #endif
 
+MODULE_PARM_DESC(pcie_gen_cap, "PCIE Gen Caps (0: autodetect (default))");
+module_param_named(pcie_gen_cap, amdgpu_pcie_gen_cap, uint, 0444);
+
+MODULE_PARM_DESC(pcie_lane_cap, "PCIE Lane Caps (0: autodetect (default))");
+module_param_named(pcie_lane_cap, amdgpu_pcie_lane_cap, uint, 0444);
+
 static struct pci_device_id pciidlist[] = {
 #ifdef CONFIG_DRM_AMDGPU_CIK
        /* Kaveri */
@@ -310,6 +318,14 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
                return -ENODEV;
        }
 
+       /*
+        * Initialize amdkfd before starting radeon. If it was not loaded yet,
+        * defer radeon probing
+        */
+       ret = amdgpu_amdkfd_init();
+       if (ret == -EPROBE_DEFER)
+               return ret;
+
        /* Get rid of things like offb */
        ret = amdgpu_kick_out_firmware_fb(pdev);
        if (ret)
@@ -553,8 +569,6 @@ static int __init amdgpu_init(void)
        driver->num_ioctls = amdgpu_max_kms_ioctl;
        amdgpu_register_atpx_handler();
 
-       amdgpu_amdkfd_init();
-
        /* let modprobe override vga console setting */
        return drm_pci_init(driver, pdriver);
 }
index 7f6b4d9..1ecdf6c 100644 (file)
@@ -631,7 +631,8 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
                break;
        }
        ttm_eu_backoff_reservation(&ticket, &list);
-       if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE))
+       if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE) &&
+           !amdgpu_vm_debug)
                amdgpu_gem_va_update_vm(adev, bo_va, args->operation);
 
        drm_gem_object_unreference_unlocked(gobj);
index d77b2bd..ff9597c 100644 (file)
@@ -113,6 +113,10 @@ static ssize_t amdgpu_get_dpm_forced_performance_level(struct device *dev,
        struct drm_device *ddev = dev_get_drvdata(dev);
        struct amdgpu_device *adev = ddev->dev_private;
 
+       if  ((adev->flags & AMD_IS_PX) &&
+            (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
+               return snprintf(buf, PAGE_SIZE, "off\n");
+
        if (adev->pp_enabled) {
                enum amd_dpm_forced_level level;
 
@@ -142,6 +146,11 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
        enum amdgpu_dpm_forced_level level;
        int ret = 0;
 
+       /* Can't force performance level when the card is off */
+       if  ((adev->flags & AMD_IS_PX) &&
+            (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
+               return -EINVAL;
+
        if (strncmp("low", buf, strlen("low")) == 0) {
                level = AMDGPU_DPM_FORCED_LEVEL_LOW;
        } else if (strncmp("high", buf, strlen("high")) == 0) {
@@ -161,6 +170,7 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
                mutex_lock(&adev->pm.mutex);
                if (adev->pm.dpm.thermal_active) {
                        count = -EINVAL;
+                       mutex_unlock(&adev->pm.mutex);
                        goto fail;
                }
                ret = amdgpu_dpm_force_performance_level(adev, level);
@@ -171,8 +181,6 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,
                mutex_unlock(&adev->pm.mutex);
        }
 fail:
-       mutex_unlock(&adev->pm.mutex);
-
        return count;
 }
 
@@ -469,8 +477,14 @@ static ssize_t amdgpu_hwmon_show_temp(struct device *dev,
                                      char *buf)
 {
        struct amdgpu_device *adev = dev_get_drvdata(dev);
+       struct drm_device *ddev = adev->ddev;
        int temp;
 
+       /* Can't get temperature when the card is off */
+       if  ((adev->flags & AMD_IS_PX) &&
+            (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
+               return -EINVAL;
+
        if (!adev->pp_enabled && !adev->pm.funcs->get_temperature)
                temp = 0;
        else
@@ -919,11 +933,6 @@ force:
 
        /* update display watermarks based on new power state */
        amdgpu_display_bandwidth_update(adev);
-       /* update displays */
-       amdgpu_dpm_display_configuration_changed(adev);
-
-       adev->pm.dpm.current_active_crtcs = adev->pm.dpm.new_active_crtcs;
-       adev->pm.dpm.current_active_crtc_count = adev->pm.dpm.new_active_crtc_count;
 
        /* wait for the rings to drain */
        for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
@@ -940,6 +949,12 @@ force:
 
        amdgpu_dpm_post_set_power_state(adev);
 
+       /* update displays */
+       amdgpu_dpm_display_configuration_changed(adev);
+
+       adev->pm.dpm.current_active_crtcs = adev->pm.dpm.new_active_crtcs;
+       adev->pm.dpm.current_active_crtc_count = adev->pm.dpm.new_active_crtc_count;
+
        if (adev->pm.funcs->force_performance_level) {
                if (adev->pm.dpm.thermal_active) {
                        enum amdgpu_dpm_forced_level level = adev->pm.dpm.forced_level;
@@ -1174,12 +1189,16 @@ static int amdgpu_debugfs_pm_info(struct seq_file *m, void *data)
        struct drm_info_node *node = (struct drm_info_node *) m->private;
        struct drm_device *dev = node->minor->dev;
        struct amdgpu_device *adev = dev->dev_private;
+       struct drm_device *ddev = adev->ddev;
 
        if (!adev->pm.dpm_enabled) {
                seq_printf(m, "dpm not enabled\n");
                return 0;
        }
-       if (adev->pp_enabled) {
+       if  ((adev->flags & AMD_IS_PX) &&
+            (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) {
+               seq_printf(m, "PX asic powered off\n");
+       } else if (adev->pp_enabled) {
                amdgpu_dpm_debugfs_print_current_performance_level(adev, m);
        } else {
                mutex_lock(&adev->pm.mutex);
index b9d0d55..3cb6d6c 100644 (file)
@@ -143,8 +143,10 @@ static int amdgpu_pp_late_init(void *handle)
                                        adev->powerplay.pp_handle);
 
 #ifdef CONFIG_DRM_AMD_POWERPLAY
-       if (adev->pp_enabled)
+       if (adev->pp_enabled) {
                amdgpu_pm_sysfs_init(adev);
+               amdgpu_dpm_dispatch_task(adev, AMD_PP_EVENT_COMPLETE_INIT, NULL, NULL);
+       }
 #endif
        return ret;
 }
index 7d8f8f1..2faf03b 100644 (file)
@@ -357,12 +357,15 @@ int amdgpu_sa_bo_new(struct amdgpu_sa_manager *sa_manager,
 
                for (i = 0, count = 0; i < AMDGPU_MAX_RINGS; ++i)
                        if (fences[i])
-                               fences[count++] = fences[i];
+                               fences[count++] = fence_get(fences[i]);
 
                if (count) {
                        spin_unlock(&sa_manager->wq.lock);
                        t = fence_wait_any_timeout(fences, count, false,
                                                   MAX_SCHEDULE_TIMEOUT);
+                       for (i = 0; i < count; ++i)
+                               fence_put(fences[i]);
+
                        r = (t > 0) ? 0 : t;
                        spin_lock(&sa_manager->wq.lock);
                } else {
index ed0d2e7..0f42b1a 100644 (file)
@@ -755,7 +755,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm)
                                                       0, PAGE_SIZE,
                                                       PCI_DMA_BIDIRECTIONAL);
                if (pci_dma_mapping_error(adev->pdev, gtt->ttm.dma_address[i])) {
-                       while (--i) {
+                       while (i--) {
                                pci_unmap_page(adev->pdev, gtt->ttm.dma_address[i],
                                               PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
                                gtt->ttm.dma_address[i] = 0;
index 21aacc1..bf731e9 100644 (file)
@@ -265,15 +265,27 @@ static int amdgpu_atombios_dp_get_dp_link_config(struct drm_connector *connector
        unsigned max_lane_num = drm_dp_max_lane_count(dpcd);
        unsigned lane_num, i, max_pix_clock;
 
-       for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) {
-               for (i = 0; i < ARRAY_SIZE(link_rates) && link_rates[i] <= max_link_rate; i++) {
-                       max_pix_clock = (lane_num * link_rates[i] * 8) / bpp;
+       if (amdgpu_connector_encoder_get_dp_bridge_encoder_id(connector) ==
+           ENCODER_OBJECT_ID_NUTMEG) {
+               for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) {
+                       max_pix_clock = (lane_num * 270000 * 8) / bpp;
                        if (max_pix_clock >= pix_clock) {
                                *dp_lanes = lane_num;
-                               *dp_rate = link_rates[i];
+                               *dp_rate = 270000;
                                return 0;
                        }
                }
+       } else {
+               for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) {
+                       for (i = 0; i < ARRAY_SIZE(link_rates) && link_rates[i] <= max_link_rate; i++) {
+                               max_pix_clock = (lane_num * link_rates[i] * 8) / bpp;
+                               if (max_pix_clock >= pix_clock) {
+                                       *dp_lanes = lane_num;
+                                       *dp_rate = link_rates[i];
+                                       return 0;
+                               }
+                       }
+               }
        }
 
        return -EINVAL;
index 061ba07..1f9109d 100644 (file)
@@ -31,6 +31,7 @@
 #include "ci_dpm.h"
 #include "gfx_v7_0.h"
 #include "atom.h"
+#include "amd_pcie.h"
 #include <linux/seq_file.h>
 
 #include "smu/smu_7_0_1_d.h"
@@ -5792,18 +5793,16 @@ static int ci_dpm_init(struct amdgpu_device *adev)
        u8 frev, crev;
        struct ci_power_info *pi;
        int ret;
-       u32 mask;
 
        pi = kzalloc(sizeof(struct ci_power_info), GFP_KERNEL);
        if (pi == NULL)
                return -ENOMEM;
        adev->pm.dpm.priv = pi;
 
-       ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask);
-       if (ret)
-               pi->sys_pcie_mask = 0;
-       else
-               pi->sys_pcie_mask = mask;
+       pi->sys_pcie_mask =
+               (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_MASK) >>
+               CAIL_PCIE_LINK_SPEED_SUPPORT_SHIFT;
+
        pi->force_pcie_gen = AMDGPU_PCIE_GEN_INVALID;
 
        pi->pcie_gen_performance.max = AMDGPU_PCIE_GEN1;
index 5da14a3..bddc9ba 100644 (file)
@@ -1462,6 +1462,9 @@ static void cik_program_aspm(struct amdgpu_device *adev)
        if (amdgpu_aspm == 0)
                return;
 
+       if (pci_is_root_bus(adev->pdev->bus))
+               return;
+
        /* XXX double check APUs */
        if (adev->flags & AMD_IS_APU)
                return;
@@ -2030,72 +2033,72 @@ static int cik_common_early_init(void *handle)
        switch (adev->asic_type) {
        case CHIP_BONAIRE:
                adev->cg_flags =
-                       AMDGPU_CG_SUPPORT_GFX_MGCG |
-                       AMDGPU_CG_SUPPORT_GFX_MGLS |
-                       /*AMDGPU_CG_SUPPORT_GFX_CGCG |*/
-                       AMDGPU_CG_SUPPORT_GFX_CGLS |
-                       AMDGPU_CG_SUPPORT_GFX_CGTS |
-                       AMDGPU_CG_SUPPORT_GFX_CGTS_LS |
-                       AMDGPU_CG_SUPPORT_GFX_CP_LS |
-                       AMDGPU_CG_SUPPORT_MC_LS |
-                       AMDGPU_CG_SUPPORT_MC_MGCG |
-                       AMDGPU_CG_SUPPORT_SDMA_MGCG |
-                       AMDGPU_CG_SUPPORT_SDMA_LS |
-                       AMDGPU_CG_SUPPORT_BIF_LS |
-                       AMDGPU_CG_SUPPORT_VCE_MGCG |
-                       AMDGPU_CG_SUPPORT_UVD_MGCG |
-                       AMDGPU_CG_SUPPORT_HDP_LS |
-                       AMDGPU_CG_SUPPORT_HDP_MGCG;
+                       AMD_CG_SUPPORT_GFX_MGCG |
+                       AMD_CG_SUPPORT_GFX_MGLS |
+                       /*AMD_CG_SUPPORT_GFX_CGCG |*/
+                       AMD_CG_SUPPORT_GFX_CGLS |
+                       AMD_CG_SUPPORT_GFX_CGTS |
+                       AMD_CG_SUPPORT_GFX_CGTS_LS |
+                       AMD_CG_SUPPORT_GFX_CP_LS |
+                       AMD_CG_SUPPORT_MC_LS |
+                       AMD_CG_SUPPORT_MC_MGCG |
+                       AMD_CG_SUPPORT_SDMA_MGCG |
+                       AMD_CG_SUPPORT_SDMA_LS |
+                       AMD_CG_SUPPORT_BIF_LS |
+                       AMD_CG_SUPPORT_VCE_MGCG |
+                       AMD_CG_SUPPORT_UVD_MGCG |
+                       AMD_CG_SUPPORT_HDP_LS |
+                       AMD_CG_SUPPORT_HDP_MGCG;
                adev->pg_flags = 0;
                adev->external_rev_id = adev->rev_id + 0x14;
                break;
        case CHIP_HAWAII:
                adev->cg_flags =
-                       AMDGPU_CG_SUPPORT_GFX_MGCG |
-                       AMDGPU_CG_SUPPORT_GFX_MGLS |
-                       /*AMDGPU_CG_SUPPORT_GFX_CGCG |*/
-                       AMDGPU_CG_SUPPORT_GFX_CGLS |
-                       AMDGPU_CG_SUPPORT_GFX_CGTS |
-                       AMDGPU_CG_SUPPORT_GFX_CP_LS |
-                       AMDGPU_CG_SUPPORT_MC_LS |
-                       AMDGPU_CG_SUPPORT_MC_MGCG |
-                       AMDGPU_CG_SUPPORT_SDMA_MGCG |
-                       AMDGPU_CG_SUPPORT_SDMA_LS |
-                       AMDGPU_CG_SUPPORT_BIF_LS |
-                       AMDGPU_CG_SUPPORT_VCE_MGCG |
-                       AMDGPU_CG_SUPPORT_UVD_MGCG |
-                       AMDGPU_CG_SUPPORT_HDP_LS |
-                       AMDGPU_CG_SUPPORT_HDP_MGCG;
+                       AMD_CG_SUPPORT_GFX_MGCG |
+                       AMD_CG_SUPPORT_GFX_MGLS |
+                       /*AMD_CG_SUPPORT_GFX_CGCG |*/
+                       AMD_CG_SUPPORT_GFX_CGLS |
+                       AMD_CG_SUPPORT_GFX_CGTS |
+                       AMD_CG_SUPPORT_GFX_CP_LS |
+                       AMD_CG_SUPPORT_MC_LS |
+                       AMD_CG_SUPPORT_MC_MGCG |
+                       AMD_CG_SUPPORT_SDMA_MGCG |
+                       AMD_CG_SUPPORT_SDMA_LS |
+                       AMD_CG_SUPPORT_BIF_LS |
+                       AMD_CG_SUPPORT_VCE_MGCG |
+                       AMD_CG_SUPPORT_UVD_MGCG |
+                       AMD_CG_SUPPORT_HDP_LS |
+                       AMD_CG_SUPPORT_HDP_MGCG;
                adev->pg_flags = 0;
                adev->external_rev_id = 0x28;
                break;
        case CHIP_KAVERI:
                adev->cg_flags =
-                       AMDGPU_CG_SUPPORT_GFX_MGCG |
-                       AMDGPU_CG_SUPPORT_GFX_MGLS |
-                       /*AMDGPU_CG_SUPPORT_GFX_CGCG |*/
-                       AMDGPU_CG_SUPPORT_GFX_CGLS |
-                       AMDGPU_CG_SUPPORT_GFX_CGTS |
-                       AMDGPU_CG_SUPPORT_GFX_CGTS_LS |
-                       AMDGPU_CG_SUPPORT_GFX_CP_LS |
-                       AMDGPU_CG_SUPPORT_SDMA_MGCG |
-                       AMDGPU_CG_SUPPORT_SDMA_LS |
-                       AMDGPU_CG_SUPPORT_BIF_LS |
-                       AMDGPU_CG_SUPPORT_VCE_MGCG |
-                       AMDGPU_CG_SUPPORT_UVD_MGCG |
-                       AMDGPU_CG_SUPPORT_HDP_LS |
-                       AMDGPU_CG_SUPPORT_HDP_MGCG;
+                       AMD_CG_SUPPORT_GFX_MGCG |
+                       AMD_CG_SUPPORT_GFX_MGLS |
+                       /*AMD_CG_SUPPORT_GFX_CGCG |*/
+                       AMD_CG_SUPPORT_GFX_CGLS |
+                       AMD_CG_SUPPORT_GFX_CGTS |
+                       AMD_CG_SUPPORT_GFX_CGTS_LS |
+                       AMD_CG_SUPPORT_GFX_CP_LS |
+                       AMD_CG_SUPPORT_SDMA_MGCG |
+                       AMD_CG_SUPPORT_SDMA_LS |
+                       AMD_CG_SUPPORT_BIF_LS |
+                       AMD_CG_SUPPORT_VCE_MGCG |
+                       AMD_CG_SUPPORT_UVD_MGCG |
+                       AMD_CG_SUPPORT_HDP_LS |
+                       AMD_CG_SUPPORT_HDP_MGCG;
                adev->pg_flags =
-                       /*AMDGPU_PG_SUPPORT_GFX_PG |
-                         AMDGPU_PG_SUPPORT_GFX_SMG |
-                         AMDGPU_PG_SUPPORT_GFX_DMG |*/
-                       AMDGPU_PG_SUPPORT_UVD |
-                       /*AMDGPU_PG_SUPPORT_VCE |
-                         AMDGPU_PG_SUPPORT_CP |
-                         AMDGPU_PG_SUPPORT_GDS |
-                         AMDGPU_PG_SUPPORT_RLC_SMU_HS |
-                         AMDGPU_PG_SUPPORT_ACP |
-                         AMDGPU_PG_SUPPORT_SAMU |*/
+                       /*AMD_PG_SUPPORT_GFX_PG |
+                         AMD_PG_SUPPORT_GFX_SMG |
+                         AMD_PG_SUPPORT_GFX_DMG |*/
+                       AMD_PG_SUPPORT_UVD |
+                       /*AMD_PG_SUPPORT_VCE |
+                         AMD_PG_SUPPORT_CP |
+                         AMD_PG_SUPPORT_GDS |
+                         AMD_PG_SUPPORT_RLC_SMU_HS |
+                         AMD_PG_SUPPORT_ACP |
+                         AMD_PG_SUPPORT_SAMU |*/
                        0;
                if (adev->pdev->device == 0x1312 ||
                        adev->pdev->device == 0x1316 ||
@@ -2107,29 +2110,29 @@ static int cik_common_early_init(void *handle)
        case CHIP_KABINI:
        case CHIP_MULLINS:
                adev->cg_flags =
-                       AMDGPU_CG_SUPPORT_GFX_MGCG |
-                       AMDGPU_CG_SUPPORT_GFX_MGLS |
-                       /*AMDGPU_CG_SUPPORT_GFX_CGCG |*/
-                       AMDGPU_CG_SUPPORT_GFX_CGLS |
-                       AMDGPU_CG_SUPPORT_GFX_CGTS |
-                       AMDGPU_CG_SUPPORT_GFX_CGTS_LS |
-                       AMDGPU_CG_SUPPORT_GFX_CP_LS |
-                       AMDGPU_CG_SUPPORT_SDMA_MGCG |
-                       AMDGPU_CG_SUPPORT_SDMA_LS |
-                       AMDGPU_CG_SUPPORT_BIF_LS |
-                       AMDGPU_CG_SUPPORT_VCE_MGCG |
-                       AMDGPU_CG_SUPPORT_UVD_MGCG |
-                       AMDGPU_CG_SUPPORT_HDP_LS |
-                       AMDGPU_CG_SUPPORT_HDP_MGCG;
+                       AMD_CG_SUPPORT_GFX_MGCG |
+                       AMD_CG_SUPPORT_GFX_MGLS |
+                       /*AMD_CG_SUPPORT_GFX_CGCG |*/
+                       AMD_CG_SUPPORT_GFX_CGLS |
+                       AMD_CG_SUPPORT_GFX_CGTS |
+                       AMD_CG_SUPPORT_GFX_CGTS_LS |
+                       AMD_CG_SUPPORT_GFX_CP_LS |
+                       AMD_CG_SUPPORT_SDMA_MGCG |
+                       AMD_CG_SUPPORT_SDMA_LS |
+                       AMD_CG_SUPPORT_BIF_LS |
+                       AMD_CG_SUPPORT_VCE_MGCG |
+                       AMD_CG_SUPPORT_UVD_MGCG |
+                       AMD_CG_SUPPORT_HDP_LS |
+                       AMD_CG_SUPPORT_HDP_MGCG;
                adev->pg_flags =
-                       /*AMDGPU_PG_SUPPORT_GFX_PG |
-                         AMDGPU_PG_SUPPORT_GFX_SMG | */
-                       AMDGPU_PG_SUPPORT_UVD |
-                       /*AMDGPU_PG_SUPPORT_VCE |
-                         AMDGPU_PG_SUPPORT_CP |
-                         AMDGPU_PG_SUPPORT_GDS |
-                         AMDGPU_PG_SUPPORT_RLC_SMU_HS |
-                         AMDGPU_PG_SUPPORT_SAMU |*/
+                       /*AMD_PG_SUPPORT_GFX_PG |
+                         AMD_PG_SUPPORT_GFX_SMG | */
+                       AMD_PG_SUPPORT_UVD |
+                       /*AMD_PG_SUPPORT_VCE |
+                         AMD_PG_SUPPORT_CP |
+                         AMD_PG_SUPPORT_GDS |
+                         AMD_PG_SUPPORT_RLC_SMU_HS |
+                         AMD_PG_SUPPORT_SAMU |*/
                        0;
                if (adev->asic_type == CHIP_KABINI) {
                        if (adev->rev_id == 0)
index 8663a27..0212219 100644 (file)
@@ -886,7 +886,7 @@ static void cik_enable_sdma_mgcg(struct amdgpu_device *adev,
 {
        u32 orig, data;
 
-       if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_SDMA_MGCG)) {
+       if (enable && (adev->cg_flags & AMD_CG_SUPPORT_SDMA_MGCG)) {
                WREG32(mmSDMA0_CLK_CTRL + SDMA0_REGISTER_OFFSET, 0x00000100);
                WREG32(mmSDMA0_CLK_CTRL + SDMA1_REGISTER_OFFSET, 0x00000100);
        } else {
@@ -907,7 +907,7 @@ static void cik_enable_sdma_mgls(struct amdgpu_device *adev,
 {
        u32 orig, data;
 
-       if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_SDMA_LS)) {
+       if (enable && (adev->cg_flags & AMD_CG_SUPPORT_SDMA_LS)) {
                orig = data = RREG32(mmSDMA0_POWER_CNTL + SDMA0_REGISTER_OFFSET);
                data |= 0x100;
                if (orig != data)
index 4dd17f2..e7ef226 100644 (file)
@@ -445,13 +445,13 @@ static int cz_dpm_init(struct amdgpu_device *adev)
        pi->gfx_pg_threshold = 500;
        pi->caps_fps = true;
        /* uvd */
-       pi->caps_uvd_pg = (adev->pg_flags & AMDGPU_PG_SUPPORT_UVD) ? true : false;
+       pi->caps_uvd_pg = (adev->pg_flags & AMD_PG_SUPPORT_UVD) ? true : false;
        pi->caps_uvd_dpm = true;
        /* vce */
-       pi->caps_vce_pg = (adev->pg_flags & AMDGPU_PG_SUPPORT_VCE) ? true : false;
+       pi->caps_vce_pg = (adev->pg_flags & AMD_PG_SUPPORT_VCE) ? true : false;
        pi->caps_vce_dpm = true;
        /* acp */
-       pi->caps_acp_pg = (adev->pg_flags & AMDGPU_PG_SUPPORT_ACP) ? true : false;
+       pi->caps_acp_pg = (adev->pg_flags & AMD_PG_SUPPORT_ACP) ? true : false;
        pi->caps_acp_dpm = true;
 
        pi->caps_stable_power_state = false;
@@ -2202,8 +2202,7 @@ static void cz_dpm_powergate_vce(struct amdgpu_device *adev, bool gate)
                                                            AMD_PG_STATE_GATE);
 
                                cz_enable_vce_dpm(adev, false);
-                               /* TODO: to figure out why vce can't be poweroff. */
-                               /* cz_send_msg_to_smc(adev, PPSMC_MSG_VCEPowerOFF); */
+                               cz_send_msg_to_smc(adev, PPSMC_MSG_VCEPowerOFF);
                                pi->vce_power_gated = true;
                        } else {
                                cz_send_msg_to_smc(adev, PPSMC_MSG_VCEPowerON);
@@ -2226,10 +2225,8 @@ static void cz_dpm_powergate_vce(struct amdgpu_device *adev, bool gate)
                }
        } else { /*pi->caps_vce_pg*/
                cz_update_vce_dpm(adev);
-               cz_enable_vce_dpm(adev, true);
+               cz_enable_vce_dpm(adev, !gate);
        }
-
-       return;
 }
 
 const struct amd_ip_funcs cz_dpm_ip_funcs = {
index a4913eb..a06045f 100644 (file)
@@ -3079,6 +3079,18 @@ static void gfx_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
                                        unsigned vm_id, uint64_t pd_addr)
 {
        int usepfp = (ring->type == AMDGPU_RING_TYPE_GFX);
+       uint32_t seq = ring->fence_drv.sync_seq;
+       uint64_t addr = ring->fence_drv.gpu_addr;
+
+       amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5));
+       amdgpu_ring_write(ring, (WAIT_REG_MEM_MEM_SPACE(1) | /* memory */
+                                WAIT_REG_MEM_FUNCTION(3) | /* equal */
+                                WAIT_REG_MEM_ENGINE(usepfp)));   /* pfp or me */
+       amdgpu_ring_write(ring, addr & 0xfffffffc);
+       amdgpu_ring_write(ring, upper_32_bits(addr) & 0xffffffff);
+       amdgpu_ring_write(ring, seq);
+       amdgpu_ring_write(ring, 0xffffffff);
+       amdgpu_ring_write(ring, 4); /* poll interval */
 
        amdgpu_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 3));
        amdgpu_ring_write(ring, (WRITE_DATA_ENGINE_SEL(usepfp) |
@@ -3553,7 +3565,7 @@ static void gfx_v7_0_enable_cgcg(struct amdgpu_device *adev, bool enable)
 
        orig = data = RREG32(mmRLC_CGCG_CGLS_CTRL);
 
-       if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_GFX_CGCG)) {
+       if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGCG)) {
                gfx_v7_0_enable_gui_idle_interrupt(adev, true);
 
                tmp = gfx_v7_0_halt_rlc(adev);
@@ -3591,9 +3603,9 @@ static void gfx_v7_0_enable_mgcg(struct amdgpu_device *adev, bool enable)
 {
        u32 data, orig, tmp = 0;
 
-       if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_GFX_MGCG)) {
-               if (adev->cg_flags & AMDGPU_CG_SUPPORT_GFX_MGLS) {
-                       if (adev->cg_flags & AMDGPU_CG_SUPPORT_GFX_CP_LS) {
+       if (enable && (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGCG)) {
+               if (adev->cg_flags & AMD_CG_SUPPORT_GFX_MGLS) {
+                       if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CP_LS) {
                                orig = data = RREG32(mmCP_MEM_SLP_CNTL);
                                data |= CP_MEM_SLP_CNTL__CP_MEM_LS_EN_MASK;
                                if (orig != data)
@@ -3620,14 +3632,14 @@ static void gfx_v7_0_enable_mgcg(struct amdgpu_device *adev, bool enable)
 
                gfx_v7_0_update_rlc(adev, tmp);
 
-               if (adev->cg_flags & AMDGPU_CG_SUPPORT_GFX_CGTS) {
+               if (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGTS) {
                        orig = data = RREG32(mmCGTS_SM_CTRL_REG);
                        data &= ~CGTS_SM_CTRL_REG__SM_MODE_MASK;
                        data |= (0x2 << CGTS_SM_CTRL_REG__SM_MODE__SHIFT);
                        data |= CGTS_SM_CTRL_REG__SM_MODE_ENABLE_MASK;
                        data &= ~CGTS_SM_CTRL_REG__OVERRIDE_MASK;
-                       if ((adev->cg_flags & AMDGPU_CG_SUPPORT_GFX_MGLS) &&
-                           (adev->cg_flags & AMDGPU_CG_SUPPORT_GFX_CGTS_LS))
+                       if ((adev->cg_flags & AMD_CG_SUPPORT_GFX_MGLS) &&
+                           (adev->cg_flags & AMD_CG_SUPPORT_GFX_CGTS_LS))
                                data &= ~CGTS_SM_CTRL_REG__LS_OVERRIDE_MASK;
                        data &= ~CGTS_SM_CTRL_REG__ON_MONITOR_ADD_MASK;
                        data |= CGTS_SM_CTRL_REG__ON_MONITOR_ADD_EN_MASK;
@@ -3693,7 +3705,7 @@ static void gfx_v7_0_enable_sclk_slowdown_on_pu(struct amdgpu_device *adev,
        u32 data, orig;
 
        orig = data = RREG32(mmRLC_PG_CNTL);
-       if (enable && (adev->pg_flags & AMDGPU_PG_SUPPORT_RLC_SMU_HS))
+       if (enable && (adev->pg_flags & AMD_PG_SUPPORT_RLC_SMU_HS))
                data |= RLC_PG_CNTL__SMU_CLK_SLOWDOWN_ON_PU_ENABLE_MASK;
        else
                data &= ~RLC_PG_CNTL__SMU_CLK_SLOWDOWN_ON_PU_ENABLE_MASK;
@@ -3707,7 +3719,7 @@ static void gfx_v7_0_enable_sclk_slowdown_on_pd(struct amdgpu_device *adev,
        u32 data, orig;
 
        orig = data = RREG32(mmRLC_PG_CNTL);
-       if (enable && (adev->pg_flags & AMDGPU_PG_SUPPORT_RLC_SMU_HS))
+       if (enable && (adev->pg_flags & AMD_PG_SUPPORT_RLC_SMU_HS))
                data |= RLC_PG_CNTL__SMU_CLK_SLOWDOWN_ON_PD_ENABLE_MASK;
        else
                data &= ~RLC_PG_CNTL__SMU_CLK_SLOWDOWN_ON_PD_ENABLE_MASK;
@@ -3720,7 +3732,7 @@ static void gfx_v7_0_enable_cp_pg(struct amdgpu_device *adev, bool enable)
        u32 data, orig;
 
        orig = data = RREG32(mmRLC_PG_CNTL);
-       if (enable && (adev->pg_flags & AMDGPU_PG_SUPPORT_CP))
+       if (enable && (adev->pg_flags & AMD_PG_SUPPORT_CP))
                data &= ~0x8000;
        else
                data |= 0x8000;
@@ -3733,7 +3745,7 @@ static void gfx_v7_0_enable_gds_pg(struct amdgpu_device *adev, bool enable)
        u32 data, orig;
 
        orig = data = RREG32(mmRLC_PG_CNTL);
-       if (enable && (adev->pg_flags & AMDGPU_PG_SUPPORT_GDS))
+       if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GDS))
                data &= ~0x2000;
        else
                data |= 0x2000;
@@ -3814,7 +3826,7 @@ static void gfx_v7_0_enable_gfx_cgpg(struct amdgpu_device *adev,
 {
        u32 data, orig;
 
-       if (enable && (adev->pg_flags & AMDGPU_PG_SUPPORT_GFX_PG)) {
+       if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)) {
                orig = data = RREG32(mmRLC_PG_CNTL);
                data |= RLC_PG_CNTL__GFX_POWER_GATING_ENABLE_MASK;
                if (orig != data)
@@ -3877,7 +3889,7 @@ static void gfx_v7_0_enable_gfx_static_mgpg(struct amdgpu_device *adev,
        u32 data, orig;
 
        orig = data = RREG32(mmRLC_PG_CNTL);
-       if (enable && (adev->pg_flags & AMDGPU_PG_SUPPORT_GFX_SMG))
+       if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_SMG))
                data |= RLC_PG_CNTL__STATIC_PER_CU_PG_ENABLE_MASK;
        else
                data &= ~RLC_PG_CNTL__STATIC_PER_CU_PG_ENABLE_MASK;
@@ -3891,7 +3903,7 @@ static void gfx_v7_0_enable_gfx_dynamic_mgpg(struct amdgpu_device *adev,
        u32 data, orig;
 
        orig = data = RREG32(mmRLC_PG_CNTL);
-       if (enable && (adev->pg_flags & AMDGPU_PG_SUPPORT_GFX_DMG))
+       if (enable && (adev->pg_flags & AMD_PG_SUPPORT_GFX_DMG))
                data |= RLC_PG_CNTL__DYN_PER_CU_PG_ENABLE_MASK;
        else
                data &= ~RLC_PG_CNTL__DYN_PER_CU_PG_ENABLE_MASK;
@@ -4058,15 +4070,15 @@ static void gfx_v7_0_get_csb_buffer(struct amdgpu_device *adev,
 
 static void gfx_v7_0_init_pg(struct amdgpu_device *adev)
 {
-       if (adev->pg_flags & (AMDGPU_PG_SUPPORT_GFX_PG |
-                             AMDGPU_PG_SUPPORT_GFX_SMG |
-                             AMDGPU_PG_SUPPORT_GFX_DMG |
-                             AMDGPU_PG_SUPPORT_CP |
-                             AMDGPU_PG_SUPPORT_GDS |
-                             AMDGPU_PG_SUPPORT_RLC_SMU_HS)) {
+       if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |
+                             AMD_PG_SUPPORT_GFX_SMG |
+                             AMD_PG_SUPPORT_GFX_DMG |
+                             AMD_PG_SUPPORT_CP |
+                             AMD_PG_SUPPORT_GDS |
+                             AMD_PG_SUPPORT_RLC_SMU_HS)) {
                gfx_v7_0_enable_sclk_slowdown_on_pu(adev, true);
                gfx_v7_0_enable_sclk_slowdown_on_pd(adev, true);
-               if (adev->pg_flags & AMDGPU_PG_SUPPORT_GFX_PG) {
+               if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) {
                        gfx_v7_0_init_gfx_cgpg(adev);
                        gfx_v7_0_enable_cp_pg(adev, true);
                        gfx_v7_0_enable_gds_pg(adev, true);
@@ -4078,14 +4090,14 @@ static void gfx_v7_0_init_pg(struct amdgpu_device *adev)
 
 static void gfx_v7_0_fini_pg(struct amdgpu_device *adev)
 {
-       if (adev->pg_flags & (AMDGPU_PG_SUPPORT_GFX_PG |
-                             AMDGPU_PG_SUPPORT_GFX_SMG |
-                             AMDGPU_PG_SUPPORT_GFX_DMG |
-                             AMDGPU_PG_SUPPORT_CP |
-                             AMDGPU_PG_SUPPORT_GDS |
-                             AMDGPU_PG_SUPPORT_RLC_SMU_HS)) {
+       if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |
+                             AMD_PG_SUPPORT_GFX_SMG |
+                             AMD_PG_SUPPORT_GFX_DMG |
+                             AMD_PG_SUPPORT_CP |
+                             AMD_PG_SUPPORT_GDS |
+                             AMD_PG_SUPPORT_RLC_SMU_HS)) {
                gfx_v7_0_update_gfx_pg(adev, false);
-               if (adev->pg_flags & AMDGPU_PG_SUPPORT_GFX_PG) {
+               if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) {
                        gfx_v7_0_enable_cp_pg(adev, false);
                        gfx_v7_0_enable_gds_pg(adev, false);
                }
@@ -5120,14 +5132,14 @@ static int gfx_v7_0_set_powergating_state(void *handle,
        if (state == AMD_PG_STATE_GATE)
                gate = true;
 
-       if (adev->pg_flags & (AMDGPU_PG_SUPPORT_GFX_PG |
-                             AMDGPU_PG_SUPPORT_GFX_SMG |
-                             AMDGPU_PG_SUPPORT_GFX_DMG |
-                             AMDGPU_PG_SUPPORT_CP |
-                             AMDGPU_PG_SUPPORT_GDS |
-                             AMDGPU_PG_SUPPORT_RLC_SMU_HS)) {
+       if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |
+                             AMD_PG_SUPPORT_GFX_SMG |
+                             AMD_PG_SUPPORT_GFX_DMG |
+                             AMD_PG_SUPPORT_CP |
+                             AMD_PG_SUPPORT_GDS |
+                             AMD_PG_SUPPORT_RLC_SMU_HS)) {
                gfx_v7_0_update_gfx_pg(adev, gate);
-               if (adev->pg_flags & AMDGPU_PG_SUPPORT_GFX_PG) {
+               if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) {
                        gfx_v7_0_enable_cp_pg(adev, gate);
                        gfx_v7_0_enable_gds_pg(adev, gate);
                }
index 828e205..509d0ba 100644 (file)
@@ -4700,7 +4700,8 @@ static void gfx_v8_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring)
 
        amdgpu_ring_write(ring, PACKET3(PACKET3_WAIT_REG_MEM, 5));
        amdgpu_ring_write(ring, (WAIT_REG_MEM_MEM_SPACE(1) | /* memory */
-                WAIT_REG_MEM_FUNCTION(3))); /* equal */
+                                WAIT_REG_MEM_FUNCTION(3) | /* equal */
+                                WAIT_REG_MEM_ENGINE(usepfp))); /* pfp or me */
        amdgpu_ring_write(ring, addr & 0xfffffffc);
        amdgpu_ring_write(ring, upper_32_bits(addr) & 0xffffffff);
        amdgpu_ring_write(ring, seq);
@@ -4892,7 +4893,7 @@ static int gfx_v8_0_set_priv_reg_fault_state(struct amdgpu_device *adev,
        case AMDGPU_IRQ_STATE_ENABLE:
                cp_int_cntl = RREG32(mmCP_INT_CNTL_RING0);
                cp_int_cntl = REG_SET_FIELD(cp_int_cntl, CP_INT_CNTL_RING0,
-                                           PRIV_REG_INT_ENABLE, 0);
+                                           PRIV_REG_INT_ENABLE, 1);
                WREG32(mmCP_INT_CNTL_RING0, cp_int_cntl);
                break;
        default:
index 45cde43..82ce7d9 100644 (file)
@@ -793,7 +793,7 @@ static void gmc_v7_0_enable_mc_ls(struct amdgpu_device *adev,
 
        for (i = 0; i < ARRAY_SIZE(mc_cg_registers); i++) {
                orig = data = RREG32(mc_cg_registers[i]);
-               if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_MC_LS))
+               if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_LS))
                        data |= mc_cg_ls_en[i];
                else
                        data &= ~mc_cg_ls_en[i];
@@ -810,7 +810,7 @@ static void gmc_v7_0_enable_mc_mgcg(struct amdgpu_device *adev,
 
        for (i = 0; i < ARRAY_SIZE(mc_cg_registers); i++) {
                orig = data = RREG32(mc_cg_registers[i]);
-               if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_MC_MGCG))
+               if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_MGCG))
                        data |= mc_cg_en[i];
                else
                        data &= ~mc_cg_en[i];
@@ -826,7 +826,7 @@ static void gmc_v7_0_enable_bif_mgls(struct amdgpu_device *adev,
 
        orig = data = RREG32_PCIE(ixPCIE_CNTL2);
 
-       if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_BIF_LS)) {
+       if (enable && (adev->cg_flags & AMD_CG_SUPPORT_BIF_LS)) {
                data = REG_SET_FIELD(data, PCIE_CNTL2, SLV_MEM_LS_EN, 1);
                data = REG_SET_FIELD(data, PCIE_CNTL2, MST_MEM_LS_EN, 1);
                data = REG_SET_FIELD(data, PCIE_CNTL2, REPLAY_MEM_LS_EN, 1);
@@ -849,7 +849,7 @@ static void gmc_v7_0_enable_hdp_mgcg(struct amdgpu_device *adev,
 
        orig = data = RREG32(mmHDP_HOST_PATH_CNTL);
 
-       if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_HDP_MGCG))
+       if (enable && (adev->cg_flags & AMD_CG_SUPPORT_HDP_MGCG))
                data = REG_SET_FIELD(data, HDP_HOST_PATH_CNTL, CLOCK_GATING_DIS, 0);
        else
                data = REG_SET_FIELD(data, HDP_HOST_PATH_CNTL, CLOCK_GATING_DIS, 1);
@@ -865,7 +865,7 @@ static void gmc_v7_0_enable_hdp_ls(struct amdgpu_device *adev,
 
        orig = data = RREG32(mmHDP_MEM_POWER_LS);
 
-       if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_HDP_LS))
+       if (enable && (adev->cg_flags & AMD_CG_SUPPORT_HDP_LS))
                data = REG_SET_FIELD(data, HDP_MEM_POWER_LS, LS_ENABLE, 1);
        else
                data = REG_SET_FIELD(data, HDP_MEM_POWER_LS, LS_ENABLE, 0);
index 7e9154c..654d767 100644 (file)
@@ -2859,11 +2859,11 @@ static int kv_dpm_init(struct amdgpu_device *adev)
        pi->voltage_drop_t = 0;
        pi->caps_sclk_throttle_low_notification = false;
        pi->caps_fps = false; /* true? */
-       pi->caps_uvd_pg = (adev->pg_flags & AMDGPU_PG_SUPPORT_UVD) ? true : false;
+       pi->caps_uvd_pg = (adev->pg_flags & AMD_PG_SUPPORT_UVD) ? true : false;
        pi->caps_uvd_dpm = true;
-       pi->caps_vce_pg = (adev->pg_flags & AMDGPU_PG_SUPPORT_VCE) ? true : false;
-       pi->caps_samu_pg = (adev->pg_flags & AMDGPU_PG_SUPPORT_SAMU) ? true : false;
-       pi->caps_acp_pg = (adev->pg_flags & AMDGPU_PG_SUPPORT_ACP) ? true : false;
+       pi->caps_vce_pg = (adev->pg_flags & AMD_PG_SUPPORT_VCE) ? true : false;
+       pi->caps_samu_pg = (adev->pg_flags & AMD_PG_SUPPORT_SAMU) ? true : false;
+       pi->caps_acp_pg = (adev->pg_flags & AMD_PG_SUPPORT_ACP) ? true : false;
        pi->caps_stable_p_state = false;
 
        ret = kv_parse_sys_info_table(adev);
index 70ed73f..c606ccb 100644 (file)
@@ -588,7 +588,7 @@ static void uvd_v4_2_enable_mgcg(struct amdgpu_device *adev,
 {
        u32 orig, data;
 
-       if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_UVD_MGCG)) {
+       if (enable && (adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG)) {
                data = RREG32_UVD_CTX(ixUVD_CGC_MEM_CTRL);
                data = 0xfff;
                WREG32_UVD_CTX(ixUVD_CGC_MEM_CTRL, data);
@@ -814,6 +814,9 @@ static int uvd_v4_2_set_clockgating_state(void *handle,
        bool gate = false;
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+       if (!(adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG))
+               return 0;
+
        if (state == AMD_CG_STATE_GATE)
                gate = true;
 
@@ -832,7 +835,10 @@ static int uvd_v4_2_set_powergating_state(void *handle,
         * revisit this when there is a cleaner line between
         * the smc and the hw blocks
         */
-        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+       if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
+               return 0;
 
        if (state == AMD_PG_STATE_GATE) {
                uvd_v4_2_stop(adev);
index 578ffb6..e3c852d 100644 (file)
@@ -757,6 +757,11 @@ static int uvd_v5_0_process_interrupt(struct amdgpu_device *adev,
 static int uvd_v5_0_set_clockgating_state(void *handle,
                                          enum amd_clockgating_state state)
 {
+       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+       if (!(adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG))
+               return 0;
+
        return 0;
 }
 
@@ -772,6 +777,9 @@ static int uvd_v5_0_set_powergating_state(void *handle,
         */
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+       if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
+               return 0;
+
        if (state == AMD_PG_STATE_GATE) {
                uvd_v5_0_stop(adev);
                return 0;
index d4da1f0..3375e61 100644 (file)
@@ -536,7 +536,7 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)
        uvd_v6_0_mc_resume(adev);
 
        /* Set dynamic clock gating in S/W control mode */
-       if (adev->cg_flags & AMDGPU_CG_SUPPORT_UVD_MGCG) {
+       if (adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG) {
                if (adev->flags & AMD_IS_APU)
                        cz_set_uvd_clock_gating_branches(adev, false);
                else
@@ -983,7 +983,7 @@ static int uvd_v6_0_set_clockgating_state(void *handle,
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
        bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
 
-       if (!(adev->cg_flags & AMDGPU_CG_SUPPORT_UVD_MGCG))
+       if (!(adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG))
                return 0;
 
        if (enable) {
@@ -1013,6 +1013,9 @@ static int uvd_v6_0_set_powergating_state(void *handle,
         */
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+       if (!(adev->pg_flags & AMD_PG_SUPPORT_UVD))
+               return 0;
+
        if (state == AMD_PG_STATE_GATE) {
                uvd_v6_0_stop(adev);
                return 0;
index 9c804f4..c7e885b 100644 (file)
@@ -373,7 +373,7 @@ static void vce_v2_0_enable_mgcg(struct amdgpu_device *adev, bool enable)
 {
        bool sw_cg = false;
 
-       if (enable && (adev->cg_flags & AMDGPU_CG_SUPPORT_VCE_MGCG)) {
+       if (enable && (adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)) {
                if (sw_cg)
                        vce_v2_0_set_sw_cg(adev, true);
                else
@@ -608,6 +608,9 @@ static int vce_v2_0_set_powergating_state(void *handle,
         */
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+       if (!(adev->pg_flags & AMD_PG_SUPPORT_VCE))
+               return 0;
+
        if (state == AMD_PG_STATE_GATE)
                /* XXX do we need a vce_v2_0_stop()? */
                return 0;
index 8f8d479..ce468ee 100644 (file)
@@ -277,7 +277,7 @@ static int vce_v3_0_start(struct amdgpu_device *adev)
                WREG32_P(mmVCE_STATUS, 0, ~1);
 
                /* Set Clock-Gating off */
-               if (adev->cg_flags & AMDGPU_CG_SUPPORT_VCE_MGCG)
+               if (adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG)
                        vce_v3_0_set_vce_sw_clock_gating(adev, false);
 
                if (r) {
@@ -676,7 +676,7 @@ static int vce_v3_0_set_clockgating_state(void *handle,
        bool enable = (state == AMD_CG_STATE_GATE) ? true : false;
        int i;
 
-       if (!(adev->cg_flags & AMDGPU_CG_SUPPORT_VCE_MGCG))
+       if (!(adev->cg_flags & AMD_CG_SUPPORT_VCE_MGCG))
                return 0;
 
        mutex_lock(&adev->grbm_idx_mutex);
@@ -728,6 +728,9 @@ static int vce_v3_0_set_powergating_state(void *handle,
         */
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
+       if (!(adev->pg_flags & AMD_PG_SUPPORT_VCE))
+               return 0;
+
        if (state == AMD_PG_STATE_GATE)
                /* XXX do we need a vce_v3_0_stop()? */
                return 0;
index 9163f59..1c120ef 100644 (file)
@@ -1088,8 +1088,7 @@ static int vi_common_early_init(void *handle)
        case CHIP_CARRIZO:
        case CHIP_STONEY:
                adev->cg_flags = 0;
-               /* Disable UVD pg */
-               adev->pg_flags = /* AMDGPU_PG_SUPPORT_UVD | */AMDGPU_PG_SUPPORT_VCE;
+               adev->pg_flags = 0;
                adev->external_rev_id = adev->rev_id + 0x1;
                break;
        default:
index c34c393..d5e19b5 100644 (file)
@@ -513,7 +513,7 @@ static int dbgdev_wave_control_set_registers(
                                union SQ_CMD_BITS *in_reg_sq_cmd,
                                union GRBM_GFX_INDEX_BITS *in_reg_gfx_index)
 {
-       int status;
+       int status = 0;
        union SQ_CMD_BITS reg_sq_cmd;
        union GRBM_GFX_INDEX_BITS reg_gfx_index;
        struct HsaDbgWaveMsgAMDGen2 *pMsg;
index ca8410e..850a562 100644 (file)
@@ -59,18 +59,23 @@ module_param(send_sigterm, int, 0444);
 MODULE_PARM_DESC(send_sigterm,
        "Send sigterm to HSA process on unhandled exception (0 = disable, 1 = enable)");
 
-bool kgd2kfd_init(unsigned interface_version, const struct kgd2kfd_calls **g2f)
+static int amdkfd_init_completed;
+
+int kgd2kfd_init(unsigned interface_version, const struct kgd2kfd_calls **g2f)
 {
+       if (!amdkfd_init_completed)
+               return -EPROBE_DEFER;
+
        /*
         * Only one interface version is supported,
         * no kfd/kgd version skew allowed.
         */
        if (interface_version != KFD_INTERFACE_VERSION)
-               return false;
+               return -EINVAL;
 
        *g2f = &kgd2kfd;
 
-       return true;
+       return 0;
 }
 EXPORT_SYMBOL(kgd2kfd_init);
 
@@ -111,6 +116,8 @@ static int __init kfd_module_init(void)
 
        kfd_process_create_wq();
 
+       amdkfd_init_completed = 1;
+
        dev_info(kfd_device, "Initialized module\n");
 
        return 0;
@@ -125,6 +132,8 @@ err_pasid:
 
 static void __exit kfd_module_exit(void)
 {
+       amdkfd_init_completed = 0;
+
        kfd_process_destroy_wq();
        kfd_topology_shutdown();
        kfd_chardev_exit();
index 15ff8b2..04e4090 100644 (file)
@@ -86,6 +86,38 @@ enum amd_powergating_state {
        AMD_PG_STATE_UNGATE,
 };
 
+/* CG flags */
+#define AMD_CG_SUPPORT_GFX_MGCG                        (1 << 0)
+#define AMD_CG_SUPPORT_GFX_MGLS                        (1 << 1)
+#define AMD_CG_SUPPORT_GFX_CGCG                        (1 << 2)
+#define AMD_CG_SUPPORT_GFX_CGLS                        (1 << 3)
+#define AMD_CG_SUPPORT_GFX_CGTS                        (1 << 4)
+#define AMD_CG_SUPPORT_GFX_CGTS_LS             (1 << 5)
+#define AMD_CG_SUPPORT_GFX_CP_LS               (1 << 6)
+#define AMD_CG_SUPPORT_GFX_RLC_LS              (1 << 7)
+#define AMD_CG_SUPPORT_MC_LS                   (1 << 8)
+#define AMD_CG_SUPPORT_MC_MGCG                 (1 << 9)
+#define AMD_CG_SUPPORT_SDMA_LS                 (1 << 10)
+#define AMD_CG_SUPPORT_SDMA_MGCG               (1 << 11)
+#define AMD_CG_SUPPORT_BIF_LS                  (1 << 12)
+#define AMD_CG_SUPPORT_UVD_MGCG                        (1 << 13)
+#define AMD_CG_SUPPORT_VCE_MGCG                        (1 << 14)
+#define AMD_CG_SUPPORT_HDP_LS                  (1 << 15)
+#define AMD_CG_SUPPORT_HDP_MGCG                        (1 << 16)
+
+/* PG flags */
+#define AMD_PG_SUPPORT_GFX_PG                  (1 << 0)
+#define AMD_PG_SUPPORT_GFX_SMG                 (1 << 1)
+#define AMD_PG_SUPPORT_GFX_DMG                 (1 << 2)
+#define AMD_PG_SUPPORT_UVD                     (1 << 3)
+#define AMD_PG_SUPPORT_VCE                     (1 << 4)
+#define AMD_PG_SUPPORT_CP                      (1 << 5)
+#define AMD_PG_SUPPORT_GDS                     (1 << 6)
+#define AMD_PG_SUPPORT_RLC_SMU_HS              (1 << 7)
+#define AMD_PG_SUPPORT_SDMA                    (1 << 8)
+#define AMD_PG_SUPPORT_ACP                     (1 << 9)
+#define AMD_PG_SUPPORT_SAMU                    (1 << 10)
+
 enum amd_pm_state_type {
        /* not used for dpm */
        POWER_STATE_TYPE_DEFAULT,
index 713aec9..aec38fc 100644 (file)
@@ -109,6 +109,8 @@ enum cgs_system_info_id {
        CGS_SYSTEM_INFO_ADAPTER_BDF_ID = 1,
        CGS_SYSTEM_INFO_PCIE_GEN_INFO,
        CGS_SYSTEM_INFO_PCIE_MLW,
+       CGS_SYSTEM_INFO_CG_FLAGS,
+       CGS_SYSTEM_INFO_PG_FLAGS,
        CGS_SYSTEM_INFO_ID_MAXIMUM,
 };
 
index 888250b..a09d9f3 100644 (file)
@@ -221,7 +221,7 @@ struct kgd2kfd_calls {
        int (*resume)(struct kfd_dev *kfd);
 };
 
-bool kgd2kfd_init(unsigned interface_version,
+int kgd2kfd_init(unsigned interface_version,
                const struct kgd2kfd_calls **g2f);
 
 #endif /* KGD_KFD_INTERFACE_H_INCLUDED */
index 0db6423..9d22900 100644 (file)
@@ -403,8 +403,11 @@ int pp_dpm_dispatch_tasks(void *handle, enum amd_pp_event event_id, void *input,
 
                data.requested_ui_label = power_state_convert(ps);
                ret = pem_handle_event(pp_handle->eventmgr, event_id, &data);
+               break;
        }
-       break;
+       case AMD_PP_EVENT_COMPLETE_INIT:
+               ret = pem_handle_event(pp_handle->eventmgr, event_id, &data);
+               break;
        default:
                break;
        }
index 83be3cf..6b52c78 100644 (file)
@@ -165,6 +165,7 @@ const struct action_chain resume_action_chain = {
 };
 
 static const pem_event_action *complete_init_event[] = {
+       unblock_adjust_power_state_tasks,
        adjust_power_state_tasks,
        enable_gfx_clock_gating_tasks,
        enable_gfx_voltage_island_power_gating_tasks,
index 52a3efc..46410e3 100644 (file)
@@ -31,7 +31,7 @@
 static int pem_init(struct pp_eventmgr *eventmgr)
 {
        int result = 0;
-       struct pem_event_data event_data;
+       struct pem_event_data event_data = { {0} };
 
        /* Initialize PowerPlay feature info */
        pem_init_feature_info(eventmgr);
@@ -52,7 +52,7 @@ static int pem_init(struct pp_eventmgr *eventmgr)
 
 static void pem_fini(struct pp_eventmgr *eventmgr)
 {
-       struct pem_event_data event_data;
+       struct pem_event_data event_data = { {0} };
 
        pem_uninit_featureInfo(eventmgr);
        pem_unregister_interrupts(eventmgr);
index ad77008..ff08ce4 100644 (file)
@@ -226,7 +226,7 @@ int cz_dpm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate)
                }
        } else {
                cz_dpm_update_vce_dpm(hwmgr);
-               cz_enable_disable_vce_dpm(hwmgr, true);
+               cz_enable_disable_vce_dpm(hwmgr, !bgate);
                return 0;
        }
 
index 7fdaf8c..727d5c9 100644 (file)
@@ -174,6 +174,8 @@ static int cz_initialize_dpm_defaults(struct pp_hwmgr *hwmgr)
 {
        struct cz_hwmgr *cz_hwmgr = (struct cz_hwmgr *)(hwmgr->backend);
        uint32_t i;
+       struct cgs_system_info sys_info = {0};
+       int result;
 
        cz_hwmgr->gfx_ramp_step = 256*25/100;
 
@@ -247,6 +249,22 @@ static int cz_initialize_dpm_defaults(struct pp_hwmgr *hwmgr)
        phm_cap_set(hwmgr->platform_descriptor.platformCaps,
                                   PHM_PlatformCaps_DisableVoltageIsland);
 
+       phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
+                     PHM_PlatformCaps_UVDPowerGating);
+       phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
+                     PHM_PlatformCaps_VCEPowerGating);
+       sys_info.size = sizeof(struct cgs_system_info);
+       sys_info.info_id = CGS_SYSTEM_INFO_PG_FLAGS;
+       result = cgs_query_system_info(hwmgr->device, &sys_info);
+       if (!result) {
+               if (sys_info.value & AMD_PG_SUPPORT_UVD)
+                       phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+                                     PHM_PlatformCaps_UVDPowerGating);
+               if (sys_info.value & AMD_PG_SUPPORT_VCE)
+                       phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+                                     PHM_PlatformCaps_VCEPowerGating);
+       }
+
        return 0;
 }
 
index bc83fa3..aec4f83 100644 (file)
@@ -4451,6 +4451,7 @@ int tonga_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
        pp_atomctrl_gpio_pin_assignment gpio_pin_assignment;
        struct phm_ppt_v1_information *pptable_info = (struct phm_ppt_v1_information *)(hwmgr->pptable);
        phw_tonga_ulv_parm *ulv;
+       struct cgs_system_info sys_info = {0};
 
        PP_ASSERT_WITH_CODE((NULL != hwmgr),
                "Invalid Parameter!", return -1;);
@@ -4615,9 +4616,23 @@ int tonga_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
 
        data->vddc_phase_shed_control = 0;
 
-       if (0 == result) {
-               struct cgs_system_info sys_info = {0};
+       phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
+                     PHM_PlatformCaps_UVDPowerGating);
+       phm_cap_unset(hwmgr->platform_descriptor.platformCaps,
+                     PHM_PlatformCaps_VCEPowerGating);
+       sys_info.size = sizeof(struct cgs_system_info);
+       sys_info.info_id = CGS_SYSTEM_INFO_PG_FLAGS;
+       result = cgs_query_system_info(hwmgr->device, &sys_info);
+       if (!result) {
+               if (sys_info.value & AMD_PG_SUPPORT_UVD)
+                       phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+                                     PHM_PlatformCaps_UVDPowerGating);
+               if (sys_info.value & AMD_PG_SUPPORT_VCE)
+                       phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+                                     PHM_PlatformCaps_VCEPowerGating);
+       }
 
+       if (0 == result) {
                data->is_tlu_enabled = 0;
                hwmgr->platform_descriptor.hardwareActivityPerformanceLevels =
                        TONGA_MAX_HARDWARE_POWERLEVELS;
index 9759009..b1480ac 100644 (file)
@@ -227,7 +227,7 @@ static int ast_get_dram_info(struct drm_device *dev)
        } while (ast_read32(ast, 0x10000) != 0x01);
        data = ast_read32(ast, 0x10004);
 
-       if (data & 0x400)
+       if (data & 0x40)
                ast->dram_bus_width = 16;
        else
                ast->dram_bus_width = 32;
index f221e2d..a965e7e 100644 (file)
@@ -497,13 +497,6 @@ static void ast_crtc_dpms(struct drm_crtc *crtc, int mode)
        }
 }
 
-static bool ast_crtc_mode_fixup(struct drm_crtc *crtc,
-                               const struct drm_display_mode *mode,
-                               struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 /* ast is different - we will force move buffers out of VRAM */
 static int ast_crtc_do_set_base(struct drm_crtc *crtc,
                                struct drm_framebuffer *fb,
@@ -617,7 +610,6 @@ static void ast_crtc_commit(struct drm_crtc *crtc)
 
 static const struct drm_crtc_helper_funcs ast_crtc_helper_funcs = {
        .dpms = ast_crtc_dpms,
-       .mode_fixup = ast_crtc_mode_fixup,
        .mode_set = ast_crtc_mode_set,
        .mode_set_base = ast_crtc_mode_set_base,
        .disable = ast_crtc_disable,
index 9863291..58c4f78 100644 (file)
@@ -121,13 +121,6 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc *c)
                           cfg);
 }
 
-static bool atmel_hlcdc_crtc_mode_fixup(struct drm_crtc *crtc,
-                                       const struct drm_display_mode *mode,
-                                       struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 static void atmel_hlcdc_crtc_disable(struct drm_crtc *c)
 {
        struct drm_device *dev = c->dev;
@@ -261,7 +254,6 @@ static void atmel_hlcdc_crtc_atomic_flush(struct drm_crtc *crtc,
 }
 
 static const struct drm_crtc_helper_funcs lcdc_crtc_helper_funcs = {
-       .mode_fixup = atmel_hlcdc_crtc_mode_fixup,
        .mode_set = drm_helper_crtc_mode_set,
        .mode_set_nofb = atmel_hlcdc_crtc_mode_set_nofb,
        .mode_set_base = drm_helper_crtc_mode_set_base,
@@ -349,4 +341,3 @@ fail:
        atmel_hlcdc_crtc_destroy(&crtc->base);
        return ret;
 }
-
index 317c27f..96926f0 100644 (file)
@@ -30,13 +30,6 @@ static void bochs_crtc_dpms(struct drm_crtc *crtc, int mode)
        }
 }
 
-static bool bochs_crtc_mode_fixup(struct drm_crtc *crtc,
-                                 const struct drm_display_mode *mode,
-                                 struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 static int bochs_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
                                    struct drm_framebuffer *old_fb)
 {
@@ -135,7 +128,6 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = {
 
 static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
        .dpms = bochs_crtc_dpms,
-       .mode_fixup = bochs_crtc_mode_fixup,
        .mode_set = bochs_crtc_mode_set,
        .mode_set_base = bochs_crtc_mode_set_base,
        .prepare = bochs_crtc_prepare,
index 432ce94..d3d8d7b 100644 (file)
@@ -91,18 +91,6 @@ static void cirrus_crtc_dpms(struct drm_crtc *crtc, int mode)
        WREG_GFX(0xe, gr0e);
 }
 
-/*
- * The core passes the desired mode to the CRTC code to see whether any
- * CRTC-specific modifications need to be made to it. We're in a position
- * to just pass that straight through, so this does nothing
- */
-static bool cirrus_crtc_mode_fixup(struct drm_crtc *crtc,
-                                  const struct drm_display_mode *mode,
-                                  struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 static void cirrus_set_start_address(struct drm_crtc *crtc, unsigned offset)
 {
        struct cirrus_device *cdev = crtc->dev->dev_private;
@@ -372,7 +360,6 @@ static const struct drm_crtc_funcs cirrus_crtc_funcs = {
 
 static const struct drm_crtc_helper_funcs cirrus_helper_funcs = {
        .dpms = cirrus_crtc_dpms,
-       .mode_fixup = cirrus_crtc_mode_fixup,
        .mode_set = cirrus_crtc_mode_set,
        .mode_set_base = cirrus_crtc_mode_set_base,
        .prepare = cirrus_crtc_prepare,
index 8fb469c..a2596eb 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <drm/drmP.h>
 #include <drm/drm_atomic.h>
+#include <drm/drm_mode.h>
 #include <drm/drm_plane_helper.h>
 
 /**
@@ -65,8 +66,6 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state)
         */
        state->allow_modeset = true;
 
-       state->num_connector = ACCESS_ONCE(dev->mode_config.num_connector);
-
        state->crtcs = kcalloc(dev->mode_config.num_crtc,
                               sizeof(*state->crtcs), GFP_KERNEL);
        if (!state->crtcs)
@@ -83,16 +82,6 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state)
                                      sizeof(*state->plane_states), GFP_KERNEL);
        if (!state->plane_states)
                goto fail;
-       state->connectors = kcalloc(state->num_connector,
-                                   sizeof(*state->connectors),
-                                   GFP_KERNEL);
-       if (!state->connectors)
-               goto fail;
-       state->connector_states = kcalloc(state->num_connector,
-                                         sizeof(*state->connector_states),
-                                         GFP_KERNEL);
-       if (!state->connector_states)
-               goto fail;
 
        state->dev = dev;
 
@@ -388,6 +377,59 @@ int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,
 EXPORT_SYMBOL(drm_atomic_set_mode_prop_for_crtc);
 
 /**
+ * drm_atomic_replace_property_blob - replace a blob property
+ * @blob: a pointer to the member blob to be replaced
+ * @new_blob: the new blob to replace with
+ * @expected_size: the expected size of the new blob
+ * @replaced: whether the blob has been replaced
+ *
+ * RETURNS:
+ * Zero on success, error code on failure
+ */
+static void
+drm_atomic_replace_property_blob(struct drm_property_blob **blob,
+                                struct drm_property_blob *new_blob,
+                                bool *replaced)
+{
+       struct drm_property_blob *old_blob = *blob;
+
+       if (old_blob == new_blob)
+               return;
+
+       if (old_blob)
+               drm_property_unreference_blob(old_blob);
+       if (new_blob)
+               drm_property_reference_blob(new_blob);
+       *blob = new_blob;
+       *replaced = true;
+
+       return;
+}
+
+static int
+drm_atomic_replace_property_blob_from_id(struct drm_crtc *crtc,
+                                        struct drm_property_blob **blob,
+                                        uint64_t blob_id,
+                                        ssize_t expected_size,
+                                        bool *replaced)
+{
+       struct drm_device *dev = crtc->dev;
+       struct drm_property_blob *new_blob = NULL;
+
+       if (blob_id != 0) {
+               new_blob = drm_property_lookup_blob(dev, blob_id);
+               if (new_blob == NULL)
+                       return -EINVAL;
+               if (expected_size > 0 && expected_size != new_blob->length)
+                       return -EINVAL;
+       }
+
+       drm_atomic_replace_property_blob(blob, new_blob, replaced);
+
+       return 0;
+}
+
+/**
  * drm_atomic_crtc_set_property - set property on CRTC
  * @crtc: the drm CRTC to set a property on
  * @state: the state object to update with the new property value
@@ -409,6 +451,7 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
 {
        struct drm_device *dev = crtc->dev;
        struct drm_mode_config *config = &dev->mode_config;
+       bool replaced = false;
        int ret;
 
        if (property == config->prop_active)
@@ -419,8 +462,31 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
                ret = drm_atomic_set_mode_prop_for_crtc(state, mode);
                drm_property_unreference_blob(mode);
                return ret;
-       }
-       else if (crtc->funcs->atomic_set_property)
+       } else if (property == config->degamma_lut_property) {
+               ret = drm_atomic_replace_property_blob_from_id(crtc,
+                                       &state->degamma_lut,
+                                       val,
+                                       -1,
+                                       &replaced);
+               state->color_mgmt_changed = replaced;
+               return ret;
+       } else if (property == config->ctm_property) {
+               ret = drm_atomic_replace_property_blob_from_id(crtc,
+                                       &state->ctm,
+                                       val,
+                                       sizeof(struct drm_color_ctm),
+                                       &replaced);
+               state->color_mgmt_changed = replaced;
+               return ret;
+       } else if (property == config->gamma_lut_property) {
+               ret = drm_atomic_replace_property_blob_from_id(crtc,
+                                       &state->gamma_lut,
+                                       val,
+                                       -1,
+                                       &replaced);
+               state->color_mgmt_changed = replaced;
+               return ret;
+       } else if (crtc->funcs->atomic_set_property)
                return crtc->funcs->atomic_set_property(crtc, state, property, val);
        else
                return -EINVAL;
@@ -456,6 +522,12 @@ drm_atomic_crtc_get_property(struct drm_crtc *crtc,
                *val = state->active;
        else if (property == config->prop_mode_id)
                *val = (state->mode_blob) ? state->mode_blob->base.id : 0;
+       else if (property == config->degamma_lut_property)
+               *val = (state->degamma_lut) ? state->degamma_lut->base.id : 0;
+       else if (property == config->ctm_property)
+               *val = (state->ctm) ? state->ctm->base.id : 0;
+       else if (property == config->gamma_lut_property)
+               *val = (state->gamma_lut) ? state->gamma_lut->base.id : 0;
        else if (crtc->funcs->atomic_get_property)
                return crtc->funcs->atomic_get_property(crtc, state, property, val);
        else
@@ -823,19 +895,27 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
 
        index = drm_connector_index(connector);
 
-       /*
-        * Construction of atomic state updates can race with a connector
-        * hot-add which might overflow. In this case flip the table and just
-        * restart the entire ioctl - no one is fast enough to livelock a cpu
-        * with physical hotplug events anyway.
-        *
-        * Note that we only grab the indexes once we have the right lock to
-        * prevent hotplug/unplugging of connectors. So removal is no problem,
-        * at most the array is a bit too large.
-        */
        if (index >= state->num_connector) {
-               DRM_DEBUG_ATOMIC("Hot-added connector would overflow state array, restarting\n");
-               return ERR_PTR(-EAGAIN);
+               struct drm_connector **c;
+               struct drm_connector_state **cs;
+               int alloc = max(index + 1, config->num_connector);
+
+               c = krealloc(state->connectors, alloc * sizeof(*state->connectors), GFP_KERNEL);
+               if (!c)
+                       return ERR_PTR(-ENOMEM);
+
+               state->connectors = c;
+               memset(&state->connectors[state->num_connector], 0,
+                      sizeof(*state->connectors) * (alloc - state->num_connector));
+
+               cs = krealloc(state->connector_states, alloc * sizeof(*state->connector_states), GFP_KERNEL);
+               if (!cs)
+                       return ERR_PTR(-ENOMEM);
+
+               state->connector_states = cs;
+               memset(&state->connector_states[state->num_connector], 0,
+                      sizeof(*state->connector_states) * (alloc - state->num_connector));
+               state->num_connector = alloc;
        }
 
        if (state->connector_states[index])
index 2b430b0..2bb90fa 100644 (file)
@@ -86,43 +86,104 @@ drm_atomic_helper_plane_changed(struct drm_atomic_state *state,
        }
 }
 
-static bool
-check_pending_encoder_assignment(struct drm_atomic_state *state,
-                                struct drm_encoder *new_encoder)
+static int handle_conflicting_encoders(struct drm_atomic_state *state,
+                                      bool disable_conflicting_encoders)
 {
-       struct drm_connector *connector;
        struct drm_connector_state *conn_state;
-       int i;
+       struct drm_connector *connector;
+       struct drm_encoder *encoder;
+       unsigned encoder_mask = 0;
+       int i, ret;
 
+       /*
+        * First loop, find all newly assigned encoders from the connectors
+        * part of the state. If the same encoder is assigned to multiple
+        * connectors bail out.
+        */
        for_each_connector_in_state(state, connector, conn_state, i) {
-               if (conn_state->best_encoder != new_encoder)
+               const struct drm_connector_helper_funcs *funcs = connector->helper_private;
+               struct drm_encoder *new_encoder;
+
+               if (!conn_state->crtc)
                        continue;
 
-               /* encoder already assigned and we're trying to re-steal it! */
-               if (connector->state->best_encoder != conn_state->best_encoder)
-                       return false;
+               if (funcs->atomic_best_encoder)
+                       new_encoder = funcs->atomic_best_encoder(connector, conn_state);
+               else
+                       new_encoder = funcs->best_encoder(connector);
+
+               if (new_encoder) {
+                       if (encoder_mask & (1 << drm_encoder_index(new_encoder))) {
+                               DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] on [CONNECTOR:%d:%s] already assigned\n",
+                                       new_encoder->base.id, new_encoder->name,
+                                       connector->base.id, connector->name);
+
+                               return -EINVAL;
+                       }
+
+                       encoder_mask |= 1 << drm_encoder_index(new_encoder);
+               }
        }
 
-       return true;
-}
+       if (!encoder_mask)
+               return 0;
 
-static struct drm_crtc *
-get_current_crtc_for_encoder(struct drm_device *dev,
-                            struct drm_encoder *encoder)
-{
-       struct drm_mode_config *config = &dev->mode_config;
-       struct drm_connector *connector;
+       /*
+        * Second loop, iterate over all connectors not part of the state.
+        *
+        * If a conflicting encoder is found and disable_conflicting_encoders
+        * is not set, an error is returned. Userspace can provide a solution
+        * through the atomic ioctl.
+        *
+        * If the flag is set conflicting connectors are removed from the crtc
+        * and the crtc is disabled if no encoder is left. This preserves
+        * compatibility with the legacy set_config behavior.
+        */
+       drm_for_each_connector(connector, state->dev) {
+               struct drm_crtc_state *crtc_state;
 
-       WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
+               if (drm_atomic_get_existing_connector_state(state, connector))
+                       continue;
 
-       drm_for_each_connector(connector, dev) {
-               if (connector->state->best_encoder != encoder)
+               encoder = connector->state->best_encoder;
+               if (!encoder || !(encoder_mask & (1 << drm_encoder_index(encoder))))
                        continue;
 
-               return connector->state->crtc;
+               if (!disable_conflicting_encoders) {
+                       DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s] by [CONNECTOR:%d:%s]\n",
+                                        encoder->base.id, encoder->name,
+                                        connector->state->crtc->base.id,
+                                        connector->state->crtc->name,
+                                        connector->base.id, connector->name);
+                       return -EINVAL;
+               }
+
+               conn_state = drm_atomic_get_connector_state(state, connector);
+               if (IS_ERR(conn_state))
+                       return PTR_ERR(conn_state);
+
+               DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s], disabling [CONNECTOR:%d:%s]\n",
+                                encoder->base.id, encoder->name,
+                                conn_state->crtc->base.id, conn_state->crtc->name,
+                                connector->base.id, connector->name);
+
+               crtc_state = drm_atomic_get_existing_crtc_state(state, conn_state->crtc);
+
+               ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
+               if (ret)
+                       return ret;
+
+               if (!crtc_state->connector_mask) {
+                       ret = drm_atomic_set_mode_prop_for_crtc(crtc_state,
+                                                               NULL);
+                       if (ret < 0)
+                               return ret;
+
+                       crtc_state->active = false;
+               }
        }
 
-       return NULL;
+       return 0;
 }
 
 static void
@@ -166,70 +227,44 @@ set_best_encoder(struct drm_atomic_state *state,
        conn_state->best_encoder = encoder;
 }
 
-static int
+static void
 steal_encoder(struct drm_atomic_state *state,
-             struct drm_encoder *encoder,
-             struct drm_crtc *encoder_crtc)
+             struct drm_encoder *encoder)
 {
-       struct drm_mode_config *config = &state->dev->mode_config;
        struct drm_crtc_state *crtc_state;
        struct drm_connector *connector;
        struct drm_connector_state *connector_state;
+       int i;
 
-       /*
-        * We can only steal an encoder coming from a connector, which means we
-        * must already hold the connection_mutex.
-        */
-       WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
-
-       DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s], stealing it\n",
-                        encoder->base.id, encoder->name,
-                        encoder_crtc->base.id, encoder_crtc->name);
-
-       crtc_state = drm_atomic_get_crtc_state(state, encoder_crtc);
-       if (IS_ERR(crtc_state))
-               return PTR_ERR(crtc_state);
-
-       crtc_state->connectors_changed = true;
+       for_each_connector_in_state(state, connector, connector_state, i) {
+               struct drm_crtc *encoder_crtc;
 
-       list_for_each_entry(connector, &config->connector_list, head) {
-               if (connector->state->best_encoder != encoder)
+               if (connector_state->best_encoder != encoder)
                        continue;
 
-               DRM_DEBUG_ATOMIC("Stealing encoder from [CONNECTOR:%d:%s]\n",
-                                connector->base.id,
-                                connector->name);
+               encoder_crtc = connector->state->crtc;
 
-               connector_state = drm_atomic_get_connector_state(state,
-                                                                connector);
-               if (IS_ERR(connector_state))
-                       return PTR_ERR(connector_state);
-
-               if (connector_state->best_encoder != encoder)
-                       continue;
+               DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s], stealing it\n",
+                                encoder->base.id, encoder->name,
+                                encoder_crtc->base.id, encoder_crtc->name);
 
                set_best_encoder(state, connector_state, NULL);
-       }
 
-       return 0;
+               crtc_state = drm_atomic_get_existing_crtc_state(state, encoder_crtc);
+               crtc_state->connectors_changed = true;
+
+               return;
+       }
 }
 
 static int
-update_connector_routing(struct drm_atomic_state *state, int conn_idx)
+update_connector_routing(struct drm_atomic_state *state,
+                        struct drm_connector *connector,
+                        struct drm_connector_state *connector_state)
 {
        const struct drm_connector_helper_funcs *funcs;
        struct drm_encoder *new_encoder;
-       struct drm_crtc *encoder_crtc;
-       struct drm_connector *connector;
-       struct drm_connector_state *connector_state;
        struct drm_crtc_state *crtc_state;
-       int idx, ret;
-
-       connector = state->connectors[conn_idx];
-       connector_state = state->connector_states[conn_idx];
-
-       if (!connector)
-               return 0;
 
        DRM_DEBUG_ATOMIC("Updating routing for [CONNECTOR:%d:%s]\n",
                         connector->base.id,
@@ -237,16 +272,12 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx)
 
        if (connector->state->crtc != connector_state->crtc) {
                if (connector->state->crtc) {
-                       idx = drm_crtc_index(connector->state->crtc);
-
-                       crtc_state = state->crtc_states[idx];
+                       crtc_state = drm_atomic_get_existing_crtc_state(state, connector->state->crtc);
                        crtc_state->connectors_changed = true;
                }
 
                if (connector_state->crtc) {
-                       idx = drm_crtc_index(connector_state->crtc);
-
-                       crtc_state = state->crtc_states[idx];
+                       crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
                        crtc_state->connectors_changed = true;
                }
        }
@@ -298,34 +329,11 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx)
                return 0;
        }
 
-       if (!check_pending_encoder_assignment(state, new_encoder)) {
-               DRM_DEBUG_ATOMIC("Encoder for [CONNECTOR:%d:%s] already assigned\n",
-                                connector->base.id,
-                                connector->name);
-               return -EINVAL;
-       }
-
-       encoder_crtc = get_current_crtc_for_encoder(state->dev,
-                                                   new_encoder);
-
-       if (encoder_crtc) {
-               ret = steal_encoder(state, new_encoder, encoder_crtc);
-               if (ret) {
-                       DRM_DEBUG_ATOMIC("Encoder stealing failed for [CONNECTOR:%d:%s]\n",
-                                        connector->base.id,
-                                        connector->name);
-                       return ret;
-               }
-       }
-
-       if (WARN_ON(!connector_state->crtc))
-               return -EINVAL;
+       steal_encoder(state, new_encoder);
 
        set_best_encoder(state, connector_state, new_encoder);
 
-       idx = drm_crtc_index(connector_state->crtc);
-
-       crtc_state = state->crtc_states[idx];
+       crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
        crtc_state->connectors_changed = true;
 
        DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] using [ENCODER:%d:%s] on [CRTC:%d:%s]\n",
@@ -488,13 +496,18 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
                }
        }
 
+       ret = handle_conflicting_encoders(state, state->legacy_set_config);
+       if (ret)
+               return ret;
+
        for_each_connector_in_state(state, connector, connector_state, i) {
                /*
                 * This only sets crtc->mode_changed for routing changes,
                 * drivers must set crtc->mode_changed themselves when connector
                 * properties need to be updated.
                 */
-               ret = update_connector_routing(state, i);
+               ret = update_connector_routing(state, connector,
+                                              connector_state);
                if (ret)
                        return ret;
        }
@@ -1535,7 +1548,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
 {
        int i;
 
-       for (i = 0; i < dev->mode_config.num_connector; i++) {
+       for (i = 0; i < state->num_connector; i++) {
                struct drm_connector *connector = state->connectors[i];
 
                if (!connector)
@@ -1761,28 +1774,18 @@ static int update_output_state(struct drm_atomic_state *state,
        struct drm_crtc_state *crtc_state;
        struct drm_connector *connector;
        struct drm_connector_state *conn_state;
-       int ret, i, j;
+       int ret, i;
 
        ret = drm_modeset_lock(&dev->mode_config.connection_mutex,
                               state->acquire_ctx);
        if (ret)
                return ret;
 
-       /* First grab all affected connector/crtc states. */
-       for (i = 0; i < set->num_connectors; i++) {
-               conn_state = drm_atomic_get_connector_state(state,
-                                                           set->connectors[i]);
-               if (IS_ERR(conn_state))
-                       return PTR_ERR(conn_state);
-       }
-
-       for_each_crtc_in_state(state, crtc, crtc_state, i) {
-               ret = drm_atomic_add_affected_connectors(state, crtc);
-               if (ret)
-                       return ret;
-       }
+       /* First disable all connectors on the target crtc. */
+       ret = drm_atomic_add_affected_connectors(state, set->crtc);
+       if (ret)
+               return ret;
 
-       /* Then recompute connector->crtc links and crtc enabling state. */
        for_each_connector_in_state(state, connector, conn_state, i) {
                if (conn_state->crtc == set->crtc) {
                        ret = drm_atomic_set_crtc_for_connector(conn_state,
@@ -1790,16 +1793,19 @@ static int update_output_state(struct drm_atomic_state *state,
                        if (ret)
                                return ret;
                }
+       }
 
-               for (j = 0; j < set->num_connectors; j++) {
-                       if (set->connectors[j] == connector) {
-                               ret = drm_atomic_set_crtc_for_connector(conn_state,
-                                                                       set->crtc);
-                               if (ret)
-                                       return ret;
-                               break;
-                       }
-               }
+       /* Then set all connectors from set->connectors on the target crtc */
+       for (i = 0; i < set->num_connectors; i++) {
+               conn_state = drm_atomic_get_connector_state(state,
+                                                           set->connectors[i]);
+               if (IS_ERR(conn_state))
+                       return PTR_ERR(conn_state);
+
+               ret = drm_atomic_set_crtc_for_connector(conn_state,
+                                                       set->crtc);
+               if (ret)
+                       return ret;
        }
 
        for_each_crtc_in_state(state, crtc, crtc_state, i) {
@@ -1842,6 +1848,7 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set)
        if (!state)
                return -ENOMEM;
 
+       state->legacy_set_config = true;
        state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
 retry:
        ret = __drm_atomic_helper_set_config(set, state);
@@ -2488,8 +2495,12 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_dpms);
  */
 void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc)
 {
-       if (crtc->state)
+       if (crtc->state) {
                drm_property_unreference_blob(crtc->state->mode_blob);
+               drm_property_unreference_blob(crtc->state->degamma_lut);
+               drm_property_unreference_blob(crtc->state->ctm);
+               drm_property_unreference_blob(crtc->state->gamma_lut);
+       }
        kfree(crtc->state);
        crtc->state = kzalloc(sizeof(*crtc->state), GFP_KERNEL);
 
@@ -2513,10 +2524,17 @@ void __drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc,
 
        if (state->mode_blob)
                drm_property_reference_blob(state->mode_blob);
+       if (state->degamma_lut)
+               drm_property_reference_blob(state->degamma_lut);
+       if (state->ctm)
+               drm_property_reference_blob(state->ctm);
+       if (state->gamma_lut)
+               drm_property_reference_blob(state->gamma_lut);
        state->mode_changed = false;
        state->active_changed = false;
        state->planes_changed = false;
        state->connectors_changed = false;
+       state->color_mgmt_changed = false;
        state->event = NULL;
 }
 EXPORT_SYMBOL(__drm_atomic_helper_crtc_duplicate_state);
@@ -2557,6 +2575,9 @@ void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc,
                                            struct drm_crtc_state *state)
 {
        drm_property_unreference_blob(state->mode_blob);
+       drm_property_unreference_blob(state->degamma_lut);
+       drm_property_unreference_blob(state->ctm);
+       drm_property_unreference_blob(state->gamma_lut);
 }
 EXPORT_SYMBOL(__drm_atomic_helper_crtc_destroy_state);
 
@@ -2870,3 +2891,98 @@ void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
        kfree(state);
 }
 EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
+
+/**
+ * drm_atomic_helper_legacy_gamma_set - set the legacy gamma correction table
+ * @crtc: CRTC object
+ * @red: red correction table
+ * @green: green correction table
+ * @blue: green correction table
+ * @start:
+ * @size: size of the tables
+ *
+ * Implements support for legacy gamma correction table for drivers
+ * that support color management through the DEGAMMA_LUT/GAMMA_LUT
+ * properties.
+ */
+void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+                                       u16 *red, u16 *green, u16 *blue,
+                                       uint32_t start, uint32_t size)
+{
+       struct drm_device *dev = crtc->dev;
+       struct drm_mode_config *config = &dev->mode_config;
+       struct drm_atomic_state *state;
+       struct drm_crtc_state *crtc_state;
+       struct drm_property_blob *blob = NULL;
+       struct drm_color_lut *blob_data;
+       int i, ret = 0;
+
+       state = drm_atomic_state_alloc(crtc->dev);
+       if (!state)
+               return;
+
+       blob = drm_property_create_blob(dev,
+                                       sizeof(struct drm_color_lut) * size,
+                                       NULL);
+       if (IS_ERR(blob)) {
+               ret = PTR_ERR(blob);
+               blob = NULL;
+               goto fail;
+       }
+
+       /* Prepare GAMMA_LUT with the legacy values. */
+       blob_data = (struct drm_color_lut *) blob->data;
+       for (i = 0; i < size; i++) {
+               blob_data[i].red = red[i];
+               blob_data[i].green = green[i];
+               blob_data[i].blue = blue[i];
+       }
+
+       state->acquire_ctx = crtc->dev->mode_config.acquire_ctx;
+retry:
+       crtc_state = drm_atomic_get_crtc_state(state, crtc);
+       if (IS_ERR(crtc_state)) {
+               ret = PTR_ERR(crtc_state);
+               goto fail;
+       }
+
+       /* Reset DEGAMMA_LUT and CTM properties. */
+       ret = drm_atomic_crtc_set_property(crtc, crtc_state,
+                       config->degamma_lut_property, 0);
+       if (ret)
+               goto fail;
+
+       ret = drm_atomic_crtc_set_property(crtc, crtc_state,
+                       config->ctm_property, 0);
+       if (ret)
+               goto fail;
+
+       ret = drm_atomic_crtc_set_property(crtc, crtc_state,
+                       config->gamma_lut_property, blob->base.id);
+       if (ret)
+               goto fail;
+
+       ret = drm_atomic_commit(state);
+       if (ret)
+               goto fail;
+
+       /* Driver takes ownership of state on successful commit. */
+
+       drm_property_unreference_blob(blob);
+
+       return;
+fail:
+       if (ret == -EDEADLK)
+               goto backoff;
+
+       drm_atomic_state_free(state);
+       drm_property_unreference_blob(blob);
+
+       return;
+backoff:
+       drm_atomic_state_clear(state);
+       drm_atomic_legacy_backoff(state);
+
+       goto retry;
+}
+EXPORT_SYMBOL(drm_atomic_helper_legacy_gamma_set);
index bd93453..b365440 100644 (file)
@@ -186,7 +186,8 @@ void drm_bridge_disable(struct drm_bridge *bridge)
 
        drm_bridge_disable(bridge->next);
 
-       bridge->funcs->disable(bridge);
+       if (bridge->funcs->disable)
+               bridge->funcs->disable(bridge);
 }
 EXPORT_SYMBOL(drm_bridge_disable);
 
@@ -206,7 +207,8 @@ void drm_bridge_post_disable(struct drm_bridge *bridge)
        if (!bridge)
                return;
 
-       bridge->funcs->post_disable(bridge);
+       if (bridge->funcs->post_disable)
+               bridge->funcs->post_disable(bridge);
 
        drm_bridge_post_disable(bridge->next);
 }
@@ -256,7 +258,8 @@ void drm_bridge_pre_enable(struct drm_bridge *bridge)
 
        drm_bridge_pre_enable(bridge->next);
 
-       bridge->funcs->pre_enable(bridge);
+       if (bridge->funcs->pre_enable)
+               bridge->funcs->pre_enable(bridge);
 }
 EXPORT_SYMBOL(drm_bridge_pre_enable);
 
@@ -276,7 +279,8 @@ void drm_bridge_enable(struct drm_bridge *bridge)
        if (!bridge)
                return;
 
-       bridge->funcs->enable(bridge);
+       if (bridge->funcs->enable)
+               bridge->funcs->enable(bridge);
 
        drm_bridge_enable(bridge->next);
 }
index 65258ac..e08f962 100644 (file)
@@ -430,9 +430,7 @@ EXPORT_SYMBOL(drm_framebuffer_init);
 static void __drm_framebuffer_unregister(struct drm_device *dev,
                                         struct drm_framebuffer *fb)
 {
-       mutex_lock(&dev->mode_config.idr_mutex);
-       idr_remove(&dev->mode_config.crtc_idr, fb->base.id);
-       mutex_unlock(&dev->mode_config.idr_mutex);
+       drm_mode_object_put(dev, &fb->base);
 
        fb->base.id = 0;
 }
@@ -918,12 +916,19 @@ int drm_connector_init(struct drm_device *dev,
        connector->base.properties = &connector->properties;
        connector->dev = dev;
        connector->funcs = funcs;
+
+       connector->connector_id = ida_simple_get(&config->connector_ida, 0, 0, GFP_KERNEL);
+       if (connector->connector_id < 0) {
+               ret = connector->connector_id;
+               goto out_put;
+       }
+
        connector->connector_type = connector_type;
        connector->connector_type_id =
                ida_simple_get(connector_ida, 1, 0, GFP_KERNEL);
        if (connector->connector_type_id < 0) {
                ret = connector->connector_type_id;
-               goto out_put;
+               goto out_put_id;
        }
        connector->name =
                kasprintf(GFP_KERNEL, "%s-%d",
@@ -931,7 +936,7 @@ int drm_connector_init(struct drm_device *dev,
                          connector->connector_type_id);
        if (!connector->name) {
                ret = -ENOMEM;
-               goto out_put;
+               goto out_put_type_id;
        }
 
        INIT_LIST_HEAD(&connector->probed_modes);
@@ -959,7 +964,12 @@ int drm_connector_init(struct drm_device *dev,
        }
 
        connector->debugfs_entry = NULL;
-
+out_put_type_id:
+       if (ret)
+               ida_remove(connector_ida, connector->connector_type_id);
+out_put_id:
+       if (ret)
+               ida_remove(&config->connector_ida, connector->connector_id);
 out_put:
        if (ret)
                drm_mode_object_put(dev, &connector->base);
@@ -996,6 +1006,9 @@ void drm_connector_cleanup(struct drm_connector *connector)
        ida_remove(&drm_connector_enum_list[connector->connector_type].ida,
                   connector->connector_type_id);
 
+       ida_remove(&dev->mode_config.connector_ida,
+                  connector->connector_id);
+
        kfree(connector->display_info.bus_formats);
        drm_mode_object_put(dev, &connector->base);
        kfree(connector->name);
@@ -1013,32 +1026,6 @@ void drm_connector_cleanup(struct drm_connector *connector)
 EXPORT_SYMBOL(drm_connector_cleanup);
 
 /**
- * drm_connector_index - find the index of a registered connector
- * @connector: connector to find index for
- *
- * Given a registered connector, return the index of that connector within a DRM
- * device's list of connectors.
- */
-unsigned int drm_connector_index(struct drm_connector *connector)
-{
-       unsigned int index = 0;
-       struct drm_connector *tmp;
-       struct drm_mode_config *config = &connector->dev->mode_config;
-
-       WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
-
-       drm_for_each_connector(tmp, connector->dev) {
-               if (tmp == connector)
-                       return index;
-
-               index++;
-       }
-
-       BUG();
-}
-EXPORT_SYMBOL(drm_connector_index);
-
-/**
  * drm_connector_register - register a connector
  * @connector: the connector to register
  *
@@ -1565,6 +1552,41 @@ static int drm_mode_create_standard_properties(struct drm_device *dev)
                return -ENOMEM;
        dev->mode_config.prop_mode_id = prop;
 
+       prop = drm_property_create(dev,
+                       DRM_MODE_PROP_BLOB,
+                       "DEGAMMA_LUT", 0);
+       if (!prop)
+               return -ENOMEM;
+       dev->mode_config.degamma_lut_property = prop;
+
+       prop = drm_property_create_range(dev,
+                       DRM_MODE_PROP_IMMUTABLE,
+                       "DEGAMMA_LUT_SIZE", 0, UINT_MAX);
+       if (!prop)
+               return -ENOMEM;
+       dev->mode_config.degamma_lut_size_property = prop;
+
+       prop = drm_property_create(dev,
+                       DRM_MODE_PROP_BLOB,
+                       "CTM", 0);
+       if (!prop)
+               return -ENOMEM;
+       dev->mode_config.ctm_property = prop;
+
+       prop = drm_property_create(dev,
+                       DRM_MODE_PROP_BLOB,
+                       "GAMMA_LUT", 0);
+       if (!prop)
+               return -ENOMEM;
+       dev->mode_config.gamma_lut_property = prop;
+
+       prop = drm_property_create_range(dev,
+                       DRM_MODE_PROP_IMMUTABLE,
+                       "GAMMA_LUT_SIZE", 0, UINT_MAX);
+       if (!prop)
+               return -ENOMEM;
+       dev->mode_config.gamma_lut_size_property = prop;
+
        return 0;
 }
 
@@ -5838,6 +5860,7 @@ void drm_mode_config_init(struct drm_device *dev)
        INIT_LIST_HEAD(&dev->mode_config.plane_list);
        idr_init(&dev->mode_config.crtc_idr);
        idr_init(&dev->mode_config.tile_idr);
+       ida_init(&dev->mode_config.connector_ida);
 
        drm_modeset_lock_all(dev);
        drm_mode_create_standard_properties(dev);
@@ -5918,6 +5941,7 @@ void drm_mode_config_cleanup(struct drm_device *dev)
                crtc->funcs->destroy(crtc);
        }
 
+       ida_destroy(&dev->mode_config.connector_ida);
        idr_destroy(&dev->mode_config.tile_idr);
        idr_destroy(&dev->mode_config.crtc_idr);
        drm_modeset_lock_fini(&dev->mode_config.connection_mutex);
index 7539eea..79555d2 100644 (file)
@@ -1075,3 +1075,36 @@ int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
        return drm_plane_helper_commit(plane, plane_state, old_fb);
 }
 EXPORT_SYMBOL(drm_helper_crtc_mode_set_base);
+
+/**
+ * drm_helper_crtc_enable_color_mgmt - enable color management properties
+ * @crtc: DRM CRTC
+ * @degamma_lut_size: the size of the degamma lut (before CSC)
+ * @gamma_lut_size: the size of the gamma lut (after CSC)
+ *
+ * This function lets the driver enable the color correction properties on a
+ * CRTC. This includes 3 degamma, csc and gamma properties that userspace can
+ * set and 2 size properties to inform the userspace of the lut sizes.
+ */
+void drm_helper_crtc_enable_color_mgmt(struct drm_crtc *crtc,
+                                      int degamma_lut_size,
+                                      int gamma_lut_size)
+{
+       struct drm_device *dev = crtc->dev;
+       struct drm_mode_config *config = &dev->mode_config;
+
+       drm_object_attach_property(&crtc->base,
+                                  config->degamma_lut_property, 0);
+       drm_object_attach_property(&crtc->base,
+                                  config->ctm_property, 0);
+       drm_object_attach_property(&crtc->base,
+                                  config->gamma_lut_property, 0);
+
+       drm_object_attach_property(&crtc->base,
+                                  config->degamma_lut_size_property,
+                                  degamma_lut_size);
+       drm_object_attach_property(&crtc->base,
+                                  config->gamma_lut_size_property,
+                                  gamma_lut_size);
+}
+EXPORT_SYMBOL(drm_helper_crtc_enable_color_mgmt);
index 8ae13de..27fbd79 100644 (file)
@@ -1159,11 +1159,13 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
                        drm_dp_put_port(port);
                        goto out;
                }
-
-               drm_mode_connector_set_tile_property(port->connector);
-
+               if (port->port_num >= DP_MST_LOGICAL_PORT_0) {
+                       port->cached_edid = drm_get_edid(port->connector, &port->aux.ddc);
+                       drm_mode_connector_set_tile_property(port->connector);
+               }
                (*mstb->mgr->cbs->register_connector)(port->connector);
        }
+
 out:
        /* put reference to this port */
        drm_dp_put_port(port);
@@ -1188,8 +1190,8 @@ static void drm_dp_update_port(struct drm_dp_mst_branch *mstb,
        port->ddps = conn_stat->displayport_device_plug_status;
 
        if (old_ddps != port->ddps) {
-               dowork = true;
                if (port->ddps) {
+                       dowork = true;
                } else {
                        port->available_pbn = 0;
                }
@@ -1294,13 +1296,8 @@ static void drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr *m
                if (port->input)
                        continue;
 
-               if (!port->ddps) {
-                       if (port->cached_edid) {
-                               kfree(port->cached_edid);
-                               port->cached_edid = NULL;
-                       }
+               if (!port->ddps)
                        continue;
-               }
 
                if (!port->available_pbn)
                        drm_dp_send_enum_path_resources(mgr, mstb, port);
@@ -1311,12 +1308,6 @@ static void drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr *m
                                drm_dp_check_and_send_link_address(mgr, mstb_child);
                                drm_dp_put_mst_branch_device(mstb_child);
                        }
-               } else if (port->pdt == DP_PEER_DEVICE_SST_SINK ||
-                       port->pdt == DP_PEER_DEVICE_DP_LEGACY_CONV) {
-                       if (!port->cached_edid) {
-                               port->cached_edid =
-                                       drm_get_edid(port->connector, &port->aux.ddc);
-                       }
                }
        }
 }
@@ -1336,8 +1327,6 @@ static void drm_dp_mst_link_probe_work(struct work_struct *work)
                drm_dp_check_and_send_link_address(mgr, mstb);
                drm_dp_put_mst_branch_device(mstb);
        }
-
-       (*mgr->cbs->hotplug)(mgr);
 }
 
 static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr,
@@ -1597,6 +1586,7 @@ static void drm_dp_send_link_address(struct drm_dp_mst_topology_mgr *mgr,
                        for (i = 0; i < txmsg->reply.u.link_addr.nports; i++) {
                                drm_dp_add_port(mstb, mgr->dev, &txmsg->reply.u.link_addr.ports[i]);
                        }
+                       (*mgr->cbs->hotplug)(mgr);
                }
        } else {
                mstb->link_address_sent = false;
@@ -2293,6 +2283,8 @@ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)
                        drm_dp_update_port(mstb, &msg.u.conn_stat);
 
                        DRM_DEBUG_KMS("Got CSN: pn: %d ldps:%d ddps: %d mcs: %d ip: %d pdt: %d\n", msg.u.conn_stat.port_number, msg.u.conn_stat.legacy_device_plug_status, msg.u.conn_stat.displayport_device_plug_status, msg.u.conn_stat.message_capability_status, msg.u.conn_stat.input_port, msg.u.conn_stat.peer_device_type);
+                       (*mgr->cbs->hotplug)(mgr);
+
                } else if (msg.req_type == DP_RESOURCE_STATUS_NOTIFY) {
                        drm_dp_send_up_ack_reply(mgr, mgr->mst_primary, msg.req_type, seqno, false);
                        if (!mstb)
@@ -2379,6 +2371,10 @@ enum drm_connector_status drm_dp_mst_detect_port(struct drm_connector *connector
 
        case DP_PEER_DEVICE_SST_SINK:
                status = connector_status_connected;
+               /* for logical ports - cache the EDID */
+               if (port->port_num >= 8 && !port->cached_edid) {
+                       port->cached_edid = drm_get_edid(connector, &port->aux.ddc);
+               }
                break;
        case DP_PEER_DEVICE_DP_LEGACY_CONV:
                if (port->ldps)
@@ -2433,7 +2429,10 @@ struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_
 
        if (port->cached_edid)
                edid = drm_edid_duplicate(port->cached_edid);
-
+       else {
+               edid = drm_get_edid(connector, &port->aux.ddc);
+               drm_mode_connector_set_tile_property(connector);
+       }
        port->has_audio = drm_detect_monitor_audio(edid);
        drm_dp_put_port(port);
        return edid;
index fdb1eb0..414d7f6 100644 (file)
@@ -3308,7 +3308,7 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
        u8 *cea;
        u8 *name;
        u8 *db;
-       int sad_count = 0;
+       int total_sad_count = 0;
        int mnl;
        int dbl;
 
@@ -3322,6 +3322,7 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
 
        name = NULL;
        drm_for_each_detailed_block((u8 *)edid, monitor_name, &name);
+       /* max: 13 bytes EDID, 16 bytes ELD */
        for (mnl = 0; name && mnl < 13; mnl++) {
                if (name[mnl] == 0x0a)
                        break;
@@ -3350,11 +3351,15 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
                        dbl = cea_db_payload_len(db);
 
                        switch (cea_db_tag(db)) {
+                               int sad_count;
+
                        case AUDIO_BLOCK:
                                /* Audio Data Block, contains SADs */
-                               sad_count = dbl / 3;
-                               if (dbl >= 1)
-                                       memcpy(eld + 20 + mnl, &db[1], dbl);
+                               sad_count = min(dbl / 3, 15 - total_sad_count);
+                               if (sad_count >= 1)
+                                       memcpy(eld + 20 + mnl + total_sad_count * 3,
+                                              &db[1], sad_count * 3);
+                               total_sad_count += sad_count;
                                break;
                        case SPEAKER_BLOCK:
                                /* Speaker Allocation Data Block */
@@ -3371,13 +3376,13 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
                        }
                }
        }
-       eld[5] |= sad_count << 4;
+       eld[5] |= total_sad_count << 4;
 
        eld[DRM_ELD_BASELINE_ELD_LEN] =
                DIV_ROUND_UP(drm_eld_calc_baseline_block_size(eld), 4);
 
        DRM_DEBUG_KMS("ELD size %d, SAD count %d\n",
-                     drm_eld_size(eld), sad_count);
+                     drm_eld_size(eld), total_sad_count);
 }
 EXPORT_SYMBOL(drm_edid_to_eld);
 
index 96d03ac..881c5a6 100644 (file)
@@ -224,6 +224,64 @@ static void drm_update_vblank_count(struct drm_device *dev, unsigned int pipe,
                diff = (flags & DRM_CALLED_FROM_VBLIRQ) != 0;
        }
 
+       /*
+        * Within a drm_vblank_pre_modeset - drm_vblank_post_modeset
+        * interval? If so then vblank irqs keep running and it will likely
+        * happen that the hardware vblank counter is not trustworthy as it
+        * might reset at some point in that interval and vblank timestamps
+        * are not trustworthy either in that interval. Iow. this can result
+        * in a bogus diff >> 1 which must be avoided as it would cause
+        * random large forward jumps of the software vblank counter.
+        */
+       if (diff > 1 && (vblank->inmodeset & 0x2)) {
+               DRM_DEBUG_VBL("clamping vblank bump to 1 on crtc %u: diffr=%u"
+                             " due to pre-modeset.\n", pipe, diff);
+               diff = 1;
+       }
+
+       /*
+        * FIMXE: Need to replace this hack with proper seqlocks.
+        *
+        * Restrict the bump of the software vblank counter to a safe maximum
+        * value of +1 whenever there is the possibility that concurrent readers
+        * of vblank timestamps could be active at the moment, as the current
+        * implementation of the timestamp caching and updating is not safe
+        * against concurrent readers for calls to store_vblank() with a bump
+        * of anything but +1. A bump != 1 would very likely return corrupted
+        * timestamps to userspace, because the same slot in the cache could
+        * be concurrently written by store_vblank() and read by one of those
+        * readers without the read-retry logic detecting the collision.
+        *
+        * Concurrent readers can exist when we are called from the
+        * drm_vblank_off() or drm_vblank_on() functions and other non-vblank-
+        * irq callers. However, all those calls to us are happening with the
+        * vbl_lock locked to prevent drm_vblank_get(), so the vblank refcount
+        * can't increase while we are executing. Therefore a zero refcount at
+        * this point is safe for arbitrary counter bumps if we are called
+        * outside vblank irq, a non-zero count is not 100% safe. Unfortunately
+        * we must also accept a refcount of 1, as whenever we are called from
+        * drm_vblank_get() -> drm_vblank_enable() the refcount will be 1 and
+        * we must let that one pass through in order to not lose vblank counts
+        * during vblank irq off - which would completely defeat the whole
+        * point of this routine.
+        *
+        * Whenever we are called from vblank irq, we have to assume concurrent
+        * readers exist or can show up any time during our execution, even if
+        * the refcount is currently zero, as vblank irqs are usually only
+        * enabled due to the presence of readers, and because when we are called
+        * from vblank irq we can't hold the vbl_lock to protect us from sudden
+        * bumps in vblank refcount. Therefore also restrict bumps to +1 when
+        * called from vblank irq.
+        */
+       if ((diff > 1) && (atomic_read(&vblank->refcount) > 1 ||
+           (flags & DRM_CALLED_FROM_VBLIRQ))) {
+               DRM_DEBUG_VBL("clamping vblank bump to 1 on crtc %u: diffr=%u "
+                             "refcount %u, vblirq %u\n", pipe, diff,
+                             atomic_read(&vblank->refcount),
+                             (flags & DRM_CALLED_FROM_VBLIRQ) != 0);
+               diff = 1;
+       }
+
        DRM_DEBUG_VBL("updating vblank count on crtc %u:"
                      " current=%u, diff=%u, hw=%u hw_last=%u\n",
                      pipe, vblank->count, diff, cur_vblank, vblank->last);
@@ -1313,7 +1371,13 @@ void drm_vblank_off(struct drm_device *dev, unsigned int pipe)
        spin_lock_irqsave(&dev->event_lock, irqflags);
 
        spin_lock(&dev->vbl_lock);
-       vblank_disable_and_save(dev, pipe);
+       DRM_DEBUG_VBL("crtc %d, vblank enabled %d, inmodeset %d\n",
+                     pipe, vblank->enabled, vblank->inmodeset);
+
+       /* Avoid redundant vblank disables without previous drm_vblank_on(). */
+       if (drm_core_check_feature(dev, DRIVER_ATOMIC) || !vblank->inmodeset)
+               vblank_disable_and_save(dev, pipe);
+
        wake_up(&vblank->queue);
 
        /*
@@ -1415,6 +1479,9 @@ void drm_vblank_on(struct drm_device *dev, unsigned int pipe)
                return;
 
        spin_lock_irqsave(&dev->vbl_lock, irqflags);
+       DRM_DEBUG_VBL("crtc %d, vblank enabled %d, inmodeset %d\n",
+                     pipe, vblank->enabled, vblank->inmodeset);
+
        /* Drop our private "prevent drm_vblank_get" refcount */
        if (vblank->inmodeset) {
                atomic_dec(&vblank->refcount);
@@ -1427,8 +1494,7 @@ void drm_vblank_on(struct drm_device *dev, unsigned int pipe)
         * re-enable interrupts if there are users left, or the
         * user wishes vblank interrupts to be enabled all the time.
         */
-       if (atomic_read(&vblank->refcount) != 0 ||
-           (!dev->vblank_disable_immediate && drm_vblank_offdelay == 0))
+       if (atomic_read(&vblank->refcount) != 0 || drm_vblank_offdelay == 0)
                WARN_ON(drm_vblank_enable(dev, pipe));
        spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
 }
@@ -1523,6 +1589,7 @@ void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe)
        if (vblank->inmodeset) {
                spin_lock_irqsave(&dev->vbl_lock, irqflags);
                dev->vblank_disable_allowed = true;
+               drm_reset_vblank_timestamp(dev, pipe);
                spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
 
                if (vblank->inmodeset & 0x2)
index 6e6a9c5..f5d8083 100644 (file)
 
 static int mipi_dsi_device_match(struct device *dev, struct device_driver *drv)
 {
-       return of_driver_match_device(dev, drv);
+       struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
+
+       /* attempt OF style match */
+       if (of_driver_match_device(dev, drv))
+               return 1;
+
+       /* compare DSI device and driver names */
+       if (!strcmp(dsi->name, drv->name))
+               return 1;
+
+       return 0;
 }
 
 static const struct dev_pm_ops mipi_dsi_device_pm_ops = {
@@ -129,14 +139,20 @@ static int mipi_dsi_device_add(struct mipi_dsi_device *dsi)
        return device_add(&dsi->dev);
 }
 
+#if IS_ENABLED(CONFIG_OF)
 static struct mipi_dsi_device *
 of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
 {
-       struct mipi_dsi_device *dsi;
        struct device *dev = host->dev;
+       struct mipi_dsi_device_info info = { };
        int ret;
        u32 reg;
 
+       if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
+               dev_err(dev, "modalias failure on %s\n", node->full_name);
+               return ERR_PTR(-EINVAL);
+       }
+
        ret = of_property_read_u32(node, "reg", &reg);
        if (ret) {
                dev_err(dev, "device node %s has no valid reg property: %d\n",
@@ -144,32 +160,111 @@ of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
                return ERR_PTR(-EINVAL);
        }
 
-       if (reg > 3) {
-               dev_err(dev, "device node %s has invalid reg property: %u\n",
-                       node->full_name, reg);
+       info.channel = reg;
+       info.node = of_node_get(node);
+
+       return mipi_dsi_device_register_full(host, &info);
+}
+#else
+static struct mipi_dsi_device *
+of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node)
+{
+       return ERR_PTR(-ENODEV);
+}
+#endif
+
+/**
+ * mipi_dsi_device_register_full - create a MIPI DSI device
+ * @host: DSI host to which this device is connected
+ * @info: pointer to template containing DSI device information
+ *
+ * Create a MIPI DSI device by using the device information provided by
+ * mipi_dsi_device_info template
+ *
+ * Returns:
+ * A pointer to the newly created MIPI DSI device, or, a pointer encoded
+ * with an error
+ */
+struct mipi_dsi_device *
+mipi_dsi_device_register_full(struct mipi_dsi_host *host,
+                             const struct mipi_dsi_device_info *info)
+{
+       struct mipi_dsi_device *dsi;
+       struct device *dev = host->dev;
+       int ret;
+
+       if (!info) {
+               dev_err(dev, "invalid mipi_dsi_device_info pointer\n");
+               return ERR_PTR(-EINVAL);
+       }
+
+       if (info->channel > 3) {
+               dev_err(dev, "invalid virtual channel: %u\n", info->channel);
                return ERR_PTR(-EINVAL);
        }
 
        dsi = mipi_dsi_device_alloc(host);
        if (IS_ERR(dsi)) {
-               dev_err(dev, "failed to allocate DSI device %s: %ld\n",
-                       node->full_name, PTR_ERR(dsi));
+               dev_err(dev, "failed to allocate DSI device %ld\n",
+                       PTR_ERR(dsi));
                return dsi;
        }
 
-       dsi->dev.of_node = of_node_get(node);
-       dsi->channel = reg;
+       dsi->dev.of_node = info->node;
+       dsi->channel = info->channel;
+       strlcpy(dsi->name, info->type, sizeof(dsi->name));
 
        ret = mipi_dsi_device_add(dsi);
        if (ret) {
-               dev_err(dev, "failed to add DSI device %s: %d\n",
-                       node->full_name, ret);
+               dev_err(dev, "failed to add DSI device %d\n", ret);
                kfree(dsi);
                return ERR_PTR(ret);
        }
 
        return dsi;
 }
+EXPORT_SYMBOL(mipi_dsi_device_register_full);
+
+/**
+ * mipi_dsi_device_unregister - unregister MIPI DSI device
+ * @dsi: DSI peripheral device
+ */
+void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi)
+{
+       device_unregister(&dsi->dev);
+}
+EXPORT_SYMBOL(mipi_dsi_device_unregister);
+
+static DEFINE_MUTEX(host_lock);
+static LIST_HEAD(host_list);
+
+/**
+ * of_find_mipi_dsi_host_by_node() - find the MIPI DSI host matching a
+ *                                  device tree node
+ * @node: device tree node
+ *
+ * Returns:
+ * A pointer to the MIPI DSI host corresponding to @node or NULL if no
+ * such device exists (or has not been registered yet).
+ */
+struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node)
+{
+       struct mipi_dsi_host *host;
+
+       mutex_lock(&host_lock);
+
+       list_for_each_entry(host, &host_list, list) {
+               if (host->dev->of_node == node) {
+                       mutex_unlock(&host_lock);
+                       return host;
+               }
+       }
+
+       mutex_unlock(&host_lock);
+
+       return NULL;
+}
+EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node);
 
 int mipi_dsi_host_register(struct mipi_dsi_host *host)
 {
@@ -182,6 +277,10 @@ int mipi_dsi_host_register(struct mipi_dsi_host *host)
                of_mipi_dsi_device_add(host, node);
        }
 
+       mutex_lock(&host_lock);
+       list_add_tail(&host->list, &host_list);
+       mutex_unlock(&host_lock);
+
        return 0;
 }
 EXPORT_SYMBOL(mipi_dsi_host_register);
@@ -190,7 +289,7 @@ static int mipi_dsi_remove_device_fn(struct device *dev, void *priv)
 {
        struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
 
-       device_unregister(&dsi->dev);
+       mipi_dsi_device_unregister(dsi);
 
        return 0;
 }
@@ -198,6 +297,10 @@ static int mipi_dsi_remove_device_fn(struct device *dev, void *priv)
 void mipi_dsi_host_unregister(struct mipi_dsi_host *host)
 {
        device_for_each_child(host->dev, NULL, mipi_dsi_remove_device_fn);
+
+       mutex_lock(&host_lock);
+       list_del_init(&host->list);
+       mutex_unlock(&host_lock);
 }
 EXPORT_SYMBOL(mipi_dsi_host_unregister);
 
index 493c05c..bc98bb9 100644 (file)
@@ -149,3 +149,37 @@ int drm_of_component_probe(struct device *dev,
        return component_master_add_with_match(dev, m_ops, match);
 }
 EXPORT_SYMBOL(drm_of_component_probe);
+
+/*
+ * drm_of_encoder_active_endpoint - return the active encoder endpoint
+ * @node: device tree node containing encoder input ports
+ * @encoder: drm_encoder
+ *
+ * Given an encoder device node and a drm_encoder with a connected crtc,
+ * parse the encoder endpoint connecting to the crtc port.
+ */
+int drm_of_encoder_active_endpoint(struct device_node *node,
+                                  struct drm_encoder *encoder,
+                                  struct of_endpoint *endpoint)
+{
+       struct device_node *ep;
+       struct drm_crtc *crtc = encoder->crtc;
+       struct device_node *port;
+       int ret;
+
+       if (!node || !crtc)
+               return -EINVAL;
+
+       for_each_endpoint_of_node(node, ep) {
+               port = of_graph_get_remote_port(ep);
+               of_node_put(port);
+               if (port == crtc->port) {
+                       ret = of_graph_parse_endpoint(ep, endpoint);
+                       of_node_put(ep);
+                       return ret;
+               }
+       }
+
+       return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint);
index 332c55e..d8d5564 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "common.xml.h"
 #include "state.xml.h"
+#include "state_3d.xml.h"
 #include "cmdstream.xml.h"
 
 /*
@@ -85,10 +86,17 @@ static inline void CMD_STALL(struct etnaviv_cmdbuf *buffer,
        OUT(buffer, VIV_FE_STALL_TOKEN_FROM(from) | VIV_FE_STALL_TOKEN_TO(to));
 }
 
-static void etnaviv_cmd_select_pipe(struct etnaviv_cmdbuf *buffer, u8 pipe)
+static inline void CMD_SEM(struct etnaviv_cmdbuf *buffer, u32 from, u32 to)
 {
-       u32 flush;
-       u32 stall;
+       CMD_LOAD_STATE(buffer, VIVS_GL_SEMAPHORE_TOKEN,
+                      VIVS_GL_SEMAPHORE_TOKEN_FROM(from) |
+                      VIVS_GL_SEMAPHORE_TOKEN_TO(to));
+}
+
+static void etnaviv_cmd_select_pipe(struct etnaviv_gpu *gpu,
+       struct etnaviv_cmdbuf *buffer, u8 pipe)
+{
+       u32 flush = 0;
 
        /*
         * This assumes that if we're switching to 2D, we're switching
@@ -96,17 +104,13 @@ static void etnaviv_cmd_select_pipe(struct etnaviv_cmdbuf *buffer, u8 pipe)
         * the 2D core, we need to flush the 3D depth and color caches,
         * otherwise we need to flush the 2D pixel engine cache.
         */
-       if (pipe == ETNA_PIPE_2D)
-               flush = VIVS_GL_FLUSH_CACHE_DEPTH | VIVS_GL_FLUSH_CACHE_COLOR;
-       else
+       if (gpu->exec_state == ETNA_PIPE_2D)
                flush = VIVS_GL_FLUSH_CACHE_PE2D;
-
-       stall = VIVS_GL_SEMAPHORE_TOKEN_FROM(SYNC_RECIPIENT_FE) |
-               VIVS_GL_SEMAPHORE_TOKEN_TO(SYNC_RECIPIENT_PE);
+       else if (gpu->exec_state == ETNA_PIPE_3D)
+               flush = VIVS_GL_FLUSH_CACHE_DEPTH | VIVS_GL_FLUSH_CACHE_COLOR;
 
        CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_CACHE, flush);
-       CMD_LOAD_STATE(buffer, VIVS_GL_SEMAPHORE_TOKEN, stall);
-
+       CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
        CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
 
        CMD_LOAD_STATE(buffer, VIVS_GL_PIPE_SELECT,
@@ -131,6 +135,36 @@ static void etnaviv_buffer_dump(struct etnaviv_gpu *gpu,
                        ptr, len * 4, 0);
 }
 
+/*
+ * Safely replace the WAIT of a waitlink with a new command and argument.
+ * The GPU may be executing this WAIT while we're modifying it, so we have
+ * to write it in a specific order to avoid the GPU branching to somewhere
+ * else.  'wl_offset' is the offset to the first byte of the WAIT command.
+ */
+static void etnaviv_buffer_replace_wait(struct etnaviv_cmdbuf *buffer,
+       unsigned int wl_offset, u32 cmd, u32 arg)
+{
+       u32 *lw = buffer->vaddr + wl_offset;
+
+       lw[1] = arg;
+       mb();
+       lw[0] = cmd;
+       mb();
+}
+
+/*
+ * Ensure that there is space in the command buffer to contiguously write
+ * 'cmd_dwords' 64-bit words into the buffer, wrapping if necessary.
+ */
+static u32 etnaviv_buffer_reserve(struct etnaviv_gpu *gpu,
+       struct etnaviv_cmdbuf *buffer, unsigned int cmd_dwords)
+{
+       if (buffer->user_size + cmd_dwords * sizeof(u64) > buffer->size)
+               buffer->user_size = 0;
+
+       return gpu_va(gpu, buffer) + buffer->user_size;
+}
+
 u16 etnaviv_buffer_init(struct etnaviv_gpu *gpu)
 {
        struct etnaviv_cmdbuf *buffer = gpu->buffer;
@@ -147,81 +181,79 @@ u16 etnaviv_buffer_init(struct etnaviv_gpu *gpu)
 void etnaviv_buffer_end(struct etnaviv_gpu *gpu)
 {
        struct etnaviv_cmdbuf *buffer = gpu->buffer;
+       unsigned int waitlink_offset = buffer->user_size - 16;
+       u32 link_target, flush = 0;
 
-       /* Replace the last WAIT with an END */
-       buffer->user_size -= 16;
-
-       CMD_END(buffer);
-       mb();
+       if (gpu->exec_state == ETNA_PIPE_2D)
+               flush = VIVS_GL_FLUSH_CACHE_PE2D;
+       else if (gpu->exec_state == ETNA_PIPE_3D)
+               flush = VIVS_GL_FLUSH_CACHE_DEPTH |
+                       VIVS_GL_FLUSH_CACHE_COLOR |
+                       VIVS_GL_FLUSH_CACHE_TEXTURE |
+                       VIVS_GL_FLUSH_CACHE_TEXTUREVS |
+                       VIVS_GL_FLUSH_CACHE_SHADER_L2;
+
+       if (flush) {
+               unsigned int dwords = 7;
+
+               link_target = etnaviv_buffer_reserve(gpu, buffer, dwords);
+
+               CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
+               CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
+               CMD_LOAD_STATE(buffer, VIVS_GL_FLUSH_CACHE, flush);
+               if (gpu->exec_state == ETNA_PIPE_3D)
+                       CMD_LOAD_STATE(buffer, VIVS_TS_FLUSH_CACHE,
+                                      VIVS_TS_FLUSH_CACHE_FLUSH);
+               CMD_SEM(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
+               CMD_STALL(buffer, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
+               CMD_END(buffer);
+
+               etnaviv_buffer_replace_wait(buffer, waitlink_offset,
+                                           VIV_FE_LINK_HEADER_OP_LINK |
+                                           VIV_FE_LINK_HEADER_PREFETCH(dwords),
+                                           link_target);
+       } else {
+               /* Replace the last link-wait with an "END" command */
+               etnaviv_buffer_replace_wait(buffer, waitlink_offset,
+                                           VIV_FE_END_HEADER_OP_END, 0);
+       }
 }
 
+/* Append a command buffer to the ring buffer. */
 void etnaviv_buffer_queue(struct etnaviv_gpu *gpu, unsigned int event,
        struct etnaviv_cmdbuf *cmdbuf)
 {
        struct etnaviv_cmdbuf *buffer = gpu->buffer;
-       u32 *lw = buffer->vaddr + buffer->user_size - 16;
-       u32 back, link_target, link_size, reserve_size, extra_size = 0;
+       unsigned int waitlink_offset = buffer->user_size - 16;
+       u32 return_target, return_dwords;
+       u32 link_target, link_dwords;
 
        if (drm_debug & DRM_UT_DRIVER)
                etnaviv_buffer_dump(gpu, buffer, 0, 0x50);
 
+       link_target = gpu_va(gpu, cmdbuf);
+       link_dwords = cmdbuf->size / 8;
+
        /*
-        * If we need to flush the MMU prior to submitting this buffer, we
-        * will need to append a mmu flush load state, followed by a new
+        * If we need maintanence prior to submitting this buffer, we will
+        * need to append a mmu flush load state, followed by a new
         * link to this buffer - a total of four additional words.
         */
        if (gpu->mmu->need_flush || gpu->switch_context) {
+               u32 target, extra_dwords;
+
                /* link command */
-               extra_size += 2;
+               extra_dwords = 1;
+
                /* flush command */
                if (gpu->mmu->need_flush)
-                       extra_size += 2;
+                       extra_dwords += 1;
+
                /* pipe switch commands */
                if (gpu->switch_context)
-                       extra_size += 8;
-       }
+                       extra_dwords += 4;
 
-       reserve_size = (6 + extra_size) * 4;
-
-       /*
-        * if we are going to completely overflow the buffer, we need to wrap.
-        */
-       if (buffer->user_size + reserve_size > buffer->size)
-               buffer->user_size = 0;
-
-       /* save offset back into main buffer */
-       back = buffer->user_size + reserve_size - 6 * 4;
-       link_target = gpu_va(gpu, buffer) + buffer->user_size;
-       link_size = 6;
-
-       /* Skip over any extra instructions */
-       link_target += extra_size * sizeof(u32);
-
-       if (drm_debug & DRM_UT_DRIVER)
-               pr_info("stream link to 0x%08x @ 0x%08x %p\n",
-                       link_target, gpu_va(gpu, cmdbuf), cmdbuf->vaddr);
-
-       /* jump back from cmd to main buffer */
-       CMD_LINK(cmdbuf, link_size, link_target);
-
-       link_target = gpu_va(gpu, cmdbuf);
-       link_size = cmdbuf->size / 8;
-
-
-
-       if (drm_debug & DRM_UT_DRIVER) {
-               print_hex_dump(KERN_INFO, "cmd ", DUMP_PREFIX_OFFSET, 16, 4,
-                              cmdbuf->vaddr, cmdbuf->size, 0);
-
-               pr_info("link op: %p\n", lw);
-               pr_info("link addr: %p\n", lw + 1);
-               pr_info("addr: 0x%08x\n", link_target);
-               pr_info("back: 0x%08x\n", gpu_va(gpu, buffer) + back);
-               pr_info("event: %d\n", event);
-       }
-
-       if (gpu->mmu->need_flush || gpu->switch_context) {
-               u32 new_target = gpu_va(gpu, buffer) + buffer->user_size;
+               target = etnaviv_buffer_reserve(gpu, buffer, extra_dwords);
 
                if (gpu->mmu->need_flush) {
                        /* Add the MMU flush */
@@ -236,32 +268,59 @@ void etnaviv_buffer_queue(struct etnaviv_gpu *gpu, unsigned int event,
                }
 
                if (gpu->switch_context) {
-                       etnaviv_cmd_select_pipe(buffer, cmdbuf->exec_state);
+                       etnaviv_cmd_select_pipe(gpu, buffer, cmdbuf->exec_state);
+                       gpu->exec_state = cmdbuf->exec_state;
                        gpu->switch_context = false;
                }
 
-               /* And the link to the first buffer */
-               CMD_LINK(buffer, link_size, link_target);
+               /* And the link to the submitted buffer */
+               CMD_LINK(buffer, link_dwords, link_target);
 
                /* Update the link target to point to above instructions */
-               link_target = new_target;
-               link_size = extra_size;
+               link_target = target;
+               link_dwords = extra_dwords;
        }
 
-       /* trigger event */
+       /*
+        * Append a LINK to the submitted command buffer to return to
+        * the ring buffer.  return_target is the ring target address.
+        * We need three dwords: event, wait, link.
+        */
+       return_dwords = 3;
+       return_target = etnaviv_buffer_reserve(gpu, buffer, return_dwords);
+       CMD_LINK(cmdbuf, return_dwords, return_target);
+
+       /*
+        * Append event, wait and link pointing back to the wait
+        * command to the ring buffer.
+        */
        CMD_LOAD_STATE(buffer, VIVS_GL_EVENT, VIVS_GL_EVENT_EVENT_ID(event) |
                       VIVS_GL_EVENT_FROM_PE);
-
-       /* append WAIT/LINK to main buffer */
        CMD_WAIT(buffer);
-       CMD_LINK(buffer, 2, gpu_va(gpu, buffer) + (buffer->user_size - 4));
+       CMD_LINK(buffer, 2, return_target + 8);
 
-       /* Change WAIT into a LINK command; write the address first. */
-       *(lw + 1) = link_target;
-       mb();
-       *(lw) = VIV_FE_LINK_HEADER_OP_LINK |
-               VIV_FE_LINK_HEADER_PREFETCH(link_size);
-       mb();
+       if (drm_debug & DRM_UT_DRIVER)
+               pr_info("stream link to 0x%08x @ 0x%08x %p\n",
+                       return_target, gpu_va(gpu, cmdbuf), cmdbuf->vaddr);
+
+       if (drm_debug & DRM_UT_DRIVER) {
+               print_hex_dump(KERN_INFO, "cmd ", DUMP_PREFIX_OFFSET, 16, 4,
+                              cmdbuf->vaddr, cmdbuf->size, 0);
+
+               pr_info("link op: %p\n", buffer->vaddr + waitlink_offset);
+               pr_info("addr: 0x%08x\n", link_target);
+               pr_info("back: 0x%08x\n", return_target);
+               pr_info("event: %d\n", event);
+       }
+
+       /*
+        * Kick off the submitted command by replacing the previous
+        * WAIT with a link to the address in the ring buffer.
+        */
+       etnaviv_buffer_replace_wait(buffer, waitlink_offset,
+                                   VIV_FE_LINK_HEADER_OP_LINK |
+                                   VIV_FE_LINK_HEADER_PREFETCH(link_dwords),
+                                   link_target);
 
        if (drm_debug & DRM_UT_DRIVER)
                etnaviv_buffer_dump(gpu, buffer, 0, 0x50);
index 1cd6046..115c5bc 100644 (file)
@@ -75,9 +75,6 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
 int etnaviv_gem_mmap(struct file *filp, struct vm_area_struct *vma);
 int etnaviv_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
 int etnaviv_gem_mmap_offset(struct drm_gem_object *obj, u64 *offset);
-int etnaviv_gem_get_iova(struct etnaviv_gpu *gpu,
-       struct drm_gem_object *obj, u32 *iova);
-void etnaviv_gem_put_iova(struct etnaviv_gpu *gpu, struct drm_gem_object *obj);
 struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj);
 void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj);
 void etnaviv_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
index 4b519e4..937a775 100644 (file)
@@ -260,8 +260,32 @@ etnaviv_gem_get_vram_mapping(struct etnaviv_gem_object *obj,
        return NULL;
 }
 
-int etnaviv_gem_get_iova(struct etnaviv_gpu *gpu,
-       struct drm_gem_object *obj, u32 *iova)
+void etnaviv_gem_mapping_reference(struct etnaviv_vram_mapping *mapping)
+{
+       struct etnaviv_gem_object *etnaviv_obj = mapping->object;
+
+       drm_gem_object_reference(&etnaviv_obj->base);
+
+       mutex_lock(&etnaviv_obj->lock);
+       WARN_ON(mapping->use == 0);
+       mapping->use += 1;
+       mutex_unlock(&etnaviv_obj->lock);
+}
+
+void etnaviv_gem_mapping_unreference(struct etnaviv_vram_mapping *mapping)
+{
+       struct etnaviv_gem_object *etnaviv_obj = mapping->object;
+
+       mutex_lock(&etnaviv_obj->lock);
+       WARN_ON(mapping->use == 0);
+       mapping->use -= 1;
+       mutex_unlock(&etnaviv_obj->lock);
+
+       drm_gem_object_unreference_unlocked(&etnaviv_obj->base);
+}
+
+struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
+       struct drm_gem_object *obj, struct etnaviv_gpu *gpu)
 {
        struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
        struct etnaviv_vram_mapping *mapping;
@@ -329,28 +353,12 @@ int etnaviv_gem_get_iova(struct etnaviv_gpu *gpu,
 out:
        mutex_unlock(&etnaviv_obj->lock);
 
-       if (!ret) {
-               /* Take a reference on the object */
-               drm_gem_object_reference(obj);
-               *iova = mapping->iova;
-       }
-
-       return ret;
-}
-
-void etnaviv_gem_put_iova(struct etnaviv_gpu *gpu, struct drm_gem_object *obj)
-{
-       struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
-       struct etnaviv_vram_mapping *mapping;
-
-       mutex_lock(&etnaviv_obj->lock);
-       mapping = etnaviv_gem_get_vram_mapping(etnaviv_obj, gpu->mmu);
-
-       WARN_ON(mapping->use == 0);
-       mapping->use -= 1;
-       mutex_unlock(&etnaviv_obj->lock);
+       if (ret)
+               return ERR_PTR(ret);
 
-       drm_gem_object_unreference_unlocked(obj);
+       /* Take a reference on the object */
+       drm_gem_object_reference(obj);
+       return mapping;
 }
 
 void *etnaviv_gem_vmap(struct drm_gem_object *obj)
index ab5df81..02665d8 100644 (file)
@@ -88,6 +88,12 @@ static inline bool is_active(struct etnaviv_gem_object *etnaviv_obj)
 
 #define MAX_CMDS 4
 
+struct etnaviv_gem_submit_bo {
+       u32 flags;
+       struct etnaviv_gem_object *obj;
+       struct etnaviv_vram_mapping *mapping;
+};
+
 /* Created per submit-ioctl, to track bo's and cmdstream bufs, etc,
  * associated with the cmdstream submission for synchronization (and
  * make it easier to unwind when things go wrong, etc).  This only
@@ -99,11 +105,7 @@ struct etnaviv_gem_submit {
        struct ww_acquire_ctx ticket;
        u32 fence;
        unsigned int nr_bos;
-       struct {
-               u32 flags;
-               struct etnaviv_gem_object *obj;
-               u32 iova;
-       } bos[0];
+       struct etnaviv_gem_submit_bo bos[0];
 };
 
 int etnaviv_gem_wait_bo(struct etnaviv_gpu *gpu, struct drm_gem_object *obj,
@@ -115,4 +117,9 @@ int etnaviv_gem_obj_add(struct drm_device *dev, struct drm_gem_object *obj);
 struct page **etnaviv_gem_get_pages(struct etnaviv_gem_object *obj);
 void etnaviv_gem_put_pages(struct etnaviv_gem_object *obj);
 
+struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
+       struct drm_gem_object *obj, struct etnaviv_gpu *gpu);
+void etnaviv_gem_mapping_reference(struct etnaviv_vram_mapping *mapping);
+void etnaviv_gem_mapping_unreference(struct etnaviv_vram_mapping *mapping);
+
 #endif /* __ETNAVIV_GEM_H__ */
index 1aba01a..236ada9 100644 (file)
@@ -187,12 +187,10 @@ static void submit_unpin_objects(struct etnaviv_gem_submit *submit)
        int i;
 
        for (i = 0; i < submit->nr_bos; i++) {
-               struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
-
                if (submit->bos[i].flags & BO_PINNED)
-                       etnaviv_gem_put_iova(submit->gpu, &etnaviv_obj->base);
+                       etnaviv_gem_mapping_unreference(submit->bos[i].mapping);
 
-               submit->bos[i].iova = 0;
+               submit->bos[i].mapping = NULL;
                submit->bos[i].flags &= ~BO_PINNED;
        }
 }
@@ -203,22 +201,24 @@ static int submit_pin_objects(struct etnaviv_gem_submit *submit)
 
        for (i = 0; i < submit->nr_bos; i++) {
                struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
-               u32 iova;
+               struct etnaviv_vram_mapping *mapping;
 
-               ret = etnaviv_gem_get_iova(submit->gpu, &etnaviv_obj->base,
-                                          &iova);
-               if (ret)
+               mapping = etnaviv_gem_mapping_get(&etnaviv_obj->base,
+                                                 submit->gpu);
+               if (IS_ERR(mapping)) {
+                       ret = PTR_ERR(mapping);
                        break;
+               }
 
                submit->bos[i].flags |= BO_PINNED;
-               submit->bos[i].iova = iova;
+               submit->bos[i].mapping = mapping;
        }
 
        return ret;
 }
 
 static int submit_bo(struct etnaviv_gem_submit *submit, u32 idx,
-               struct etnaviv_gem_object **obj, u32 *iova)
+       struct etnaviv_gem_submit_bo **bo)
 {
        if (idx >= submit->nr_bos) {
                DRM_ERROR("invalid buffer index: %u (out of %u)\n",
@@ -226,10 +226,7 @@ static int submit_bo(struct etnaviv_gem_submit *submit, u32 idx,
                return -EINVAL;
        }
 
-       if (obj)
-               *obj = submit->bos[idx].obj;
-       if (iova)
-               *iova = submit->bos[idx].iova;
+       *bo = &submit->bos[idx];
 
        return 0;
 }
@@ -245,8 +242,8 @@ static int submit_reloc(struct etnaviv_gem_submit *submit, void *stream,
 
        for (i = 0; i < nr_relocs; i++) {
                const struct drm_etnaviv_gem_submit_reloc *r = relocs + i;
-               struct etnaviv_gem_object *bobj;
-               u32 iova, off;
+               struct etnaviv_gem_submit_bo *bo;
+               u32 off;
 
                if (unlikely(r->flags)) {
                        DRM_ERROR("invalid reloc flags\n");
@@ -268,17 +265,16 @@ static int submit_reloc(struct etnaviv_gem_submit *submit, void *stream,
                        return -EINVAL;
                }
 
-               ret = submit_bo(submit, r->reloc_idx, &bobj, &iova);
+               ret = submit_bo(submit, r->reloc_idx, &bo);
                if (ret)
                        return ret;
 
-               if (r->reloc_offset >=
-                   bobj->base.size - sizeof(*ptr)) {
+               if (r->reloc_offset >= bo->obj->base.size - sizeof(*ptr)) {
                        DRM_ERROR("relocation %u outside object", i);
                        return -EINVAL;
                }
 
-               ptr[off] = iova + r->reloc_offset;
+               ptr[off] = bo->mapping->iova + r->reloc_offset;
 
                last_offset = off;
        }
index a33162c..d13303c 100644 (file)
@@ -628,6 +628,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
        /* Now program the hardware */
        mutex_lock(&gpu->lock);
        etnaviv_gpu_hw_init(gpu);
+       gpu->exec_state = -1;
        mutex_unlock(&gpu->lock);
 
        pm_runtime_mark_last_busy(gpu->dev);
@@ -871,17 +872,13 @@ static void recover_worker(struct work_struct *work)
                gpu->event[i].fence = NULL;
                gpu->event[i].used = false;
                complete(&gpu->event_free);
-               /*
-                * Decrement the PM count for each stuck event. This is safe
-                * even in atomic context as we use ASYNC RPM here.
-                */
-               pm_runtime_put_autosuspend(gpu->dev);
        }
        spin_unlock_irqrestore(&gpu->event_spinlock, flags);
        gpu->completed_fence = gpu->active_fence;
 
        etnaviv_gpu_hw_init(gpu);
        gpu->switch_context = true;
+       gpu->exec_state = -1;
 
        mutex_unlock(&gpu->lock);
        pm_runtime_mark_last_busy(gpu->dev);
@@ -1106,7 +1103,7 @@ struct etnaviv_cmdbuf *etnaviv_gpu_cmdbuf_new(struct etnaviv_gpu *gpu, u32 size,
        size_t nr_bos)
 {
        struct etnaviv_cmdbuf *cmdbuf;
-       size_t sz = size_vstruct(nr_bos, sizeof(cmdbuf->bo[0]),
+       size_t sz = size_vstruct(nr_bos, sizeof(cmdbuf->bo_map[0]),
                                 sizeof(*cmdbuf));
 
        cmdbuf = kzalloc(sz, GFP_KERNEL);
@@ -1150,14 +1147,23 @@ static void retire_worker(struct work_struct *work)
                fence_put(cmdbuf->fence);
 
                for (i = 0; i < cmdbuf->nr_bos; i++) {
-                       struct etnaviv_gem_object *etnaviv_obj = cmdbuf->bo[i];
+                       struct etnaviv_vram_mapping *mapping = cmdbuf->bo_map[i];
+                       struct etnaviv_gem_object *etnaviv_obj = mapping->object;
 
                        atomic_dec(&etnaviv_obj->gpu_active);
                        /* drop the refcount taken in etnaviv_gpu_submit */
-                       etnaviv_gem_put_iova(gpu, &etnaviv_obj->base);
+                       etnaviv_gem_mapping_unreference(mapping);
                }
 
                etnaviv_gpu_cmdbuf_free(cmdbuf);
+               /*
+                * We need to balance the runtime PM count caused by
+                * each submission.  Upon submission, we increment
+                * the runtime PM counter, and allocate one event.
+                * So here, we put the runtime PM count for each
+                * completed event.
+                */
+               pm_runtime_put_autosuspend(gpu->dev);
        }
 
        gpu->retired_fence = fence;
@@ -1304,11 +1310,10 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
 
        for (i = 0; i < submit->nr_bos; i++) {
                struct etnaviv_gem_object *etnaviv_obj = submit->bos[i].obj;
-               u32 iova;
 
-               /* Each cmdbuf takes a refcount on the iova */
-               etnaviv_gem_get_iova(gpu, &etnaviv_obj->base, &iova);
-               cmdbuf->bo[i] = etnaviv_obj;
+               /* Each cmdbuf takes a refcount on the mapping */
+               etnaviv_gem_mapping_reference(submit->bos[i].mapping);
+               cmdbuf->bo_map[i] = submit->bos[i].mapping;
                atomic_inc(&etnaviv_obj->gpu_active);
 
                if (submit->bos[i].flags & ETNA_SUBMIT_BO_WRITE)
@@ -1378,15 +1383,6 @@ static irqreturn_t irq_handler(int irq, void *data)
                                gpu->completed_fence = fence->seqno;
 
                        event_free(gpu, event);
-
-                       /*
-                        * We need to balance the runtime PM count caused by
-                        * each submission.  Upon submission, we increment
-                        * the runtime PM counter, and allocate one event.
-                        * So here, we put the runtime PM count for each
-                        * completed event.
-                        */
-                       pm_runtime_put_autosuspend(gpu->dev);
                }
 
                /* Retire the buffer objects in a work */
@@ -1481,6 +1477,7 @@ static int etnaviv_gpu_hw_resume(struct etnaviv_gpu *gpu)
        etnaviv_gpu_hw_init(gpu);
 
        gpu->switch_context = true;
+       gpu->exec_state = -1;
 
        mutex_unlock(&gpu->lock);
 
@@ -1569,6 +1566,7 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct etnaviv_gpu *gpu;
+       u32 dma_mask;
        int err = 0;
 
        gpu = devm_kzalloc(dev, sizeof(*gpu), GFP_KERNEL);
@@ -1579,12 +1577,16 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)
        mutex_init(&gpu->lock);
 
        /*
-        * Set the GPU base address to the start of physical memory.  This
-        * ensures that if we have up to 2GB, the v1 MMU can address the
-        * highest memory.  This is important as command buffers may be
-        * allocated outside of this limit.
+        * Set the GPU linear window to be at the end of the DMA window, where
+        * the CMA area is likely to reside. This ensures that we are able to
+        * map the command buffers while having the linear window overlap as
+        * much RAM as possible, so we can optimize mappings for other buffers.
         */
-       gpu->memory_base = PHYS_OFFSET;
+       dma_mask = (u32)dma_get_required_mask(dev);
+       if (dma_mask < PHYS_OFFSET + SZ_2G)
+               gpu->memory_base = PHYS_OFFSET;
+       else
+               gpu->memory_base = dma_mask - SZ_2G + 1;
 
        /* Map registers: */
        gpu->mmio = etnaviv_ioremap(pdev, NULL, dev_name(gpu->dev));
index f233ac4..f5321e2 100644 (file)
@@ -23,6 +23,7 @@
 #include "etnaviv_drv.h"
 
 struct etnaviv_gem_submit;
+struct etnaviv_vram_mapping;
 
 struct etnaviv_chip_identity {
        /* Chip model. */
@@ -103,6 +104,7 @@ struct etnaviv_gpu {
 
        /* 'ring'-buffer: */
        struct etnaviv_cmdbuf *buffer;
+       int exec_state;
 
        /* bus base address of memory  */
        u32 memory_base;
@@ -166,7 +168,7 @@ struct etnaviv_cmdbuf {
        struct list_head node;
        /* BOs attached to this command buffer */
        unsigned int nr_bos;
-       struct etnaviv_gem_object *bo[0];
+       struct etnaviv_vram_mapping *bo_map[0];
 };
 
 static inline void gpu_write(struct etnaviv_gpu *gpu, u32 reg, u32 data)
index 6743bc6..29a723f 100644 (file)
@@ -193,7 +193,7 @@ int etnaviv_iommu_map_gem(struct etnaviv_iommu *mmu,
 
                /*
                 * Unmap the blocks which need to be reaped from the MMU.
-                * Clear the mmu pointer to prevent the get_iova finding
+                * Clear the mmu pointer to prevent the mapping_get finding
                 * this mapping.
                 */
                list_for_each_entry_safe(m, n, &list, scan_node) {
diff --git a/drivers/gpu/drm/etnaviv/state_3d.xml.h b/drivers/gpu/drm/etnaviv/state_3d.xml.h
new file mode 100644 (file)
index 0000000..d7146fd
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef STATE_3D_XML
+#define STATE_3D_XML
+
+/* This is a cut-down version of the state_3d.xml.h file */
+
+#define VIVS_TS_FLUSH_CACHE                                    0x00001650
+#define VIVS_TS_FLUSH_CACHE_FLUSH                              0x00000001
+
+#endif /* STATE_3D_XML */
index 83efca9..f17d392 100644 (file)
@@ -1,6 +1,6 @@
 config DRM_EXYNOS
        tristate "DRM Support for Samsung SoC EXYNOS Series"
-       depends on OF && DRM && (PLAT_SAMSUNG || ARCH_MULTIPLATFORM)
+       depends on OF && DRM && (ARCH_S3C64XX || ARCH_EXYNOS || ARCH_MULTIPLATFORM)
        select DRM_KMS_HELPER
        select DRM_KMS_FB_HELPER
        select FB_CFB_FILLRECT
index 6496532..968b31c 100644 (file)
@@ -2,7 +2,6 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
 
-ccflags-y := -Iinclude/drm -Idrivers/gpu/drm/exynos
 exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fbdev.o \
                exynos_drm_fb.o exynos_drm_gem.o exynos_drm_core.o \
                exynos_drm_plane.o
index 1bf6a21..5245bc5 100644 (file)
@@ -93,7 +93,7 @@ static int decon_enable_vblank(struct exynos_drm_crtc *crtc)
        if (test_bit(BIT_SUSPENDED, &ctx->flags))
                return -EPERM;
 
-       if (test_and_set_bit(BIT_IRQS_ENABLED, &ctx->flags)) {
+       if (!test_and_set_bit(BIT_IRQS_ENABLED, &ctx->flags)) {
                val = VIDINTCON0_INTEN;
                if (ctx->out_type == IFTYPE_I80)
                        val |= VIDINTCON0_FRAMEDONE;
@@ -402,8 +402,6 @@ static void decon_enable(struct exynos_drm_crtc *crtc)
                decon_enable_vblank(ctx->crtc);
 
        decon_commit(ctx->crtc);
-
-       set_bit(BIT_SUSPENDED, &ctx->flags);
 }
 
 static void decon_disable(struct exynos_drm_crtc *crtc)
@@ -431,7 +429,7 @@ static void decon_disable(struct exynos_drm_crtc *crtc)
        set_bit(BIT_SUSPENDED, &ctx->flags);
 }
 
-void decon_te_irq_handler(struct exynos_drm_crtc *crtc)
+static void decon_te_irq_handler(struct exynos_drm_crtc *crtc)
 {
        struct decon_context *ctx = crtc->ctx;
 
@@ -582,9 +580,9 @@ out:
 static int exynos5433_decon_suspend(struct device *dev)
 {
        struct decon_context *ctx = dev_get_drvdata(dev);
-       int i;
+       int i = ARRAY_SIZE(decon_clks_name);
 
-       for (i = 0; i < ARRAY_SIZE(decon_clks_name); i++)
+       while (--i >= 0)
                clk_disable_unprepare(ctx->clks[i]);
 
        return 0;
index 52bda3b..9336107 100644 (file)
@@ -60,7 +60,6 @@ struct decon_context {
        wait_queue_head_t               wait_vsync_queue;
        atomic_t                        wait_vsync_event;
 
-       struct exynos_drm_panel_info panel;
        struct drm_encoder *encoder;
 };
 
index 9fd12c6..cff8dc7 100644 (file)
@@ -977,9 +977,7 @@ static int exynos_dp_get_modes(struct drm_connector *connector)
                return 0;
        }
 
-       drm_display_mode_from_videomode(&dp->priv.vm, mode);
-       mode->width_mm = dp->priv.width_mm;
-       mode->height_mm = dp->priv.height_mm;
+       drm_display_mode_from_videomode(&dp->vm, mode);
        connector->display_info.width_mm = mode->width_mm;
        connector->display_info.height_mm = mode->height_mm;
 
@@ -1241,8 +1239,7 @@ static int exynos_dp_dt_parse_panel(struct exynos_dp_device *dp)
 {
        int ret;
 
-       ret = of_get_videomode(dp->dev->of_node, &dp->priv.vm,
-                       OF_USE_NATIVE_MODE);
+       ret = of_get_videomode(dp->dev->of_node, &dp->vm, OF_USE_NATIVE_MODE);
        if (ret) {
                DRM_ERROR("failed: of_get_videomode() : %d\n", ret);
                return ret;
index 66eec4b..b5c2d8f 100644 (file)
@@ -16,6 +16,7 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_dp_helper.h>
 #include <drm/exynos_drm.h>
+#include <video/videomode.h>
 
 #include "exynos_drm_drv.h"
 
@@ -164,8 +165,7 @@ struct exynos_dp_device {
        struct phy              *phy;
        int                     dpms_mode;
        int                     hpd_gpio;
-
-       struct exynos_drm_panel_info priv;
+       struct videomode        vm;
 };
 
 /* exynos_dp_reg.c */
index 1e535f9..5344940 100644 (file)
@@ -130,6 +130,8 @@ static void exynos_drm_atomic_work(struct work_struct *work)
        exynos_atomic_commit_complete(commit);
 }
 
+static struct device *exynos_drm_get_dma_device(void);
+
 static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
 {
        struct exynos_drm_private *private;
@@ -147,6 +149,16 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
        dev_set_drvdata(dev->dev, dev);
        dev->dev_private = (void *)private;
 
+       /* the first real CRTC device is used for all dma mapping operations */
+       private->dma_dev = exynos_drm_get_dma_device();
+       if (!private->dma_dev) {
+               DRM_ERROR("no device found for DMA mapping operations.\n");
+               ret = -ENODEV;
+               goto err_free_private;
+       }
+       DRM_INFO("Exynos DRM: using %s device for DMA mapping operations\n",
+                dev_name(private->dma_dev));
+
        /*
         * create mapping to manage iommu table and set a pointer to iommu
         * mapping structure to iommu_mapping of private data.
@@ -358,6 +370,8 @@ static const struct vm_operations_struct exynos_drm_gem_vm_ops = {
 static const struct drm_ioctl_desc exynos_ioctls[] = {
        DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
                        DRM_AUTH | DRM_RENDER_ALLOW),
+       DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP, exynos_drm_gem_map_ioctl,
+                       DRM_AUTH | DRM_RENDER_ALLOW),
        DRM_IOCTL_DEF_DRV(EXYNOS_GEM_GET, exynos_drm_gem_get_ioctl,
                        DRM_RENDER_ALLOW),
        DRM_IOCTL_DEF_DRV(EXYNOS_VIDI_CONNECTION, vidi_connection_ioctl,
@@ -481,69 +495,65 @@ static const struct dev_pm_ops exynos_drm_pm_ops = {
 /* forward declaration */
 static struct platform_driver exynos_drm_platform_driver;
 
+struct exynos_drm_driver_info {
+       struct platform_driver *driver;
+       unsigned int flags;
+};
+
+#define DRM_COMPONENT_DRIVER   BIT(0)  /* supports component framework */
+#define DRM_VIRTUAL_DEVICE     BIT(1)  /* create virtual platform device */
+#define DRM_DMA_DEVICE         BIT(2)  /* can be used for dma allocations */
+
+#define DRV_PTR(drv, cond) (IS_ENABLED(cond) ? &drv : NULL)
+
 /*
  * Connector drivers should not be placed before associated crtc drivers,
  * because connector requires pipe number of its crtc during initialization.
  */
-static struct platform_driver *const exynos_drm_kms_drivers[] = {
-#ifdef CONFIG_DRM_EXYNOS_FIMD
-       &fimd_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS5433_DECON
-       &exynos5433_decon_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS7_DECON
-       &decon_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_MIC
-       &mic_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_DP
-       &dp_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_DSI
-       &dsi_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_MIXER
-       &mixer_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_HDMI
-       &hdmi_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_VIDI
-       &vidi_driver,
-#endif
-};
-
-static struct platform_driver *const exynos_drm_non_kms_drivers[] = {
-#ifdef CONFIG_DRM_EXYNOS_G2D
-       &g2d_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_FIMC
-       &fimc_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_ROTATOR
-       &rotator_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_GSC
-       &gsc_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_IPP
-       &ipp_driver,
-#endif
-       &exynos_drm_platform_driver,
-};
-
-static struct platform_driver *const exynos_drm_drv_with_simple_dev[] = {
-#ifdef CONFIG_DRM_EXYNOS_VIDI
-       &vidi_driver,
-#endif
-#ifdef CONFIG_DRM_EXYNOS_IPP
-       &ipp_driver,
-#endif
-       &exynos_drm_platform_driver,
+static struct exynos_drm_driver_info exynos_drm_drivers[] = {
+       {
+               DRV_PTR(fimd_driver, CONFIG_DRM_EXYNOS_FIMD),
+               DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE
+       }, {
+               DRV_PTR(exynos5433_decon_driver, CONFIG_DRM_EXYNOS5433_DECON),
+               DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE
+       }, {
+               DRV_PTR(decon_driver, CONFIG_DRM_EXYNOS7_DECON),
+               DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE
+       }, {
+               DRV_PTR(mixer_driver, CONFIG_DRM_EXYNOS_MIXER),
+               DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE
+       }, {
+               DRV_PTR(mic_driver, CONFIG_DRM_EXYNOS_MIC),
+               DRM_COMPONENT_DRIVER
+       }, {
+               DRV_PTR(dp_driver, CONFIG_DRM_EXYNOS_DP),
+               DRM_COMPONENT_DRIVER
+       }, {
+               DRV_PTR(dsi_driver, CONFIG_DRM_EXYNOS_DSI),
+               DRM_COMPONENT_DRIVER
+       }, {
+               DRV_PTR(hdmi_driver, CONFIG_DRM_EXYNOS_HDMI),
+               DRM_COMPONENT_DRIVER
+       }, {
+               DRV_PTR(vidi_driver, CONFIG_DRM_EXYNOS_VIDI),
+               DRM_COMPONENT_DRIVER | DRM_VIRTUAL_DEVICE
+       }, {
+               DRV_PTR(g2d_driver, CONFIG_DRM_EXYNOS_G2D),
+       }, {
+               DRV_PTR(fimc_driver, CONFIG_DRM_EXYNOS_FIMC),
+       }, {
+               DRV_PTR(rotator_driver, CONFIG_DRM_EXYNOS_ROTATOR),
+       }, {
+               DRV_PTR(gsc_driver, CONFIG_DRM_EXYNOS_GSC),
+       }, {
+               DRV_PTR(ipp_driver, CONFIG_DRM_EXYNOS_IPP),
+               DRM_VIRTUAL_DEVICE
+       }, {
+               &exynos_drm_platform_driver,
+               DRM_VIRTUAL_DEVICE
+       }
 };
-#define PDEV_COUNT ARRAY_SIZE(exynos_drm_drv_with_simple_dev)
 
 static int compare_dev(struct device *dev, void *data)
 {
@@ -555,11 +565,15 @@ static struct component_match *exynos_drm_match_add(struct device *dev)
        struct component_match *match = NULL;
        int i;
 
-       for (i = 0; i < ARRAY_SIZE(exynos_drm_kms_drivers); ++i) {
-               struct device_driver *drv = &exynos_drm_kms_drivers[i]->driver;
+       for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
+               struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
                struct device *p = NULL, *d;
 
-               while ((d = bus_find_device(&platform_bus_type, p, drv,
+               if (!info->driver || !(info->flags & DRM_COMPONENT_DRIVER))
+                       continue;
+
+               while ((d = bus_find_device(&platform_bus_type, p,
+                                           &info->driver->driver,
                                            (void *)platform_bus_type.match))) {
                        put_device(p);
                        component_match_add(dev, &match, compare_dev, d);
@@ -616,91 +630,102 @@ static struct platform_driver exynos_drm_platform_driver = {
        },
 };
 
-static struct platform_device *exynos_drm_pdevs[PDEV_COUNT];
+static struct device *exynos_drm_get_dma_device(void)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
+               struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
+               struct device *dev;
+
+               if (!info->driver || !(info->flags & DRM_DMA_DEVICE))
+                       continue;
+
+               while ((dev = bus_find_device(&platform_bus_type, NULL,
+                                           &info->driver->driver,
+                                           (void *)platform_bus_type.match))) {
+                       put_device(dev);
+                       return dev;
+               }
+       }
+       return NULL;
+}
 
 static void exynos_drm_unregister_devices(void)
 {
-       int i = PDEV_COUNT;
+       int i;
+
+       for (i = ARRAY_SIZE(exynos_drm_drivers) - 1; i >= 0; --i) {
+               struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
+               struct device *dev;
 
-       while (--i >= 0) {
-               platform_device_unregister(exynos_drm_pdevs[i]);
-               exynos_drm_pdevs[i] = NULL;
+               if (!info->driver || !(info->flags & DRM_VIRTUAL_DEVICE))
+                       continue;
+
+               while ((dev = bus_find_device(&platform_bus_type, NULL,
+                                           &info->driver->driver,
+                                           (void *)platform_bus_type.match))) {
+                       put_device(dev);
+                       platform_device_unregister(to_platform_device(dev));
+               }
        }
 }
 
 static int exynos_drm_register_devices(void)
 {
+       struct platform_device *pdev;
        int i;
 
-       for (i = 0; i < PDEV_COUNT; ++i) {
-               struct platform_driver *d = exynos_drm_drv_with_simple_dev[i];
-               struct platform_device *pdev =
-                       platform_device_register_simple(d->driver.name, -1,
-                                                       NULL, 0);
+       for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
+               struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
 
-               if (!IS_ERR(pdev)) {
-                       exynos_drm_pdevs[i] = pdev;
+               if (!info->driver || !(info->flags & DRM_VIRTUAL_DEVICE))
                        continue;
-               }
-               while (--i >= 0) {
-                       platform_device_unregister(exynos_drm_pdevs[i]);
-                       exynos_drm_pdevs[i] = NULL;
-               }
 
-               return PTR_ERR(pdev);
+               pdev = platform_device_register_simple(
+                                       info->driver->driver.name, -1, NULL, 0);
+               if (IS_ERR(pdev))
+                       goto fail;
        }
 
        return 0;
+fail:
+       exynos_drm_unregister_devices();
+       return PTR_ERR(pdev);
 }
 
-static void exynos_drm_unregister_drivers(struct platform_driver * const *drv,
-                                         int count)
+static void exynos_drm_unregister_drivers(void)
 {
-       while (--count >= 0)
-               platform_driver_unregister(drv[count]);
-}
+       int i;
 
-static int exynos_drm_register_drivers(struct platform_driver * const *drv,
-                                      int count)
-{
-       int i, ret;
+       for (i = ARRAY_SIZE(exynos_drm_drivers) - 1; i >= 0; --i) {
+               struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
 
-       for (i = 0; i < count; ++i) {
-               ret = platform_driver_register(drv[i]);
-               if (!ret)
+               if (!info->driver)
                        continue;
 
-               while (--i >= 0)
-                       platform_driver_unregister(drv[i]);
-
-               return ret;
+               platform_driver_unregister(info->driver);
        }
-
-       return 0;
 }
 
-static inline int exynos_drm_register_kms_drivers(void)
+static int exynos_drm_register_drivers(void)
 {
-       return exynos_drm_register_drivers(exynos_drm_kms_drivers,
-                                       ARRAY_SIZE(exynos_drm_kms_drivers));
-}
+       int i, ret;
 
-static inline int exynos_drm_register_non_kms_drivers(void)
-{
-       return exynos_drm_register_drivers(exynos_drm_non_kms_drivers,
-                                       ARRAY_SIZE(exynos_drm_non_kms_drivers));
-}
+       for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) {
+               struct exynos_drm_driver_info *info = &exynos_drm_drivers[i];
 
-static inline void exynos_drm_unregister_kms_drivers(void)
-{
-       exynos_drm_unregister_drivers(exynos_drm_kms_drivers,
-                                       ARRAY_SIZE(exynos_drm_kms_drivers));
-}
+               if (!info->driver)
+                       continue;
 
-static inline void exynos_drm_unregister_non_kms_drivers(void)
-{
-       exynos_drm_unregister_drivers(exynos_drm_non_kms_drivers,
-                                       ARRAY_SIZE(exynos_drm_non_kms_drivers));
+               ret = platform_driver_register(info->driver);
+               if (ret)
+                       goto fail;
+       }
+       return 0;
+fail:
+       exynos_drm_unregister_drivers();
+       return ret;
 }
 
 static int exynos_drm_init(void)
@@ -711,19 +736,12 @@ static int exynos_drm_init(void)
        if (ret)
                return ret;
 
-       ret = exynos_drm_register_kms_drivers();
+       ret = exynos_drm_register_drivers();
        if (ret)
                goto err_unregister_pdevs;
 
-       ret = exynos_drm_register_non_kms_drivers();
-       if (ret)
-               goto err_unregister_kms_drivers;
-
        return 0;
 
-err_unregister_kms_drivers:
-       exynos_drm_unregister_kms_drivers();
-
 err_unregister_pdevs:
        exynos_drm_unregister_devices();
 
@@ -732,8 +750,7 @@ err_unregister_pdevs:
 
 static void exynos_drm_exit(void)
 {
-       exynos_drm_unregister_non_kms_drivers();
-       exynos_drm_unregister_kms_drivers();
+       exynos_drm_unregister_drivers();
        exynos_drm_unregister_devices();
 }
 
index 17b5ded..502f750 100644 (file)
@@ -219,8 +219,10 @@ struct exynos_drm_private {
        struct drm_crtc *crtc[MAX_CRTC];
        struct drm_property *plane_zpos_property;
 
+       struct device *dma_dev;
        unsigned long da_start;
        unsigned long da_space_size;
+       void *mapping;
 
        unsigned int pipe;
 
@@ -230,6 +232,13 @@ struct exynos_drm_private {
        wait_queue_head_t       wait;
 };
 
+static inline struct device *to_dma_dev(struct drm_device *dev)
+{
+       struct exynos_drm_private *priv = dev->dev_private;
+
+       return priv->dma_dev;
+}
+
 /*
  * Exynos drm sub driver structure.
  *
@@ -297,7 +306,6 @@ extern struct platform_driver dp_driver;
 extern struct platform_driver dsi_driver;
 extern struct platform_driver mixer_driver;
 extern struct platform_driver hdmi_driver;
-extern struct platform_driver exynos_drm_common_hdmi_driver;
 extern struct platform_driver vidi_driver;
 extern struct platform_driver g2d_driver;
 extern struct platform_driver fimc_driver;
index 736115c..63c84a1 100644 (file)
@@ -10,6 +10,8 @@
  * published by the Free Software Foundation.
 */
 
+#include <asm/unaligned.h>
+
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_mipi_dsi.h>
 
 #define OLD_SCLK_MIPI_CLK_NAME "pll_clk"
 
-#define REG_ADDR(dsi, reg_idx)         ((dsi)->reg_base + \
-                                       dsi->driver_data->reg_ofs[(reg_idx)])
-#define DSI_WRITE(dsi, reg_idx, val)   writel((val), \
-                                       REG_ADDR((dsi), (reg_idx)))
-#define DSI_READ(dsi, reg_idx)         readl(REG_ADDR((dsi), (reg_idx)))
-
 static char *clk_names[5] = { "bus_clk", "sclk_mipi",
        "phyclk_mipidphy0_bitclkdiv8", "phyclk_mipidphy0_rxclkesc0",
        "sclk_rgb_vclk_to_dsim0" };
@@ -228,12 +224,8 @@ struct exynos_dsi_transfer {
        struct list_head list;
        struct completion completed;
        int result;
-       u8 data_id;
-       u8 data[2];
+       struct mipi_dsi_packet packet;
        u16 flags;
-
-       const u8 *tx_payload;
-       u16 tx_len;
        u16 tx_done;
 
        u8 *rx_payload;
@@ -247,7 +239,7 @@ struct exynos_dsi_transfer {
 #define DSIM_STATE_VIDOUT_AVAILABLE    BIT(3)
 
 struct exynos_dsi_driver_data {
-       unsigned int *reg_ofs;
+       const unsigned int *reg_ofs;
        unsigned int plltmr_reg;
        unsigned int has_freqband:1;
        unsigned int has_clklane_stop:1;
@@ -255,7 +247,7 @@ struct exynos_dsi_driver_data {
        unsigned int max_freq;
        unsigned int wait_for_reset;
        unsigned int num_bits_resol;
-       unsigned int *reg_values;
+       const unsigned int *reg_values;
 };
 
 struct exynos_dsi {
@@ -324,7 +316,20 @@ enum reg_idx {
        DSIM_PHYTIMING2_REG,
        NUM_REGS
 };
-static unsigned int exynos_reg_ofs[] = {
+
+static inline void exynos_dsi_write(struct exynos_dsi *dsi, enum reg_idx idx,
+                                   u32 val)
+{
+
+       writel(val, dsi->reg_base + dsi->driver_data->reg_ofs[idx]);
+}
+
+static inline u32 exynos_dsi_read(struct exynos_dsi *dsi, enum reg_idx idx)
+{
+       return readl(dsi->reg_base + dsi->driver_data->reg_ofs[idx]);
+}
+
+static const unsigned int exynos_reg_ofs[] = {
        [DSIM_STATUS_REG] =  0x00,
        [DSIM_SWRST_REG] =  0x04,
        [DSIM_CLKCTRL_REG] =  0x08,
@@ -348,7 +353,7 @@ static unsigned int exynos_reg_ofs[] = {
        [DSIM_PHYTIMING2_REG] =  0x6c,
 };
 
-static unsigned int exynos5433_reg_ofs[] = {
+static const unsigned int exynos5433_reg_ofs[] = {
        [DSIM_STATUS_REG] = 0x04,
        [DSIM_SWRST_REG] = 0x0C,
        [DSIM_CLKCTRL_REG] = 0x10,
@@ -390,7 +395,7 @@ enum reg_value_idx {
        PHYTIMING_HS_TRAIL
 };
 
-static unsigned int reg_values[] = {
+static const unsigned int reg_values[] = {
        [RESET_TYPE] = DSIM_SWRST,
        [PLL_TIMER] = 500,
        [STOP_STATE_CNT] = 0xf,
@@ -408,7 +413,25 @@ static unsigned int reg_values[] = {
        [PHYTIMING_HS_TRAIL] = DSIM_PHYTIMING2_HS_TRAIL(0x0b),
 };
 
-static unsigned int exynos5433_reg_values[] = {
+static const unsigned int exynos5422_reg_values[] = {
+       [RESET_TYPE] = DSIM_SWRST,
+       [PLL_TIMER] = 500,
+       [STOP_STATE_CNT] = 0xf,
+       [PHYCTRL_ULPS_EXIT] = DSIM_PHYCTRL_ULPS_EXIT(0xaf),
+       [PHYCTRL_VREG_LP] = 0,
+       [PHYCTRL_SLEW_UP] = 0,
+       [PHYTIMING_LPX] = DSIM_PHYTIMING_LPX(0x08),
+       [PHYTIMING_HS_EXIT] = DSIM_PHYTIMING_HS_EXIT(0x0d),
+       [PHYTIMING_CLK_PREPARE] = DSIM_PHYTIMING1_CLK_PREPARE(0x09),
+       [PHYTIMING_CLK_ZERO] = DSIM_PHYTIMING1_CLK_ZERO(0x30),
+       [PHYTIMING_CLK_POST] = DSIM_PHYTIMING1_CLK_POST(0x0e),
+       [PHYTIMING_CLK_TRAIL] = DSIM_PHYTIMING1_CLK_TRAIL(0x0a),
+       [PHYTIMING_HS_PREPARE] = DSIM_PHYTIMING2_HS_PREPARE(0x0c),
+       [PHYTIMING_HS_ZERO] = DSIM_PHYTIMING2_HS_ZERO(0x11),
+       [PHYTIMING_HS_TRAIL] = DSIM_PHYTIMING2_HS_TRAIL(0x0d),
+};
+
+static const unsigned int exynos5433_reg_values[] = {
        [RESET_TYPE] = DSIM_FUNCRST,
        [PLL_TIMER] = 22200,
        [STOP_STATE_CNT] = 0xa,
@@ -426,7 +449,7 @@ static unsigned int exynos5433_reg_values[] = {
        [PHYTIMING_HS_TRAIL] = DSIM_PHYTIMING2_HS_TRAIL(0x0c),
 };
 
-static struct exynos_dsi_driver_data exynos3_dsi_driver_data = {
+static const struct exynos_dsi_driver_data exynos3_dsi_driver_data = {
        .reg_ofs = exynos_reg_ofs,
        .plltmr_reg = 0x50,
        .has_freqband = 1,
@@ -438,7 +461,7 @@ static struct exynos_dsi_driver_data exynos3_dsi_driver_data = {
        .reg_values = reg_values,
 };
 
-static struct exynos_dsi_driver_data exynos4_dsi_driver_data = {
+static const struct exynos_dsi_driver_data exynos4_dsi_driver_data = {
        .reg_ofs = exynos_reg_ofs,
        .plltmr_reg = 0x50,
        .has_freqband = 1,
@@ -450,7 +473,7 @@ static struct exynos_dsi_driver_data exynos4_dsi_driver_data = {
        .reg_values = reg_values,
 };
 
-static struct exynos_dsi_driver_data exynos4415_dsi_driver_data = {
+static const struct exynos_dsi_driver_data exynos4415_dsi_driver_data = {
        .reg_ofs = exynos_reg_ofs,
        .plltmr_reg = 0x58,
        .has_clklane_stop = 1,
@@ -461,7 +484,7 @@ static struct exynos_dsi_driver_data exynos4415_dsi_driver_data = {
        .reg_values = reg_values,
 };
 
-static struct exynos_dsi_driver_data exynos5_dsi_driver_data = {
+static const struct exynos_dsi_driver_data exynos5_dsi_driver_data = {
        .reg_ofs = exynos_reg_ofs,
        .plltmr_reg = 0x58,
        .num_clks = 2,
@@ -471,7 +494,7 @@ static struct exynos_dsi_driver_data exynos5_dsi_driver_data = {
        .reg_values = reg_values,
 };
 
-static struct exynos_dsi_driver_data exynos5433_dsi_driver_data = {
+static const struct exynos_dsi_driver_data exynos5433_dsi_driver_data = {
        .reg_ofs = exynos5433_reg_ofs,
        .plltmr_reg = 0xa0,
        .has_clklane_stop = 1,
@@ -482,7 +505,18 @@ static struct exynos_dsi_driver_data exynos5433_dsi_driver_data = {
        .reg_values = exynos5433_reg_values,
 };
 
-static struct of_device_id exynos_dsi_of_match[] = {
+static const struct exynos_dsi_driver_data exynos5422_dsi_driver_data = {
+       .reg_ofs = exynos5433_reg_ofs,
+       .plltmr_reg = 0xa0,
+       .has_clklane_stop = 1,
+       .num_clks = 2,
+       .max_freq = 1500,
+       .wait_for_reset = 1,
+       .num_bits_resol = 12,
+       .reg_values = exynos5422_reg_values,
+};
+
+static const struct of_device_id exynos_dsi_of_match[] = {
        { .compatible = "samsung,exynos3250-mipi-dsi",
          .data = &exynos3_dsi_driver_data },
        { .compatible = "samsung,exynos4210-mipi-dsi",
@@ -491,6 +525,8 @@ static struct of_device_id exynos_dsi_of_match[] = {
          .data = &exynos4415_dsi_driver_data },
        { .compatible = "samsung,exynos5410-mipi-dsi",
          .data = &exynos5_dsi_driver_data },
+       { .compatible = "samsung,exynos5422-mipi-dsi",
+         .data = &exynos5422_dsi_driver_data },
        { .compatible = "samsung,exynos5433-mipi-dsi",
          .data = &exynos5433_dsi_driver_data },
        { }
@@ -515,10 +551,10 @@ static void exynos_dsi_wait_for_reset(struct exynos_dsi *dsi)
 
 static void exynos_dsi_reset(struct exynos_dsi *dsi)
 {
-       struct exynos_dsi_driver_data *driver_data = dsi->driver_data;
+       u32 reset_val = dsi->driver_data->reg_values[RESET_TYPE];
 
        reinit_completion(&dsi->completed);
-       DSI_WRITE(dsi, DSIM_SWRST_REG, driver_data->reg_values[RESET_TYPE]);
+       exynos_dsi_write(dsi, DSIM_SWRST_REG, reset_val);
 }
 
 #ifndef MHZ
@@ -621,7 +657,7 @@ static unsigned long exynos_dsi_set_pll(struct exynos_dsi *dsi,
                reg |= DSIM_FREQ_BAND(band);
        }
 
-       DSI_WRITE(dsi, DSIM_PLLCTRL_REG, reg);
+       exynos_dsi_write(dsi, DSIM_PLLCTRL_REG, reg);
 
        timeout = 1000;
        do {
@@ -629,7 +665,7 @@ static unsigned long exynos_dsi_set_pll(struct exynos_dsi *dsi,
                        dev_err(dsi->dev, "PLL failed to stabilize\n");
                        return 0;
                }
-               reg = DSI_READ(dsi, DSIM_STATUS_REG);
+               reg = exynos_dsi_read(dsi, DSIM_STATUS_REG);
        } while ((reg & DSIM_PLL_STABLE) == 0);
 
        return fout;
@@ -659,7 +695,7 @@ static int exynos_dsi_enable_clock(struct exynos_dsi *dsi)
        dev_dbg(dsi->dev, "hs_clk = %lu, byte_clk = %lu, esc_clk = %lu\n",
                hs_clk, byte_clk, esc_clk);
 
-       reg = DSI_READ(dsi, DSIM_CLKCTRL_REG);
+       reg = exynos_dsi_read(dsi, DSIM_CLKCTRL_REG);
        reg &= ~(DSIM_ESC_PRESCALER_MASK | DSIM_LANE_ESC_CLK_EN_CLK
                        | DSIM_LANE_ESC_CLK_EN_DATA_MASK | DSIM_PLL_BYPASS
                        | DSIM_BYTE_CLK_SRC_MASK);
@@ -669,7 +705,7 @@ static int exynos_dsi_enable_clock(struct exynos_dsi *dsi)
                        | DSIM_LANE_ESC_CLK_EN_DATA(BIT(dsi->lanes) - 1)
                        | DSIM_BYTE_CLK_SRC(0)
                        | DSIM_TX_REQUEST_HSCLK;
-       DSI_WRITE(dsi, DSIM_CLKCTRL_REG, reg);
+       exynos_dsi_write(dsi, DSIM_CLKCTRL_REG, reg);
 
        return 0;
 }
@@ -677,7 +713,7 @@ static int exynos_dsi_enable_clock(struct exynos_dsi *dsi)
 static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi)
 {
        struct exynos_dsi_driver_data *driver_data = dsi->driver_data;
-       unsigned int *reg_values = driver_data->reg_values;
+       const unsigned int *reg_values = driver_data->reg_values;
        u32 reg;
 
        if (driver_data->has_freqband)
@@ -686,7 +722,7 @@ static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi)
        /* B D-PHY: D-PHY Master & Slave Analog Block control */
        reg = reg_values[PHYCTRL_ULPS_EXIT] | reg_values[PHYCTRL_VREG_LP] |
                reg_values[PHYCTRL_SLEW_UP];
-       DSI_WRITE(dsi, DSIM_PHYCTRL_REG, reg);
+       exynos_dsi_write(dsi, DSIM_PHYCTRL_REG, reg);
 
        /*
         * T LPX: Transmitted length of any Low-Power state period
@@ -694,7 +730,7 @@ static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi)
         *      burst
         */
        reg = reg_values[PHYTIMING_LPX] | reg_values[PHYTIMING_HS_EXIT];
-       DSI_WRITE(dsi, DSIM_PHYTIMING_REG, reg);
+       exynos_dsi_write(dsi, DSIM_PHYTIMING_REG, reg);
 
        /*
         * T CLK-PREPARE: Time that the transmitter drives the Clock Lane LP-00
@@ -714,7 +750,7 @@ static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi)
                reg_values[PHYTIMING_CLK_POST] |
                reg_values[PHYTIMING_CLK_TRAIL];
 
-       DSI_WRITE(dsi, DSIM_PHYTIMING1_REG, reg);
+       exynos_dsi_write(dsi, DSIM_PHYTIMING1_REG, reg);
 
        /*
         * T HS-PREPARE: Time that the transmitter drives the Data Lane LP-00
@@ -727,29 +763,29 @@ static void exynos_dsi_set_phy_ctrl(struct exynos_dsi *dsi)
         */
        reg = reg_values[PHYTIMING_HS_PREPARE] | reg_values[PHYTIMING_HS_ZERO] |
                reg_values[PHYTIMING_HS_TRAIL];
-       DSI_WRITE(dsi, DSIM_PHYTIMING2_REG, reg);
+       exynos_dsi_write(dsi, DSIM_PHYTIMING2_REG, reg);
 }
 
 static void exynos_dsi_disable_clock(struct exynos_dsi *dsi)
 {
        u32 reg;
 
-       reg = DSI_READ(dsi, DSIM_CLKCTRL_REG);
+       reg = exynos_dsi_read(dsi, DSIM_CLKCTRL_REG);
        reg &= ~(DSIM_LANE_ESC_CLK_EN_CLK | DSIM_LANE_ESC_CLK_EN_DATA_MASK
                        | DSIM_ESC_CLKEN | DSIM_BYTE_CLKEN);
-       DSI_WRITE(dsi, DSIM_CLKCTRL_REG, reg);
+       exynos_dsi_write(dsi, DSIM_CLKCTRL_REG, reg);
 
-       reg = DSI_READ(dsi, DSIM_PLLCTRL_REG);
+       reg = exynos_dsi_read(dsi, DSIM_PLLCTRL_REG);
        reg &= ~DSIM_PLL_EN;
-       DSI_WRITE(dsi, DSIM_PLLCTRL_REG, reg);
+       exynos_dsi_write(dsi, DSIM_PLLCTRL_REG, reg);
 }
 
 static void exynos_dsi_enable_lane(struct exynos_dsi *dsi, u32 lane)
 {
-       u32 reg = DSI_READ(dsi, DSIM_CONFIG_REG);
+       u32 reg = exynos_dsi_read(dsi, DSIM_CONFIG_REG);
        reg |= (DSIM_NUM_OF_DATA_LANE(dsi->lanes - 1) | DSIM_LANE_EN_CLK |
                        DSIM_LANE_EN(lane));
-       DSI_WRITE(dsi, DSIM_CONFIG_REG, reg);
+       exynos_dsi_write(dsi, DSIM_CONFIG_REG, reg);
 }
 
 static int exynos_dsi_init_link(struct exynos_dsi *dsi)
@@ -760,14 +796,14 @@ static int exynos_dsi_init_link(struct exynos_dsi *dsi)
        u32 lanes_mask;
 
        /* Initialize FIFO pointers */
-       reg = DSI_READ(dsi, DSIM_FIFOCTRL_REG);
+       reg = exynos_dsi_read(dsi, DSIM_FIFOCTRL_REG);
        reg &= ~0x1f;
-       DSI_WRITE(dsi, DSIM_FIFOCTRL_REG, reg);
+       exynos_dsi_write(dsi, DSIM_FIFOCTRL_REG, reg);
 
        usleep_range(9000, 11000);
 
        reg |= 0x1f;
-       DSI_WRITE(dsi, DSIM_FIFOCTRL_REG, reg);
+       exynos_dsi_write(dsi, DSIM_FIFOCTRL_REG, reg);
        usleep_range(9000, 11000);
 
        /* DSI configuration */
@@ -836,7 +872,7 @@ static int exynos_dsi_init_link(struct exynos_dsi *dsi)
                        dsi->mode_flags & MIPI_DSI_CLOCK_NON_CONTINUOUS) {
                reg |= DSIM_CLKLANE_STOP;
        }
-       DSI_WRITE(dsi, DSIM_CONFIG_REG, reg);
+       exynos_dsi_write(dsi, DSIM_CONFIG_REG, reg);
 
        lanes_mask = BIT(dsi->lanes) - 1;
        exynos_dsi_enable_lane(dsi, lanes_mask);
@@ -849,19 +885,19 @@ static int exynos_dsi_init_link(struct exynos_dsi *dsi)
                        return -EFAULT;
                }
 
-               reg = DSI_READ(dsi, DSIM_STATUS_REG);
+               reg = exynos_dsi_read(dsi, DSIM_STATUS_REG);
                if ((reg & DSIM_STOP_STATE_DAT(lanes_mask))
                    != DSIM_STOP_STATE_DAT(lanes_mask))
                        continue;
        } while (!(reg & (DSIM_STOP_STATE_CLK | DSIM_TX_READY_HS_CLK)));
 
-       reg = DSI_READ(dsi, DSIM_ESCMODE_REG);
+       reg = exynos_dsi_read(dsi, DSIM_ESCMODE_REG);
        reg &= ~DSIM_STOP_STATE_CNT_MASK;
        reg |= DSIM_STOP_STATE_CNT(driver_data->reg_values[STOP_STATE_CNT]);
-       DSI_WRITE(dsi, DSIM_ESCMODE_REG, reg);
+       exynos_dsi_write(dsi, DSIM_ESCMODE_REG, reg);
 
        reg = DSIM_BTA_TIMEOUT(0xff) | DSIM_LPDR_TIMEOUT(0xffff);
-       DSI_WRITE(dsi, DSIM_TIMEOUT_REG, reg);
+       exynos_dsi_write(dsi, DSIM_TIMEOUT_REG, reg);
 
        return 0;
 }
@@ -876,20 +912,20 @@ static void exynos_dsi_set_display_mode(struct exynos_dsi *dsi)
                reg = DSIM_CMD_ALLOW(0xf)
                        | DSIM_STABLE_VFP(vm->vfront_porch)
                        | DSIM_MAIN_VBP(vm->vback_porch);
-               DSI_WRITE(dsi, DSIM_MVPORCH_REG, reg);
+               exynos_dsi_write(dsi, DSIM_MVPORCH_REG, reg);
 
                reg = DSIM_MAIN_HFP(vm->hfront_porch)
                        | DSIM_MAIN_HBP(vm->hback_porch);
-               DSI_WRITE(dsi, DSIM_MHPORCH_REG, reg);
+               exynos_dsi_write(dsi, DSIM_MHPORCH_REG, reg);
 
                reg = DSIM_MAIN_VSA(vm->vsync_len)
                        | DSIM_MAIN_HSA(vm->hsync_len);
-               DSI_WRITE(dsi, DSIM_MSYNC_REG, reg);
+               exynos_dsi_write(dsi, DSIM_MSYNC_REG, reg);
        }
        reg =  DSIM_MAIN_HRESOL(vm->hactive, num_bits_resol) |
                DSIM_MAIN_VRESOL(vm->vactive, num_bits_resol);
 
-       DSI_WRITE(dsi, DSIM_MDRESOL_REG, reg);
+       exynos_dsi_write(dsi, DSIM_MDRESOL_REG, reg);
 
        dev_dbg(dsi->dev, "LCD size = %dx%d\n", vm->hactive, vm->vactive);
 }
@@ -898,12 +934,12 @@ static void exynos_dsi_set_display_enable(struct exynos_dsi *dsi, bool enable)
 {
        u32 reg;
 
-       reg = DSI_READ(dsi, DSIM_MDRESOL_REG);
+       reg = exynos_dsi_read(dsi, DSIM_MDRESOL_REG);
        if (enable)
                reg |= DSIM_MAIN_STAND_BY;
        else
                reg &= ~DSIM_MAIN_STAND_BY;
-       DSI_WRITE(dsi, DSIM_MDRESOL_REG, reg);
+       exynos_dsi_write(dsi, DSIM_MDRESOL_REG, reg);
 }
 
 static int exynos_dsi_wait_for_hdr_fifo(struct exynos_dsi *dsi)
@@ -911,7 +947,7 @@ static int exynos_dsi_wait_for_hdr_fifo(struct exynos_dsi *dsi)
        int timeout = 2000;
 
        do {
-               u32 reg = DSI_READ(dsi, DSIM_FIFOCTRL_REG);
+               u32 reg = exynos_dsi_read(dsi, DSIM_FIFOCTRL_REG);
 
                if (!(reg & DSIM_SFR_HEADER_FULL))
                        return 0;
@@ -925,34 +961,35 @@ static int exynos_dsi_wait_for_hdr_fifo(struct exynos_dsi *dsi)
 
 static void exynos_dsi_set_cmd_lpm(struct exynos_dsi *dsi, bool lpm)
 {
-       u32 v = DSI_READ(dsi, DSIM_ESCMODE_REG);
+       u32 v = exynos_dsi_read(dsi, DSIM_ESCMODE_REG);
 
        if (lpm)
                v |= DSIM_CMD_LPDT_LP;
        else
                v &= ~DSIM_CMD_LPDT_LP;
 
-       DSI_WRITE(dsi, DSIM_ESCMODE_REG, v);
+       exynos_dsi_write(dsi, DSIM_ESCMODE_REG, v);
 }
 
 static void exynos_dsi_force_bta(struct exynos_dsi *dsi)
 {
-       u32 v = DSI_READ(dsi, DSIM_ESCMODE_REG);
+       u32 v = exynos_dsi_read(dsi, DSIM_ESCMODE_REG);
        v |= DSIM_FORCE_BTA;
-       DSI_WRITE(dsi, DSIM_ESCMODE_REG, v);
+       exynos_dsi_write(dsi, DSIM_ESCMODE_REG, v);
 }
 
 static void exynos_dsi_send_to_fifo(struct exynos_dsi *dsi,
                                        struct exynos_dsi_transfer *xfer)
 {
        struct device *dev = dsi->dev;
-       const u8 *payload = xfer->tx_payload + xfer->tx_done;
-       u16 length = xfer->tx_len - xfer->tx_done;
+       struct mipi_dsi_packet *pkt = &xfer->packet;
+       const u8 *payload = pkt->payload + xfer->tx_done;
+       u16 length = pkt->payload_length - xfer->tx_done;
        bool first = !xfer->tx_done;
        u32 reg;
 
        dev_dbg(dev, "< xfer %p: tx len %u, done %u, rx len %u, done %u\n",
-               xfer, xfer->tx_len, xfer->tx_done, xfer->rx_len, xfer->rx_done);
+               xfer, length, xfer->tx_done, xfer->rx_len, xfer->rx_done);
 
        if (length > DSI_TX_FIFO_SIZE)
                length = DSI_TX_FIFO_SIZE;
@@ -961,9 +998,8 @@ static void exynos_dsi_send_to_fifo(struct exynos_dsi *dsi,
 
        /* Send payload */
        while (length >= 4) {
-               reg = (payload[3] << 24) | (payload[2] << 16)
-                                       | (payload[1] << 8) | payload[0];
-               DSI_WRITE(dsi, DSIM_PAYLOAD_REG, reg);
+               reg = get_unaligned_le32(payload);
+               exynos_dsi_write(dsi, DSIM_PAYLOAD_REG, reg);
                payload += 4;
                length -= 4;
        }
@@ -978,10 +1014,7 @@ static void exynos_dsi_send_to_fifo(struct exynos_dsi *dsi,
                /* Fall through */
        case 1:
                reg |= payload[0];
-               DSI_WRITE(dsi, DSIM_PAYLOAD_REG, reg);
-               break;
-       case 0:
-               /* Do nothing */
+               exynos_dsi_write(dsi, DSIM_PAYLOAD_REG, reg);
                break;
        }
 
@@ -989,7 +1022,7 @@ static void exynos_dsi_send_to_fifo(struct exynos_dsi *dsi,
        if (!first)
                return;
 
-       reg = (xfer->data[1] << 16) | (xfer->data[0] << 8) | xfer->data_id;
+       reg = get_unaligned_le32(pkt->header);
        if (exynos_dsi_wait_for_hdr_fifo(dsi)) {
                dev_err(dev, "waiting for header FIFO timed out\n");
                return;
@@ -1001,7 +1034,7 @@ static void exynos_dsi_send_to_fifo(struct exynos_dsi *dsi,
                dsi->state ^= DSIM_STATE_CMD_LPM;
        }
 
-       DSI_WRITE(dsi, DSIM_PKTHDR_REG, reg);
+       exynos_dsi_write(dsi, DSIM_PKTHDR_REG, reg);
 
        if (xfer->flags & MIPI_DSI_MSG_REQ_ACK)
                exynos_dsi_force_bta(dsi);
@@ -1017,7 +1050,7 @@ static void exynos_dsi_read_from_fifo(struct exynos_dsi *dsi,
        u32 reg;
 
        if (first) {
-               reg = DSI_READ(dsi, DSIM_RXFIFO_REG);
+               reg = exynos_dsi_read(dsi, DSIM_RXFIFO_REG);
 
                switch (reg & 0x3f) {
                case MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_2BYTE:
@@ -1056,7 +1089,7 @@ static void exynos_dsi_read_from_fifo(struct exynos_dsi *dsi,
 
        /* Receive payload */
        while (length >= 4) {
-               reg = DSI_READ(dsi, DSIM_RXFIFO_REG);
+               reg = exynos_dsi_read(dsi, DSIM_RXFIFO_REG);
                payload[0] = (reg >>  0) & 0xff;
                payload[1] = (reg >>  8) & 0xff;
                payload[2] = (reg >> 16) & 0xff;
@@ -1066,7 +1099,7 @@ static void exynos_dsi_read_from_fifo(struct exynos_dsi *dsi,
        }
 
        if (length) {
-               reg = DSI_READ(dsi, DSIM_RXFIFO_REG);
+               reg = exynos_dsi_read(dsi, DSIM_RXFIFO_REG);
                switch (length) {
                case 3:
                        payload[2] = (reg >> 16) & 0xff;
@@ -1085,7 +1118,7 @@ static void exynos_dsi_read_from_fifo(struct exynos_dsi *dsi,
 clear_fifo:
        length = DSI_RX_FIFO_SIZE / 4;
        do {
-               reg = DSI_READ(dsi, DSIM_RXFIFO_REG);
+               reg = exynos_dsi_read(dsi, DSIM_RXFIFO_REG);
                if (reg == DSI_RX_FIFO_EMPTY)
                        break;
        } while (--length);
@@ -1110,13 +1143,14 @@ again:
 
        spin_unlock_irqrestore(&dsi->transfer_lock, flags);
 
-       if (xfer->tx_len && xfer->tx_done == xfer->tx_len)
+       if (xfer->packet.payload_length &&
+           xfer->tx_done == xfer->packet.payload_length)
                /* waiting for RX */
                return;
 
        exynos_dsi_send_to_fifo(dsi, xfer);
 
-       if (xfer->tx_len || xfer->rx_len)
+       if (xfer->packet.payload_length || xfer->rx_len)
                return;
 
        xfer->result = 0;
@@ -1152,10 +1186,11 @@ static bool exynos_dsi_transfer_finish(struct exynos_dsi *dsi)
        spin_unlock_irqrestore(&dsi->transfer_lock, flags);
 
        dev_dbg(dsi->dev,
-               "> xfer %p, tx_len %u, tx_done %u, rx_len %u, rx_done %u\n",
-               xfer, xfer->tx_len, xfer->tx_done, xfer->rx_len, xfer->rx_done);
+               "> xfer %p, tx_len %zu, tx_done %u, rx_len %u, rx_done %u\n",
+               xfer, xfer->packet.payload_length, xfer->tx_done, xfer->rx_len,
+               xfer->rx_done);
 
-       if (xfer->tx_done != xfer->tx_len)
+       if (xfer->tx_done != xfer->packet.payload_length)
                return true;
 
        if (xfer->rx_done != xfer->rx_len)
@@ -1226,9 +1261,10 @@ static int exynos_dsi_transfer(struct exynos_dsi *dsi,
        wait_for_completion_timeout(&xfer->completed,
                                    msecs_to_jiffies(DSI_XFER_TIMEOUT_MS));
        if (xfer->result == -ETIMEDOUT) {
+               struct mipi_dsi_packet *pkt = &xfer->packet;
                exynos_dsi_remove_transfer(dsi, xfer);
-               dev_err(dsi->dev, "xfer timed out: %*ph %*ph\n", 2, xfer->data,
-                       xfer->tx_len, xfer->tx_payload);
+               dev_err(dsi->dev, "xfer timed out: %*ph %*ph\n", 4, pkt->header,
+                       (int)pkt->payload_length, pkt->payload);
                return -ETIMEDOUT;
        }
 
@@ -1241,20 +1277,20 @@ static irqreturn_t exynos_dsi_irq(int irq, void *dev_id)
        struct exynos_dsi *dsi = dev_id;
        u32 status;
 
-       status = DSI_READ(dsi, DSIM_INTSRC_REG);
+       status = exynos_dsi_read(dsi, DSIM_INTSRC_REG);
        if (!status) {
                static unsigned long int j;
                if (printk_timed_ratelimit(&j, 500))
                        dev_warn(dsi->dev, "spurious interrupt\n");
                return IRQ_HANDLED;
        }
-       DSI_WRITE(dsi, DSIM_INTSRC_REG, status);
+       exynos_dsi_write(dsi, DSIM_INTSRC_REG, status);
 
        if (status & DSIM_INT_SW_RST_RELEASE) {
                u32 mask = ~(DSIM_INT_RX_DONE | DSIM_INT_SFR_FIFO_EMPTY |
                        DSIM_INT_SFR_HDR_FIFO_EMPTY | DSIM_INT_FRAME_DONE |
                        DSIM_INT_RX_ECC_ERR | DSIM_INT_SW_RST_RELEASE);
-               DSI_WRITE(dsi, DSIM_INTMSK_REG, mask);
+               exynos_dsi_write(dsi, DSIM_INTMSK_REG, mask);
                complete(&dsi->completed);
                return IRQ_HANDLED;
        }
@@ -1401,12 +1437,6 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host,
        return 0;
 }
 
-/* distinguish between short and long DSI packet types */
-static bool exynos_dsi_is_short_dsi_type(u8 type)
-{
-       return (type & 0x0f) <= 8;
-}
-
 static ssize_t exynos_dsi_host_transfer(struct mipi_dsi_host *host,
                                        const struct mipi_dsi_msg *msg)
 {
@@ -1424,25 +1454,9 @@ static ssize_t exynos_dsi_host_transfer(struct mipi_dsi_host *host,
                dsi->state |= DSIM_STATE_INITIALIZED;
        }
 
-       if (msg->tx_len == 0)
-               return -EINVAL;
-
-       xfer.data_id = msg->type | (msg->channel << 6);
-
-       if (exynos_dsi_is_short_dsi_type(msg->type)) {
-               const char *tx_buf = msg->tx_buf;
-
-               if (msg->tx_len > 2)
-                       return -EINVAL;
-               xfer.tx_len = 0;
-               xfer.data[0] = tx_buf[0];
-               xfer.data[1] = (msg->tx_len == 2) ? tx_buf[1] : 0;
-       } else {
-               xfer.tx_len = msg->tx_len;
-               xfer.data[0] = msg->tx_len & 0xff;
-               xfer.data[1] = msg->tx_len >> 8;
-               xfer.tx_payload = msg->tx_buf;
-       }
+       ret = mipi_dsi_create_packet(&xfer.packet, msg);
+       if (ret < 0)
+               return ret;
 
        xfer.rx_len = msg->rx_len;
        xfer.rx_payload = msg->rx_buf;
@@ -1774,6 +1788,7 @@ static int exynos_dsi_bind(struct device *dev, struct device *master,
 
        bridge = of_drm_find_bridge(dsi->bridge_node);
        if (bridge) {
+               encoder->bridge = bridge;
                drm_bridge_attach(drm_dev, bridge);
        }
 
index f6118ba..4ae860c 100644 (file)
@@ -50,7 +50,7 @@ static int exynos_drm_fb_mmap(struct fb_info *info,
        if (vm_size > exynos_gem->size)
                return -EINVAL;
 
-       ret = dma_mmap_attrs(helper->dev->dev, vma, exynos_gem->pages,
+       ret = dma_mmap_attrs(to_dma_dev(helper->dev), vma, exynos_gem->cookie,
                             exynos_gem->dma_addr, exynos_gem->size,
                             &exynos_gem->dma_attrs);
        if (ret < 0) {
index c747824..0525c56 100644 (file)
@@ -163,7 +163,6 @@ struct fimc_context {
        u32             clk_frequency;
        struct regmap   *sysreg;
        struct fimc_scaler      sc;
-       struct exynos_drm_ipp_pol       pol;
        int     id;
        int     irq;
        bool    suspended;
@@ -260,32 +259,6 @@ static void fimc_set_type_ctrl(struct fimc_context *ctx, enum fimc_wb wb)
        fimc_write(ctx, cfg, EXYNOS_CIGCTRL);
 }
 
-static void fimc_set_polarity(struct fimc_context *ctx,
-               struct exynos_drm_ipp_pol *pol)
-{
-       u32 cfg;
-
-       DRM_DEBUG_KMS("inv_pclk[%d]inv_vsync[%d]\n",
-               pol->inv_pclk, pol->inv_vsync);
-       DRM_DEBUG_KMS("inv_href[%d]inv_hsync[%d]\n",
-               pol->inv_href, pol->inv_hsync);
-
-       cfg = fimc_read(ctx, EXYNOS_CIGCTRL);
-       cfg &= ~(EXYNOS_CIGCTRL_INVPOLPCLK | EXYNOS_CIGCTRL_INVPOLVSYNC |
-                EXYNOS_CIGCTRL_INVPOLHREF | EXYNOS_CIGCTRL_INVPOLHSYNC);
-
-       if (pol->inv_pclk)
-               cfg |= EXYNOS_CIGCTRL_INVPOLPCLK;
-       if (pol->inv_vsync)
-               cfg |= EXYNOS_CIGCTRL_INVPOLVSYNC;
-       if (pol->inv_href)
-               cfg |= EXYNOS_CIGCTRL_INVPOLHREF;
-       if (pol->inv_hsync)
-               cfg |= EXYNOS_CIGCTRL_INVPOLHSYNC;
-
-       fimc_write(ctx, cfg, EXYNOS_CIGCTRL);
-}
-
 static void fimc_handle_jpeg(struct fimc_context *ctx, bool enable)
 {
        u32 cfg;
@@ -1467,7 +1440,6 @@ static int fimc_ippdrv_start(struct device *dev, enum drm_exynos_ipp_cmd cmd)
        /* If set ture, we can save jpeg about screen */
        fimc_handle_jpeg(ctx, false);
        fimc_set_scaler(ctx, &ctx->sc);
-       fimc_set_polarity(ctx, &ctx->pol);
 
        switch (cmd) {
        case IPP_CMD_M2M:
@@ -1723,7 +1695,7 @@ static int fimc_probe(struct platform_device *pdev)
                goto err_put_clk;
        }
 
-       DRM_DEBUG_KMS("id[%d]ippdrv[0x%x]\n", ctx->id, (int)ippdrv);
+       DRM_DEBUG_KMS("id[%d]ippdrv[%p]\n", ctx->id, ippdrv);
 
        spin_lock_init(&ctx->lock);
        platform_set_drvdata(pdev, ctx);
index 70194d0..51d484a 100644 (file)
@@ -94,12 +94,14 @@ struct fimd_driver_data {
        unsigned int lcdblk_offset;
        unsigned int lcdblk_vt_shift;
        unsigned int lcdblk_bypass_shift;
+       unsigned int lcdblk_mic_bypass_shift;
 
        unsigned int has_shadowcon:1;
        unsigned int has_clksel:1;
        unsigned int has_limited_fmt:1;
        unsigned int has_vidoutcon:1;
        unsigned int has_vtsel:1;
+       unsigned int has_mic_bypass:1;
 };
 
 static struct fimd_driver_data s3c64xx_fimd_driver_data = {
@@ -145,6 +147,18 @@ static struct fimd_driver_data exynos5_fimd_driver_data = {
        .has_vtsel = 1,
 };
 
+static struct fimd_driver_data exynos5420_fimd_driver_data = {
+       .timing_base = 0x20000,
+       .lcdblk_offset = 0x214,
+       .lcdblk_vt_shift = 24,
+       .lcdblk_bypass_shift = 15,
+       .lcdblk_mic_bypass_shift = 11,
+       .has_shadowcon = 1,
+       .has_vidoutcon = 1,
+       .has_vtsel = 1,
+       .has_mic_bypass = 1,
+};
+
 struct fimd_context {
        struct device                   *dev;
        struct drm_device               *drm_dev;
@@ -168,7 +182,6 @@ struct fimd_context {
        atomic_t                        win_updated;
        atomic_t                        triggering;
 
-       struct exynos_drm_panel_info panel;
        struct fimd_driver_data *driver_data;
        struct drm_encoder *encoder;
 };
@@ -184,6 +197,8 @@ static const struct of_device_id fimd_driver_dt_match[] = {
          .data = &exynos4415_fimd_driver_data },
        { .compatible = "samsung,exynos5250-fimd",
          .data = &exynos5_fimd_driver_data },
+       { .compatible = "samsung,exynos5420-fimd",
+         .data = &exynos5420_fimd_driver_data },
        {},
 };
 MODULE_DEVICE_TABLE(of, fimd_driver_dt_match);
@@ -380,7 +395,7 @@ static u32 fimd_calc_clkdiv(struct fimd_context *ctx,
        }
 
        /* Find the clock divider value that gets us closest to ideal_clk */
-       clkdiv = DIV_ROUND_UP(clk_get_rate(ctx->lcd_clk), ideal_clk);
+       clkdiv = DIV_ROUND_CLOSEST(clk_get_rate(ctx->lcd_clk), ideal_clk);
 
        return (clkdiv < 0x100) ? clkdiv : 0xff;
 }
@@ -461,6 +476,18 @@ static void fimd_commit(struct exynos_drm_crtc *crtc)
                return;
        }
 
+       /* TODO: When MIC is enabled for display path, the lcdblk_mic_bypass
+        * bit should be cleared.
+        */
+       if (driver_data->has_mic_bypass && ctx->sysreg &&
+           regmap_update_bits(ctx->sysreg,
+                               driver_data->lcdblk_offset,
+                               0x1 << driver_data->lcdblk_mic_bypass_shift,
+                               0x1 << driver_data->lcdblk_mic_bypass_shift)) {
+               DRM_ERROR("Failed to update sysreg for bypass mic.\n");
+               return;
+       }
+
        /* setup horizontal and vertical display size. */
        val = VIDTCON2_LINEVAL(mode->vdisplay - 1) |
               VIDTCON2_HOZVAL(mode->hdisplay - 1) |
@@ -861,7 +888,8 @@ static void fimd_dp_clock_enable(struct exynos_drm_crtc *crtc, bool enable)
         * clock. On these SoCs the bootloader may enable it but any
         * power domain off/on will reset it to disable state.
         */
-       if (ctx->driver_data != &exynos5_fimd_driver_data)
+       if (ctx->driver_data != &exynos5_fimd_driver_data ||
+           ctx->driver_data != &exynos5420_fimd_driver_data)
                return;
 
        val = enable ? DP_MIE_CLK_DP_ENABLE : DP_MIE_CLK_DISABLE;
index 9936981..193d360 100644 (file)
@@ -259,7 +259,7 @@ static int g2d_init_cmdlist(struct g2d_data *g2d)
        init_dma_attrs(&g2d->cmdlist_dma_attrs);
        dma_set_attr(DMA_ATTR_WRITE_COMBINE, &g2d->cmdlist_dma_attrs);
 
-       g2d->cmdlist_pool_virt = dma_alloc_attrs(subdrv->drm_dev->dev,
+       g2d->cmdlist_pool_virt = dma_alloc_attrs(to_dma_dev(subdrv->drm_dev),
                                                G2D_CMDLIST_POOL_SIZE,
                                                &g2d->cmdlist_pool, GFP_KERNEL,
                                                &g2d->cmdlist_dma_attrs);
@@ -293,7 +293,7 @@ static int g2d_init_cmdlist(struct g2d_data *g2d)
        return 0;
 
 err:
-       dma_free_attrs(subdrv->drm_dev->dev, G2D_CMDLIST_POOL_SIZE,
+       dma_free_attrs(to_dma_dev(subdrv->drm_dev), G2D_CMDLIST_POOL_SIZE,
                        g2d->cmdlist_pool_virt,
                        g2d->cmdlist_pool, &g2d->cmdlist_dma_attrs);
        return ret;
@@ -306,7 +306,8 @@ static void g2d_fini_cmdlist(struct g2d_data *g2d)
        kfree(g2d->cmdlist_node);
 
        if (g2d->cmdlist_pool_virt && g2d->cmdlist_pool) {
-               dma_free_attrs(subdrv->drm_dev->dev, G2D_CMDLIST_POOL_SIZE,
+               dma_free_attrs(to_dma_dev(subdrv->drm_dev),
+                               G2D_CMDLIST_POOL_SIZE,
                                g2d->cmdlist_pool_virt,
                                g2d->cmdlist_pool, &g2d->cmdlist_dma_attrs);
        }
@@ -1151,7 +1152,7 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data,
                goto err_free_event;
        }
 
-       cmd = (struct drm_exynos_g2d_cmd *)(uint32_t)req->cmd;
+       cmd = (struct drm_exynos_g2d_cmd *)(unsigned long)req->cmd;
 
        if (copy_from_user(cmdlist->data + cmdlist->last,
                                (void __user *)cmd,
@@ -1169,7 +1170,8 @@ int exynos_g2d_set_cmdlist_ioctl(struct drm_device *drm_dev, void *data,
        if (req->cmd_buf_nr) {
                struct drm_exynos_g2d_cmd *cmd_buf;
 
-               cmd_buf = (struct drm_exynos_g2d_cmd *)(uint32_t)req->cmd_buf;
+               cmd_buf = (struct drm_exynos_g2d_cmd *)
+                               (unsigned long)req->cmd_buf;
 
                if (copy_from_user(cmdlist->data + cmdlist->last,
                                        (void __user *)cmd_buf,
index 32358c5..2914d62 100644 (file)
@@ -65,7 +65,7 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)
                return -ENOMEM;
        }
 
-       exynos_gem->cookie = dma_alloc_attrs(dev->dev, exynos_gem->size,
+       exynos_gem->cookie = dma_alloc_attrs(to_dma_dev(dev), exynos_gem->size,
                                             &exynos_gem->dma_addr, GFP_KERNEL,
                                             &exynos_gem->dma_attrs);
        if (!exynos_gem->cookie) {
@@ -73,7 +73,7 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)
                goto err_free;
        }
 
-       ret = dma_get_sgtable_attrs(dev->dev, &sgt, exynos_gem->cookie,
+       ret = dma_get_sgtable_attrs(to_dma_dev(dev), &sgt, exynos_gem->cookie,
                                    exynos_gem->dma_addr, exynos_gem->size,
                                    &exynos_gem->dma_attrs);
        if (ret < 0) {
@@ -98,7 +98,7 @@ static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem)
 err_sgt_free:
        sg_free_table(&sgt);
 err_dma_free:
-       dma_free_attrs(dev->dev, exynos_gem->size, exynos_gem->cookie,
+       dma_free_attrs(to_dma_dev(dev), exynos_gem->size, exynos_gem->cookie,
                       exynos_gem->dma_addr, &exynos_gem->dma_attrs);
 err_free:
        drm_free_large(exynos_gem->pages);
@@ -118,7 +118,7 @@ static void exynos_drm_free_buf(struct exynos_drm_gem *exynos_gem)
        DRM_DEBUG_KMS("dma_addr(0x%lx), size(0x%lx)\n",
                        (unsigned long)exynos_gem->dma_addr, exynos_gem->size);
 
-       dma_free_attrs(dev->dev, exynos_gem->size, exynos_gem->cookie,
+       dma_free_attrs(to_dma_dev(dev), exynos_gem->size, exynos_gem->cookie,
                        (dma_addr_t)exynos_gem->dma_addr,
                        &exynos_gem->dma_attrs);
 
@@ -218,7 +218,7 @@ static struct exynos_drm_gem *exynos_drm_gem_init(struct drm_device *dev,
                return ERR_PTR(ret);
        }
 
-       DRM_DEBUG_KMS("created file object = 0x%x\n", (unsigned int)obj->filp);
+       DRM_DEBUG_KMS("created file object = %p\n", obj->filp);
 
        return exynos_gem;
 }
@@ -280,6 +280,15 @@ int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
        return 0;
 }
 
+int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
+                            struct drm_file *file_priv)
+{
+       struct drm_exynos_gem_map *args = data;
+
+       return exynos_drm_gem_dumb_map_offset(file_priv, dev, args->handle,
+                                             &args->offset);
+}
+
 dma_addr_t *exynos_drm_gem_get_dma_addr(struct drm_device *dev,
                                        unsigned int gem_handle,
                                        struct drm_file *filp)
@@ -335,7 +344,7 @@ static int exynos_drm_gem_mmap_buffer(struct exynos_drm_gem *exynos_gem,
        if (vm_size > exynos_gem->size)
                return -EINVAL;
 
-       ret = dma_mmap_attrs(drm_dev->dev, vma, exynos_gem->pages,
+       ret = dma_mmap_attrs(to_dma_dev(drm_dev), vma, exynos_gem->cookie,
                             exynos_gem->dma_addr, exynos_gem->size,
                             &exynos_gem->dma_attrs);
        if (ret < 0) {
@@ -381,7 +390,7 @@ int exynos_gem_map_sgt_with_dma(struct drm_device *drm_dev,
 
        mutex_lock(&drm_dev->struct_mutex);
 
-       nents = dma_map_sg(drm_dev->dev, sgt->sgl, sgt->nents, dir);
+       nents = dma_map_sg(to_dma_dev(drm_dev), sgt->sgl, sgt->nents, dir);
        if (!nents) {
                DRM_ERROR("failed to map sgl with dma.\n");
                mutex_unlock(&drm_dev->struct_mutex);
@@ -396,7 +405,7 @@ void exynos_gem_unmap_sgt_from_dma(struct drm_device *drm_dev,
                                struct sg_table *sgt,
                                enum dma_data_direction dir)
 {
-       dma_unmap_sg(drm_dev->dev, sgt->sgl, sgt->nents, dir);
+       dma_unmap_sg(to_dma_dev(drm_dev), sgt->sgl, sgt->nents, dir);
 }
 
 void exynos_drm_gem_free_object(struct drm_gem_object *obj)
index 9ca5047..0022305 100644 (file)
@@ -71,6 +71,10 @@ struct exynos_drm_gem *exynos_drm_gem_create(struct drm_device *dev,
 int exynos_drm_gem_create_ioctl(struct drm_device *dev, void *data,
                                struct drm_file *file_priv);
 
+/* get fake-offset of gem object that can be used with mmap. */
+int exynos_drm_gem_map_ioctl(struct drm_device *dev, void *data,
+                            struct drm_file *file_priv);
+
 /*
  * get dma address from gem handle and this function could be used for
  * other drivers such as 2d/3d acceleration drivers.
index 7aecd23..5d20da8 100644 (file)
@@ -1723,7 +1723,7 @@ static int gsc_probe(struct platform_device *pdev)
                return ret;
        }
 
-       DRM_DEBUG_KMS("id[%d]ippdrv[0x%x]\n", ctx->id, (int)ippdrv);
+       DRM_DEBUG_KMS("id[%d]ippdrv[%p]\n", ctx->id, ippdrv);
 
        mutex_init(&ctx->lock);
        platform_set_drvdata(pdev, ctx);
index d73b9ad..7ca09ee 100644 (file)
@@ -9,7 +9,7 @@
  * option) any later version.
  */
 
-#include <drmP.h>
+#include <drm/drmP.h>
 #include <drm/exynos_drm.h>
 
 #include <linux/dma-mapping.h>
@@ -30,7 +30,6 @@ int drm_create_iommu_mapping(struct drm_device *drm_dev)
 {
        struct dma_iommu_mapping *mapping = NULL;
        struct exynos_drm_private *priv = drm_dev->dev_private;
-       struct device *dev = drm_dev->dev;
 
        if (!priv->da_start)
                priv->da_start = EXYNOS_DEV_ADDR_START;
@@ -43,18 +42,9 @@ int drm_create_iommu_mapping(struct drm_device *drm_dev)
        if (IS_ERR(mapping))
                return PTR_ERR(mapping);
 
-       dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms),
-                                       GFP_KERNEL);
-       if (!dev->dma_parms)
-               goto error;
-
-       dma_set_max_seg_size(dev, 0xffffffffu);
-       dev->archdata.mapping = mapping;
+       priv->mapping = mapping;
 
        return 0;
-error:
-       arm_iommu_release_mapping(mapping);
-       return -ENOMEM;
 }
 
 /*
@@ -67,9 +57,9 @@ error:
  */
 void drm_release_iommu_mapping(struct drm_device *drm_dev)
 {
-       struct device *dev = drm_dev->dev;
+       struct exynos_drm_private *priv = drm_dev->dev_private;
 
-       arm_iommu_release_mapping(dev->archdata.mapping);
+       arm_iommu_release_mapping(priv->mapping);
 }
 
 /*
@@ -84,10 +74,10 @@ void drm_release_iommu_mapping(struct drm_device *drm_dev)
 int drm_iommu_attach_device(struct drm_device *drm_dev,
                                struct device *subdrv_dev)
 {
-       struct device *dev = drm_dev->dev;
+       struct exynos_drm_private *priv = drm_dev->dev_private;
        int ret;
 
-       if (!dev->archdata.mapping)
+       if (!priv->mapping)
                return 0;
 
        subdrv_dev->dma_parms = devm_kzalloc(subdrv_dev,
@@ -101,23 +91,12 @@ int drm_iommu_attach_device(struct drm_device *drm_dev,
        if (subdrv_dev->archdata.mapping)
                arm_iommu_detach_device(subdrv_dev);
 
-       ret = arm_iommu_attach_device(subdrv_dev, dev->archdata.mapping);
+       ret = arm_iommu_attach_device(subdrv_dev, priv->mapping);
        if (ret < 0) {
                DRM_DEBUG_KMS("failed iommu attach.\n");
                return ret;
        }
 
-       /*
-        * Set dma_ops to drm_device just one time.
-        *
-        * The dma mapping api needs device object and the api is used
-        * to allocate physial memory and map it with iommu table.
-        * If iommu attach succeeded, the sub driver would have dma_ops
-        * for iommu and also all sub drivers have same dma_ops.
-        */
-       if (get_dma_ops(dev) == get_dma_ops(NULL))
-               set_dma_ops(dev, get_dma_ops(subdrv_dev));
-
        return 0;
 }
 
@@ -133,8 +112,8 @@ int drm_iommu_attach_device(struct drm_device *drm_dev,
 void drm_iommu_detach_device(struct drm_device *drm_dev,
                                struct device *subdrv_dev)
 {
-       struct device *dev = drm_dev->dev;
-       struct dma_iommu_mapping *mapping = dev->archdata.mapping;
+       struct exynos_drm_private *priv = drm_dev->dev_private;
+       struct dma_iommu_mapping *mapping = priv->mapping;
 
        if (!mapping || !mapping->domain)
                return;
index dc1b544..5ffebe0 100644 (file)
@@ -29,9 +29,9 @@ void drm_iommu_detach_device(struct drm_device *dev_dev,
 
 static inline bool is_drm_iommu_supported(struct drm_device *drm_dev)
 {
-       struct device *dev = drm_dev->dev;
+       struct exynos_drm_private *priv = drm_dev->dev_private;
 
-       return dev->archdata.mapping ? true : false;
+       return priv->mapping ? true : false;
 }
 
 #else
index 3eab0d1..9c84ee7 100644 (file)
@@ -208,7 +208,7 @@ static struct exynos_drm_ippdrv *ipp_find_drv_by_handle(u32 prop_id)
         * e.g PAUSE state, queue buf, command control.
         */
        list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
-               DRM_DEBUG_KMS("count[%d]ippdrv[0x%x]\n", count++, (int)ippdrv);
+               DRM_DEBUG_KMS("count[%d]ippdrv[%p]\n", count++, ippdrv);
 
                mutex_lock(&ippdrv->cmd_lock);
                list_for_each_entry(c_node, &ippdrv->cmd_list, list) {
@@ -388,8 +388,8 @@ int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
        }
        property->prop_id = ret;
 
-       DRM_DEBUG_KMS("created prop_id[%d]cmd[%d]ippdrv[0x%x]\n",
-               property->prop_id, property->cmd, (int)ippdrv);
+       DRM_DEBUG_KMS("created prop_id[%d]cmd[%d]ippdrv[%p]\n",
+               property->prop_id, property->cmd, ippdrv);
 
        /* stored property information and ippdrv in private data */
        c_node->property = *property;
@@ -518,7 +518,7 @@ static int ipp_put_mem_node(struct drm_device *drm_dev,
 {
        int i;
 
-       DRM_DEBUG_KMS("node[0x%x]\n", (int)m_node);
+       DRM_DEBUG_KMS("node[%p]\n", m_node);
 
        if (!m_node) {
                DRM_ERROR("invalid dequeue node.\n");
@@ -562,7 +562,7 @@ static struct drm_exynos_ipp_mem_node
        m_node->buf_id = qbuf->buf_id;
        INIT_LIST_HEAD(&m_node->list);
 
-       DRM_DEBUG_KMS("m_node[0x%x]ops_id[%d]\n", (int)m_node, qbuf->ops_id);
+       DRM_DEBUG_KMS("m_node[%p]ops_id[%d]\n", m_node, qbuf->ops_id);
        DRM_DEBUG_KMS("prop_id[%d]buf_id[%d]\n", qbuf->prop_id, m_node->buf_id);
 
        for_each_ipp_planar(i) {
@@ -582,8 +582,8 @@ static struct drm_exynos_ipp_mem_node
 
                        buf_info->handles[i] = qbuf->handle[i];
                        buf_info->base[i] = *addr;
-                       DRM_DEBUG_KMS("i[%d]base[0x%x]hd[0x%lx]\n", i,
-                                     buf_info->base[i], buf_info->handles[i]);
+                       DRM_DEBUG_KMS("i[%d]base[%pad]hd[0x%lx]\n", i,
+                                     &buf_info->base[i], buf_info->handles[i]);
                }
        }
 
@@ -659,7 +659,7 @@ static void ipp_put_event(struct drm_exynos_ipp_cmd_node *c_node,
 
        mutex_lock(&c_node->event_lock);
        list_for_each_entry_safe(e, te, &c_node->event_list, base.link) {
-               DRM_DEBUG_KMS("count[%d]e[0x%x]\n", count++, (int)e);
+               DRM_DEBUG_KMS("count[%d]e[%p]\n", count++, e);
 
                /*
                 * qbuf == NULL condition means all event deletion.
@@ -750,7 +750,7 @@ static struct drm_exynos_ipp_mem_node
 
        /* find memory node from memory list */
        list_for_each_entry(m_node, head, list) {
-               DRM_DEBUG_KMS("count[%d]m_node[0x%x]\n", count++, (int)m_node);
+               DRM_DEBUG_KMS("count[%d]m_node[%p]\n", count++, m_node);
 
                /* compare buffer id */
                if (m_node->buf_id == qbuf->buf_id)
@@ -767,7 +767,7 @@ static int ipp_set_mem_node(struct exynos_drm_ippdrv *ippdrv,
        struct exynos_drm_ipp_ops *ops = NULL;
        int ret = 0;
 
-       DRM_DEBUG_KMS("node[0x%x]\n", (int)m_node);
+       DRM_DEBUG_KMS("node[%p]\n", m_node);
 
        if (!m_node) {
                DRM_ERROR("invalid queue node.\n");
@@ -1232,7 +1232,7 @@ static int ipp_start_property(struct exynos_drm_ippdrv *ippdrv,
                        m_node = list_first_entry(head,
                                struct drm_exynos_ipp_mem_node, list);
 
-                       DRM_DEBUG_KMS("m_node[0x%x]\n", (int)m_node);
+                       DRM_DEBUG_KMS("m_node[%p]\n", m_node);
 
                        ret = ipp_set_mem_node(ippdrv, c_node, m_node);
                        if (ret) {
@@ -1601,8 +1601,8 @@ static int ipp_subdrv_probe(struct drm_device *drm_dev, struct device *dev)
                }
                ippdrv->prop_list.ipp_id = ret;
 
-               DRM_DEBUG_KMS("count[%d]ippdrv[0x%x]ipp_id[%d]\n",
-                       count++, (int)ippdrv, ret);
+               DRM_DEBUG_KMS("count[%d]ippdrv[%p]ipp_id[%d]\n",
+                       count++, ippdrv, ret);
 
                /* store parent device for node */
                ippdrv->parent_dev = dev;
@@ -1659,7 +1659,7 @@ static int ipp_subdrv_open(struct drm_device *drm_dev, struct device *dev,
 
        file_priv->ipp_dev = dev;
 
-       DRM_DEBUG_KMS("done priv[0x%x]\n", (int)dev);
+       DRM_DEBUG_KMS("done priv[%p]\n", dev);
 
        return 0;
 }
@@ -1676,8 +1676,8 @@ static void ipp_subdrv_close(struct drm_device *drm_dev, struct device *dev,
                mutex_lock(&ippdrv->cmd_lock);
                list_for_each_entry_safe(c_node, tc_node,
                        &ippdrv->cmd_list, list) {
-                       DRM_DEBUG_KMS("count[%d]ippdrv[0x%x]\n",
-                               count++, (int)ippdrv);
+                       DRM_DEBUG_KMS("count[%d]ippdrv[%p]\n",
+                               count++, ippdrv);
 
                        if (c_node->filp == file) {
                                /*
index 4eaef36..9869d70 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/of.h>
 #include <linux/of_graph.h>
 #include <linux/clk.h>
+#include <linux/component.h>
 #include <drm/drmP.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
@@ -306,9 +307,9 @@ exit:
        return ret;
 }
 
-void mic_disable(struct drm_bridge *bridge) { }
+static void mic_disable(struct drm_bridge *bridge) { }
 
-void mic_post_disable(struct drm_bridge *bridge)
+static void mic_post_disable(struct drm_bridge *bridge)
 {
        struct exynos_mic *mic = bridge->driver_private;
        int i;
@@ -328,7 +329,7 @@ already_disabled:
        mutex_unlock(&mic_mutex);
 }
 
-void mic_pre_enable(struct drm_bridge *bridge)
+static void mic_pre_enable(struct drm_bridge *bridge)
 {
        struct exynos_mic *mic = bridge->driver_private;
        int ret, i;
@@ -371,11 +372,35 @@ already_enabled:
        mutex_unlock(&mic_mutex);
 }
 
-void mic_enable(struct drm_bridge *bridge) { }
+static void mic_enable(struct drm_bridge *bridge) { }
 
-void mic_destroy(struct drm_bridge *bridge)
+static const struct drm_bridge_funcs mic_bridge_funcs = {
+       .disable = mic_disable,
+       .post_disable = mic_post_disable,
+       .pre_enable = mic_pre_enable,
+       .enable = mic_enable,
+};
+
+static int exynos_mic_bind(struct device *dev, struct device *master,
+                          void *data)
 {
-       struct exynos_mic *mic = bridge->driver_private;
+       struct exynos_mic *mic = dev_get_drvdata(dev);
+       int ret;
+
+       mic->bridge.funcs = &mic_bridge_funcs;
+       mic->bridge.of_node = dev->of_node;
+       mic->bridge.driver_private = mic;
+       ret = drm_bridge_add(&mic->bridge);
+       if (ret)
+               DRM_ERROR("mic: Failed to add MIC to the global bridge list\n");
+
+       return ret;
+}
+
+static void exynos_mic_unbind(struct device *dev, struct device *master,
+                             void *data)
+{
+       struct exynos_mic *mic = dev_get_drvdata(dev);
        int i;
 
        mutex_lock(&mic_mutex);
@@ -387,16 +412,16 @@ void mic_destroy(struct drm_bridge *bridge)
 
 already_disabled:
        mutex_unlock(&mic_mutex);
+
+       drm_bridge_remove(&mic->bridge);
 }
 
-static const struct drm_bridge_funcs mic_bridge_funcs = {
-       .disable = mic_disable,
-       .post_disable = mic_post_disable,
-       .pre_enable = mic_pre_enable,
-       .enable = mic_enable,
+static const struct component_ops exynos_mic_component_ops = {
+       .bind   = exynos_mic_bind,
+       .unbind = exynos_mic_unbind,
 };
 
-int exynos_mic_probe(struct platform_device *pdev)
+static int exynos_mic_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct exynos_mic *mic;
@@ -435,17 +460,8 @@ int exynos_mic_probe(struct platform_device *pdev)
                goto err;
        }
 
-       mic->bridge.funcs = &mic_bridge_funcs;
-       mic->bridge.of_node = dev->of_node;
-       mic->bridge.driver_private = mic;
-       ret = drm_bridge_add(&mic->bridge);
-       if (ret) {
-               DRM_ERROR("mic: Failed to add MIC to the global bridge list\n");
-               goto err;
-       }
-
        for (i = 0; i < NUM_CLKS; i++) {
-               mic->clks[i] = of_clk_get_by_name(dev->of_node, clk_names[i]);
+               mic->clks[i] = devm_clk_get(dev, clk_names[i]);
                if (IS_ERR(mic->clks[i])) {
                        DRM_ERROR("mic: Failed to get clock (%s)\n",
                                                                clk_names[i]);
@@ -454,7 +470,10 @@ int exynos_mic_probe(struct platform_device *pdev)
                }
        }
 
+       platform_set_drvdata(pdev, mic);
+
        DRM_DEBUG_KMS("MIC has been probed\n");
+       return component_add(dev, &exynos_mic_component_ops);
 
 err:
        return ret;
@@ -462,14 +481,7 @@ err:
 
 static int exynos_mic_remove(struct platform_device *pdev)
 {
-       struct exynos_mic *mic = platform_get_drvdata(pdev);
-       int i;
-
-       drm_bridge_remove(&mic->bridge);
-
-       for (i = NUM_CLKS - 1; i > -1; i--)
-               clk_put(mic->clks[i]);
-
+       component_del(&pdev->dev, &exynos_mic_component_ops);
        return 0;
 }
 
index bea0f78..f18fbe4 100644 (file)
@@ -20,7 +20,6 @@
 #include <drm/drmP.h>
 #include <drm/exynos_drm.h>
 #include "regs-rotator.h"
-#include "exynos_drm.h"
 #include "exynos_drm_drv.h"
 #include "exynos_drm_ipp.h"
 
@@ -754,7 +753,7 @@ static int rotator_probe(struct platform_device *pdev)
                goto err_ippdrv_register;
        }
 
-       DRM_DEBUG_KMS("ippdrv[0x%x]\n", (int)ippdrv);
+       DRM_DEBUG_KMS("ippdrv[%p]\n", ippdrv);
 
        platform_set_drvdata(pdev, rot);
 
index 65108cb..608b0af 100644 (file)
@@ -223,7 +223,7 @@ static void vidi_fake_vblank_handler(struct work_struct *work)
        }
 }
 
-static int vidi_show_connection(struct device *dev,
+static ssize_t vidi_show_connection(struct device *dev,
                                struct device_attribute *attr, char *buf)
 {
        struct vidi_context *ctx = dev_get_drvdata(dev);
@@ -238,7 +238,7 @@ static int vidi_show_connection(struct device *dev,
        return rc;
 }
 
-static int vidi_store_connection(struct device *dev,
+static ssize_t vidi_store_connection(struct device *dev,
                                struct device_attribute *attr,
                                const char *buf, size_t len)
 {
@@ -294,7 +294,9 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
        }
 
        if (vidi->connection) {
-               struct edid *raw_edid  = (struct edid *)(uint32_t)vidi->edid;
+               struct edid *raw_edid;
+
+               raw_edid = (struct edid *)(unsigned long)vidi->edid;
                if (!drm_edid_is_valid(raw_edid)) {
                        DRM_DEBUG_KMS("edid data is invalid.\n");
                        return -EINVAL;
index 21a29db..e148d72 100644 (file)
@@ -867,10 +867,8 @@ static void hdmi_reg_infoframe(struct hdmi_context *hdata,
 {
        u32 hdr_sum;
        u8 chksum;
-       u32 mod;
        u8 ar;
 
-       mod = hdmi_reg_read(hdata, HDMI_MODE_SEL);
        if (hdata->dvi_mode) {
                hdmi_reg_writeb(hdata, HDMI_VSI_CON,
                                HDMI_VSI_CON_DO_NOT_TRANSMIT);
index d8ab8f0..4ed7798 100644 (file)
@@ -42,41 +42,24 @@ static void fsl_dcu_drm_disable_crtc(struct drm_crtc *crtc)
 {
        struct drm_device *dev = crtc->dev;
        struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
-       int ret;
 
-       ret = regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
-                                DCU_MODE_DCU_MODE_MASK,
-                                DCU_MODE_DCU_MODE(DCU_MODE_OFF));
-       if (ret)
-               dev_err(fsl_dev->dev, "Disable CRTC failed\n");
-       ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
-                          DCU_UPDATE_MODE_READREG);
-       if (ret)
-               dev_err(fsl_dev->dev, "Enable CRTC failed\n");
+       regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+                          DCU_MODE_DCU_MODE_MASK,
+                          DCU_MODE_DCU_MODE(DCU_MODE_OFF));
+       regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+                    DCU_UPDATE_MODE_READREG);
 }
 
 static void fsl_dcu_drm_crtc_enable(struct drm_crtc *crtc)
 {
        struct drm_device *dev = crtc->dev;
        struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
-       int ret;
-
-       ret = regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
-                                DCU_MODE_DCU_MODE_MASK,
-                                DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
-       if (ret)
-               dev_err(fsl_dev->dev, "Enable CRTC failed\n");
-       ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
-                          DCU_UPDATE_MODE_READREG);
-       if (ret)
-               dev_err(fsl_dev->dev, "Enable CRTC failed\n");
-}
 
-static bool fsl_dcu_drm_crtc_mode_fixup(struct drm_crtc *crtc,
-                                       const struct drm_display_mode *mode,
-                                       struct drm_display_mode *adjusted_mode)
-{
-       return true;
+       regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+                          DCU_MODE_DCU_MODE_MASK,
+                          DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
+       regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+                    DCU_UPDATE_MODE_READREG);
 }
 
 static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
@@ -84,9 +67,8 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
        struct drm_device *dev = crtc->dev;
        struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
        struct drm_display_mode *mode = &crtc->state->mode;
-       unsigned int hbp, hfp, hsw, vbp, vfp, vsw, div, index;
+       unsigned int hbp, hfp, hsw, vbp, vfp, vsw, div, index, pol = 0;
        unsigned long dcuclk;
-       int ret;
 
        index = drm_crtc_index(crtc);
        dcuclk = clk_get_rate(fsl_dev->clk);
@@ -100,51 +82,36 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
        vfp = mode->vsync_start - mode->vdisplay;
        vsw = mode->vsync_end - mode->vsync_start;
 
-       ret = regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
-                          DCU_HSYN_PARA_BP(hbp) |
-                          DCU_HSYN_PARA_PW(hsw) |
-                          DCU_HSYN_PARA_FP(hfp));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
-                          DCU_VSYN_PARA_BP(vbp) |
-                          DCU_VSYN_PARA_PW(vsw) |
-                          DCU_VSYN_PARA_FP(vfp));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
-                          DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
-                          DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_SYN_POL,
-                          DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW);
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
-                          DCU_BGND_G(0) | DCU_BGND_B(0));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
-                          DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
-                          DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
-                          DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
-                          DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
-                          DCU_UPDATE_MODE_READREG);
-       if (ret)
-               goto set_failed;
+       if (mode->flags & DRM_MODE_FLAG_NHSYNC)
+               pol |= DCU_SYN_POL_INV_HS_LOW;
+
+       if (mode->flags & DRM_MODE_FLAG_NVSYNC)
+               pol |= DCU_SYN_POL_INV_VS_LOW;
+
+       regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
+                    DCU_HSYN_PARA_BP(hbp) |
+                    DCU_HSYN_PARA_PW(hsw) |
+                    DCU_HSYN_PARA_FP(hfp));
+       regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
+                    DCU_VSYN_PARA_BP(vbp) |
+                    DCU_VSYN_PARA_PW(vsw) |
+                    DCU_VSYN_PARA_FP(vfp));
+       regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
+                    DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
+                    DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
+       regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
+       regmap_write(fsl_dev->regmap, DCU_SYN_POL, pol);
+       regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
+                    DCU_BGND_G(0) | DCU_BGND_B(0));
+       regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
+                    DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
+       regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
+                    DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
+                    DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
+                    DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
+       regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+                    DCU_UPDATE_MODE_READREG);
        return;
-set_failed:
-       dev_err(dev->dev, "set DCU register failed\n");
 }
 
 static const struct drm_crtc_helper_funcs fsl_dcu_drm_crtc_helper_funcs = {
@@ -153,7 +120,6 @@ static const struct drm_crtc_helper_funcs fsl_dcu_drm_crtc_helper_funcs = {
        .atomic_flush = fsl_dcu_drm_crtc_atomic_flush,
        .disable = fsl_dcu_drm_disable_crtc,
        .enable = fsl_dcu_drm_crtc_enable,
-       .mode_fixup = fsl_dcu_drm_crtc_mode_fixup,
        .mode_set_nofb = fsl_dcu_drm_crtc_mode_set_nofb,
 };
 
@@ -174,10 +140,15 @@ int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev)
        int ret;
 
        primary = fsl_dcu_drm_primary_create_plane(fsl_dev->drm);
+       if (!primary)
+               return -ENOMEM;
+
        ret = drm_crtc_init_with_planes(fsl_dev->drm, crtc, primary, NULL,
                                        &fsl_dcu_drm_crtc_funcs, NULL);
-       if (ret < 0)
+       if (ret) {
+               primary->funcs->destroy(primary);
                return ret;
+       }
 
        drm_crtc_helper_add(crtc, &fsl_dcu_drm_crtc_helper_funcs);
 
@@ -185,26 +156,15 @@ int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev)
                reg_num = LS1021A_LAYER_REG_NUM;
        else
                reg_num = VF610_LAYER_REG_NUM;
-       for (i = 0; i <= fsl_dev->soc->total_layer; i++) {
-               for (j = 0; j < reg_num; j++) {
-                       ret = regmap_write(fsl_dev->regmap,
-                                          DCU_CTRLDESCLN(i, j), 0);
-                       if (ret)
-                               goto init_failed;
-               }
+       for (i = 0; i < fsl_dev->soc->total_layer; i++) {
+               for (j = 1; j <= reg_num; j++)
+                       regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(i, j), 0);
        }
-       ret = regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
-                                DCU_MODE_DCU_MODE_MASK,
-                                DCU_MODE_DCU_MODE(DCU_MODE_OFF));
-       if (ret)
-               goto init_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
-                          DCU_UPDATE_MODE_READREG);
-       if (ret)
-               goto init_failed;
+       regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+                          DCU_MODE_DCU_MODE_MASK,
+                          DCU_MODE_DCU_MODE(DCU_MODE_OFF));
+       regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+                    DCU_UPDATE_MODE_READREG);
 
        return 0;
-init_failed:
-       dev_err(fsl_dev->dev, "init DCU register failed\n");
-       return ret;
 }
index 9648b7f..e8d9337 100644 (file)
 #include "fsl_dcu_drm_crtc.h"
 #include "fsl_dcu_drm_drv.h"
 
+static bool fsl_dcu_drm_is_volatile_reg(struct device *dev, unsigned int reg)
+{
+       if (reg == DCU_INT_STATUS || reg == DCU_UPDATE_MODE)
+               return true;
+
+       return false;
+}
+
 static const struct regmap_config fsl_dcu_regmap_config = {
        .reg_bits = 32,
        .reg_stride = 4,
        .val_bits = 32,
        .cache_type = REGCACHE_RBTREE,
+
+       .volatile_reg = fsl_dcu_drm_is_volatile_reg,
 };
 
 static int fsl_dcu_drm_irq_init(struct drm_device *dev)
 {
        struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
-       unsigned int value;
        int ret;
 
        ret = drm_irq_install(dev, fsl_dev->irq);
        if (ret < 0)
                dev_err(dev->dev, "failed to install IRQ handler\n");
 
-       ret = regmap_write(fsl_dev->regmap, DCU_INT_STATUS, 0);
-       if (ret)
-               dev_err(dev->dev, "set DCU_INT_STATUS failed\n");
-       ret = regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
-       if (ret)
-               dev_err(dev->dev, "read DCU_INT_MASK failed\n");
-       value &= DCU_INT_MASK_VBLANK;
-       ret = regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
-       if (ret)
-               dev_err(dev->dev, "set DCU_INT_MASK failed\n");
-       ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
-                          DCU_UPDATE_MODE_READREG);
-       if (ret)
-               dev_err(dev->dev, "set DCU_UPDATE_MODE failed\n");
+       regmap_write(fsl_dev->regmap, DCU_INT_STATUS, 0);
+       regmap_write(fsl_dev->regmap, DCU_INT_MASK, ~0);
+       regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+                    DCU_UPDATE_MODE_READREG);
 
        return ret;
 }
@@ -120,18 +119,17 @@ static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg)
        int ret;
 
        ret = regmap_read(fsl_dev->regmap, DCU_INT_STATUS, &int_status);
-       if (ret)
-               dev_err(dev->dev, "set DCU_INT_STATUS failed\n");
+       if (ret) {
+               dev_err(dev->dev, "read DCU_INT_STATUS failed\n");
+               return IRQ_NONE;
+       }
+
        if (int_status & DCU_INT_STATUS_VBLANK)
                drm_handle_vblank(dev, 0);
 
-       ret = regmap_write(fsl_dev->regmap, DCU_INT_STATUS, 0xffffffff);
-       if (ret)
-               dev_err(dev->dev, "set DCU_INT_STATUS failed\n");
-       ret = regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
-                          DCU_UPDATE_MODE_READREG);
-       if (ret)
-               dev_err(dev->dev, "set DCU_UPDATE_MODE failed\n");
+       regmap_write(fsl_dev->regmap, DCU_INT_STATUS, int_status);
+       regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+                    DCU_UPDATE_MODE_READREG);
 
        return IRQ_HANDLED;
 }
@@ -140,15 +138,11 @@ static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
        struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
        unsigned int value;
-       int ret;
 
-       ret = regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
-       if (ret)
-               dev_err(dev->dev, "read DCU_INT_MASK failed\n");
+       regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
        value &= ~DCU_INT_MASK_VBLANK;
-       ret = regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
-       if (ret)
-               dev_err(dev->dev, "set DCU_INT_MASK failed\n");
+       regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
+
        return 0;
 }
 
@@ -157,15 +151,10 @@ static void fsl_dcu_drm_disable_vblank(struct drm_device *dev,
 {
        struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
        unsigned int value;
-       int ret;
 
-       ret = regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
-       if (ret)
-               dev_err(dev->dev, "read DCU_INT_MASK failed\n");
+       regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
        value |= DCU_INT_MASK_VBLANK;
-       ret = regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
-       if (ret)
-               dev_err(dev->dev, "set DCU_INT_MASK failed\n");
+       regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
 }
 
 static const struct file_operations fsl_dcu_drm_fops = {
index 579b9e4..6413ac9 100644 (file)
 #define DCU_LAYER_RLE_EN               BIT(15)
 #define DCU_LAYER_LUOFFS(x)            ((x) << 4)
 #define DCU_LAYER_BB_ON                        BIT(2)
-#define DCU_LAYER_AB(x)                        (x)
+#define DCU_LAYER_AB_NONE              0
+#define DCU_LAYER_AB_CHROMA_KEYING     1
+#define DCU_LAYER_AB_WHOLE_FRAME       2
 
 #define DCU_LAYER_CKMAX_R(x)           ((x) << 16)
 #define DCU_LAYER_CKMAX_G(x)           ((x) << 8)
index 0ef5959..c564ec6 100644 (file)
@@ -25,6 +25,8 @@ static const struct drm_mode_config_funcs fsl_dcu_drm_mode_config_funcs = {
 
 int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev)
 {
+       int ret;
+
        drm_mode_config_init(fsl_dev->drm);
 
        fsl_dev->drm->mode_config.min_width = 0;
@@ -33,11 +35,25 @@ int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev)
        fsl_dev->drm->mode_config.max_height = 2047;
        fsl_dev->drm->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs;
 
-       drm_kms_helper_poll_init(fsl_dev->drm);
-       fsl_dcu_drm_crtc_create(fsl_dev);
-       fsl_dcu_drm_encoder_create(fsl_dev, &fsl_dev->crtc);
-       fsl_dcu_drm_connector_create(fsl_dev, &fsl_dev->encoder);
+       ret = fsl_dcu_drm_crtc_create(fsl_dev);
+       if (ret)
+               return ret;
+
+       ret = fsl_dcu_drm_encoder_create(fsl_dev, &fsl_dev->crtc);
+       if (ret)
+               goto fail_encoder;
+
+       ret = fsl_dcu_drm_connector_create(fsl_dev, &fsl_dev->encoder);
+       if (ret)
+               goto fail_connector;
+
        drm_mode_config_reset(fsl_dev->drm);
+       drm_kms_helper_poll_init(fsl_dev->drm);
 
        return 0;
+fail_encoder:
+       fsl_dev->crtc.funcs->destroy(&fsl_dev->crtc);
+fail_connector:
+       fsl_dev->encoder.funcs->destroy(&fsl_dev->encoder);
+       return ret;
 }
index 4b13cf9..274558b 100644 (file)
@@ -41,11 +41,17 @@ static int fsl_dcu_drm_plane_atomic_check(struct drm_plane *plane,
 {
        struct drm_framebuffer *fb = state->fb;
 
+       if (!state->fb || !state->crtc)
+               return 0;
+
        switch (fb->pixel_format) {
        case DRM_FORMAT_RGB565:
        case DRM_FORMAT_RGB888:
+       case DRM_FORMAT_XRGB8888:
        case DRM_FORMAT_ARGB8888:
-       case DRM_FORMAT_BGRA4444:
+       case DRM_FORMAT_XRGB4444:
+       case DRM_FORMAT_ARGB4444:
+       case DRM_FORMAT_XRGB1555:
        case DRM_FORMAT_ARGB1555:
        case DRM_FORMAT_YUV422:
                return 0;
@@ -59,19 +65,15 @@ static void fsl_dcu_drm_plane_atomic_disable(struct drm_plane *plane,
 {
        struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
        unsigned int value;
-       int index, ret;
+       int index;
 
        index = fsl_dcu_drm_plane_index(plane);
        if (index < 0)
                return;
 
-       ret = regmap_read(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), &value);
-       if (ret)
-               dev_err(fsl_dev->dev, "read DCU_INT_MASK failed\n");
+       regmap_read(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), &value);
        value &= ~DCU_LAYER_EN;
-       ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), value);
-       if (ret)
-               dev_err(fsl_dev->dev, "set DCU register failed\n");
+       regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4), value);
 }
 
 static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
@@ -82,8 +84,8 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
        struct drm_plane_state *state = plane->state;
        struct drm_framebuffer *fb = plane->state->fb;
        struct drm_gem_cma_object *gem;
-       unsigned int alpha, bpp;
-       int index, ret;
+       unsigned int alpha = DCU_LAYER_AB_NONE, bpp;
+       int index;
 
        if (!fb)
                return;
@@ -97,96 +99,74 @@ static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
        switch (fb->pixel_format) {
        case DRM_FORMAT_RGB565:
                bpp = FSL_DCU_RGB565;
-               alpha = 0xff;
                break;
        case DRM_FORMAT_RGB888:
                bpp = FSL_DCU_RGB888;
-               alpha = 0xff;
                break;
        case DRM_FORMAT_ARGB8888:
+               alpha = DCU_LAYER_AB_WHOLE_FRAME;
+               /* fall-through */
+       case DRM_FORMAT_XRGB8888:
                bpp = FSL_DCU_ARGB8888;
-               alpha = 0xff;
                break;
-       case DRM_FORMAT_BGRA4444:
+       case DRM_FORMAT_ARGB4444:
+               alpha = DCU_LAYER_AB_WHOLE_FRAME;
+               /* fall-through */
+       case DRM_FORMAT_XRGB4444:
                bpp = FSL_DCU_ARGB4444;
-               alpha = 0xff;
                break;
        case DRM_FORMAT_ARGB1555:
+               alpha = DCU_LAYER_AB_WHOLE_FRAME;
+               /* fall-through */
+       case DRM_FORMAT_XRGB1555:
                bpp = FSL_DCU_ARGB1555;
-               alpha = 0xff;
                break;
        case DRM_FORMAT_YUV422:
                bpp = FSL_DCU_YUV422;
-               alpha = 0xff;
                break;
        default:
                return;
        }
 
-       ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 1),
-                          DCU_LAYER_HEIGHT(state->crtc_h) |
-                          DCU_LAYER_WIDTH(state->crtc_w));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 2),
-                          DCU_LAYER_POSY(state->crtc_y) |
-                          DCU_LAYER_POSX(state->crtc_x));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap,
-                          DCU_CTRLDESCLN(index, 3), gem->paddr);
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4),
-                          DCU_LAYER_EN |
-                          DCU_LAYER_TRANS(alpha) |
-                          DCU_LAYER_BPP(bpp) |
-                          DCU_LAYER_AB(0));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 5),
-                          DCU_LAYER_CKMAX_R(0xFF) |
-                          DCU_LAYER_CKMAX_G(0xFF) |
-                          DCU_LAYER_CKMAX_B(0xFF));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 6),
-                          DCU_LAYER_CKMIN_R(0) |
-                          DCU_LAYER_CKMIN_G(0) |
-                          DCU_LAYER_CKMIN_B(0));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 7), 0);
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 8),
-                          DCU_LAYER_FG_FCOLOR(0));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 9),
-                          DCU_LAYER_BG_BCOLOR(0));
-       if (ret)
-               goto set_failed;
+       regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 1),
+                    DCU_LAYER_HEIGHT(state->crtc_h) |
+                    DCU_LAYER_WIDTH(state->crtc_w));
+       regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 2),
+                    DCU_LAYER_POSY(state->crtc_y) |
+                    DCU_LAYER_POSX(state->crtc_x));
+       regmap_write(fsl_dev->regmap,
+                    DCU_CTRLDESCLN(index, 3), gem->paddr);
+       regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 4),
+                    DCU_LAYER_EN |
+                    DCU_LAYER_TRANS(0xff) |
+                    DCU_LAYER_BPP(bpp) |
+                    alpha);
+       regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 5),
+                    DCU_LAYER_CKMAX_R(0xFF) |
+                    DCU_LAYER_CKMAX_G(0xFF) |
+                    DCU_LAYER_CKMAX_B(0xFF));
+       regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 6),
+                    DCU_LAYER_CKMIN_R(0) |
+                    DCU_LAYER_CKMIN_G(0) |
+                    DCU_LAYER_CKMIN_B(0));
+       regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 7), 0);
+       regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 8),
+                    DCU_LAYER_FG_FCOLOR(0));
+       regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 9),
+                    DCU_LAYER_BG_BCOLOR(0));
+
        if (!strcmp(fsl_dev->soc->name, "ls1021a")) {
-               ret = regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 10),
-                                  DCU_LAYER_POST_SKIP(0) |
-                                  DCU_LAYER_PRE_SKIP(0));
-               if (ret)
-                       goto set_failed;
+               regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN(index, 10),
+                            DCU_LAYER_POST_SKIP(0) |
+                            DCU_LAYER_PRE_SKIP(0));
        }
-       ret = regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
-                                DCU_MODE_DCU_MODE_MASK,
-                                DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
-       if (ret)
-               goto set_failed;
-       ret = regmap_write(fsl_dev->regmap,
-                          DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG);
-       if (ret)
-               goto set_failed;
-       return;
+       regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+                          DCU_MODE_DCU_MODE_MASK,
+                          DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
+       regmap_write(fsl_dev->regmap,
+                    DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG);
 
-set_failed:
-       dev_err(fsl_dev->dev, "set DCU register failed\n");
+       return;
 }
 
 static void
@@ -213,6 +193,7 @@ static const struct drm_plane_helper_funcs fsl_dcu_drm_plane_helper_funcs = {
 static void fsl_dcu_drm_plane_destroy(struct drm_plane *plane)
 {
        drm_plane_cleanup(plane);
+       kfree(plane);
 }
 
 static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
@@ -227,8 +208,11 @@ static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
 static const u32 fsl_dcu_drm_plane_formats[] = {
        DRM_FORMAT_RGB565,
        DRM_FORMAT_RGB888,
+       DRM_FORMAT_XRGB8888,
        DRM_FORMAT_ARGB8888,
+       DRM_FORMAT_XRGB4444,
        DRM_FORMAT_ARGB4444,
+       DRM_FORMAT_XRGB1555,
        DRM_FORMAT_ARGB1555,
        DRM_FORMAT_YUV422,
 };
index 6126546..17db4b4 100644 (file)
@@ -116,7 +116,7 @@ static const struct gma_limit_t cdv_intel_limits[] = {
         .p1 = {.min = 1, .max = 10},
         .p2 = {.dot_limit = 225000, .p2_slow = 10, .p2_fast = 10},
         .find_pll = cdv_intel_find_dp_pll,
-        }      
+       }
 };
 
 #define _wait_for(COND, MS, W) ({ \
@@ -245,7 +245,7 @@ cdv_dpll_set_clock_cdv(struct drm_device *dev, struct drm_crtc *crtc,
        /* We don't know what the other fields of these regs are, so
         * leave them in place.
         */
-       /* 
+       /*
         * The BIT 14:13 of 0x8010/0x8030 is used to select the ref clk
         * for the pipe A/B. Display spec 1.06 has wrong definition.
         * Correct definition is like below:
@@ -256,7 +256,7 @@ cdv_dpll_set_clock_cdv(struct drm_device *dev, struct drm_crtc *crtc,
         *
         * if DPLLA sets 01 and DPLLB sets 02, both use clk from DPLLA
         *
-        */  
+        */
        ret = cdv_sb_read(dev, ref_sfr, &ref_value);
        if (ret)
                return ret;
@@ -646,7 +646,7 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc,
                 * for DP/eDP. When using SSC clock, the ref clk is 100MHz.Otherwise
                 * it will be 27MHz. From the VBIOS code it seems that the pipe A choose
                 * 27MHz for DP/eDP while the Pipe B chooses the 100MHz.
-                */ 
+                */
                if (pipe == 0)
                        refclk = 27000;
                else
@@ -659,7 +659,7 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc,
        }
 
        drm_mode_debug_printmodeline(adjusted_mode);
-       
+
        limit = gma_crtc->clock_funcs->limit(crtc, refclk);
 
        ok = limit->find_pll(limit, crtc, adjusted_mode->clock, refclk,
@@ -721,7 +721,7 @@ static int cdv_intel_crtc_mode_set(struct drm_crtc *crtc,
                        pipeconf |= PIPE_6BPC;
        } else
                pipeconf |= PIPE_8BPC;
-                       
+
        /* Set up the display plane register */
        dspcntr = DISPPLANE_GAMMA_ENABLE;
 
@@ -974,7 +974,6 @@ struct drm_display_mode *cdv_intel_crtc_mode_get(struct drm_device *dev,
 
 const struct drm_crtc_helper_funcs cdv_intel_helper_funcs = {
        .dpms = gma_crtc_dpms,
-       .mode_fixup = gma_crtc_mode_fixup,
        .mode_set = cdv_intel_crtc_mode_set,
        .mode_set_base = gma_pipe_set_base,
        .prepare = gma_crtc_prepare,
index 9270821..5bf765d 100644 (file)
@@ -478,13 +478,6 @@ int gma_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
        return 0;
 }
 
-bool gma_crtc_mode_fixup(struct drm_crtc *crtc,
-                        const struct drm_display_mode *mode,
-                        struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 void gma_crtc_prepare(struct drm_crtc *crtc)
 {
        const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
index 78b9f98..b2491c6 100644 (file)
@@ -75,9 +75,6 @@ extern void gma_crtc_load_lut(struct drm_crtc *crtc);
 extern void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
                               u16 *blue, u32 start, u32 size);
 extern void gma_crtc_dpms(struct drm_crtc *crtc, int mode);
-extern bool gma_crtc_mode_fixup(struct drm_crtc *crtc,
-                               const struct drm_display_mode *mode,
-                               struct drm_display_mode *adjusted_mode);
 extern void gma_crtc_prepare(struct drm_crtc *crtc);
 extern void gma_crtc_commit(struct drm_crtc *crtc);
 extern void gma_crtc_disable(struct drm_crtc *crtc);
index acd3834..92e3f93 100644 (file)
@@ -1026,10 +1026,8 @@ mrst_crtc_mode_set_exit:
 
 const struct drm_crtc_helper_funcs mdfld_helper_funcs = {
        .dpms = mdfld_crtc_dpms,
-       .mode_fixup = gma_crtc_mode_fixup,
        .mode_set = mdfld_crtc_mode_set,
        .mode_set_base = mdfld__intel_pipe_set_base,
        .prepare = gma_crtc_prepare,
        .commit = gma_crtc_commit,
 };
-
index 1048f0c..da9fd34 100644 (file)
@@ -657,7 +657,6 @@ pipe_set_base_exit:
 
 const struct drm_crtc_helper_funcs oaktrail_helper_funcs = {
        .dpms = oaktrail_crtc_dpms,
-       .mode_fixup = gma_crtc_mode_fixup,
        .mode_set = oaktrail_crtc_mode_set,
        .mode_set_base = oaktrail_pipe_set_base,
        .prepare = gma_crtc_prepare,
index dcdbc37..398015b 100644 (file)
@@ -430,7 +430,6 @@ struct drm_display_mode *psb_intel_crtc_mode_get(struct drm_device *dev,
 
 const struct drm_crtc_helper_funcs psb_intel_helper_funcs = {
        .dpms = gma_crtc_dpms,
-       .mode_fixup = gma_crtc_mode_fixup,
        .mode_set = psb_intel_crtc_mode_set,
        .mode_set_base = gma_pipe_set_base,
        .prepare = gma_crtc_prepare,
index b61282d..f4315bc 100644 (file)
@@ -1373,8 +1373,16 @@ static void tda998x_connector_destroy(struct drm_connector *connector)
        drm_connector_cleanup(connector);
 }
 
+static int tda998x_connector_dpms(struct drm_connector *connector, int mode)
+{
+       if (drm_core_check_feature(connector->dev, DRIVER_ATOMIC))
+               return drm_atomic_helper_connector_dpms(connector, mode);
+       else
+               return drm_helper_connector_dpms(connector, mode);
+}
+
 static const struct drm_connector_funcs tda998x_connector_funcs = {
-       .dpms = drm_atomic_helper_connector_dpms,
+       .dpms = tda998x_connector_dpms,
        .reset = drm_atomic_helper_connector_reset,
        .fill_modes = drm_helper_probe_single_connector_modes,
        .detect = tda998x_connector_detect,
index 051eab3..20a5d04 100644 (file)
@@ -2,9 +2,7 @@ config DRM_I915
        tristate "Intel 8xx/9xx/G3x/G4x/HD Graphics"
        depends on DRM
        depends on X86 && PCI
-       depends on (AGP || AGP=n)
        select INTEL_GTT
-       select AGP_INTEL if AGP
        select INTERVAL_TREE
        # we need shmfs for the swappable backing store, and in particular
        # the shmem_readpage() which depends upon tmpfs
@@ -47,3 +45,14 @@ config DRM_I915_PRELIMINARY_HW_SUPPORT
          option changes the default for that module option.
 
          If in doubt, say "N".
+
+config DRM_I915_USERPTR
+       bool "Always enable userptr support"
+       depends on DRM_I915
+       select MMU_NOTIFIER
+       default y
+       help
+         This option selects CONFIG_MMU_NOTIFIER if it isn't already
+         selected to enabled full userptr support.
+
+         If in doubt, say "Y".
index c5db235..a0f1bd7 100644 (file)
@@ -117,9 +117,8 @@ static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
        u64 size = 0;
        struct i915_vma *vma;
 
-       list_for_each_entry(vma, &obj->vma_list, vma_link) {
-               if (i915_is_ggtt(vma->vm) &&
-                   drm_mm_node_allocated(&vma->node))
+       list_for_each_entry(vma, &obj->vma_list, obj_link) {
+               if (vma->is_ggtt && drm_mm_node_allocated(&vma->node))
                        size += vma->node.size;
        }
 
@@ -155,7 +154,7 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
                   obj->madv == I915_MADV_DONTNEED ? " purgeable" : "");
        if (obj->base.name)
                seq_printf(m, " (name: %d)", obj->base.name);
-       list_for_each_entry(vma, &obj->vma_list, vma_link) {
+       list_for_each_entry(vma, &obj->vma_list, obj_link) {
                if (vma->pin_count > 0)
                        pin_count++;
        }
@@ -164,14 +163,13 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
                seq_printf(m, " (display)");
        if (obj->fence_reg != I915_FENCE_REG_NONE)
                seq_printf(m, " (fence: %d)", obj->fence_reg);
-       list_for_each_entry(vma, &obj->vma_list, vma_link) {
+       list_for_each_entry(vma, &obj->vma_list, obj_link) {
                seq_printf(m, " (%sgtt offset: %08llx, size: %08llx",
-                          i915_is_ggtt(vma->vm) ? "g" : "pp",
+                          vma->is_ggtt ? "g" : "pp",
                           vma->node.start, vma->node.size);
-               if (i915_is_ggtt(vma->vm))
-                       seq_printf(m, ", type: %u)", vma->ggtt_view.type);
-               else
-                       seq_puts(m, ")");
+               if (vma->is_ggtt)
+                       seq_printf(m, ", type: %u", vma->ggtt_view.type);
+               seq_puts(m, ")");
        }
        if (obj->stolen)
                seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
@@ -230,7 +228,7 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)
        }
 
        total_obj_size = total_gtt_size = count = 0;
-       list_for_each_entry(vma, head, mm_list) {
+       list_for_each_entry(vma, head, vm_link) {
                seq_printf(m, "   ");
                describe_obj(m, vma->obj);
                seq_printf(m, "\n");
@@ -342,13 +340,13 @@ static int per_file_stats(int id, void *ptr, void *data)
                stats->shared += obj->base.size;
 
        if (USES_FULL_PPGTT(obj->base.dev)) {
-               list_for_each_entry(vma, &obj->vma_list, vma_link) {
+               list_for_each_entry(vma, &obj->vma_list, obj_link) {
                        struct i915_hw_ppgtt *ppgtt;
 
                        if (!drm_mm_node_allocated(&vma->node))
                                continue;
 
-                       if (i915_is_ggtt(vma->vm)) {
+                       if (vma->is_ggtt) {
                                stats->global += obj->base.size;
                                continue;
                        }
@@ -454,12 +452,12 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
                   count, mappable_count, size, mappable_size);
 
        size = count = mappable_size = mappable_count = 0;
-       count_vmas(&vm->active_list, mm_list);
+       count_vmas(&vm->active_list, vm_link);
        seq_printf(m, "  %u [%u] active objects, %llu [%llu] bytes\n",
                   count, mappable_count, size, mappable_size);
 
        size = count = mappable_size = mappable_count = 0;
-       count_vmas(&vm->inactive_list, mm_list);
+       count_vmas(&vm->inactive_list, vm_link);
        seq_printf(m, "  %u [%u] inactive objects, %llu [%llu] bytes\n",
                   count, mappable_count, size, mappable_size);
 
@@ -825,8 +823,11 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
                }
 
                for_each_pipe(dev_priv, pipe) {
-                       if (!intel_display_power_is_enabled(dev_priv,
-                                               POWER_DOMAIN_PIPE(pipe))) {
+                       enum intel_display_power_domain power_domain;
+
+                       power_domain = POWER_DOMAIN_PIPE(pipe);
+                       if (!intel_display_power_get_if_enabled(dev_priv,
+                                                               power_domain)) {
                                seq_printf(m, "Pipe %c power disabled\n",
                                           pipe_name(pipe));
                                continue;
@@ -840,6 +841,8 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
                        seq_printf(m, "Pipe %c IER:\t%08x\n",
                                   pipe_name(pipe),
                                   I915_READ(GEN8_DE_PIPE_IER(pipe)));
+
+                       intel_display_power_put(dev_priv, power_domain);
                }
 
                seq_printf(m, "Display Engine port interrupt mask:\t%08x\n",
@@ -2463,9 +2466,9 @@ static void i915_guc_client_info(struct seq_file *m,
 
        for_each_ring(ring, dev_priv, i) {
                seq_printf(m, "\tSubmissions: %llu %s\n",
-                               client->submissions[i],
+                               client->submissions[ring->guc_id],
                                ring->name);
-               tot += client->submissions[i];
+               tot += client->submissions[ring->guc_id];
        }
        seq_printf(m, "\tTotal: %llu\n", tot);
 }
@@ -2502,10 +2505,10 @@ static int i915_guc_info(struct seq_file *m, void *data)
 
        seq_printf(m, "\nGuC submissions:\n");
        for_each_ring(ring, dev_priv, i) {
-               seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x %9d\n",
-                       ring->name, guc.submissions[i],
-                       guc.last_seqno[i], guc.last_seqno[i]);
-               total += guc.submissions[i];
+               seq_printf(m, "\t%-24s: %10llu, last seqno 0x%08x\n",
+                       ring->name, guc.submissions[ring->guc_id],
+                       guc.last_seqno[ring->guc_id]);
+               total += guc.submissions[ring->guc_id];
        }
        seq_printf(m, "\t%s: %llu\n", "Total", total);
 
@@ -2583,6 +2586,10 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
                                enabled = true;
                }
        }
+
+       seq_printf(m, "Main link in standby mode: %s\n",
+                  yesno(dev_priv->psr.link_standby));
+
        seq_printf(m, "HW Enabled & Active bit: %s", yesno(enabled));
 
        if (!HAS_DDI(dev))
@@ -3221,9 +3228,11 @@ static int i915_wa_registers(struct seq_file *m, void *unused)
 {
        int i;
        int ret;
+       struct intel_engine_cs *ring;
        struct drm_info_node *node = (struct drm_info_node *) m->private;
        struct drm_device *dev = node->minor->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
+       struct i915_workarounds *workarounds = &dev_priv->workarounds;
 
        ret = mutex_lock_interruptible(&dev->struct_mutex);
        if (ret)
@@ -3231,15 +3240,18 @@ static int i915_wa_registers(struct seq_file *m, void *unused)
 
        intel_runtime_pm_get(dev_priv);
 
-       seq_printf(m, "Workarounds applied: %d\n", dev_priv->workarounds.count);
-       for (i = 0; i < dev_priv->workarounds.count; ++i) {
+       seq_printf(m, "Workarounds applied: %d\n", workarounds->count);
+       for_each_ring(ring, dev_priv, i)
+               seq_printf(m, "HW whitelist count for %s: %d\n",
+                          ring->name, workarounds->hw_whitelist_count[i]);
+       for (i = 0; i < workarounds->count; ++i) {
                i915_reg_t addr;
                u32 mask, value, read;
                bool ok;
 
-               addr = dev_priv->workarounds.reg[i].addr;
-               mask = dev_priv->workarounds.reg[i].mask;
-               value = dev_priv->workarounds.reg[i].value;
+               addr = workarounds->reg[i].addr;
+               mask = workarounds->reg[i].mask;
+               value = workarounds->reg[i].value;
                read = I915_READ(addr);
                ok = (value & mask) == (read & mask);
                seq_printf(m, "0x%X: 0x%08X, mask: 0x%08X, read: 0x%08x, status: %s\n",
@@ -3995,6 +4007,7 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
        struct intel_pipe_crc *pipe_crc = &dev_priv->pipe_crc[pipe];
        struct intel_crtc *crtc = to_intel_crtc(intel_get_crtc_for_pipe(dev,
                                                                        pipe));
+       enum intel_display_power_domain power_domain;
        u32 val = 0; /* shut up gcc */
        int ret;
 
@@ -4005,7 +4018,8 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
        if (pipe_crc->source && source)
                return -EINVAL;
 
-       if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PIPE(pipe))) {
+       power_domain = POWER_DOMAIN_PIPE(pipe);
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain)) {
                DRM_DEBUG_KMS("Trying to capture CRC while pipe is off\n");
                return -EIO;
        }
@@ -4022,7 +4036,7 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
                ret = ivb_pipe_crc_ctl_reg(dev, pipe, &source, &val);
 
        if (ret != 0)
-               return ret;
+               goto out;
 
        /* none -> real source transition */
        if (source) {
@@ -4034,8 +4048,10 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
                entries = kcalloc(INTEL_PIPE_CRC_ENTRIES_NR,
                                  sizeof(pipe_crc->entries[0]),
                                  GFP_KERNEL);
-               if (!entries)
-                       return -ENOMEM;
+               if (!entries) {
+                       ret = -ENOMEM;
+                       goto out;
+               }
 
                /*
                 * When IPS gets enabled, the pipe CRC changes. Since IPS gets
@@ -4091,7 +4107,12 @@ static int pipe_crc_set_source(struct drm_device *dev, enum pipe pipe,
                hsw_enable_ips(crtc);
        }
 
-       return 0;
+       ret = 0;
+
+out:
+       intel_display_power_put(dev_priv, power_domain);
+
+       return ret;
 }
 
 /*
index 1c3d254..1c6d227 100644 (file)
@@ -391,20 +391,13 @@ static int i915_load_modeset_init(struct drm_device *dev)
        if (ret)
                goto cleanup_vga_client;
 
-       /* Initialise stolen first so that we may reserve preallocated
-        * objects for the BIOS to KMS transition.
-        */
-       ret = i915_gem_init_stolen(dev);
-       if (ret)
-               goto cleanup_vga_switcheroo;
-
        intel_power_domains_init_hw(dev_priv, false);
 
        intel_csr_ucode_init(dev_priv);
 
        ret = intel_irq_install(dev_priv);
        if (ret)
-               goto cleanup_gem_stolen;
+               goto cleanup_csr;
 
        intel_setup_gmbus(dev);
 
@@ -458,9 +451,8 @@ cleanup_irq:
        intel_guc_ucode_fini(dev);
        drm_irq_uninstall(dev);
        intel_teardown_gmbus(dev);
-cleanup_gem_stolen:
-       i915_gem_cleanup_stolen(dev);
-cleanup_vga_switcheroo:
+cleanup_csr:
+       intel_csr_ucode_fini(dev_priv);
        vga_switcheroo_unregister_client(dev->pdev);
 cleanup_vga_client:
        vga_client_register(dev->pdev, NULL, NULL, NULL);
@@ -816,7 +808,41 @@ static void intel_device_info_runtime_init(struct drm_device *dev)
                     !(sfuse_strap & SFUSE_STRAP_FUSE_LOCK))) {
                        DRM_INFO("Display fused off, disabling\n");
                        info->num_pipes = 0;
+               } else if (fuse_strap & IVB_PIPE_C_DISABLE) {
+                       DRM_INFO("PipeC fused off\n");
+                       info->num_pipes -= 1;
                }
+       } else if (info->num_pipes > 0 && INTEL_INFO(dev)->gen == 9) {
+               u32 dfsm = I915_READ(SKL_DFSM);
+               u8 disabled_mask = 0;
+               bool invalid;
+               int num_bits;
+
+               if (dfsm & SKL_DFSM_PIPE_A_DISABLE)
+                       disabled_mask |= BIT(PIPE_A);
+               if (dfsm & SKL_DFSM_PIPE_B_DISABLE)
+                       disabled_mask |= BIT(PIPE_B);
+               if (dfsm & SKL_DFSM_PIPE_C_DISABLE)
+                       disabled_mask |= BIT(PIPE_C);
+
+               num_bits = hweight8(disabled_mask);
+
+               switch (disabled_mask) {
+               case BIT(PIPE_A):
+               case BIT(PIPE_B):
+               case BIT(PIPE_A) | BIT(PIPE_B):
+               case BIT(PIPE_A) | BIT(PIPE_C):
+                       invalid = true;
+                       break;
+               default:
+                       invalid = false;
+               }
+
+               if (num_bits > info->num_pipes || invalid)
+                       DRM_ERROR("invalid pipe fuse configuration: 0x%x\n",
+                                 disabled_mask);
+               else
+                       info->num_pipes -= num_bits;
        }
 
        /* Initialize slice/subslice/EU info */
@@ -855,6 +881,94 @@ static void intel_init_dpio(struct drm_i915_private *dev_priv)
        }
 }
 
+static int i915_workqueues_init(struct drm_i915_private *dev_priv)
+{
+       /*
+        * The i915 workqueue is primarily used for batched retirement of
+        * requests (and thus managing bo) once the task has been completed
+        * by the GPU. i915_gem_retire_requests() is called directly when we
+        * need high-priority retirement, such as waiting for an explicit
+        * bo.
+        *
+        * It is also used for periodic low-priority events, such as
+        * idle-timers and recording error state.
+        *
+        * All tasks on the workqueue are expected to acquire the dev mutex
+        * so there is no point in running more than one instance of the
+        * workqueue at any time.  Use an ordered one.
+        */
+       dev_priv->wq = alloc_ordered_workqueue("i915", 0);
+       if (dev_priv->wq == NULL)
+               goto out_err;
+
+       dev_priv->hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0);
+       if (dev_priv->hotplug.dp_wq == NULL)
+               goto out_free_wq;
+
+       dev_priv->gpu_error.hangcheck_wq =
+               alloc_ordered_workqueue("i915-hangcheck", 0);
+       if (dev_priv->gpu_error.hangcheck_wq == NULL)
+               goto out_free_dp_wq;
+
+       return 0;
+
+out_free_dp_wq:
+       destroy_workqueue(dev_priv->hotplug.dp_wq);
+out_free_wq:
+       destroy_workqueue(dev_priv->wq);
+out_err:
+       DRM_ERROR("Failed to allocate workqueues.\n");
+
+       return -ENOMEM;
+}
+
+static void i915_workqueues_cleanup(struct drm_i915_private *dev_priv)
+{
+       destroy_workqueue(dev_priv->gpu_error.hangcheck_wq);
+       destroy_workqueue(dev_priv->hotplug.dp_wq);
+       destroy_workqueue(dev_priv->wq);
+}
+
+static int i915_mmio_setup(struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = to_i915(dev);
+       int mmio_bar;
+       int mmio_size;
+
+       mmio_bar = IS_GEN2(dev) ? 1 : 0;
+       /*
+        * Before gen4, the registers and the GTT are behind different BARs.
+        * However, from gen4 onwards, the registers and the GTT are shared
+        * in the same BAR, so we want to restrict this ioremap from
+        * clobbering the GTT which we want ioremap_wc instead. Fortunately,
+        * the register BAR remains the same size for all the earlier
+        * generations up to Ironlake.
+        */
+       if (INTEL_INFO(dev)->gen < 5)
+               mmio_size = 512 * 1024;
+       else
+               mmio_size = 2 * 1024 * 1024;
+       dev_priv->regs = pci_iomap(dev->pdev, mmio_bar, mmio_size);
+       if (dev_priv->regs == NULL) {
+               DRM_ERROR("failed to map registers\n");
+
+               return -EIO;
+       }
+
+       /* Try to make sure MCHBAR is enabled before poking at it */
+       intel_setup_mchbar(dev);
+
+       return 0;
+}
+
+static void i915_mmio_cleanup(struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = to_i915(dev);
+
+       intel_teardown_mchbar(dev);
+       pci_iounmap(dev->pdev, dev_priv->regs);
+}
+
 /**
  * i915_driver_load - setup chip and create an initial config
  * @dev: DRM device
@@ -870,7 +984,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 {
        struct drm_i915_private *dev_priv;
        struct intel_device_info *info, *device_info;
-       int ret = 0, mmio_bar, mmio_size;
+       int ret = 0;
        uint32_t aperture_size;
 
        info = (struct intel_device_info *) flags;
@@ -897,6 +1011,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
        mutex_init(&dev_priv->modeset_restore_lock);
        mutex_init(&dev_priv->av_mutex);
 
+       ret = i915_workqueues_init(dev_priv);
+       if (ret < 0)
+               goto out_free_priv;
+
        intel_pm_setup(dev);
 
        intel_runtime_pm_get(dev_priv);
@@ -915,28 +1033,12 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
        if (i915_get_bridge_dev(dev)) {
                ret = -EIO;
-               goto free_priv;
+               goto out_runtime_pm_put;
        }
 
-       mmio_bar = IS_GEN2(dev) ? 1 : 0;
-       /* Before gen4, the registers and the GTT are behind different BARs.
-        * However, from gen4 onwards, the registers and the GTT are shared
-        * in the same BAR, so we want to restrict this ioremap from
-        * clobbering the GTT which we want ioremap_wc instead. Fortunately,
-        * the register BAR remains the same size for all the earlier
-        * generations up to Ironlake.
-        */
-       if (info->gen < 5)
-               mmio_size = 512*1024;
-       else
-               mmio_size = 2*1024*1024;
-
-       dev_priv->regs = pci_iomap(dev->pdev, mmio_bar, mmio_size);
-       if (!dev_priv->regs) {
-               DRM_ERROR("failed to map registers\n");
-               ret = -EIO;
+       ret = i915_mmio_setup(dev);
+       if (ret < 0)
                goto put_bridge;
-       }
 
        /* This must be called before any calls to HAS_PCH_* */
        intel_detect_pch(dev);
@@ -945,7 +1047,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 
        ret = i915_gem_gtt_init(dev);
        if (ret)
-               goto out_freecsr;
+               goto out_uncore_fini;
 
        /* WARNING: Apparently we must kick fbdev drivers before vgacon,
         * otherwise the vga fbdev driver falls over. */
@@ -991,49 +1093,13 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
        dev_priv->gtt.mtrr = arch_phys_wc_add(dev_priv->gtt.mappable_base,
                                              aperture_size);
 
-       /* The i915 workqueue is primarily used for batched retirement of
-        * requests (and thus managing bo) once the task has been completed
-        * by the GPU. i915_gem_retire_requests() is called directly when we
-        * need high-priority retirement, such as waiting for an explicit
-        * bo.
-        *
-        * It is also used for periodic low-priority events, such as
-        * idle-timers and recording error state.
-        *
-        * All tasks on the workqueue are expected to acquire the dev mutex
-        * so there is no point in running more than one instance of the
-        * workqueue at any time.  Use an ordered one.
-        */
-       dev_priv->wq = alloc_ordered_workqueue("i915", 0);
-       if (dev_priv->wq == NULL) {
-               DRM_ERROR("Failed to create our workqueue.\n");
-               ret = -ENOMEM;
-               goto out_mtrrfree;
-       }
-
-       dev_priv->hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0);
-       if (dev_priv->hotplug.dp_wq == NULL) {
-               DRM_ERROR("Failed to create our dp workqueue.\n");
-               ret = -ENOMEM;
-               goto out_freewq;
-       }
-
-       dev_priv->gpu_error.hangcheck_wq =
-               alloc_ordered_workqueue("i915-hangcheck", 0);
-       if (dev_priv->gpu_error.hangcheck_wq == NULL) {
-               DRM_ERROR("Failed to create our hangcheck workqueue.\n");
-               ret = -ENOMEM;
-               goto out_freedpwq;
-       }
-
        intel_irq_init(dev_priv);
        intel_uncore_sanitize(dev);
 
-       /* Try to make sure MCHBAR is enabled before poking at it */
-       intel_setup_mchbar(dev);
        intel_opregion_setup(dev);
 
-       i915_gem_load(dev);
+       i915_gem_load_init(dev);
+       i915_gem_shrinker_init(dev_priv);
 
        /* On the 945G/GM, the chipset reports the MSI capability on the
         * integrated graphics even though the support isn't actually there
@@ -1046,8 +1112,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
         * be lost or delayed, but we use them anyways to avoid
         * stuck interrupts on some machines.
         */
-       if (!IS_I945G(dev) && !IS_I945GM(dev))
-               pci_enable_msi(dev->pdev);
+       if (!IS_I945G(dev) && !IS_I945GM(dev)) {
+               if (pci_enable_msi(dev->pdev) < 0)
+                       DRM_DEBUG_DRIVER("can't enable MSI");
+       }
 
        intel_device_info_runtime_init(dev);
 
@@ -1097,38 +1165,29 @@ out_power_well:
        intel_power_domains_fini(dev_priv);
        drm_vblank_cleanup(dev);
 out_gem_unload:
-       WARN_ON(unregister_oom_notifier(&dev_priv->mm.oom_notifier));
-       unregister_shrinker(&dev_priv->mm.shrinker);
+       i915_gem_shrinker_cleanup(dev_priv);
 
        if (dev->pdev->msi_enabled)
                pci_disable_msi(dev->pdev);
 
        intel_teardown_mchbar(dev);
        pm_qos_remove_request(&dev_priv->pm_qos);
-       destroy_workqueue(dev_priv->gpu_error.hangcheck_wq);
-out_freedpwq:
-       destroy_workqueue(dev_priv->hotplug.dp_wq);
-out_freewq:
-       destroy_workqueue(dev_priv->wq);
-out_mtrrfree:
        arch_phys_wc_del(dev_priv->gtt.mtrr);
        io_mapping_free(dev_priv->gtt.mappable);
 out_gtt:
        i915_global_gtt_cleanup(dev);
-out_freecsr:
-       intel_csr_ucode_fini(dev_priv);
+out_uncore_fini:
        intel_uncore_fini(dev);
-       pci_iounmap(dev->pdev, dev_priv->regs);
+       i915_mmio_cleanup(dev);
 put_bridge:
        pci_dev_put(dev_priv->bridge_dev);
-free_priv:
-       kmem_cache_destroy(dev_priv->requests);
-       kmem_cache_destroy(dev_priv->vmas);
-       kmem_cache_destroy(dev_priv->objects);
-
+       i915_gem_load_cleanup(dev);
+out_runtime_pm_put:
        intel_runtime_pm_put(dev_priv);
-
+       i915_workqueues_cleanup(dev_priv);
+out_free_priv:
        kfree(dev_priv);
+
        return ret;
 }
 
@@ -1153,8 +1212,7 @@ int i915_driver_unload(struct drm_device *dev)
 
        i915_teardown_sysfs(dev);
 
-       WARN_ON(unregister_oom_notifier(&dev_priv->mm.oom_notifier));
-       unregister_shrinker(&dev_priv->mm.shrinker);
+       i915_gem_shrinker_cleanup(dev_priv);
 
        io_mapping_free(dev_priv->gtt.mappable);
        arch_phys_wc_del(dev_priv->gtt.mtrr);
@@ -1182,6 +1240,8 @@ int i915_driver_unload(struct drm_device *dev)
        vga_switcheroo_unregister_client(dev->pdev);
        vga_client_register(dev->pdev, NULL, NULL, NULL);
 
+       intel_csr_ucode_fini(dev_priv);
+
        /* Free error state after interrupts are fully disabled. */
        cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work);
        i915_destroy_error_state(dev);
@@ -1200,27 +1260,17 @@ int i915_driver_unload(struct drm_device *dev)
        i915_gem_context_fini(dev);
        mutex_unlock(&dev->struct_mutex);
        intel_fbc_cleanup_cfb(dev_priv);
-       i915_gem_cleanup_stolen(dev);
 
-       intel_csr_ucode_fini(dev_priv);
-
-       intel_teardown_mchbar(dev);
-
-       destroy_workqueue(dev_priv->hotplug.dp_wq);
-       destroy_workqueue(dev_priv->wq);
-       destroy_workqueue(dev_priv->gpu_error.hangcheck_wq);
        pm_qos_remove_request(&dev_priv->pm_qos);
 
        i915_global_gtt_cleanup(dev);
 
        intel_uncore_fini(dev);
-       if (dev_priv->regs != NULL)
-               pci_iounmap(dev->pdev, dev_priv->regs);
+       i915_mmio_cleanup(dev);
 
-       kmem_cache_destroy(dev_priv->requests);
-       kmem_cache_destroy(dev_priv->vmas);
-       kmem_cache_destroy(dev_priv->objects);
+       i915_gem_load_cleanup(dev);
        pci_dev_put(dev_priv->bridge_dev);
+       i915_workqueues_cleanup(dev_priv);
        kfree(dev_priv);
 
        return 0;
index 44912ec..20e8200 100644 (file)
@@ -603,13 +603,7 @@ static int i915_drm_suspend(struct drm_device *dev)
 
        intel_suspend_gt_powersave(dev);
 
-       /*
-        * Disable CRTCs directly since we want to preserve sw state
-        * for _thaw. Also, power gate the CRTC power wells.
-        */
-       drm_modeset_lock_all(dev);
        intel_display_suspend(dev);
-       drm_modeset_unlock_all(dev);
 
        intel_dp_mst_suspend(dev);
 
@@ -764,9 +758,7 @@ static int i915_drm_resume(struct drm_device *dev)
                dev_priv->display.hpd_irq_setup(dev);
        spin_unlock_irq(&dev_priv->irq_lock);
 
-       drm_modeset_lock_all(dev);
        intel_display_resume(dev);
-       drm_modeset_unlock_all(dev);
 
        intel_dp_mst_resume(dev);
 
index afb0bee..1048093 100644 (file)
@@ -59,7 +59,7 @@
 
 #define DRIVER_NAME            "i915"
 #define DRIVER_DESC            "Intel Graphics"
-#define DRIVER_DATE            "20160124"
+#define DRIVER_DATE            "20160229"
 
 #undef WARN_ON
 /* Many gcc seem to no see through this and fall over :( */
@@ -261,6 +261,9 @@ struct i915_hotplug {
 
 #define for_each_pipe(__dev_priv, __p) \
        for ((__p) = 0; (__p) < INTEL_INFO(__dev_priv)->num_pipes; (__p)++)
+#define for_each_pipe_masked(__dev_priv, __p, __mask) \
+       for ((__p) = 0; (__p) < INTEL_INFO(__dev_priv)->num_pipes; (__p)++) \
+               for_each_if ((__mask) & (1 << (__p)))
 #define for_each_plane(__dev_priv, __pipe, __p)                                \
        for ((__p) = 0;                                                 \
             (__p) < INTEL_INFO(__dev_priv)->num_sprites[(__pipe)] + 1; \
@@ -746,6 +749,7 @@ struct intel_csr {
        uint32_t mmio_count;
        i915_reg_t mmioaddr[8];
        uint32_t mmiodata[8];
+       uint32_t dc_state;
 };
 
 #define DEV_INFO_FOR_EACH_FLAG(func, sep) \
@@ -900,16 +904,15 @@ enum fb_op_origin {
        ORIGIN_DIRTYFB,
 };
 
-struct i915_fbc {
+struct intel_fbc {
        /* This is always the inner lock when overlapping with struct_mutex and
         * it's the outer lock when overlapping with stolen_lock. */
        struct mutex lock;
        unsigned threshold;
-       unsigned int fb_id;
        unsigned int possible_framebuffer_bits;
        unsigned int busy_bits;
+       unsigned int visible_pipes_mask;
        struct intel_crtc *crtc;
-       int y;
 
        struct drm_mm_node compressed_fb;
        struct drm_mm_node *compressed_llb;
@@ -919,18 +922,52 @@ struct i915_fbc {
        bool enabled;
        bool active;
 
+       struct intel_fbc_state_cache {
+               struct {
+                       unsigned int mode_flags;
+                       uint32_t hsw_bdw_pixel_rate;
+               } crtc;
+
+               struct {
+                       unsigned int rotation;
+                       int src_w;
+                       int src_h;
+                       bool visible;
+               } plane;
+
+               struct {
+                       u64 ilk_ggtt_offset;
+                       uint32_t pixel_format;
+                       unsigned int stride;
+                       int fence_reg;
+                       unsigned int tiling_mode;
+               } fb;
+       } state_cache;
+
+       struct intel_fbc_reg_params {
+               struct {
+                       enum pipe pipe;
+                       enum plane plane;
+                       unsigned int fence_y_offset;
+               } crtc;
+
+               struct {
+                       u64 ggtt_offset;
+                       uint32_t pixel_format;
+                       unsigned int stride;
+                       int fence_reg;
+               } fb;
+
+               int cfb_size;
+       } params;
+
        struct intel_fbc_work {
                bool scheduled;
+               u32 scheduled_vblank;
                struct work_struct work;
-               struct drm_framebuffer *fb;
-               unsigned long enable_jiffies;
        } work;
 
        const char *no_fbc_reason;
-
-       bool (*is_active)(struct drm_i915_private *dev_priv);
-       void (*activate)(struct intel_crtc *crtc);
-       void (*deactivate)(struct drm_i915_private *dev_priv);
 };
 
 /**
@@ -970,6 +1007,7 @@ struct i915_psr {
        unsigned busy_frontbuffer_bits;
        bool psr2_support;
        bool aux_frame_sync;
+       bool link_standby;
 };
 
 enum intel_pch {
@@ -1657,11 +1695,18 @@ struct i915_wa_reg {
        u32 mask;
 };
 
-#define I915_MAX_WA_REGS 16
+/*
+ * RING_MAX_NONPRIV_SLOTS is per-engine but at this point we are only
+ * allowing it for RCS as we don't foresee any requirement of having
+ * a whitelist for other engines. When it is really required for
+ * other engines then the limit need to be increased.
+ */
+#define I915_MAX_WA_REGS (16 + RING_MAX_NONPRIV_SLOTS)
 
 struct i915_workarounds {
        struct i915_wa_reg reg[I915_MAX_WA_REGS];
        u32 count;
+       u32 hw_whitelist_count[I915_NUM_RINGS];
 };
 
 struct i915_virtual_gpu {
@@ -1758,7 +1803,7 @@ struct drm_i915_private {
        u32 pipestat_irq_mask[I915_MAX_PIPES];
 
        struct i915_hotplug hotplug;
-       struct i915_fbc fbc;
+       struct intel_fbc fbc;
        struct i915_drrs drrs;
        struct intel_opregion opregion;
        struct intel_vbt_data vbt;
@@ -1807,6 +1852,7 @@ struct drm_i915_private {
 
        enum modeset_restore modeset_restore;
        struct mutex modeset_restore_lock;
+       struct drm_atomic_state *modeset_restore_state;
 
        struct list_head vm_list; /* Global list of all address spaces */
        struct i915_gtt gtt; /* VM representing the global address space */
@@ -1993,6 +2039,9 @@ enum hdmi_force_audio {
 #define I915_GTT_OFFSET_NONE ((u32)-1)
 
 struct drm_i915_gem_object_ops {
+       unsigned int flags;
+#define I915_GEM_OBJECT_HAS_STRUCT_PAGE 0x1
+
        /* Interface between the GEM object and its backing storage.
         * get_pages() is called once prior to the use of the associated set
         * of pages before to binding them into the GTT, and put_pages() is
@@ -2008,6 +2057,7 @@ struct drm_i915_gem_object_ops {
         */
        int (*get_pages)(struct drm_i915_gem_object *);
        void (*put_pages)(struct drm_i915_gem_object *);
+
        int (*dmabuf_export)(struct drm_i915_gem_object *);
        void (*release)(struct drm_i915_gem_object *);
 };
@@ -2841,7 +2891,8 @@ int i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
                                struct drm_file *file_priv);
 int i915_gem_wait_ioctl(struct drm_device *dev, void *data,
                        struct drm_file *file_priv);
-void i915_gem_load(struct drm_device *dev);
+void i915_gem_load_init(struct drm_device *dev);
+void i915_gem_load_cleanup(struct drm_device *dev);
 void *i915_gem_object_alloc(struct drm_device *dev);
 void i915_gem_object_free(struct drm_i915_gem_object *obj);
 void i915_gem_object_init(struct drm_i915_gem_object *obj,
@@ -3105,18 +3156,11 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj);
 /* Some GGTT VM helpers */
 #define i915_obj_to_ggtt(obj) \
        (&((struct drm_i915_private *)(obj)->base.dev->dev_private)->gtt.base)
-static inline bool i915_is_ggtt(struct i915_address_space *vm)
-{
-       struct i915_address_space *ggtt =
-               &((struct drm_i915_private *)(vm)->dev->dev_private)->gtt.base;
-       return vm == ggtt;
-}
 
 static inline struct i915_hw_ppgtt *
 i915_vm_to_ppgtt(struct i915_address_space *vm)
 {
        WARN_ON(i915_is_ggtt(vm));
-
        return container_of(vm, struct i915_hw_ppgtt, base);
 }
 
@@ -3254,6 +3298,7 @@ unsigned long i915_gem_shrink(struct drm_i915_private *dev_priv,
 #define I915_SHRINK_ACTIVE 0x8
 unsigned long i915_gem_shrink_all(struct drm_i915_private *dev_priv);
 void i915_gem_shrinker_init(struct drm_i915_private *dev_priv);
+void i915_gem_shrinker_cleanup(struct drm_i915_private *dev_priv);
 
 
 /* i915_gem_tiling.c */
@@ -3424,16 +3469,14 @@ int sandybridge_pcode_write(struct drm_i915_private *dev_priv, u32 mbox, u32 val
 u32 vlv_punit_read(struct drm_i915_private *dev_priv, u32 addr);
 void vlv_punit_write(struct drm_i915_private *dev_priv, u32 addr, u32 val);
 u32 vlv_nc_read(struct drm_i915_private *dev_priv, u8 addr);
-u32 vlv_gpio_nc_read(struct drm_i915_private *dev_priv, u32 reg);
-void vlv_gpio_nc_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
+u32 vlv_iosf_sb_read(struct drm_i915_private *dev_priv, u8 port, u32 reg);
+void vlv_iosf_sb_write(struct drm_i915_private *dev_priv, u8 port, u32 reg, u32 val);
 u32 vlv_cck_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_cck_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 u32 vlv_ccu_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_ccu_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 u32 vlv_bunit_read(struct drm_i915_private *dev_priv, u32 reg);
 void vlv_bunit_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
-u32 vlv_gps_core_read(struct drm_i915_private *dev_priv, u32 reg);
-void vlv_gps_core_write(struct drm_i915_private *dev_priv, u32 reg, u32 val);
 u32 vlv_dpio_read(struct drm_i915_private *dev_priv, enum pipe pipe, int reg);
 void vlv_dpio_write(struct drm_i915_private *dev_priv, enum pipe pipe, int reg, u32 val);
 u32 intel_sbi_read(struct drm_i915_private *dev_priv, u16 reg,
index 371bbb2..3d31d3a 100644 (file)
@@ -138,10 +138,10 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
 
        pinned = 0;
        mutex_lock(&dev->struct_mutex);
-       list_for_each_entry(vma, &ggtt->base.active_list, mm_list)
+       list_for_each_entry(vma, &ggtt->base.active_list, vm_link)
                if (vma->pin_count)
                        pinned += vma->node.size;
-       list_for_each_entry(vma, &ggtt->base.inactive_list, mm_list)
+       list_for_each_entry(vma, &ggtt->base.inactive_list, vm_link)
                if (vma->pin_count)
                        pinned += vma->node.size;
        mutex_unlock(&dev->struct_mutex);
@@ -272,7 +272,7 @@ drop_pages(struct drm_i915_gem_object *obj)
        int ret;
 
        drm_gem_object_reference(&obj->base);
-       list_for_each_entry_safe(vma, next, &obj->vma_list, vma_link)
+       list_for_each_entry_safe(vma, next, &obj->vma_list, obj_link)
                if (i915_vma_unbind(vma))
                        break;
 
@@ -489,7 +489,7 @@ int i915_gem_obj_prepare_shmem_read(struct drm_i915_gem_object *obj,
 
        *needs_clflush = 0;
 
-       if (!obj->base.filp)
+       if (WARN_ON((obj->ops->flags & I915_GEM_OBJECT_HAS_STRUCT_PAGE) == 0))
                return -EINVAL;
 
        if (!(obj->base.read_domains & I915_GEM_DOMAIN_CPU)) {
@@ -2416,7 +2416,7 @@ void i915_vma_move_to_active(struct i915_vma *vma,
        list_move_tail(&obj->ring_list[ring->id], &ring->active_list);
        i915_gem_request_assign(&obj->last_read_req[ring->id], req);
 
-       list_move_tail(&vma->mm_list, &vma->vm->active_list);
+       list_move_tail(&vma->vm_link, &vma->vm->active_list);
 }
 
 static void
@@ -2454,9 +2454,9 @@ i915_gem_object_retire__read(struct drm_i915_gem_object *obj, int ring)
        list_move_tail(&obj->global_list,
                       &to_i915(obj->base.dev)->mm.bound_list);
 
-       list_for_each_entry(vma, &obj->vma_list, vma_link) {
-               if (!list_empty(&vma->mm_list))
-                       list_move_tail(&vma->mm_list, &vma->vm->inactive_list);
+       list_for_each_entry(vma, &obj->vma_list, obj_link) {
+               if (!list_empty(&vma->vm_link))
+                       list_move_tail(&vma->vm_link, &vma->vm->inactive_list);
        }
 
        i915_gem_request_assign(&obj->last_fenced_req, NULL);
@@ -2680,7 +2680,7 @@ void i915_gem_request_free(struct kref *req_ref)
 
        if (ctx) {
                if (i915.enable_execlists && ctx != req->i915->kernel_context)
-                       intel_lr_context_unpin(req);
+                       intel_lr_context_unpin(ctx, req->ring);
 
                i915_gem_context_unreference(ctx);
        }
@@ -2970,11 +2970,9 @@ i915_gem_retire_requests(struct drm_device *dev)
                i915_gem_retire_requests_ring(ring);
                idle &= list_empty(&ring->request_list);
                if (i915.enable_execlists) {
-                       unsigned long flags;
-
-                       spin_lock_irqsave(&ring->execlist_lock, flags);
+                       spin_lock_irq(&ring->execlist_lock);
                        idle &= list_empty(&ring->execlist_queue);
-                       spin_unlock_irqrestore(&ring->execlist_lock, flags);
+                       spin_unlock_irq(&ring->execlist_lock);
 
                        intel_execlists_retire_requests(ring);
                }
@@ -3319,7 +3317,7 @@ static int __i915_vma_unbind(struct i915_vma *vma, bool wait)
        struct drm_i915_private *dev_priv = obj->base.dev->dev_private;
        int ret;
 
-       if (list_empty(&vma->vma_link))
+       if (list_empty(&vma->obj_link))
                return 0;
 
        if (!drm_mm_node_allocated(&vma->node)) {
@@ -3338,8 +3336,7 @@ static int __i915_vma_unbind(struct i915_vma *vma, bool wait)
                        return ret;
        }
 
-       if (i915_is_ggtt(vma->vm) &&
-           vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL) {
+       if (vma->is_ggtt && vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL) {
                i915_gem_object_finish_gtt(obj);
 
                /* release the fence reg _after_ flushing */
@@ -3353,8 +3350,8 @@ static int __i915_vma_unbind(struct i915_vma *vma, bool wait)
        vma->vm->unbind_vma(vma);
        vma->bound = 0;
 
-       list_del_init(&vma->mm_list);
-       if (i915_is_ggtt(vma->vm)) {
+       list_del_init(&vma->vm_link);
+       if (vma->is_ggtt) {
                if (vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL) {
                        obj->map_and_fenceable = false;
                } else if (vma->ggtt_view.pages) {
@@ -3611,7 +3608,7 @@ search_free:
                goto err_remove_node;
 
        list_move_tail(&obj->global_list, &dev_priv->mm.bound_list);
-       list_add_tail(&vma->mm_list, &vm->inactive_list);
+       list_add_tail(&vma->vm_link, &vm->inactive_list);
 
        return vma;
 
@@ -3776,7 +3773,7 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)
        /* And bump the LRU for this access */
        vma = i915_gem_obj_to_ggtt(obj);
        if (vma && drm_mm_node_allocated(&vma->node) && !obj->active)
-               list_move_tail(&vma->mm_list,
+               list_move_tail(&vma->vm_link,
                               &to_i915(obj->base.dev)->gtt.base.inactive_list);
 
        return 0;
@@ -3811,7 +3808,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
         * catch the issue of the CS prefetch crossing page boundaries and
         * reading an invalid PTE on older architectures.
         */
-       list_for_each_entry_safe(vma, next, &obj->vma_list, vma_link) {
+       list_for_each_entry_safe(vma, next, &obj->vma_list, obj_link) {
                if (!drm_mm_node_allocated(&vma->node))
                        continue;
 
@@ -3874,7 +3871,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
                         */
                }
 
-               list_for_each_entry(vma, &obj->vma_list, vma_link) {
+               list_for_each_entry(vma, &obj->vma_list, obj_link) {
                        if (!drm_mm_node_allocated(&vma->node))
                                continue;
 
@@ -3884,7 +3881,7 @@ int i915_gem_object_set_cache_level(struct drm_i915_gem_object *obj,
                }
        }
 
-       list_for_each_entry(vma, &obj->vma_list, vma_link)
+       list_for_each_entry(vma, &obj->vma_list, obj_link)
                vma->node.color = cache_level;
        obj->cache_level = cache_level;
 
@@ -4465,6 +4462,7 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,
 }
 
 static const struct drm_i915_gem_object_ops i915_gem_object_ops = {
+       .flags = I915_GEM_OBJECT_HAS_STRUCT_PAGE,
        .get_pages = i915_gem_object_get_pages_gtt,
        .put_pages = i915_gem_object_put_pages_gtt,
 };
@@ -4557,7 +4555,7 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj)
 
        trace_i915_gem_object_destroy(obj);
 
-       list_for_each_entry_safe(vma, next, &obj->vma_list, vma_link) {
+       list_for_each_entry_safe(vma, next, &obj->vma_list, obj_link) {
                int ret;
 
                vma->pin_count = 0;
@@ -4614,7 +4612,7 @@ struct i915_vma *i915_gem_obj_to_vma(struct drm_i915_gem_object *obj,
                                     struct i915_address_space *vm)
 {
        struct i915_vma *vma;
-       list_for_each_entry(vma, &obj->vma_list, vma_link) {
+       list_for_each_entry(vma, &obj->vma_list, obj_link) {
                if (vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL &&
                    vma->vm == vm)
                        return vma;
@@ -4631,7 +4629,7 @@ struct i915_vma *i915_gem_obj_to_ggtt_view(struct drm_i915_gem_object *obj,
        if (WARN_ONCE(!view, "no view specified"))
                return ERR_PTR(-EINVAL);
 
-       list_for_each_entry(vma, &obj->vma_list, vma_link)
+       list_for_each_entry(vma, &obj->vma_list, obj_link)
                if (vma->vm == ggtt &&
                    i915_ggtt_view_equal(&vma->ggtt_view, view))
                        return vma;
@@ -4640,19 +4638,16 @@ struct i915_vma *i915_gem_obj_to_ggtt_view(struct drm_i915_gem_object *obj,
 
 void i915_gem_vma_destroy(struct i915_vma *vma)
 {
-       struct i915_address_space *vm = NULL;
        WARN_ON(vma->node.allocated);
 
        /* Keep the vma as a placeholder in the execbuffer reservation lists */
        if (!list_empty(&vma->exec_list))
                return;
 
-       vm = vma->vm;
-
-       if (!i915_is_ggtt(vm))
-               i915_ppgtt_put(i915_vm_to_ppgtt(vm));
+       if (!vma->is_ggtt)
+               i915_ppgtt_put(i915_vm_to_ppgtt(vma->vm));
 
-       list_del(&vma->vma_link);
+       list_del(&vma->obj_link);
 
        kmem_cache_free(to_i915(vma->obj->base.dev)->vmas, vma);
 }
@@ -5034,7 +5029,7 @@ init_ring_lists(struct intel_engine_cs *ring)
 }
 
 void
-i915_gem_load(struct drm_device *dev)
+i915_gem_load_init(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        int i;
@@ -5100,11 +5095,18 @@ i915_gem_load(struct drm_device *dev)
 
        dev_priv->mm.interruptible = true;
 
-       i915_gem_shrinker_init(dev_priv);
-
        mutex_init(&dev_priv->fb_tracking.lock);
 }
 
+void i915_gem_load_cleanup(struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = to_i915(dev);
+
+       kmem_cache_destroy(dev_priv->requests);
+       kmem_cache_destroy(dev_priv->vmas);
+       kmem_cache_destroy(dev_priv->objects);
+}
+
 void i915_gem_release(struct drm_device *dev, struct drm_file *file)
 {
        struct drm_i915_file_private *file_priv = file->driver_priv;
@@ -5195,8 +5197,8 @@ u64 i915_gem_obj_offset(struct drm_i915_gem_object *o,
 
        WARN_ON(vm == &dev_priv->mm.aliasing_ppgtt->base);
 
-       list_for_each_entry(vma, &o->vma_list, vma_link) {
-               if (i915_is_ggtt(vma->vm) &&
+       list_for_each_entry(vma, &o->vma_list, obj_link) {
+               if (vma->is_ggtt &&
                    vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL)
                        continue;
                if (vma->vm == vm)
@@ -5214,7 +5216,7 @@ u64 i915_gem_obj_ggtt_offset_view(struct drm_i915_gem_object *o,
        struct i915_address_space *ggtt = i915_obj_to_ggtt(o);
        struct i915_vma *vma;
 
-       list_for_each_entry(vma, &o->vma_list, vma_link)
+       list_for_each_entry(vma, &o->vma_list, obj_link)
                if (vma->vm == ggtt &&
                    i915_ggtt_view_equal(&vma->ggtt_view, view))
                        return vma->node.start;
@@ -5228,8 +5230,8 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o,
 {
        struct i915_vma *vma;
 
-       list_for_each_entry(vma, &o->vma_list, vma_link) {
-               if (i915_is_ggtt(vma->vm) &&
+       list_for_each_entry(vma, &o->vma_list, obj_link) {
+               if (vma->is_ggtt &&
                    vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL)
                        continue;
                if (vma->vm == vm && drm_mm_node_allocated(&vma->node))
@@ -5245,7 +5247,7 @@ bool i915_gem_obj_ggtt_bound_view(struct drm_i915_gem_object *o,
        struct i915_address_space *ggtt = i915_obj_to_ggtt(o);
        struct i915_vma *vma;
 
-       list_for_each_entry(vma, &o->vma_list, vma_link)
+       list_for_each_entry(vma, &o->vma_list, obj_link)
                if (vma->vm == ggtt &&
                    i915_ggtt_view_equal(&vma->ggtt_view, view) &&
                    drm_mm_node_allocated(&vma->node))
@@ -5258,7 +5260,7 @@ bool i915_gem_obj_bound_any(struct drm_i915_gem_object *o)
 {
        struct i915_vma *vma;
 
-       list_for_each_entry(vma, &o->vma_list, vma_link)
+       list_for_each_entry(vma, &o->vma_list, obj_link)
                if (drm_mm_node_allocated(&vma->node))
                        return true;
 
@@ -5275,8 +5277,8 @@ unsigned long i915_gem_obj_size(struct drm_i915_gem_object *o,
 
        BUG_ON(list_empty(&o->vma_list));
 
-       list_for_each_entry(vma, &o->vma_list, vma_link) {
-               if (i915_is_ggtt(vma->vm) &&
+       list_for_each_entry(vma, &o->vma_list, obj_link) {
+               if (vma->is_ggtt &&
                    vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL)
                        continue;
                if (vma->vm == vm)
@@ -5288,7 +5290,7 @@ unsigned long i915_gem_obj_size(struct drm_i915_gem_object *o,
 bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)
 {
        struct i915_vma *vma;
-       list_for_each_entry(vma, &obj->vma_list, vma_link)
+       list_for_each_entry(vma, &obj->vma_list, obj_link)
                if (vma->pin_count > 0)
                        return true;
 
@@ -5302,7 +5304,7 @@ i915_gem_object_get_dirty_page(struct drm_i915_gem_object *obj, int n)
        struct page *page;
 
        /* Only default objects have per-page dirty tracking */
-       if (WARN_ON(obj->ops != &i915_gem_object_ops))
+       if (WARN_ON((obj->ops->flags & I915_GEM_OBJECT_HAS_STRUCT_PAGE) == 0))
                return NULL;
 
        page = i915_gem_object_get_page(obj, n);
index 6a4f64b..5dd84e1 100644 (file)
@@ -142,7 +142,7 @@ static void i915_gem_context_clean(struct intel_context *ctx)
                return;
 
        list_for_each_entry_safe(vma, next, &ppgtt->base.inactive_list,
-                                mm_list) {
+                                vm_link) {
                if (WARN_ON(__i915_vma_unbind_no_wait(vma)))
                        break;
        }
@@ -321,6 +321,18 @@ err_destroy:
        return ERR_PTR(ret);
 }
 
+static void i915_gem_context_unpin(struct intel_context *ctx,
+                                  struct intel_engine_cs *engine)
+{
+       if (i915.enable_execlists) {
+               intel_lr_context_unpin(ctx, engine);
+       } else {
+               if (engine->id == RCS && ctx->legacy_hw_ctx.rcs_state)
+                       i915_gem_object_ggtt_unpin(ctx->legacy_hw_ctx.rcs_state);
+               i915_gem_context_unreference(ctx);
+       }
+}
+
 void i915_gem_context_reset(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
@@ -329,22 +341,15 @@ void i915_gem_context_reset(struct drm_device *dev)
        if (i915.enable_execlists) {
                struct intel_context *ctx;
 
-               list_for_each_entry(ctx, &dev_priv->context_list, link) {
+               list_for_each_entry(ctx, &dev_priv->context_list, link)
                        intel_lr_context_reset(dev, ctx);
-               }
-
-               return;
        }
 
        for (i = 0; i < I915_NUM_RINGS; i++) {
                struct intel_engine_cs *ring = &dev_priv->ring[i];
-               struct intel_context *lctx = ring->last_context;
-
-               if (lctx) {
-                       if (lctx->legacy_hw_ctx.rcs_state && i == RCS)
-                               i915_gem_object_ggtt_unpin(lctx->legacy_hw_ctx.rcs_state);
 
-                       i915_gem_context_unreference(lctx);
+               if (ring->last_context) {
+                       i915_gem_context_unpin(ring->last_context, ring);
                        ring->last_context = NULL;
                }
        }
@@ -417,13 +422,6 @@ void i915_gem_context_fini(struct drm_device *dev)
                 * to offset the do_switch part, so that i915_gem_context_unreference()
                 * can then free the base object correctly. */
                WARN_ON(!dev_priv->ring[RCS].last_context);
-               if (dev_priv->ring[RCS].last_context == dctx) {
-                       /* Fake switch to NULL context */
-                       WARN_ON(dctx->legacy_hw_ctx.rcs_state->active);
-                       i915_gem_object_ggtt_unpin(dctx->legacy_hw_ctx.rcs_state);
-                       i915_gem_context_unreference(dctx);
-                       dev_priv->ring[RCS].last_context = NULL;
-               }
 
                i915_gem_object_ggtt_unpin(dctx->legacy_hw_ctx.rcs_state);
        }
@@ -432,7 +430,7 @@ void i915_gem_context_fini(struct drm_device *dev)
                struct intel_engine_cs *ring = &dev_priv->ring[i];
 
                if (ring->last_context) {
-                       i915_gem_context_unreference(ring->last_context);
+                       i915_gem_context_unpin(ring->last_context, ring);
                        ring->last_context = NULL;
                }
        }
@@ -857,6 +855,9 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
        if (!contexts_enabled(dev))
                return -ENODEV;
 
+       if (args->pad != 0)
+               return -EINVAL;
+
        ret = i915_mutex_lock_interruptible(dev);
        if (ret)
                return ret;
@@ -880,6 +881,9 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
        struct intel_context *ctx;
        int ret;
 
+       if (args->pad != 0)
+               return -EINVAL;
+
        if (args->ctx_id == DEFAULT_CONTEXT_HANDLE)
                return -ENOENT;
 
index 07c6e4d..ea1f8d1 100644 (file)
@@ -116,7 +116,7 @@ i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm,
 
 search_again:
        /* First see if there is a large enough contiguous idle region... */
-       list_for_each_entry(vma, &vm->inactive_list, mm_list) {
+       list_for_each_entry(vma, &vm->inactive_list, vm_link) {
                if (mark_free(vma, &unwind_list))
                        goto found;
        }
@@ -125,7 +125,7 @@ search_again:
                goto none;
 
        /* Now merge in the soon-to-be-expired objects... */
-       list_for_each_entry(vma, &vm->active_list, mm_list) {
+       list_for_each_entry(vma, &vm->active_list, vm_link) {
                if (mark_free(vma, &unwind_list))
                        goto found;
        }
@@ -270,7 +270,7 @@ int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle)
                WARN_ON(!list_empty(&vm->active_list));
        }
 
-       list_for_each_entry_safe(vma, next, &vm->inactive_list, mm_list)
+       list_for_each_entry_safe(vma, next, &vm->inactive_list, vm_link)
                if (vma->pin_count == 0)
                        WARN_ON(i915_vma_unbind(vma));
 
index 2dc08ce..1328bc5 100644 (file)
@@ -668,7 +668,7 @@ need_reloc_mappable(struct i915_vma *vma)
        if (entry->relocation_count == 0)
                return false;
 
-       if (!i915_is_ggtt(vma->vm))
+       if (!vma->is_ggtt)
                return false;
 
        /* See also use_cpu_reloc() */
@@ -687,8 +687,7 @@ eb_vma_misplaced(struct i915_vma *vma)
        struct drm_i915_gem_exec_object2 *entry = vma->exec_entry;
        struct drm_i915_gem_object *obj = vma->obj;
 
-       WARN_ON(entry->flags & __EXEC_OBJECT_NEEDS_MAP &&
-              !i915_is_ggtt(vma->vm));
+       WARN_ON(entry->flags & __EXEC_OBJECT_NEEDS_MAP && !vma->is_ggtt);
 
        if (entry->alignment &&
            vma->node.start & (entry->alignment - 1))
@@ -1401,6 +1400,7 @@ eb_select_ring(struct drm_i915_private *dev_priv,
                        bsd_idx = gen8_dispatch_bsd_ring(dev_priv, file);
                } else if (bsd_idx >= I915_EXEC_BSD_RING1 &&
                           bsd_idx <= I915_EXEC_BSD_RING2) {
+                       bsd_idx >>= I915_EXEC_BSD_SHIFT;
                        bsd_idx--;
                } else {
                        DRM_DEBUG("execbuf with unknown bsd ring: %u\n",
@@ -1654,7 +1654,7 @@ err:
         * must be freed again. If it was submitted then it is being tracked
         * on the active request list and no clean up is required here.
         */
-       if (ret && req)
+       if (ret && !IS_ERR_OR_NULL(req))
                i915_gem_request_cancel(req);
 
        mutex_unlock(&dev->struct_mutex);
index 7377b67..49e4f26 100644 (file)
@@ -2132,6 +2132,25 @@ static void i915_address_space_init(struct i915_address_space *vm,
        list_add_tail(&vm->global_link, &dev_priv->vm_list);
 }
 
+static void gtt_write_workarounds(struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+
+       /* This function is for gtt related workarounds. This function is
+        * called on driver load and after a GPU reset, so you can place
+        * workarounds here even if they get overwritten by GPU reset.
+        */
+       /* WaIncreaseDefaultTLBEntries:chv,bdw,skl,bxt */
+       if (IS_BROADWELL(dev))
+               I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN8_L3_LRA_1_GPGPU_DEFAULT_VALUE_BDW);
+       else if (IS_CHERRYVIEW(dev))
+               I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN8_L3_LRA_1_GPGPU_DEFAULT_VALUE_CHV);
+       else if (IS_SKYLAKE(dev))
+               I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_SKL);
+       else if (IS_BROXTON(dev))
+               I915_WRITE(GEN8_L3_LRA_1_GPGPU, GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_BXT);
+}
+
 int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
@@ -2148,6 +2167,8 @@ int i915_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)
 
 int i915_ppgtt_init_hw(struct drm_device *dev)
 {
+       gtt_write_workarounds(dev);
+
        /* In the case of execlists, PPGTT is enabled by the context descriptor
         * and the PDPs are contained within the context itself.  We don't
         * need to do anything here. */
@@ -2737,7 +2758,7 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,
                }
                vma->bound |= GLOBAL_BIND;
                __i915_vma_set_map_and_fenceable(vma);
-               list_add_tail(&vma->mm_list, &ggtt_vm->inactive_list);
+               list_add_tail(&vma->vm_link, &ggtt_vm->inactive_list);
        }
 
        /* Clear any non-preallocated blocks */
@@ -2809,6 +2830,8 @@ void i915_global_gtt_cleanup(struct drm_device *dev)
                ppgtt->base.cleanup(&ppgtt->base);
        }
 
+       i915_gem_cleanup_stolen(dev);
+
        if (drm_mm_initialized(&vm->mm)) {
                if (intel_vgpu_active(dev))
                        intel_vgt_deballoon();
@@ -3175,12 +3198,21 @@ int i915_gem_gtt_init(struct drm_device *dev)
        }
 
        gtt->base.dev = dev;
+       gtt->base.is_ggtt = true;
 
        ret = gtt->gtt_probe(dev, &gtt->base.total, &gtt->stolen_size,
                             &gtt->mappable_base, &gtt->mappable_end);
        if (ret)
                return ret;
 
+       /*
+        * Initialise stolen early so that we may reserve preallocated
+        * objects for the BIOS to KMS transition.
+        */
+       ret = i915_gem_init_stolen(dev);
+       if (ret)
+               goto out_gtt_cleanup;
+
        /* GMADR is the PCI mmio aperture into the global GTT. */
        DRM_INFO("Memory usable by graphics device = %lluM\n",
                 gtt->base.total >> 20);
@@ -3200,6 +3232,11 @@ int i915_gem_gtt_init(struct drm_device *dev)
        DRM_DEBUG_DRIVER("ppgtt mode: %i\n", i915.enable_ppgtt);
 
        return 0;
+
+out_gtt_cleanup:
+       gtt->base.cleanup(&dev_priv->gtt.base);
+
+       return ret;
 }
 
 void i915_gem_restore_gtt_mappings(struct drm_device *dev)
@@ -3222,7 +3259,7 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)
        vm = &dev_priv->gtt.base;
        list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
                flush = false;
-               list_for_each_entry(vma, &obj->vma_list, vma_link) {
+               list_for_each_entry(vma, &obj->vma_list, obj_link) {
                        if (vma->vm != vm)
                                continue;
 
@@ -3278,19 +3315,20 @@ __i915_gem_vma_create(struct drm_i915_gem_object *obj,
        if (vma == NULL)
                return ERR_PTR(-ENOMEM);
 
-       INIT_LIST_HEAD(&vma->vma_link);
-       INIT_LIST_HEAD(&vma->mm_list);
+       INIT_LIST_HEAD(&vma->vm_link);
+       INIT_LIST_HEAD(&vma->obj_link);
        INIT_LIST_HEAD(&vma->exec_list);
        vma->vm = vm;
        vma->obj = obj;
+       vma->is_ggtt = i915_is_ggtt(vm);
 
        if (i915_is_ggtt(vm))
                vma->ggtt_view = *ggtt_view;
-
-       list_add_tail(&vma->vma_link, &obj->vma_list);
-       if (!i915_is_ggtt(vm))
+       else
                i915_ppgtt_get(i915_vm_to_ppgtt(vm));
 
+       list_add_tail(&vma->obj_link, &obj->vma_list);
+
        return vma;
 }
 
@@ -3333,6 +3371,7 @@ i915_gem_obj_lookup_or_create_ggtt_vma(struct drm_i915_gem_object *obj,
 static struct scatterlist *
 rotate_pages(const dma_addr_t *in, unsigned int offset,
             unsigned int width, unsigned int height,
+            unsigned int stride,
             struct sg_table *st, struct scatterlist *sg)
 {
        unsigned int column, row;
@@ -3344,7 +3383,7 @@ rotate_pages(const dma_addr_t *in, unsigned int offset,
        }
 
        for (column = 0; column < width; column++) {
-               src_idx = width * (height - 1) + column;
+               src_idx = stride * (height - 1) + column;
                for (row = 0; row < height; row++) {
                        st->nents++;
                        /* We don't need the pages, but need to initialize
@@ -3355,7 +3394,7 @@ rotate_pages(const dma_addr_t *in, unsigned int offset,
                        sg_dma_address(sg) = in[offset + src_idx];
                        sg_dma_len(sg) = PAGE_SIZE;
                        sg = sg_next(sg);
-                       src_idx -= width;
+                       src_idx -= stride;
                }
        }
 
@@ -3363,10 +3402,9 @@ rotate_pages(const dma_addr_t *in, unsigned int offset,
 }
 
 static struct sg_table *
-intel_rotate_fb_obj_pages(struct i915_ggtt_view *ggtt_view,
+intel_rotate_fb_obj_pages(struct intel_rotation_info *rot_info,
                          struct drm_i915_gem_object *obj)
 {
-       struct intel_rotation_info *rot_info = &ggtt_view->params.rotation_info;
        unsigned int size_pages = rot_info->size >> PAGE_SHIFT;
        unsigned int size_pages_uv;
        struct sg_page_iter sg_iter;
@@ -3408,6 +3446,7 @@ intel_rotate_fb_obj_pages(struct i915_ggtt_view *ggtt_view,
        /* Rotate the pages. */
        sg = rotate_pages(page_addr_list, 0,
                     rot_info->width_pages, rot_info->height_pages,
+                    rot_info->width_pages,
                     st, NULL);
 
        /* Append the UV plane if NV12. */
@@ -3423,6 +3462,7 @@ intel_rotate_fb_obj_pages(struct i915_ggtt_view *ggtt_view,
                rotate_pages(page_addr_list, uv_start_page,
                             rot_info->width_pages_uv,
                             rot_info->height_pages_uv,
+                            rot_info->width_pages_uv,
                             st, sg);
        }
 
@@ -3504,7 +3544,7 @@ i915_get_ggtt_vma_pages(struct i915_vma *vma)
                vma->ggtt_view.pages = vma->obj->pages;
        else if (vma->ggtt_view.type == I915_GGTT_VIEW_ROTATED)
                vma->ggtt_view.pages =
-                       intel_rotate_fb_obj_pages(&vma->ggtt_view, vma->obj);
+                       intel_rotate_fb_obj_pages(&vma->ggtt_view.params.rotated, vma->obj);
        else if (vma->ggtt_view.type == I915_GGTT_VIEW_PARTIAL)
                vma->ggtt_view.pages =
                        intel_partial_pages(&vma->ggtt_view, vma->obj);
@@ -3560,13 +3600,9 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
                return 0;
 
        if (vma->bound == 0 && vma->vm->allocate_va_range) {
-               trace_i915_va_alloc(vma->vm,
-                                   vma->node.start,
-                                   vma->node.size,
-                                   VM_TO_TRACE_NAME(vma->vm));
-
                /* XXX: i915_vma_pin() will fix this +- hack */
                vma->pin_count++;
+               trace_i915_va_alloc(vma);
                ret = vma->vm->allocate_va_range(vma->vm,
                                                 vma->node.start,
                                                 vma->node.size);
@@ -3598,7 +3634,7 @@ i915_ggtt_view_size(struct drm_i915_gem_object *obj,
        if (view->type == I915_GGTT_VIEW_NORMAL) {
                return obj->base.size;
        } else if (view->type == I915_GGTT_VIEW_ROTATED) {
-               return view->params.rotation_info.size;
+               return view->params.rotated.size;
        } else if (view->type == I915_GGTT_VIEW_PARTIAL) {
                return view->params.partial.size << PAGE_SHIFT;
        } else {
index e573796..8774f1b 100644 (file)
@@ -155,7 +155,7 @@ struct i915_ggtt_view {
                        u64 offset;
                        unsigned int size;
                } partial;
-               struct intel_rotation_info rotation_info;
+               struct intel_rotation_info rotated;
        } params;
 
        struct sg_table *pages;
@@ -183,6 +183,7 @@ struct i915_vma {
 #define GLOBAL_BIND    (1<<0)
 #define LOCAL_BIND     (1<<1)
        unsigned int bound : 4;
+       bool is_ggtt : 1;
 
        /**
         * Support different GGTT views into the same object.
@@ -194,9 +195,9 @@ struct i915_vma {
        struct i915_ggtt_view ggtt_view;
 
        /** This object's place on the active/inactive lists */
-       struct list_head mm_list;
+       struct list_head vm_link;
 
-       struct list_head vma_link; /* Link in the object's VMA list */
+       struct list_head obj_link; /* Link in the object's VMA list */
 
        /** This vma's place in the batchbuffer or on the eviction list */
        struct list_head exec_list;
@@ -275,6 +276,8 @@ struct i915_address_space {
        u64 start;              /* Start offset always 0 for dri2 */
        u64 total;              /* size addr space maps (ex. 2GB for ggtt) */
 
+       bool is_ggtt;
+
        struct i915_page_scratch *scratch_page;
        struct i915_page_table *scratch_pt;
        struct i915_page_directory *scratch_pd;
@@ -330,6 +333,8 @@ struct i915_address_space {
                        u32 flags);
 };
 
+#define i915_is_ggtt(V) ((V)->is_ggtt)
+
 /* The Graphics Translation Table is the way in which GEN hardware translates a
  * Graphics Virtual Address into a Physical Address. In addition to the normal
  * collateral associated with any va->pa translations GEN hardware also has a
@@ -342,6 +347,8 @@ struct i915_gtt {
 
        size_t stolen_size;             /* Total size of stolen memory */
        size_t stolen_usable_size;      /* Total size minus BIOS reserved */
+       size_t stolen_reserved_base;
+       size_t stolen_reserved_size;
        u64 mappable_end;               /* End offset that we can CPU map */
        struct io_mapping *mappable;    /* Mapping to our CPU mappable region */
        phys_addr_t mappable_base;      /* PA of our GMADR */
@@ -416,7 +423,7 @@ static inline uint32_t i915_pte_index(uint64_t address, uint32_t pde_shift)
 static inline uint32_t i915_pte_count(uint64_t addr, size_t length,
                                      uint32_t pde_shift)
 {
-       const uint64_t mask = ~((1 << pde_shift) - 1);
+       const uint64_t mask = ~((1ULL << pde_shift) - 1);
        uint64_t end;
 
        WARN_ON(length == 0);
index 16da9c1..d3c473f 100644 (file)
@@ -52,7 +52,7 @@ static int num_vma_bound(struct drm_i915_gem_object *obj)
        struct i915_vma *vma;
        int count = 0;
 
-       list_for_each_entry(vma, &obj->vma_list, vma_link) {
+       list_for_each_entry(vma, &obj->vma_list, obj_link) {
                if (drm_mm_node_allocated(&vma->node))
                        count++;
                if (vma->pin_count)
@@ -176,7 +176,7 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,
 
                        /* For the unbound phase, this should be a no-op! */
                        list_for_each_entry_safe(vma, v,
-                                                &obj->vma_list, vma_link)
+                                                &obj->vma_list, obj_link)
                                if (i915_vma_unbind(vma))
                                        break;
 
@@ -367,8 +367,20 @@ void i915_gem_shrinker_init(struct drm_i915_private *dev_priv)
        dev_priv->mm.shrinker.scan_objects = i915_gem_shrinker_scan;
        dev_priv->mm.shrinker.count_objects = i915_gem_shrinker_count;
        dev_priv->mm.shrinker.seeks = DEFAULT_SEEKS;
-       register_shrinker(&dev_priv->mm.shrinker);
+       WARN_ON(register_shrinker(&dev_priv->mm.shrinker));
 
        dev_priv->mm.oom_notifier.notifier_call = i915_gem_shrinker_oom;
-       register_oom_notifier(&dev_priv->mm.oom_notifier);
+       WARN_ON(register_oom_notifier(&dev_priv->mm.oom_notifier));
+}
+
+/**
+ * i915_gem_shrinker_cleanup - Clean up i915 shrinker
+ * @dev_priv: i915 device
+ *
+ * This function unregisters the i915 shrinker and OOM handler.
+ */
+void i915_gem_shrinker_cleanup(struct drm_i915_private *dev_priv)
+{
+       WARN_ON(unregister_oom_notifier(&dev_priv->mm.oom_notifier));
+       unregister_shrinker(&dev_priv->mm.shrinker);
 }
index c384dc9..2e6e9fb 100644 (file)
@@ -458,6 +458,9 @@ int i915_gem_init_stolen(struct drm_device *dev)
                return 0;
        }
 
+       dev_priv->gtt.stolen_reserved_base = reserved_base;
+       dev_priv->gtt.stolen_reserved_size = reserved_size;
+
        /* It is possible for the reserved area to end before the end of stolen
         * memory, so just consider the start. */
        reserved_total = stolen_top - reserved_base;
@@ -635,6 +638,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
        if (!drm_mm_initialized(&dev_priv->mm.stolen))
                return NULL;
 
+       lockdep_assert_held(&dev->struct_mutex);
+
        DRM_DEBUG_KMS("creating preallocated stolen object: stolen_offset=%x, gtt_offset=%x, size=%x\n",
                        stolen_offset, gtt_offset, size);
 
@@ -692,7 +697,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
 
                vma->bound |= GLOBAL_BIND;
                __i915_vma_set_map_and_fenceable(vma);
-               list_add_tail(&vma->mm_list, &ggtt->inactive_list);
+               list_add_tail(&vma->vm_link, &ggtt->inactive_list);
        }
 
        list_add_tail(&obj->global_list, &dev_priv->mm.bound_list);
index 19fb0bd..4b09c84 100644 (file)
@@ -49,21 +49,18 @@ struct i915_mmu_notifier {
        struct hlist_node node;
        struct mmu_notifier mn;
        struct rb_root objects;
-       struct list_head linear;
-       bool has_linear;
 };
 
 struct i915_mmu_object {
        struct i915_mmu_notifier *mn;
+       struct drm_i915_gem_object *obj;
        struct interval_tree_node it;
        struct list_head link;
-       struct drm_i915_gem_object *obj;
        struct work_struct work;
-       bool active;
-       bool is_linear;
+       bool attached;
 };
 
-static void __cancel_userptr__worker(struct work_struct *work)
+static void cancel_userptr(struct work_struct *work)
 {
        struct i915_mmu_object *mo = container_of(work, typeof(*mo), work);
        struct drm_i915_gem_object *obj = mo->obj;
@@ -81,7 +78,7 @@ static void __cancel_userptr__worker(struct work_struct *work)
                was_interruptible = dev_priv->mm.interruptible;
                dev_priv->mm.interruptible = false;
 
-               list_for_each_entry_safe(vma, tmp, &obj->vma_list, vma_link) {
+               list_for_each_entry_safe(vma, tmp, &obj->vma_list, obj_link) {
                        int ret = i915_vma_unbind(vma);
                        WARN_ON(ret && ret != -EIO);
                }
@@ -94,24 +91,22 @@ static void __cancel_userptr__worker(struct work_struct *work)
        mutex_unlock(&dev->struct_mutex);
 }
 
-static unsigned long cancel_userptr(struct i915_mmu_object *mo)
+static void add_object(struct i915_mmu_object *mo)
 {
-       unsigned long end = mo->obj->userptr.ptr + mo->obj->base.size;
-
-       /* The mmu_object is released late when destroying the
-        * GEM object so it is entirely possible to gain a
-        * reference on an object in the process of being freed
-        * since our serialisation is via the spinlock and not
-        * the struct_mutex - and consequently use it after it
-        * is freed and then double free it.
-        */
-       if (mo->active && kref_get_unless_zero(&mo->obj->base.refcount)) {
-               schedule_work(&mo->work);
-               /* only schedule one work packet to avoid the refleak */
-               mo->active = false;
-       }
+       if (mo->attached)
+               return;
+
+       interval_tree_insert(&mo->it, &mo->mn->objects);
+       mo->attached = true;
+}
 
-       return end;
+static void del_object(struct i915_mmu_object *mo)
+{
+       if (!mo->attached)
+               return;
+
+       interval_tree_remove(&mo->it, &mo->mn->objects);
+       mo->attached = false;
 }
 
 static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn,
@@ -122,28 +117,36 @@ static void i915_gem_userptr_mn_invalidate_range_start(struct mmu_notifier *_mn,
        struct i915_mmu_notifier *mn =
                container_of(_mn, struct i915_mmu_notifier, mn);
        struct i915_mmu_object *mo;
+       struct interval_tree_node *it;
+       LIST_HEAD(cancelled);
+
+       if (RB_EMPTY_ROOT(&mn->objects))
+               return;
 
        /* interval ranges are inclusive, but invalidate range is exclusive */
        end--;
 
        spin_lock(&mn->lock);
-       if (mn->has_linear) {
-               list_for_each_entry(mo, &mn->linear, link) {
-                       if (mo->it.last < start || mo->it.start > end)
-                               continue;
-
-                       cancel_userptr(mo);
-               }
-       } else {
-               struct interval_tree_node *it;
+       it = interval_tree_iter_first(&mn->objects, start, end);
+       while (it) {
+               /* The mmu_object is released late when destroying the
+                * GEM object so it is entirely possible to gain a
+                * reference on an object in the process of being freed
+                * since our serialisation is via the spinlock and not
+                * the struct_mutex - and consequently use it after it
+                * is freed and then double free it. To prevent that
+                * use-after-free we only acquire a reference on the
+                * object if it is not in the process of being destroyed.
+                */
+               mo = container_of(it, struct i915_mmu_object, it);
+               if (kref_get_unless_zero(&mo->obj->base.refcount))
+                       schedule_work(&mo->work);
 
-               it = interval_tree_iter_first(&mn->objects, start, end);
-               while (it) {
-                       mo = container_of(it, struct i915_mmu_object, it);
-                       start = cancel_userptr(mo);
-                       it = interval_tree_iter_next(it, start, end);
-               }
+               list_add(&mo->link, &cancelled);
+               it = interval_tree_iter_next(it, start, end);
        }
+       list_for_each_entry(mo, &cancelled, link)
+               del_object(mo);
        spin_unlock(&mn->lock);
 }
 
@@ -164,8 +167,6 @@ i915_mmu_notifier_create(struct mm_struct *mm)
        spin_lock_init(&mn->lock);
        mn->mn.ops = &i915_gem_userptr_notifier;
        mn->objects = RB_ROOT;
-       INIT_LIST_HEAD(&mn->linear);
-       mn->has_linear = false;
 
         /* Protected by mmap_sem (write-lock) */
        ret = __mmu_notifier_register(&mn->mn, mm);
@@ -177,85 +178,6 @@ i915_mmu_notifier_create(struct mm_struct *mm)
        return mn;
 }
 
-static int
-i915_mmu_notifier_add(struct drm_device *dev,
-                     struct i915_mmu_notifier *mn,
-                     struct i915_mmu_object *mo)
-{
-       struct interval_tree_node *it;
-       int ret = 0;
-
-       /* By this point we have already done a lot of expensive setup that
-        * we do not want to repeat just because the caller (e.g. X) has a
-        * signal pending (and partly because of that expensive setup, X
-        * using an interrupt timer is likely to get stuck in an EINTR loop).
-        */
-       mutex_lock(&dev->struct_mutex);
-
-       /* Make sure we drop the final active reference (and thereby
-        * remove the objects from the interval tree) before we do
-        * the check for overlapping objects.
-        */
-       i915_gem_retire_requests(dev);
-
-       spin_lock(&mn->lock);
-       it = interval_tree_iter_first(&mn->objects,
-                                     mo->it.start, mo->it.last);
-       if (it) {
-               struct drm_i915_gem_object *obj;
-
-               /* We only need to check the first object in the range as it
-                * either has cancelled gup work queued and we need to
-                * return back to the user to give time for the gup-workers
-                * to flush their object references upon which the object will
-                * be removed from the interval-tree, or the the range is
-                * still in use by another client and the overlap is invalid.
-                *
-                * If we do have an overlap, we cannot use the interval tree
-                * for fast range invalidation.
-                */
-
-               obj = container_of(it, struct i915_mmu_object, it)->obj;
-               if (!obj->userptr.workers)
-                       mn->has_linear = mo->is_linear = true;
-               else
-                       ret = -EAGAIN;
-       } else
-               interval_tree_insert(&mo->it, &mn->objects);
-
-       if (ret == 0)
-               list_add(&mo->link, &mn->linear);
-
-       spin_unlock(&mn->lock);
-       mutex_unlock(&dev->struct_mutex);
-
-       return ret;
-}
-
-static bool i915_mmu_notifier_has_linear(struct i915_mmu_notifier *mn)
-{
-       struct i915_mmu_object *mo;
-
-       list_for_each_entry(mo, &mn->linear, link)
-               if (mo->is_linear)
-                       return true;
-
-       return false;
-}
-
-static void
-i915_mmu_notifier_del(struct i915_mmu_notifier *mn,
-                     struct i915_mmu_object *mo)
-{
-       spin_lock(&mn->lock);
-       list_del(&mo->link);
-       if (mo->is_linear)
-               mn->has_linear = i915_mmu_notifier_has_linear(mn);
-       else
-               interval_tree_remove(&mo->it, &mn->objects);
-       spin_unlock(&mn->lock);
-}
-
 static void
 i915_gem_userptr_release__mmu_notifier(struct drm_i915_gem_object *obj)
 {
@@ -265,7 +187,9 @@ i915_gem_userptr_release__mmu_notifier(struct drm_i915_gem_object *obj)
        if (mo == NULL)
                return;
 
-       i915_mmu_notifier_del(mo->mn, mo);
+       spin_lock(&mo->mn->lock);
+       del_object(mo);
+       spin_unlock(&mo->mn->lock);
        kfree(mo);
 
        obj->userptr.mmu_object = NULL;
@@ -299,7 +223,6 @@ i915_gem_userptr_init__mmu_notifier(struct drm_i915_gem_object *obj,
 {
        struct i915_mmu_notifier *mn;
        struct i915_mmu_object *mo;
-       int ret;
 
        if (flags & I915_USERPTR_UNSYNCHRONIZED)
                return capable(CAP_SYS_ADMIN) ? 0 : -EPERM;
@@ -316,16 +239,10 @@ i915_gem_userptr_init__mmu_notifier(struct drm_i915_gem_object *obj,
                return -ENOMEM;
 
        mo->mn = mn;
-       mo->it.start = obj->userptr.ptr;
-       mo->it.last = mo->it.start + obj->base.size - 1;
        mo->obj = obj;
-       INIT_WORK(&mo->work, __cancel_userptr__worker);
-
-       ret = i915_mmu_notifier_add(obj->base.dev, mn, mo);
-       if (ret) {
-               kfree(mo);
-               return ret;
-       }
+       mo->it.start = obj->userptr.ptr;
+       mo->it.last = obj->userptr.ptr + obj->base.size - 1;
+       INIT_WORK(&mo->work, cancel_userptr);
 
        obj->userptr.mmu_object = mo;
        return 0;
@@ -552,8 +469,10 @@ __i915_gem_userptr_set_active(struct drm_i915_gem_object *obj,
        /* In order to serialise get_pages with an outstanding
         * cancel_userptr, we must drop the struct_mutex and try again.
         */
-       if (!value || !work_pending(&obj->userptr.mmu_object->work))
-               obj->userptr.mmu_object->active = value;
+       if (!value)
+               del_object(obj->userptr.mmu_object);
+       else if (!work_pending(&obj->userptr.mmu_object->work))
+               add_object(obj->userptr.mmu_object);
        else
                ret = -EAGAIN;
        spin_unlock(&obj->userptr.mmu_object->mn->lock);
@@ -789,9 +708,10 @@ i915_gem_userptr_dmabuf_export(struct drm_i915_gem_object *obj)
 }
 
 static const struct drm_i915_gem_object_ops i915_gem_userptr_ops = {
-       .dmabuf_export = i915_gem_userptr_dmabuf_export,
+       .flags = I915_GEM_OBJECT_HAS_STRUCT_PAGE,
        .get_pages = i915_gem_userptr_get_pages,
        .put_pages = i915_gem_userptr_put_pages,
+       .dmabuf_export = i915_gem_userptr_dmabuf_export,
        .release = i915_gem_userptr_release,
 };
 
index 7eeb244..831895b 100644 (file)
@@ -365,6 +365,10 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m,
        err_printf(m, "Reset count: %u\n", error->reset_count);
        err_printf(m, "Suspend count: %u\n", error->suspend_count);
        err_printf(m, "PCI ID: 0x%04x\n", dev->pdev->device);
+       err_printf(m, "PCI Revision: 0x%02x\n", dev->pdev->revision);
+       err_printf(m, "PCI Subsystem: %04x:%04x\n",
+                  dev->pdev->subsystem_vendor,
+                  dev->pdev->subsystem_device);
        err_printf(m, "IOMMU enabled?: %d\n", error->iommu);
 
        if (HAS_CSR(dev)) {
@@ -732,7 +736,7 @@ static u32 capture_active_bo(struct drm_i915_error_buffer *err,
        struct i915_vma *vma;
        int i = 0;
 
-       list_for_each_entry(vma, head, mm_list) {
+       list_for_each_entry(vma, head, vm_link) {
                capture_bo(err++, vma);
                if (++i == count)
                        break;
@@ -755,7 +759,7 @@ static u32 capture_pinned_bo(struct drm_i915_error_buffer *err,
                if (err == last)
                        break;
 
-               list_for_each_entry(vma, &obj->vma_list, vma_link)
+               list_for_each_entry(vma, &obj->vma_list, obj_link)
                        if (vma->vm == vm && vma->pin_count > 0)
                                capture_bo(err++, vma);
        }
@@ -1123,12 +1127,12 @@ static void i915_gem_capture_vm(struct drm_i915_private *dev_priv,
        int i;
 
        i = 0;
-       list_for_each_entry(vma, &vm->active_list, mm_list)
+       list_for_each_entry(vma, &vm->active_list, vm_link)
                i++;
        error->active_bo_count[ndx] = i;
 
        list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
-               list_for_each_entry(vma, &obj->vma_list, vma_link)
+               list_for_each_entry(vma, &obj->vma_list, obj_link)
                        if (vma->vm == vm && vma->pin_count > 0)
                                i++;
        }
index 51ae5c1..d7543ef 100644 (file)
@@ -376,6 +376,8 @@ static void guc_init_proc_desc(struct intel_guc *guc,
 static void guc_init_ctx_desc(struct intel_guc *guc,
                              struct i915_guc_client *client)
 {
+       struct drm_i915_private *dev_priv = guc_to_i915(guc);
+       struct intel_engine_cs *ring;
        struct intel_context *ctx = client->owner;
        struct guc_context_desc desc;
        struct sg_table *sg;
@@ -388,10 +390,8 @@ static void guc_init_ctx_desc(struct intel_guc *guc,
        desc.priority = client->priority;
        desc.db_id = client->doorbell_id;
 
-       for (i = 0; i < I915_NUM_RINGS; i++) {
-               struct guc_execlist_context *lrc = &desc.lrc[i];
-               struct intel_ringbuffer *ringbuf = ctx->engine[i].ringbuf;
-               struct intel_engine_cs *ring;
+       for_each_ring(ring, dev_priv, i) {
+               struct guc_execlist_context *lrc = &desc.lrc[ring->guc_id];
                struct drm_i915_gem_object *obj;
                uint64_t ctx_desc;
 
@@ -406,7 +406,6 @@ static void guc_init_ctx_desc(struct intel_guc *guc,
                if (!obj)
                        break;  /* XXX: continue? */
 
-               ring = ringbuf->ring;
                ctx_desc = intel_lr_context_descriptor(ctx, ring);
                lrc->context_desc = (u32)ctx_desc;
 
@@ -414,16 +413,16 @@ static void guc_init_ctx_desc(struct intel_guc *guc,
                lrc->ring_lcra = i915_gem_obj_ggtt_offset(obj) +
                                LRC_STATE_PN * PAGE_SIZE;
                lrc->context_id = (client->ctx_index << GUC_ELC_CTXID_OFFSET) |
-                               (ring->id << GUC_ELC_ENGINE_OFFSET);
+                               (ring->guc_id << GUC_ELC_ENGINE_OFFSET);
 
-               obj = ringbuf->obj;
+               obj = ctx->engine[i].ringbuf->obj;
 
                lrc->ring_begin = i915_gem_obj_ggtt_offset(obj);
                lrc->ring_end = lrc->ring_begin + obj->base.size - 1;
                lrc->ring_next_free_location = lrc->ring_begin;
                lrc->ring_current_tail_pointer_value = 0;
 
-               desc.engines_used |= (1 << ring->id);
+               desc.engines_used |= (1 << ring->guc_id);
        }
 
        WARN_ON(desc.engines_used == 0);
@@ -510,7 +509,6 @@ int i915_guc_wq_check_space(struct i915_guc_client *gc)
 static int guc_add_workqueue_item(struct i915_guc_client *gc,
                                  struct drm_i915_gem_request *rq)
 {
-       enum intel_ring_id ring_id = rq->ring->id;
        struct guc_wq_item *wqi;
        void *base;
        u32 tail, wq_len, wq_off, space;
@@ -544,7 +542,7 @@ static int guc_add_workqueue_item(struct i915_guc_client *gc,
        wq_len = sizeof(struct guc_wq_item) / sizeof(u32) - 1;
        wqi->header = WQ_TYPE_INORDER |
                        (wq_len << WQ_LEN_SHIFT) |
-                       (ring_id << WQ_TARGET_SHIFT) |
+                       (rq->ring->guc_id << WQ_TARGET_SHIFT) |
                        WQ_NO_WCFLUSH_WAIT;
 
        /* The GuC wants only the low-order word of the context descriptor */
@@ -560,29 +558,6 @@ static int guc_add_workqueue_item(struct i915_guc_client *gc,
        return 0;
 }
 
-#define CTX_RING_BUFFER_START          0x08
-
-/* Update the ringbuffer pointer in a saved context image */
-static void lr_context_update(struct drm_i915_gem_request *rq)
-{
-       enum intel_ring_id ring_id = rq->ring->id;
-       struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring_id].state;
-       struct drm_i915_gem_object *rb_obj = rq->ringbuf->obj;
-       struct page *page;
-       uint32_t *reg_state;
-
-       BUG_ON(!ctx_obj);
-       WARN_ON(!i915_gem_obj_is_pinned(ctx_obj));
-       WARN_ON(!i915_gem_obj_is_pinned(rb_obj));
-
-       page = i915_gem_object_get_dirty_page(ctx_obj, LRC_STATE_PN);
-       reg_state = kmap_atomic(page);
-
-       reg_state[CTX_RING_BUFFER_START+1] = i915_gem_obj_ggtt_offset(rb_obj);
-
-       kunmap_atomic(reg_state);
-}
-
 /**
  * i915_guc_submit() - Submit commands through GuC
  * @client:    the guc client where commands will go through
@@ -594,18 +569,14 @@ int i915_guc_submit(struct i915_guc_client *client,
                    struct drm_i915_gem_request *rq)
 {
        struct intel_guc *guc = client->guc;
-       enum intel_ring_id ring_id = rq->ring->id;
+       unsigned int engine_id = rq->ring->guc_id;
        int q_ret, b_ret;
 
-       /* Need this because of the deferred pin ctx and ring */
-       /* Shall we move this right after ring is pinned? */
-       lr_context_update(rq);
-
        q_ret = guc_add_workqueue_item(client, rq);
        if (q_ret == 0)
                b_ret = guc_ring_doorbell(client);
 
-       client->submissions[ring_id] += 1;
+       client->submissions[engine_id] += 1;
        if (q_ret) {
                client->q_fail += 1;
                client->retcode = q_ret;
@@ -615,8 +586,8 @@ int i915_guc_submit(struct i915_guc_client *client,
        } else {
                client->retcode = 0;
        }
-       guc->submissions[ring_id] += 1;
-       guc->last_seqno[ring_id] = rq->seqno;
+       guc->submissions[engine_id] += 1;
+       guc->last_seqno[engine_id] = rq->seqno;
 
        return q_ret;
 }
@@ -848,7 +819,7 @@ static void init_guc_policies(struct guc_policies *policies)
        policies->max_num_work_items = POLICY_MAX_NUM_WI;
 
        for (p = 0; p < GUC_CTX_PRIORITY_NUM; p++) {
-               for (i = 0; i < I915_NUM_RINGS; i++) {
+               for (i = GUC_RENDER_ENGINE; i < GUC_MAX_ENGINES_NUM; i++) {
                        policy = &policies->policy[p][i];
 
                        policy->execution_quantum = 1000000;
@@ -900,7 +871,7 @@ static void guc_create_ads(struct intel_guc *guc)
        ads->golden_context_lrca = ring->status_page.gfx_addr;
 
        for_each_ring(ring, dev_priv, i)
-               ads->eng_state_size[i] = intel_lr_context_size(ring);
+               ads->eng_state_size[ring->guc_id] = intel_lr_context_size(ring);
 
        /* GuC scheduling policies */
        policies = (void *)ads + sizeof(struct guc_ads);
@@ -912,12 +883,12 @@ static void guc_create_ads(struct intel_guc *guc)
        /* MMIO reg state */
        reg_state = (void *)policies + sizeof(struct guc_policies);
 
-       for (i = 0; i < I915_NUM_RINGS; i++) {
-               reg_state->mmio_white_list[i].mmio_start =
-                       dev_priv->ring[i].mmio_base + GUC_MMIO_WHITE_LIST_START;
+       for_each_ring(ring, dev_priv, i) {
+               reg_state->mmio_white_list[ring->guc_id].mmio_start =
+                       ring->mmio_base + GUC_MMIO_WHITE_LIST_START;
 
                /* Nothing to be saved or restored for now. */
-               reg_state->mmio_white_list[i].count = 0;
+               reg_state->mmio_white_list[ring->guc_id].count = 0;
        }
 
        ads->reg_state_addr = ads->scheduler_policies +
index 25a8937..d1a46ef 100644 (file)
@@ -1651,6 +1651,12 @@ static void valleyview_pipestat_irq_handler(struct drm_device *dev, u32 iir)
        int pipe;
 
        spin_lock(&dev_priv->irq_lock);
+
+       if (!dev_priv->display_irqs_enabled) {
+               spin_unlock(&dev_priv->irq_lock);
+               return;
+       }
+
        for_each_pipe(dev_priv, pipe) {
                i915_reg_t reg;
                u32 mask, iir_bit = 0;
@@ -3343,21 +3349,28 @@ void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
                                     unsigned int pipe_mask)
 {
        uint32_t extra_ier = GEN8_PIPE_VBLANK | GEN8_PIPE_FIFO_UNDERRUN;
+       enum pipe pipe;
+
+       spin_lock_irq(&dev_priv->irq_lock);
+       for_each_pipe_masked(dev_priv, pipe, pipe_mask)
+               GEN8_IRQ_INIT_NDX(DE_PIPE, pipe,
+                                 dev_priv->de_irq_mask[pipe],
+                                 ~dev_priv->de_irq_mask[pipe] | extra_ier);
+       spin_unlock_irq(&dev_priv->irq_lock);
+}
+
+void gen8_irq_power_well_pre_disable(struct drm_i915_private *dev_priv,
+                                    unsigned int pipe_mask)
+{
+       enum pipe pipe;
 
        spin_lock_irq(&dev_priv->irq_lock);
-       if (pipe_mask & 1 << PIPE_A)
-               GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_A,
-                                 dev_priv->de_irq_mask[PIPE_A],
-                                 ~dev_priv->de_irq_mask[PIPE_A] | extra_ier);
-       if (pipe_mask & 1 << PIPE_B)
-               GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_B,
-                                 dev_priv->de_irq_mask[PIPE_B],
-                                 ~dev_priv->de_irq_mask[PIPE_B] | extra_ier);
-       if (pipe_mask & 1 << PIPE_C)
-               GEN8_IRQ_INIT_NDX(DE_PIPE, PIPE_C,
-                                 dev_priv->de_irq_mask[PIPE_C],
-                                 ~dev_priv->de_irq_mask[PIPE_C] | extra_ier);
+       for_each_pipe_masked(dev_priv, pipe, pipe_mask)
+               GEN8_IRQ_RESET_NDX(DE_PIPE, pipe);
        spin_unlock_irq(&dev_priv->irq_lock);
+
+       /* make sure we're done processing display irqs */
+       synchronize_irq(dev_priv->dev->irq);
 }
 
 static void cherryview_irq_preinstall(struct drm_device *dev)
index 8d90c25..278c9c4 100644 (file)
@@ -38,7 +38,7 @@ struct i915_params i915 __read_mostly = {
        .enable_execlists = -1,
        .enable_hangcheck = true,
        .enable_ppgtt = -1,
-       .enable_psr = 0,
+       .enable_psr = -1,
        .preliminary_hw_support = IS_ENABLED(CONFIG_DRM_I915_PRELIMINARY_HW_SUPPORT),
        .disable_power_well = -1,
        .enable_ips = 1,
@@ -49,7 +49,6 @@ struct i915_params i915 __read_mostly = {
        .invert_brightness = 0,
        .disable_display = 0,
        .enable_cmd_parser = 1,
-       .disable_vtd_wa = 0,
        .use_mmio_flip = 0,
        .mmio_debug = 0,
        .verbose_state_checks = 1,
@@ -92,7 +91,7 @@ MODULE_PARM_DESC(enable_fbc,
        "Enable frame buffer compression for power savings "
        "(default: -1 (use per-chip default))");
 
-module_param_named_unsafe(lvds_channel_mode, i915.lvds_channel_mode, int, 0600);
+module_param_named_unsafe(lvds_channel_mode, i915.lvds_channel_mode, int, 0400);
 MODULE_PARM_DESC(lvds_channel_mode,
         "Specify LVDS channel mode "
         "(0=probe BIOS [default], 1=single-channel, 2=dual-channel)");
@@ -102,7 +101,7 @@ MODULE_PARM_DESC(lvds_use_ssc,
        "Use Spread Spectrum Clock with panels [LVDS/eDP] "
        "(default: auto from VBT)");
 
-module_param_named_unsafe(vbt_sdvo_panel_type, i915.vbt_sdvo_panel_type, int, 0600);
+module_param_named_unsafe(vbt_sdvo_panel_type, i915.vbt_sdvo_panel_type, int, 0400);
 MODULE_PARM_DESC(vbt_sdvo_panel_type,
        "Override/Ignore selection of SDVO panel mode in the VBT "
        "(-2=ignore, -1=auto [default], index in VBT BIOS table)");
@@ -127,9 +126,11 @@ MODULE_PARM_DESC(enable_execlists,
        "(-1=auto [default], 0=disabled, 1=enabled)");
 
 module_param_named_unsafe(enable_psr, i915.enable_psr, int, 0600);
-MODULE_PARM_DESC(enable_psr, "Enable PSR (default: false)");
+MODULE_PARM_DESC(enable_psr, "Enable PSR "
+                "(0=disabled, 1=enabled - link mode chosen per-platform, 2=force link-standby mode, 3=force link-off mode) "
+                "Default: -1 (use per-chip default)");
 
-module_param_named_unsafe(preliminary_hw_support, i915.preliminary_hw_support, int, 0600);
+module_param_named_unsafe(preliminary_hw_support, i915.preliminary_hw_support, int, 0400);
 MODULE_PARM_DESC(preliminary_hw_support,
        "Enable preliminary hardware support.");
 
@@ -163,12 +164,9 @@ MODULE_PARM_DESC(invert_brightness,
        "to dri-devel@lists.freedesktop.org, if your machine needs it. "
        "It will then be included in an upcoming module version.");
 
-module_param_named(disable_display, i915.disable_display, bool, 0600);
+module_param_named(disable_display, i915.disable_display, bool, 0400);
 MODULE_PARM_DESC(disable_display, "Disable display (default: false)");
 
-module_param_named_unsafe(disable_vtd_wa, i915.disable_vtd_wa, bool, 0600);
-MODULE_PARM_DESC(disable_vtd_wa, "Disable all VT-d workarounds (default: false)");
-
 module_param_named_unsafe(enable_cmd_parser, i915.enable_cmd_parser, int, 0600);
 MODULE_PARM_DESC(enable_cmd_parser,
                 "Enable command parsing (1=enabled [default], 0=disabled)");
index 5299290..bd5026b 100644 (file)
@@ -56,7 +56,6 @@ struct i915_params {
        bool load_detect_test;
        bool reset;
        bool disable_display;
-       bool disable_vtd_wa;
        bool enable_guc_submission;
        bool verbose_state_checks;
        bool nuclear_pageflip;
index 0a98889..f76cbf3 100644 (file)
@@ -610,16 +610,17 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
 #define   IOSF_BYTE_ENABLES_SHIFT              4
 #define   IOSF_BAR_SHIFT                       1
 #define   IOSF_SB_BUSY                         (1<<0)
-#define   IOSF_PORT_BUNIT                      0x3
-#define   IOSF_PORT_PUNIT                      0x4
+#define   IOSF_PORT_BUNIT                      0x03
+#define   IOSF_PORT_PUNIT                      0x04
 #define   IOSF_PORT_NC                         0x11
 #define   IOSF_PORT_DPIO                       0x12
-#define   IOSF_PORT_DPIO_2                     0x1a
 #define   IOSF_PORT_GPIO_NC                    0x13
 #define   IOSF_PORT_CCK                                0x14
-#define   IOSF_PORT_CCU                                0xA9
-#define   IOSF_PORT_GPS_CORE                   0x48
-#define   IOSF_PORT_FLISDSI                    0x1B
+#define   IOSF_PORT_DPIO_2                     0x1a
+#define   IOSF_PORT_FLISDSI                    0x1b
+#define   IOSF_PORT_GPIO_SC                    0x48
+#define   IOSF_PORT_GPIO_SUS                   0xa8
+#define   IOSF_PORT_CCU                                0xa9
 #define VLV_IOSF_DATA                          _MMIO(VLV_DISPLAY_BASE + 0x2104)
 #define VLV_IOSF_ADDR                          _MMIO(VLV_DISPLAY_BASE + 0x2108)
 
@@ -1635,6 +1636,9 @@ enum skl_disp_power_wells {
 #define   RING_WAIT            (1<<11) /* gen3+, PRBx_CTL */
 #define   RING_WAIT_SEMAPHORE  (1<<10) /* gen6+ */
 
+#define RING_FORCE_TO_NONPRIV(base, i) _MMIO(((base)+0x4D0) + (i)*4)
+#define   RING_MAX_NONPRIV_SLOTS  12
+
 #define GEN7_TLB_RD_ADDR       _MMIO(0x4700)
 
 #if 0
@@ -3292,19 +3296,20 @@ enum skl_disp_power_wells {
 
 #define PORT_HOTPLUG_STAT      _MMIO(dev_priv->info.display_mmio_offset + 0x61114)
 /*
- * HDMI/DP bits are gen4+
+ * HDMI/DP bits are g4x+
  *
  * WARNING: Bspec for hpd status bits on gen4 seems to be completely confused.
  * Please check the detailed lore in the commit message for for experimental
  * evidence.
  */
-#define   PORTD_HOTPLUG_LIVE_STATUS_G4X                (1 << 29)
+/* Bspec says GM45 should match G4X/VLV/CHV, but reality disagrees */
+#define   PORTD_HOTPLUG_LIVE_STATUS_GM45       (1 << 29)
+#define   PORTC_HOTPLUG_LIVE_STATUS_GM45       (1 << 28)
+#define   PORTB_HOTPLUG_LIVE_STATUS_GM45       (1 << 27)
+/* G4X/VLV/CHV DP/HDMI bits again match Bspec */
+#define   PORTD_HOTPLUG_LIVE_STATUS_G4X                (1 << 27)
 #define   PORTC_HOTPLUG_LIVE_STATUS_G4X                (1 << 28)
-#define   PORTB_HOTPLUG_LIVE_STATUS_G4X                (1 << 27)
-/* VLV DP/HDMI bits again match Bspec */
-#define   PORTD_HOTPLUG_LIVE_STATUS_VLV                (1 << 27)
-#define   PORTC_HOTPLUG_LIVE_STATUS_VLV                (1 << 28)
-#define   PORTB_HOTPLUG_LIVE_STATUS_VLV                (1 << 29)
+#define   PORTB_HOTPLUG_LIVE_STATUS_G4X                (1 << 29)
 #define   PORTD_HOTPLUG_INT_STATUS             (3 << 21)
 #define   PORTD_HOTPLUG_INT_LONG_PULSE         (2 << 21)
 #define   PORTD_HOTPLUG_INT_SHORT_PULSE                (1 << 21)
@@ -5945,6 +5950,7 @@ enum skl_disp_power_wells {
 #define  ILK_INTERNAL_GRAPHICS_DISABLE (1 << 31)
 #define  ILK_INTERNAL_DISPLAY_DISABLE  (1 << 30)
 #define  ILK_DISPLAY_DEBUG_DISABLE     (1 << 29)
+#define  IVB_PIPE_C_DISABLE            (1 << 28)
 #define  ILK_HDCP_DISABLE              (1 << 25)
 #define  ILK_eDP_A_DISABLE             (1 << 24)
 #define  HSW_CDCLK_LIMIT               (1 << 24)
@@ -5991,10 +5997,19 @@ enum skl_disp_power_wells {
 #define SKL_DFSM_CDCLK_LIMIT_540       (1 << 23)
 #define SKL_DFSM_CDCLK_LIMIT_450       (2 << 23)
 #define SKL_DFSM_CDCLK_LIMIT_337_5     (3 << 23)
+#define SKL_DFSM_PIPE_A_DISABLE                (1 << 30)
+#define SKL_DFSM_PIPE_B_DISABLE                (1 << 21)
+#define SKL_DFSM_PIPE_C_DISABLE                (1 << 28)
+
+#define GEN7_FF_SLICE_CS_CHICKEN1      _MMIO(0x20e0)
+#define   GEN9_FFSC_PERCTX_PREEMPT_CTRL        (1<<14)
 
 #define FF_SLICE_CS_CHICKEN2                   _MMIO(0x20e4)
 #define  GEN9_TSG_BARRIER_ACK_DISABLE          (1<<8)
 
+#define GEN9_CS_DEBUG_MODE1            _MMIO(0x20ec)
+#define GEN8_CS_CHICKEN1               _MMIO(0x2580)
+
 /* GEN7 chicken */
 #define GEN7_COMMON_SLICE_CHICKEN1             _MMIO(0x7010)
 # define GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC     ((1<<10) | (1<<26))
@@ -6040,6 +6055,8 @@ enum skl_disp_power_wells {
 #define  HDC_FORCE_NON_COHERENT                        (1<<4)
 #define  HDC_BARRIER_PERFORMANCE_DISABLE       (1<<10)
 
+#define GEN8_HDC_CHICKEN1                      _MMIO(0x7304)
+
 /* GEN9 chicken */
 #define SLICE_ECO_CHICKEN0                     _MMIO(0x7308)
 #define   PIXEL_MASK_CAMMING_DISABLE           (1 << 14)
@@ -6770,6 +6787,16 @@ enum skl_disp_power_wells {
 
 #define  VLV_PMWGICZ                           _MMIO(0x1300a4)
 
+#define  RC6_LOCATION                          _MMIO(0xD40)
+#define           RC6_CTX_IN_DRAM                      (1 << 0)
+#define  RC6_CTX_BASE                          _MMIO(0xD48)
+#define    RC6_CTX_BASE_MASK                   0xFFFFFFF0
+#define  PWRCTX_MAXCNT_RCSUNIT                 _MMIO(0x2054)
+#define  PWRCTX_MAXCNT_VCSUNIT0                        _MMIO(0x12054)
+#define  PWRCTX_MAXCNT_BCSUNIT                 _MMIO(0x22054)
+#define  PWRCTX_MAXCNT_VECSUNIT                        _MMIO(0x1A054)
+#define  PWRCTX_MAXCNT_VCSUNIT1                        _MMIO(0x1C054)
+#define    IDLE_TIME_MASK                      0xFFFFF
 #define  FORCEWAKE                             _MMIO(0xA18C)
 #define  FORCEWAKE_VLV                         _MMIO(0x1300b0)
 #define  FORCEWAKE_ACK_VLV                     _MMIO(0x1300b4)
@@ -6908,6 +6935,7 @@ enum skl_disp_power_wells {
 #define GEN6_RPDEUC                            _MMIO(0xA084)
 #define GEN6_RPDEUCSW                          _MMIO(0xA088)
 #define GEN6_RC_STATE                          _MMIO(0xA094)
+#define   RC6_STATE                            (1 << 18)
 #define GEN6_RC1_WAKE_RATE_LIMIT               _MMIO(0xA098)
 #define GEN6_RC6_WAKE_RATE_LIMIT               _MMIO(0xA09C)
 #define GEN6_RC6pp_WAKE_RATE_LIMIT             _MMIO(0xA0A0)
@@ -7519,7 +7547,7 @@ enum skl_disp_power_wells {
 #define  DPLL_CFGCR2_PDIV_7 (4<<2)
 #define  DPLL_CFGCR2_CENTRAL_FREQ_MASK (3)
 
-#define DPLL_CFGCR1(id)        _MMIO_PIPE((id) - SKL_DPLL1, _DPLL1_CFGCR1, _DPLL2_CFGCR2)
+#define DPLL_CFGCR1(id)        _MMIO_PIPE((id) - SKL_DPLL1, _DPLL1_CFGCR1, _DPLL2_CFGCR1)
 #define DPLL_CFGCR2(id)        _MMIO_PIPE((id) - SKL_DPLL1, _DPLL1_CFGCR2, _DPLL2_CFGCR2)
 
 /* BXT display engine PLL */
@@ -7540,6 +7568,7 @@ enum skl_disp_power_wells {
 #define  DC_STATE_EN_UPTO_DC5_DC6_MASK   0x3
 
 #define  DC_STATE_DEBUG                  _MMIO(0x45520)
+#define  DC_STATE_DEBUG_MASK_CORES     (1<<0)
 #define  DC_STATE_DEBUG_MASK_MEMORY_UP (1<<1)
 
 /* Please see hsw_read_dcomp() and hsw_write_dcomp() before using this register,
@@ -8159,4 +8188,11 @@ enum skl_disp_power_wells {
 #define GEN9_VEBOX_MOCS(i)     _MMIO(0xcb00 + (i) * 4) /* Video MOCS registers */
 #define GEN9_BLT_MOCS(i)       _MMIO(0xcc00 + (i) * 4) /* Blitter MOCS registers */
 
+/* gamt regs */
+#define GEN8_L3_LRA_1_GPGPU _MMIO(0x4dd4)
+#define   GEN8_L3_LRA_1_GPGPU_DEFAULT_VALUE_BDW  0x67F1427F /* max/min for LRA1/2 */
+#define   GEN8_L3_LRA_1_GPGPU_DEFAULT_VALUE_CHV  0x5FF101FF /* max/min for LRA1/2 */
+#define   GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_SKL  0x67F1427F /*    "        " */
+#define   GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_BXT  0x5FF101FF /*    "        " */
+
 #endif /* _I915_REG_H_ */
index a2aa09c..34e061a 100644 (file)
@@ -49,7 +49,7 @@ static void i915_save_display(struct drm_device *dev)
                dev_priv->regfile.savePP_ON_DELAYS = I915_READ(PCH_PP_ON_DELAYS);
                dev_priv->regfile.savePP_OFF_DELAYS = I915_READ(PCH_PP_OFF_DELAYS);
                dev_priv->regfile.savePP_DIVISOR = I915_READ(PCH_PP_DIVISOR);
-       } else if (!IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev)) {
+       } else if (INTEL_INFO(dev)->gen <= 4) {
                dev_priv->regfile.savePP_CONTROL = I915_READ(PP_CONTROL);
                dev_priv->regfile.savePP_ON_DELAYS = I915_READ(PP_ON_DELAYS);
                dev_priv->regfile.savePP_OFF_DELAYS = I915_READ(PP_OFF_DELAYS);
@@ -84,7 +84,7 @@ static void i915_restore_display(struct drm_device *dev)
                I915_WRITE(PCH_PP_OFF_DELAYS, dev_priv->regfile.savePP_OFF_DELAYS);
                I915_WRITE(PCH_PP_DIVISOR, dev_priv->regfile.savePP_DIVISOR);
                I915_WRITE(PCH_PP_CONTROL, dev_priv->regfile.savePP_CONTROL);
-       } else if (!IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev)) {
+       } else if (INTEL_INFO(dev)->gen <= 4) {
                I915_WRITE(PP_ON_DELAYS, dev_priv->regfile.savePP_ON_DELAYS);
                I915_WRITE(PP_OFF_DELAYS, dev_priv->regfile.savePP_OFF_DELAYS);
                I915_WRITE(PP_DIVISOR, dev_priv->regfile.savePP_DIVISOR);
@@ -92,7 +92,7 @@ static void i915_restore_display(struct drm_device *dev)
        }
 
        /* only restore FBC info on the platform that supports FBC*/
-       intel_fbc_disable(dev_priv);
+       intel_fbc_global_disable(dev_priv);
 
        /* restore FBC interval */
        if (HAS_FBC(dev) && INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev))
index 52b2d40..fa09e55 100644 (file)
@@ -175,35 +175,24 @@ TRACE_EVENT(i915_vma_unbind,
                      __entry->obj, __entry->offset, __entry->size, __entry->vm)
 );
 
-#define VM_TO_TRACE_NAME(vm) \
-       (i915_is_ggtt(vm) ? "G" : \
-                     "P")
-
-DECLARE_EVENT_CLASS(i915_va,
-       TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name),
-       TP_ARGS(vm, start, length, name),
+TRACE_EVENT(i915_va_alloc,
+       TP_PROTO(struct i915_vma *vma),
+       TP_ARGS(vma),
 
        TP_STRUCT__entry(
                __field(struct i915_address_space *, vm)
                __field(u64, start)
                __field(u64, end)
-               __string(name, name)
        ),
 
        TP_fast_assign(
-               __entry->vm = vm;
-               __entry->start = start;
-               __entry->end = start + length - 1;
-               __assign_str(name, name);
+               __entry->vm = vma->vm;
+               __entry->start = vma->node.start;
+               __entry->end = vma->node.start + vma->node.size - 1;
        ),
 
-       TP_printk("vm=%p (%s), 0x%llx-0x%llx",
-                 __entry->vm, __get_str(name),  __entry->start, __entry->end)
-);
-
-DEFINE_EVENT(i915_va, i915_va_alloc,
-            TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name),
-            TP_ARGS(vm, start, length, name)
+       TP_printk("vm=%p (%c), 0x%llx-0x%llx",
+                 __entry->vm, i915_is_ggtt(__entry->vm) ? 'G' : 'P',  __entry->start, __entry->end)
 );
 
 DECLARE_EVENT_CLASS(i915_px_entry,
index 4625f8a..8e579a8 100644 (file)
@@ -97,6 +97,7 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc)
        crtc_state->disable_lp_wm = false;
        crtc_state->disable_cxsr = false;
        crtc_state->wm_changed = false;
+       crtc_state->fb_changed = false;
 
        return &crtc_state->base;
 }
index 31f6d21..30f9214 100644 (file)
@@ -527,6 +527,8 @@ void intel_audio_codec_enable(struct intel_encoder *intel_encoder)
 
        mutex_lock(&dev_priv->av_mutex);
        intel_dig_port->audio_connector = connector;
+       /* referred in audio callbacks */
+       dev_priv->dig_port_map[port] = intel_encoder;
        mutex_unlock(&dev_priv->av_mutex);
 
        if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
@@ -554,6 +556,7 @@ void intel_audio_codec_disable(struct intel_encoder *intel_encoder)
 
        mutex_lock(&dev_priv->av_mutex);
        intel_dig_port->audio_connector = NULL;
+       dev_priv->dig_port_map[port] = NULL;
        mutex_unlock(&dev_priv->av_mutex);
 
        if (acomp && acomp->audio_ops && acomp->audio_ops->pin_eld_notify)
index 9c89df1..505fc5c 100644 (file)
@@ -71,22 +71,29 @@ static bool intel_crt_get_hw_state(struct intel_encoder *encoder,
        struct intel_crt *crt = intel_encoder_to_crt(encoder);
        enum intel_display_power_domain power_domain;
        u32 tmp;
+       bool ret;
 
        power_domain = intel_display_port_power_domain(encoder);
-       if (!intel_display_power_is_enabled(dev_priv, power_domain))
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                return false;
 
+       ret = false;
+
        tmp = I915_READ(crt->adpa_reg);
 
        if (!(tmp & ADPA_DAC_ENABLE))
-               return false;
+               goto out;
 
        if (HAS_PCH_CPT(dev))
                *pipe = PORT_TO_PIPE_CPT(tmp);
        else
                *pipe = PORT_TO_PIPE(tmp);
 
-       return true;
+       ret = true;
+out:
+       intel_display_power_put(dev_priv, power_domain);
+
+       return ret;
 }
 
 static unsigned int intel_crt_get_flags(struct intel_encoder *encoder)
@@ -206,9 +213,7 @@ static void pch_post_disable_crt(struct intel_encoder *encoder)
 
 static void intel_enable_crt(struct intel_encoder *encoder)
 {
-       struct intel_crt *crt = intel_encoder_to_crt(encoder);
-
-       intel_crt_set_dpms(encoder, crt->connector->base.dpms);
+       intel_crt_set_dpms(encoder, DRM_MODE_DPMS_ON);
 }
 
 static enum drm_mode_status
@@ -216,6 +221,7 @@ intel_crt_mode_valid(struct drm_connector *connector,
                     struct drm_display_mode *mode)
 {
        struct drm_device *dev = connector->dev;
+       int max_dotclk = to_i915(dev)->max_dotclk_freq;
 
        int max_clock = 0;
        if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
@@ -231,6 +237,9 @@ intel_crt_mode_valid(struct drm_connector *connector,
        if (mode->clock > max_clock)
                return MODE_CLOCK_HIGH;
 
+       if (mode->clock > max_dotclk)
+               return MODE_CLOCK_HIGH;
+
        /* The FDI receiver on LPT only supports 8bpc and only has 2 lanes. */
        if (HAS_PCH_LPT(dev) &&
            (ironlake_get_lanes_required(mode->clock, 270000, 24) > 2))
@@ -469,11 +478,10 @@ static bool intel_crt_detect_ddc(struct drm_connector *connector)
 }
 
 static enum drm_connector_status
-intel_crt_load_detect(struct intel_crt *crt)
+intel_crt_load_detect(struct intel_crt *crt, uint32_t pipe)
 {
        struct drm_device *dev = crt->base.base.dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
-       uint32_t pipe = to_intel_crtc(crt->base.base.crtc)->pipe;
        uint32_t save_bclrpat;
        uint32_t save_vtotal;
        uint32_t vtotal, vactive;
@@ -642,7 +650,8 @@ intel_crt_detect(struct drm_connector *connector, bool force)
                if (intel_crt_detect_ddc(connector))
                        status = connector_status_connected;
                else if (INTEL_INFO(dev)->gen < 4)
-                       status = intel_crt_load_detect(crt);
+                       status = intel_crt_load_detect(crt,
+                               to_intel_crtc(connector->state->crtc)->pipe);
                else
                        status = connector_status_unknown;
                intel_release_load_detect_pipe(connector, &tmp, &ctx);
index 5c2f9a4..902054e 100644 (file)
@@ -179,7 +179,8 @@ static const struct stepping_info kbl_stepping_info[] = {
 static const struct stepping_info skl_stepping_info[] = {
        {'A', '0'}, {'B', '0'}, {'C', '0'},
        {'D', '0'}, {'E', '0'}, {'F', '0'},
-       {'G', '0'}, {'H', '0'}, {'I', '0'}
+       {'G', '0'}, {'H', '0'}, {'I', '0'},
+       {'J', '0'}, {'K', '0'}
 };
 
 static const struct stepping_info bxt_stepping_info[] = {
@@ -219,19 +220,19 @@ static const struct stepping_info *intel_get_stepping_info(struct drm_device *de
  * Everytime display comes back from low power state this function is called to
  * copy the firmware from internal memory to registers.
  */
-void intel_csr_load_program(struct drm_i915_private *dev_priv)
+bool intel_csr_load_program(struct drm_i915_private *dev_priv)
 {
        u32 *payload = dev_priv->csr.dmc_payload;
        uint32_t i, fw_size;
 
        if (!IS_GEN9(dev_priv)) {
                DRM_ERROR("No CSR support available for this platform\n");
-               return;
+               return false;
        }
 
        if (!dev_priv->csr.dmc_payload) {
                DRM_ERROR("Tried to program CSR with empty payload\n");
-               return;
+               return false;
        }
 
        fw_size = dev_priv->csr.dmc_fw_size;
@@ -242,6 +243,10 @@ void intel_csr_load_program(struct drm_i915_private *dev_priv)
                I915_WRITE(dev_priv->csr.mmioaddr[i],
                           dev_priv->csr.mmiodata[i]);
        }
+
+       dev_priv->csr.dc_state = 0;
+
+       return true;
 }
 
 static uint32_t *parse_csr_fw(struct drm_i915_private *dev_priv,
index 1f9a368..62de9f4 100644 (file)
@@ -1531,7 +1531,8 @@ skl_ddi_pll_select(struct intel_crtc *intel_crtc,
                         DPLL_CFGCR2_KDIV(wrpll_params.kdiv) |
                         DPLL_CFGCR2_PDIV(wrpll_params.pdiv) |
                         wrpll_params.central_freq;
-       } else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT) {
+       } else if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT ||
+                  intel_encoder->type == INTEL_OUTPUT_DP_MST) {
                switch (crtc_state->port_clock / 2) {
                case 81000:
                        ctrl1 |= DPLL_CTRL1_LINK_RATE(DPLL_CTRL1_LINK_RATE_810, 0);
@@ -1545,8 +1546,10 @@ skl_ddi_pll_select(struct intel_crtc *intel_crtc,
                }
 
                cfgcr1 = cfgcr2 = 0;
-       } else /* eDP */
+       } else if (intel_encoder->type == INTEL_OUTPUT_EDP) {
                return true;
+       } else
+               return false;
 
        memset(&crtc_state->dpll_hw_state, 0,
               sizeof(crtc_state->dpll_hw_state));
@@ -1910,13 +1913,16 @@ bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector)
        enum transcoder cpu_transcoder;
        enum intel_display_power_domain power_domain;
        uint32_t tmp;
+       bool ret;
 
        power_domain = intel_display_port_power_domain(intel_encoder);
-       if (!intel_display_power_is_enabled(dev_priv, power_domain))
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                return false;
 
-       if (!intel_encoder->get_hw_state(intel_encoder, &pipe))
-               return false;
+       if (!intel_encoder->get_hw_state(intel_encoder, &pipe)) {
+               ret = false;
+               goto out;
+       }
 
        if (port == PORT_A)
                cpu_transcoder = TRANSCODER_EDP;
@@ -1928,23 +1934,33 @@ bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector)
        switch (tmp & TRANS_DDI_MODE_SELECT_MASK) {
        case TRANS_DDI_MODE_SELECT_HDMI:
        case TRANS_DDI_MODE_SELECT_DVI:
-               return (type == DRM_MODE_CONNECTOR_HDMIA);
+               ret = type == DRM_MODE_CONNECTOR_HDMIA;
+               break;
 
        case TRANS_DDI_MODE_SELECT_DP_SST:
-               if (type == DRM_MODE_CONNECTOR_eDP)
-                       return true;
-               return (type == DRM_MODE_CONNECTOR_DisplayPort);
+               ret = type == DRM_MODE_CONNECTOR_eDP ||
+                     type == DRM_MODE_CONNECTOR_DisplayPort;
+               break;
+
        case TRANS_DDI_MODE_SELECT_DP_MST:
                /* if the transcoder is in MST state then
                 * connector isn't connected */
-               return false;
+               ret = false;
+               break;
 
        case TRANS_DDI_MODE_SELECT_FDI:
-               return (type == DRM_MODE_CONNECTOR_VGA);
+               ret = type == DRM_MODE_CONNECTOR_VGA;
+               break;
 
        default:
-               return false;
+               ret = false;
+               break;
        }
+
+out:
+       intel_display_power_put(dev_priv, power_domain);
+
+       return ret;
 }
 
 bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
@@ -1956,15 +1972,18 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
        enum intel_display_power_domain power_domain;
        u32 tmp;
        int i;
+       bool ret;
 
        power_domain = intel_display_port_power_domain(encoder);
-       if (!intel_display_power_is_enabled(dev_priv, power_domain))
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                return false;
 
+       ret = false;
+
        tmp = I915_READ(DDI_BUF_CTL(port));
 
        if (!(tmp & DDI_BUF_CTL_ENABLE))
-               return false;
+               goto out;
 
        if (port == PORT_A) {
                tmp = I915_READ(TRANS_DDI_FUNC_CTL(TRANSCODER_EDP));
@@ -1982,25 +2001,32 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
                        break;
                }
 
-               return true;
-       } else {
-               for (i = TRANSCODER_A; i <= TRANSCODER_C; i++) {
-                       tmp = I915_READ(TRANS_DDI_FUNC_CTL(i));
+               ret = true;
 
-                       if ((tmp & TRANS_DDI_PORT_MASK)
-                           == TRANS_DDI_SELECT_PORT(port)) {
-                               if ((tmp & TRANS_DDI_MODE_SELECT_MASK) == TRANS_DDI_MODE_SELECT_DP_MST)
-                                       return false;
+               goto out;
+       }
 
-                               *pipe = i;
-                               return true;
-                       }
+       for (i = TRANSCODER_A; i <= TRANSCODER_C; i++) {
+               tmp = I915_READ(TRANS_DDI_FUNC_CTL(i));
+
+               if ((tmp & TRANS_DDI_PORT_MASK) == TRANS_DDI_SELECT_PORT(port)) {
+                       if ((tmp & TRANS_DDI_MODE_SELECT_MASK) ==
+                           TRANS_DDI_MODE_SELECT_DP_MST)
+                               goto out;
+
+                       *pipe = i;
+                       ret = true;
+
+                       goto out;
                }
        }
 
        DRM_DEBUG_KMS("No pipe for ddi port %c found\n", port_name(port));
 
-       return false;
+out:
+       intel_display_power_put(dev_priv, power_domain);
+
+       return ret;
 }
 
 void intel_ddi_enable_pipe_clock(struct intel_crtc *intel_crtc)
@@ -2446,12 +2472,14 @@ static bool hsw_ddi_wrpll_get_hw_state(struct drm_i915_private *dev_priv,
 {
        uint32_t val;
 
-       if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS))
+       if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS))
                return false;
 
        val = I915_READ(WRPLL_CTL(pll->id));
        hw_state->wrpll = val;
 
+       intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
+
        return val & WRPLL_PLL_ENABLE;
 }
 
@@ -2461,12 +2489,14 @@ static bool hsw_ddi_spll_get_hw_state(struct drm_i915_private *dev_priv,
 {
        uint32_t val;
 
-       if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS))
+       if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS))
                return false;
 
        val = I915_READ(SPLL_CTL);
        hw_state->spll = val;
 
+       intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
+
        return val & SPLL_PLL_ENABLE;
 }
 
@@ -2583,16 +2613,19 @@ static bool skl_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,
        uint32_t val;
        unsigned int dpll;
        const struct skl_dpll_regs *regs = skl_dpll_regs;
+       bool ret;
 
-       if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS))
+       if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS))
                return false;
 
+       ret = false;
+
        /* DPLL0 is not part of the shared DPLLs, so pll->id is 0 for DPLL1 */
        dpll = pll->id + 1;
 
        val = I915_READ(regs[pll->id].ctl);
        if (!(val & LCPLL_PLL_ENABLE))
-               return false;
+               goto out;
 
        val = I915_READ(DPLL_CTRL1);
        hw_state->ctrl1 = (val >> (dpll * 6)) & 0x3f;
@@ -2602,8 +2635,12 @@ static bool skl_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,
                hw_state->cfgcr1 = I915_READ(regs[pll->id].cfgcr1);
                hw_state->cfgcr2 = I915_READ(regs[pll->id].cfgcr2);
        }
+       ret = true;
 
-       return true;
+out:
+       intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
+
+       return ret;
 }
 
 static void skl_shared_dplls_init(struct drm_i915_private *dev_priv)
@@ -2870,13 +2907,16 @@ static bool bxt_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,
 {
        enum port port = (enum port)pll->id;    /* 1:1 port->PLL mapping */
        uint32_t val;
+       bool ret;
 
-       if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS))
+       if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS))
                return false;
 
+       ret = false;
+
        val = I915_READ(BXT_PORT_PLL_ENABLE(port));
        if (!(val & PORT_PLL_ENABLE))
-               return false;
+               goto out;
 
        hw_state->ebb0 = I915_READ(BXT_PORT_PLL_EBB_0(port));
        hw_state->ebb0 &= PORT_PLL_P1_MASK | PORT_PLL_P2_MASK;
@@ -2923,7 +2963,12 @@ static bool bxt_ddi_pll_get_hw_state(struct drm_i915_private *dev_priv,
                                 I915_READ(BXT_PORT_PCS_DW12_LN23(port)));
        hw_state->pcsdw12 &= LANE_STAGGER_MASK | LANESTAGGER_STRAP_OVRD;
 
-       return true;
+       ret = true;
+
+out:
+       intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
+
+       return ret;
 }
 
 static void bxt_shared_dplls_init(struct drm_i915_private *dev_priv)
@@ -3058,11 +3103,15 @@ bool intel_ddi_is_audio_enabled(struct drm_i915_private *dev_priv,
 {
        u32 temp;
 
-       if (intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_AUDIO)) {
+       if (intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_AUDIO)) {
                temp = I915_READ(HSW_AUD_PIN_ELD_CP_VLD);
+
+               intel_display_power_put(dev_priv, POWER_DOMAIN_AUDIO);
+
                if (temp & AUDIO_OUTPUT_ENABLE(intel_crtc->pipe))
                        return true;
        }
+
        return false;
 }
 
@@ -3277,11 +3326,9 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
        intel_encoder->get_config = intel_ddi_get_config;
 
        intel_dig_port->port = port;
-       dev_priv->dig_port_map[port] = intel_encoder;
        intel_dig_port->saved_port_bits = I915_READ(DDI_BUF_CTL(port)) &
                                          (DDI_BUF_PORT_REVERSAL |
                                           DDI_A_4_LANES);
-       intel_dig_port->max_lanes = max_lanes;
 
        /*
         * Bspec says that DDI_A_4_LANES is the only supported configuration
@@ -3294,9 +3341,12 @@ void intel_ddi_init(struct drm_device *dev, enum port port)
                if (!(intel_dig_port->saved_port_bits & DDI_A_4_LANES)) {
                        DRM_DEBUG_KMS("BXT BIOS forgot to set DDI_A_4_LANES for port A; fixing\n");
                        intel_dig_port->saved_port_bits |= DDI_A_4_LANES;
+                       max_lanes = 4;
                }
        }
 
+       intel_dig_port->max_lanes = max_lanes;
+
        intel_encoder->type = INTEL_OUTPUT_UNKNOWN;
        intel_encoder->crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
        intel_encoder->cloneable = 0;
index e1e7cde..6e0d828 100644 (file)
@@ -1343,18 +1343,21 @@ void assert_pipe(struct drm_i915_private *dev_priv,
        bool cur_state;
        enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv,
                                                                      pipe);
+       enum intel_display_power_domain power_domain;
 
        /* if we need the pipe quirk it must be always on */
        if ((pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) ||
            (pipe == PIPE_B && dev_priv->quirks & QUIRK_PIPEB_FORCE))
                state = true;
 
-       if (!intel_display_power_is_enabled(dev_priv,
-                               POWER_DOMAIN_TRANSCODER(cpu_transcoder))) {
-               cur_state = false;
-       } else {
+       power_domain = POWER_DOMAIN_TRANSCODER(cpu_transcoder);
+       if (intel_display_power_get_if_enabled(dev_priv, power_domain)) {
                u32 val = I915_READ(PIPECONF(cpu_transcoder));
                cur_state = !!(val & PIPECONF_ENABLE);
+
+               intel_display_power_put(dev_priv, power_domain);
+       } else {
+               cur_state = false;
        }
 
        I915_STATE_WARN(cur_state != state,
@@ -2284,7 +2287,7 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb,
                        const struct drm_plane_state *plane_state)
 {
        struct drm_i915_private *dev_priv = to_i915(fb->dev);
-       struct intel_rotation_info *info = &view->params.rotation_info;
+       struct intel_rotation_info *info = &view->params.rotated;
        unsigned int tile_size, tile_width, tile_height, cpp;
 
        *view = i915_ggtt_view_normal;
@@ -2306,7 +2309,7 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb,
        tile_size = intel_tile_size(dev_priv);
 
        cpp = drm_format_plane_cpp(fb->pixel_format, 0);
-       tile_width = intel_tile_width(dev_priv, cpp, fb->modifier[0]);
+       tile_width = intel_tile_width(dev_priv, fb->modifier[0], cpp);
        tile_height = tile_size / tile_width;
 
        info->width_pages = DIV_ROUND_UP(fb->pitches[0], tile_width);
@@ -2448,11 +2451,11 @@ static void intel_unpin_fb_obj(struct drm_framebuffer *fb,
 
 /* Computes the linear offset to the base tile and adjusts x, y. bytes per pixel
  * is assumed to be a power-of-two. */
-unsigned long intel_compute_tile_offset(struct drm_i915_private *dev_priv,
-                                       int *x, int *y,
-                                       uint64_t fb_modifier,
-                                       unsigned int cpp,
-                                       unsigned int pitch)
+u32 intel_compute_tile_offset(struct drm_i915_private *dev_priv,
+                             int *x, int *y,
+                             uint64_t fb_modifier,
+                             unsigned int cpp,
+                             unsigned int pitch)
 {
        if (fb_modifier != DRM_FORMAT_MOD_NONE) {
                unsigned int tile_size, tile_width, tile_height;
@@ -2551,12 +2554,16 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
        if (size_aligned * 2 > dev_priv->gtt.stolen_usable_size)
                return false;
 
+       mutex_lock(&dev->struct_mutex);
+
        obj = i915_gem_object_create_stolen_for_preallocated(dev,
                                                             base_aligned,
                                                             base_aligned,
                                                             size_aligned);
-       if (!obj)
+       if (!obj) {
+               mutex_unlock(&dev->struct_mutex);
                return false;
+       }
 
        obj->tiling_mode = plane_config->tiling;
        if (obj->tiling_mode == I915_TILING_X)
@@ -2569,12 +2576,12 @@ intel_alloc_initial_plane_obj(struct intel_crtc *crtc,
        mode_cmd.modifier[0] = fb->modifier[0];
        mode_cmd.flags = DRM_MODE_FB_MODIFIERS;
 
-       mutex_lock(&dev->struct_mutex);
        if (intel_framebuffer_init(dev, to_intel_framebuffer(fb),
                                   &mode_cmd, obj)) {
                DRM_DEBUG_KMS("intel fb init failed\n");
                goto out_unref_obj;
        }
+
        mutex_unlock(&dev->struct_mutex);
 
        DRM_DEBUG_KMS("initial plane fb obj %p\n", obj);
@@ -2706,14 +2713,12 @@ static void i9xx_update_primary_plane(struct drm_plane *primary,
        struct drm_framebuffer *fb = plane_state->base.fb;
        struct drm_i915_gem_object *obj = intel_fb_obj(fb);
        int plane = intel_crtc->plane;
-       unsigned long linear_offset;
-       int x = plane_state->src.x1 >> 16;
-       int y = plane_state->src.y1 >> 16;
+       u32 linear_offset;
        u32 dspcntr;
        i915_reg_t reg = DSPCNTR(plane);
-       int pixel_size;
-
-       pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
+       int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+       int x = plane_state->src.x1 >> 16;
+       int y = plane_state->src.y1 >> 16;
 
        dspcntr = DISPPLANE_GAMMA_ENABLE;
 
@@ -2771,13 +2776,12 @@ static void i9xx_update_primary_plane(struct drm_plane *primary,
        if (IS_G4X(dev))
                dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;
 
-       linear_offset = y * fb->pitches[0] + x * pixel_size;
+       linear_offset = y * fb->pitches[0] + x * cpp;
 
        if (INTEL_INFO(dev)->gen >= 4) {
                intel_crtc->dspaddr_offset =
                        intel_compute_tile_offset(dev_priv, &x, &y,
-                                                 fb->modifier[0],
-                                                 pixel_size,
+                                                 fb->modifier[0], cpp,
                                                  fb->pitches[0]);
                linear_offset -= intel_crtc->dspaddr_offset;
        } else {
@@ -2794,7 +2798,7 @@ static void i9xx_update_primary_plane(struct drm_plane *primary,
                data and adding to linear_offset*/
                linear_offset +=
                        (crtc_state->pipe_src_h - 1) * fb->pitches[0] +
-                       (crtc_state->pipe_src_w - 1) * pixel_size;
+                       (crtc_state->pipe_src_w - 1) * cpp;
        }
 
        intel_crtc->adjusted_x = x;
@@ -2839,10 +2843,10 @@ static void ironlake_update_primary_plane(struct drm_plane *primary,
        struct drm_framebuffer *fb = plane_state->base.fb;
        struct drm_i915_gem_object *obj = intel_fb_obj(fb);
        int plane = intel_crtc->plane;
-       unsigned long linear_offset;
+       u32 linear_offset;
        u32 dspcntr;
        i915_reg_t reg = DSPCNTR(plane);
-       int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
+       int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
        int x = plane_state->src.x1 >> 16;
        int y = plane_state->src.y1 >> 16;
 
@@ -2881,11 +2885,10 @@ static void ironlake_update_primary_plane(struct drm_plane *primary,
        if (!IS_HASWELL(dev) && !IS_BROADWELL(dev))
                dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;
 
-       linear_offset = y * fb->pitches[0] + x * pixel_size;
+       linear_offset = y * fb->pitches[0] + x * cpp;
        intel_crtc->dspaddr_offset =
                intel_compute_tile_offset(dev_priv, &x, &y,
-                                         fb->modifier[0],
-                                         pixel_size,
+                                         fb->modifier[0], cpp,
                                          fb->pitches[0]);
        linear_offset -= intel_crtc->dspaddr_offset;
        if (plane_state->base.rotation == BIT(DRM_ROTATE_180)) {
@@ -2899,7 +2902,7 @@ static void ironlake_update_primary_plane(struct drm_plane *primary,
                        data and adding to linear_offset*/
                        linear_offset +=
                                (crtc_state->pipe_src_h - 1) * fb->pitches[0] +
-                               (crtc_state->pipe_src_w - 1) * pixel_size;
+                               (crtc_state->pipe_src_w - 1) * cpp;
                }
        }
 
@@ -2951,7 +2954,7 @@ u32 intel_plane_obj_offset(struct intel_plane *intel_plane,
        offset = vma->node.start;
 
        if (plane == 1) {
-               offset += vma->ggtt_view.params.rotation_info.uv_start_page *
+               offset += vma->ggtt_view.params.rotated.uv_start_page *
                          PAGE_SIZE;
        }
 
@@ -3160,9 +3163,6 @@ static void skylake_disable_primary_plane(struct drm_plane *primary,
        struct drm_i915_private *dev_priv = dev->dev_private;
        int pipe = to_intel_crtc(crtc)->pipe;
 
-       if (dev_priv->fbc.deactivate)
-               dev_priv->fbc.deactivate(dev_priv);
-
        I915_WRITE(PLANE_CTL(pipe, 0), 0);
        I915_WRITE(PLANE_SURF(pipe, 0), 0);
        POSTING_READ(PLANE_SURF(pipe, 0));
@@ -4792,9 +4792,6 @@ static void intel_post_plane_update(struct intel_crtc *crtc)
                to_intel_crtc_state(crtc->base.state);
        struct drm_device *dev = crtc->base.dev;
 
-       if (atomic->wait_vblank)
-               intel_wait_for_vblank(dev, crtc->pipe);
-
        intel_frontbuffer_flip(dev, atomic->fb_bits);
 
        crtc->wm.cxsr_allowed = true;
@@ -4803,7 +4800,7 @@ static void intel_post_plane_update(struct intel_crtc *crtc)
                intel_update_watermarks(&crtc->base);
 
        if (atomic->update_fbc)
-               intel_fbc_update(crtc);
+               intel_fbc_post_update(crtc);
 
        if (atomic->post_enable_primary)
                intel_post_enable_primary(&crtc->base);
@@ -4811,26 +4808,39 @@ static void intel_post_plane_update(struct intel_crtc *crtc)
        memset(atomic, 0, sizeof(*atomic));
 }
 
-static void intel_pre_plane_update(struct intel_crtc *crtc)
+static void intel_pre_plane_update(struct intel_crtc_state *old_crtc_state)
 {
+       struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->base.crtc);
        struct drm_device *dev = crtc->base.dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_crtc_atomic_commit *atomic = &crtc->atomic;
        struct intel_crtc_state *pipe_config =
                to_intel_crtc_state(crtc->base.state);
+       struct drm_atomic_state *old_state = old_crtc_state->base.state;
+       struct drm_plane *primary = crtc->base.primary;
+       struct drm_plane_state *old_pri_state =
+               drm_atomic_get_existing_plane_state(old_state, primary);
+       bool modeset = needs_modeset(&pipe_config->base);
 
-       if (atomic->disable_fbc)
-               intel_fbc_deactivate(crtc);
+       if (atomic->update_fbc)
+               intel_fbc_pre_update(crtc);
 
-       if (crtc->atomic.disable_ips)
-               hsw_disable_ips(crtc);
+       if (old_pri_state) {
+               struct intel_plane_state *primary_state =
+                       to_intel_plane_state(primary->state);
+               struct intel_plane_state *old_primary_state =
+                       to_intel_plane_state(old_pri_state);
 
-       if (atomic->pre_disable_primary)
-               intel_pre_disable_primary(&crtc->base);
+               if (old_primary_state->visible &&
+                   (modeset || !primary_state->visible))
+                       intel_pre_disable_primary(&crtc->base);
+       }
 
        if (pipe_config->disable_cxsr) {
                crtc->wm.cxsr_allowed = false;
-               intel_set_memory_cxsr(dev_priv, false);
+
+               if (old_crtc_state->base.active)
+                       intel_set_memory_cxsr(dev_priv, false);
        }
 
        if (!needs_modeset(&pipe_config->base) && pipe_config->wm_changed)
@@ -4931,8 +4941,6 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
        if (intel_crtc->config->has_pch_encoder)
                intel_wait_for_vblank(dev, pipe);
        intel_set_pch_fifo_underrun_reporting(dev_priv, pipe, true);
-
-       intel_fbc_enable(intel_crtc);
 }
 
 /* IPS only exists on ULT machines and is tied to pipe A. */
@@ -5045,8 +5053,6 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
                intel_wait_for_vblank(dev, hsw_workaround_pipe);
                intel_wait_for_vblank(dev, hsw_workaround_pipe);
        }
-
-       intel_fbc_enable(intel_crtc);
 }
 
 static void ironlake_pfit_disable(struct intel_crtc *crtc, bool force)
@@ -5127,8 +5133,6 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
        }
 
        intel_set_pch_fifo_underrun_reporting(dev_priv, pipe, true);
-
-       intel_fbc_disable_crtc(intel_crtc);
 }
 
 static void haswell_crtc_disable(struct drm_crtc *crtc)
@@ -5179,8 +5183,6 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
                intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A,
                                                      true);
        }
-
-       intel_fbc_disable_crtc(intel_crtc);
 }
 
 static void i9xx_pfit_enable(struct intel_crtc *crtc)
@@ -5303,31 +5305,37 @@ intel_display_port_aux_power_domain(struct intel_encoder *intel_encoder)
        }
 }
 
-static unsigned long get_crtc_power_domains(struct drm_crtc *crtc)
+static unsigned long get_crtc_power_domains(struct drm_crtc *crtc,
+                                           struct intel_crtc_state *crtc_state)
 {
        struct drm_device *dev = crtc->dev;
-       struct intel_encoder *intel_encoder;
+       struct drm_encoder *encoder;
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
        enum pipe pipe = intel_crtc->pipe;
        unsigned long mask;
-       enum transcoder transcoder = intel_crtc->config->cpu_transcoder;
+       enum transcoder transcoder = crtc_state->cpu_transcoder;
 
-       if (!crtc->state->active)
+       if (!crtc_state->base.active)
                return 0;
 
        mask = BIT(POWER_DOMAIN_PIPE(pipe));
        mask |= BIT(POWER_DOMAIN_TRANSCODER(transcoder));
-       if (intel_crtc->config->pch_pfit.enabled ||
-           intel_crtc->config->pch_pfit.force_thru)
+       if (crtc_state->pch_pfit.enabled ||
+           crtc_state->pch_pfit.force_thru)
                mask |= BIT(POWER_DOMAIN_PIPE_PANEL_FITTER(pipe));
 
-       for_each_encoder_on_crtc(dev, crtc, intel_encoder)
+       drm_for_each_encoder_mask(encoder, dev, crtc_state->base.encoder_mask) {
+               struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
+
                mask |= BIT(intel_display_port_power_domain(intel_encoder));
+       }
 
        return mask;
 }
 
-static unsigned long modeset_get_crtc_power_domains(struct drm_crtc *crtc)
+static unsigned long
+modeset_get_crtc_power_domains(struct drm_crtc *crtc,
+                              struct intel_crtc_state *crtc_state)
 {
        struct drm_i915_private *dev_priv = crtc->dev->dev_private;
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
@@ -5335,7 +5343,8 @@ static unsigned long modeset_get_crtc_power_domains(struct drm_crtc *crtc)
        unsigned long domains, new_domains, old_domains;
 
        old_domains = intel_crtc->enabled_power_domains;
-       intel_crtc->enabled_power_domains = new_domains = get_crtc_power_domains(crtc);
+       intel_crtc->enabled_power_domains = new_domains =
+               get_crtc_power_domains(crtc, crtc_state);
 
        domains = new_domains & ~old_domains;
 
@@ -5354,31 +5363,6 @@ static void modeset_put_power_domains(struct drm_i915_private *dev_priv,
                intel_display_power_put(dev_priv, domain);
 }
 
-static void modeset_update_crtc_power_domains(struct drm_atomic_state *state)
-{
-       struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
-       struct drm_device *dev = state->dev;
-       struct drm_i915_private *dev_priv = dev->dev_private;
-       unsigned long put_domains[I915_MAX_PIPES] = {};
-       struct drm_crtc_state *crtc_state;
-       struct drm_crtc *crtc;
-       int i;
-
-       for_each_crtc_in_state(state, crtc, crtc_state, i) {
-               if (needs_modeset(crtc->state))
-                       put_domains[to_intel_crtc(crtc)->pipe] =
-                               modeset_get_crtc_power_domains(crtc);
-       }
-
-       if (dev_priv->display.modeset_commit_cdclk &&
-           intel_state->dev_cdclk != dev_priv->cdclk_freq)
-               dev_priv->display.modeset_commit_cdclk(state);
-
-       for (i = 0; i < I915_MAX_PIPES; i++)
-               if (put_domains[i])
-                       modeset_put_power_domains(dev_priv, put_domains[i]);
-}
-
 static int intel_compute_max_dotclk(struct drm_i915_private *dev_priv)
 {
        int max_cdclk_freq = dev_priv->max_cdclk_freq;
@@ -6041,8 +6025,7 @@ static int broxton_calc_cdclk(struct drm_i915_private *dev_priv,
                return 144000;
 }
 
-/* Compute the max pixel clock for new configuration. Uses atomic state if
- * that's non-NULL, look at current state otherwise. */
+/* Compute the max pixel clock for new configuration. */
 static int intel_mode_max_pixclk(struct drm_device *dev,
                                 struct drm_atomic_state *state)
 {
@@ -6065,9 +6048,6 @@ static int intel_mode_max_pixclk(struct drm_device *dev,
                intel_state->min_pixclk[i] = pixclk;
        }
 
-       if (!intel_state->active_crtcs)
-               return 0;
-
        for_each_pipe(dev_priv, pipe)
                max_pixclk = max(intel_state->min_pixclk[pipe], max_pixclk);
 
@@ -6291,8 +6271,6 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc)
 
        for_each_encoder_on_crtc(dev, crtc, encoder)
                encoder->enable(encoder);
-
-       intel_fbc_enable(intel_crtc);
 }
 
 static void i9xx_pfit_disable(struct intel_crtc *crtc)
@@ -6355,8 +6333,6 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
 
        if (!IS_GEN2(dev))
                intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false);
-
-       intel_fbc_disable_crtc(intel_crtc);
 }
 
 static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
@@ -6380,6 +6356,7 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
 
        dev_priv->display.crtc_disable(crtc);
        intel_crtc->active = false;
+       intel_fbc_disable(intel_crtc);
        intel_update_watermarks(crtc);
        intel_disable_shared_dpll(intel_crtc);
 
@@ -6398,55 +6375,16 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
  */
 int intel_display_suspend(struct drm_device *dev)
 {
-       struct drm_mode_config *config = &dev->mode_config;
-       struct drm_modeset_acquire_ctx *ctx = config->acquire_ctx;
+       struct drm_i915_private *dev_priv = to_i915(dev);
        struct drm_atomic_state *state;
-       struct drm_crtc *crtc;
-       unsigned crtc_mask = 0;
-       int ret = 0;
-
-       if (WARN_ON(!ctx))
-               return 0;
-
-       lockdep_assert_held(&ctx->ww_ctx);
-       state = drm_atomic_state_alloc(dev);
-       if (WARN_ON(!state))
-               return -ENOMEM;
-
-       state->acquire_ctx = ctx;
-       state->allow_modeset = true;
-
-       for_each_crtc(dev, crtc) {
-               struct drm_crtc_state *crtc_state =
-                       drm_atomic_get_crtc_state(state, crtc);
-
-               ret = PTR_ERR_OR_ZERO(crtc_state);
-               if (ret)
-                       goto free;
-
-               if (!crtc_state->active)
-                       continue;
-
-               crtc_state->active = false;
-               crtc_mask |= 1 << drm_crtc_index(crtc);
-       }
-
-       if (crtc_mask) {
-               ret = drm_atomic_commit(state);
-
-               if (!ret) {
-                       for_each_crtc(dev, crtc)
-                               if (crtc_mask & (1 << drm_crtc_index(crtc)))
-                                       crtc->state->active = true;
-
-                       return ret;
-               }
-       }
+       int ret;
 
-free:
+       state = drm_atomic_helper_suspend(dev);
+       ret = PTR_ERR_OR_ZERO(state);
        if (ret)
                DRM_ERROR("Suspending crtc's failed with %i\n", ret);
-       drm_atomic_state_free(state);
+       else
+               dev_priv->modeset_restore_state = state;
        return ret;
 }
 
@@ -8186,18 +8124,22 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
 {
        struct drm_device *dev = crtc->base.dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
+       enum intel_display_power_domain power_domain;
        uint32_t tmp;
+       bool ret;
 
-       if (!intel_display_power_is_enabled(dev_priv,
-                                           POWER_DOMAIN_PIPE(crtc->pipe)))
+       power_domain = POWER_DOMAIN_PIPE(crtc->pipe);
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                return false;
 
        pipe_config->cpu_transcoder = (enum transcoder) crtc->pipe;
        pipe_config->shared_dpll = DPLL_ID_PRIVATE;
 
+       ret = false;
+
        tmp = I915_READ(PIPECONF(crtc->pipe));
        if (!(tmp & PIPECONF_ENABLE))
-               return false;
+               goto out;
 
        if (IS_G4X(dev) || IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) {
                switch (tmp & PIPECONF_BPC_MASK) {
@@ -8277,7 +8219,12 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
        pipe_config->base.adjusted_mode.crtc_clock =
                pipe_config->port_clock / pipe_config->pixel_multiplier;
 
-       return true;
+       ret = true;
+
+out:
+       intel_display_power_put(dev_priv, power_domain);
+
+       return ret;
 }
 
 static void ironlake_init_pch_refclk(struct drm_device *dev)
@@ -9381,18 +9328,21 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
 {
        struct drm_device *dev = crtc->base.dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
+       enum intel_display_power_domain power_domain;
        uint32_t tmp;
+       bool ret;
 
-       if (!intel_display_power_is_enabled(dev_priv,
-                                           POWER_DOMAIN_PIPE(crtc->pipe)))
+       power_domain = POWER_DOMAIN_PIPE(crtc->pipe);
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                return false;
 
        pipe_config->cpu_transcoder = (enum transcoder) crtc->pipe;
        pipe_config->shared_dpll = DPLL_ID_PRIVATE;
 
+       ret = false;
        tmp = I915_READ(PIPECONF(crtc->pipe));
        if (!(tmp & PIPECONF_ENABLE))
-               return false;
+               goto out;
 
        switch (tmp & PIPECONF_BPC_MASK) {
        case PIPECONF_6BPC:
@@ -9455,7 +9405,12 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc,
 
        ironlake_get_pfit_config(crtc, pipe_config);
 
-       return true;
+       ret = true;
+
+out:
+       intel_display_power_put(dev_priv, power_domain);
+
+       return ret;
 }
 
 static void assert_can_disable_lcpll(struct drm_i915_private *dev_priv)
@@ -9721,9 +9676,6 @@ static int ilk_max_pixel_rate(struct drm_atomic_state *state)
                intel_state->min_pixclk[i] = pixel_rate;
        }
 
-       if (!intel_state->active_crtcs)
-               return 0;
-
        for_each_pipe(dev_priv, pipe)
                max_pixel_rate = max(intel_state->min_pixclk[pipe], max_pixel_rate);
 
@@ -9853,8 +9805,13 @@ static void broadwell_modeset_commit_cdclk(struct drm_atomic_state *old_state)
 static int haswell_crtc_compute_clock(struct intel_crtc *crtc,
                                      struct intel_crtc_state *crtc_state)
 {
-       if (!intel_ddi_pll_select(crtc, crtc_state))
-               return -EINVAL;
+       struct intel_encoder *intel_encoder =
+               intel_ddi_get_crtc_new_encoder(crtc_state);
+
+       if (intel_encoder->type != INTEL_OUTPUT_DSI) {
+               if (!intel_ddi_pll_select(crtc, crtc_state))
+                       return -EINVAL;
+       }
 
        crtc->lowfreq_avail = false;
 
@@ -9982,12 +9939,17 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
 {
        struct drm_device *dev = crtc->base.dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
-       enum intel_display_power_domain pfit_domain;
+       enum intel_display_power_domain power_domain;
+       unsigned long power_domain_mask;
        uint32_t tmp;
+       bool ret;
 
-       if (!intel_display_power_is_enabled(dev_priv,
-                                        POWER_DOMAIN_PIPE(crtc->pipe)))
+       power_domain = POWER_DOMAIN_PIPE(crtc->pipe);
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                return false;
+       power_domain_mask = BIT(power_domain);
+
+       ret = false;
 
        pipe_config->cpu_transcoder = (enum transcoder) crtc->pipe;
        pipe_config->shared_dpll = DPLL_ID_PRIVATE;
@@ -10014,13 +9976,14 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
                        pipe_config->cpu_transcoder = TRANSCODER_EDP;
        }
 
-       if (!intel_display_power_is_enabled(dev_priv,
-                       POWER_DOMAIN_TRANSCODER(pipe_config->cpu_transcoder)))
-               return false;
+       power_domain = POWER_DOMAIN_TRANSCODER(pipe_config->cpu_transcoder);
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
+               goto out;
+       power_domain_mask |= BIT(power_domain);
 
        tmp = I915_READ(PIPECONF(pipe_config->cpu_transcoder));
        if (!(tmp & PIPECONF_ENABLE))
-               return false;
+               goto out;
 
        haswell_get_ddi_port_state(crtc, pipe_config);
 
@@ -10030,14 +9993,14 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
                skl_init_scalers(dev, crtc, pipe_config);
        }
 
-       pfit_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe);
-
        if (INTEL_INFO(dev)->gen >= 9) {
                pipe_config->scaler_state.scaler_id = -1;
                pipe_config->scaler_state.scaler_users &= ~(1 << SKL_CRTC_INDEX);
        }
 
-       if (intel_display_power_is_enabled(dev_priv, pfit_domain)) {
+       power_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe);
+       if (intel_display_power_get_if_enabled(dev_priv, power_domain)) {
+               power_domain_mask |= BIT(power_domain);
                if (INTEL_INFO(dev)->gen >= 9)
                        skylake_get_pfit_config(crtc, pipe_config);
                else
@@ -10055,7 +10018,13 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
                pipe_config->pixel_multiplier = 1;
        }
 
-       return true;
+       ret = true;
+
+out:
+       for_each_power_domain(power_domain, power_domain_mask)
+               intel_display_power_put(dev_priv, power_domain);
+
+       return ret;
 }
 
 static void i845_update_cursor(struct drm_crtc *crtc, u32 base,
@@ -10376,6 +10345,7 @@ mode_fits_in_fbdev(struct drm_device *dev,
        if (obj->base.size < mode->vdisplay * fb->pitches[0])
                return NULL;
 
+       drm_framebuffer_reference(fb);
        return fb;
 #else
        return NULL;
@@ -10431,7 +10401,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
        struct drm_device *dev = encoder->dev;
        struct drm_framebuffer *fb;
        struct drm_mode_config *config = &dev->mode_config;
-       struct drm_atomic_state *state = NULL;
+       struct drm_atomic_state *state = NULL, *restore_state = NULL;
        struct drm_connector_state *connector_state;
        struct intel_crtc_state *crtc_state;
        int ret, i = -1;
@@ -10440,6 +10410,8 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector,
                      connector->base.id, connector->name,
                      encoder->base.id, encoder->name);
 
+       old->restore_state = NULL;
+
 retry:
        ret = drm_modeset_lock(&config->connection_mutex, ctx);
        if (ret)
@@ -10456,24 +10428,15 @@ retry:
         */
 
        /* See if we already have a CRTC for this connector */
-       if (encoder->crtc) {
-               crtc = encoder->crtc;
+       if (connector->state->crtc) {
+               crtc = connector->state->crtc;
 
                ret = drm_modeset_lock(&crtc->mutex, ctx);
                if (ret)
                        goto fail;
-               ret = drm_modeset_lock(&crtc->primary->mutex, ctx);
-               if (ret)
-                       goto fail;
-
-               old->dpms_mode = connector->dpms;
-               old->load_detect_temp = false;
 
                /* Make sure the crtc and connector are running */
-               if (connector->dpms != DRM_MODE_DPMS_ON)
-                       connector->funcs->dpms(connector, DRM_MODE_DPMS_ON);
-
-               return true;
+               goto found;
        }
 
        /* Find an unused one (if possible) */
@@ -10481,8 +10444,15 @@ retry:
                i++;
                if (!(encoder->possible_crtcs & (1 << i)))
                        continue;
-               if (possible_crtc->state->enable)
+
+               ret = drm_modeset_lock(&possible_crtc->mutex, ctx);
+               if (ret)
+                       goto fail;
+
+               if (possible_crtc->state->enable) {
+                       drm_modeset_unlock(&possible_crtc->mutex);
                        continue;
+               }
 
                crtc = possible_crtc;
                break;
@@ -10496,23 +10466,22 @@ retry:
                goto fail;
        }
 
-       ret = drm_modeset_lock(&crtc->mutex, ctx);
-       if (ret)
-               goto fail;
+found:
+       intel_crtc = to_intel_crtc(crtc);
+
        ret = drm_modeset_lock(&crtc->primary->mutex, ctx);
        if (ret)
                goto fail;
 
-       intel_crtc = to_intel_crtc(crtc);
-       old->dpms_mode = connector->dpms;
-       old->load_detect_temp = true;
-       old->release_fb = NULL;
-
        state = drm_atomic_state_alloc(dev);
-       if (!state)
-               return false;
+       restore_state = drm_atomic_state_alloc(dev);
+       if (!state || !restore_state) {
+               ret = -ENOMEM;
+               goto fail;
+       }
 
        state->acquire_ctx = ctx;
+       restore_state->acquire_ctx = ctx;
 
        connector_state = drm_atomic_get_connector_state(state, connector);
        if (IS_ERR(connector_state)) {
@@ -10520,7 +10489,9 @@ retry:
                goto fail;
        }
 
-       connector_state->crtc = crtc;
+       ret = drm_atomic_set_crtc_for_connector(connector_state, crtc);
+       if (ret)
+               goto fail;
 
        crtc_state = intel_atomic_get_crtc_state(state, intel_crtc);
        if (IS_ERR(crtc_state)) {
@@ -10544,7 +10515,6 @@ retry:
        if (fb == NULL) {
                DRM_DEBUG_KMS("creating tmp fb for load-detection\n");
                fb = intel_framebuffer_create_for_mode(dev, mode, 24, 32);
-               old->release_fb = fb;
        } else
                DRM_DEBUG_KMS("reusing fbdev for load-detection framebuffer\n");
        if (IS_ERR(fb)) {
@@ -10556,15 +10526,29 @@ retry:
        if (ret)
                goto fail;
 
-       drm_mode_copy(&crtc_state->base.mode, mode);
+       drm_framebuffer_unreference(fb);
+
+       ret = drm_atomic_set_mode_for_crtc(&crtc_state->base, mode);
+       if (ret)
+               goto fail;
+
+       ret = PTR_ERR_OR_ZERO(drm_atomic_get_connector_state(restore_state, connector));
+       if (!ret)
+               ret = PTR_ERR_OR_ZERO(drm_atomic_get_crtc_state(restore_state, crtc));
+       if (!ret)
+               ret = PTR_ERR_OR_ZERO(drm_atomic_get_plane_state(restore_state, crtc->primary));
+       if (ret) {
+               DRM_DEBUG_KMS("Failed to create a copy of old state to restore: %i\n", ret);
+               goto fail;
+       }
 
-       if (drm_atomic_commit(state)) {
+       ret = drm_atomic_commit(state);
+       if (ret) {
                DRM_DEBUG_KMS("failed to set mode on load-detect pipe\n");
-               if (old->release_fb)
-                       old->release_fb->funcs->destroy(old->release_fb);
                goto fail;
        }
-       crtc->primary->crtc = crtc;
+
+       old->restore_state = restore_state;
 
        /* let the connector get through one full cycle before testing */
        intel_wait_for_vblank(dev, intel_crtc->pipe);
@@ -10572,7 +10556,8 @@ retry:
 
 fail:
        drm_atomic_state_free(state);
-       state = NULL;
+       drm_atomic_state_free(restore_state);
+       restore_state = state = NULL;
 
        if (ret == -EDEADLK) {
                drm_modeset_backoff(ctx);
@@ -10586,65 +10571,24 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
                                    struct intel_load_detect_pipe *old,
                                    struct drm_modeset_acquire_ctx *ctx)
 {
-       struct drm_device *dev = connector->dev;
        struct intel_encoder *intel_encoder =
                intel_attached_encoder(connector);
        struct drm_encoder *encoder = &intel_encoder->base;
-       struct drm_crtc *crtc = encoder->crtc;
-       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-       struct drm_atomic_state *state;
-       struct drm_connector_state *connector_state;
-       struct intel_crtc_state *crtc_state;
+       struct drm_atomic_state *state = old->restore_state;
        int ret;
 
        DRM_DEBUG_KMS("[CONNECTOR:%d:%s], [ENCODER:%d:%s]\n",
                      connector->base.id, connector->name,
                      encoder->base.id, encoder->name);
 
-       if (old->load_detect_temp) {
-               state = drm_atomic_state_alloc(dev);
-               if (!state)
-                       goto fail;
-
-               state->acquire_ctx = ctx;
-
-               connector_state = drm_atomic_get_connector_state(state, connector);
-               if (IS_ERR(connector_state))
-                       goto fail;
-
-               crtc_state = intel_atomic_get_crtc_state(state, intel_crtc);
-               if (IS_ERR(crtc_state))
-                       goto fail;
-
-               connector_state->crtc = NULL;
-
-               crtc_state->base.enable = crtc_state->base.active = false;
-
-               ret = intel_modeset_setup_plane_state(state, crtc, NULL, NULL,
-                                                     0, 0);
-               if (ret)
-                       goto fail;
-
-               ret = drm_atomic_commit(state);
-               if (ret)
-                       goto fail;
-
-               if (old->release_fb) {
-                       drm_framebuffer_unregister_private(old->release_fb);
-                       drm_framebuffer_unreference(old->release_fb);
-               }
-
+       if (!state)
                return;
-       }
 
-       /* Switch crtc and encoder back off if necessary */
-       if (old->dpms_mode != DRM_MODE_DPMS_ON)
-               connector->funcs->dpms(connector, old->dpms_mode);
-
-       return;
-fail:
-       DRM_DEBUG_KMS("Couldn't release load detect pipe.\n");
-       drm_atomic_state_free(state);
+       ret = drm_atomic_commit(state);
+       if (ret) {
+               DRM_DEBUG_KMS("Couldn't release load detect pipe: %i\n", ret);
+               drm_atomic_state_free(state);
+       }
 }
 
 static int i9xx_pll_refclk(struct drm_device *dev,
@@ -10914,6 +10858,7 @@ static void intel_unpin_work_fn(struct work_struct *__work)
        mutex_unlock(&dev->struct_mutex);
 
        intel_frontbuffer_flip_complete(dev, to_intel_plane(primary)->frontbuffer_bit);
+       intel_fbc_post_update(crtc);
        drm_framebuffer_unreference(work->old_fb);
 
        BUG_ON(atomic_read(&crtc->unpin_work_count) == 0);
@@ -10995,6 +10940,12 @@ static bool page_flip_finished(struct intel_crtc *crtc)
                return true;
 
        /*
+        * BDW signals flip done immediately if the plane
+        * is disabled, even if the plane enable is already
+        * armed to occur at the next vblank :(
+        */
+
+       /*
         * A DSPSURFLIVE check isn't enough in case the mmio and CS flips
         * used the same base address. In that case the mmio flip might
         * have completed, but the CS hasn't even executed the flip yet.
@@ -11629,6 +11580,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 
        crtc->primary->fb = fb;
        update_state_fb(crtc->primary);
+       intel_fbc_pre_update(intel_crtc);
 
        work->pending_flip_obj = obj;
 
@@ -11713,7 +11665,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
                          to_intel_plane(primary)->frontbuffer_bit);
        mutex_unlock(&dev->struct_mutex);
 
-       intel_fbc_deactivate(intel_crtc);
        intel_frontbuffer_flip_prepare(dev,
                                       to_intel_plane(primary)->frontbuffer_bit);
 
@@ -11724,7 +11675,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 cleanup_unpin:
        intel_unpin_fb_obj(fb, crtc->primary->state);
 cleanup_pending:
-       if (request)
+       if (!IS_ERR_OR_NULL(request))
                i915_gem_request_cancel(request);
        atomic_dec(&intel_crtc->unpin_work_count);
        mutex_unlock(&dev->struct_mutex);
@@ -11835,11 +11786,9 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
        struct drm_plane *plane = plane_state->plane;
        struct drm_device *dev = crtc->dev;
-       struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_plane_state *old_plane_state =
                to_intel_plane_state(plane->state);
        int idx = intel_crtc->base.base.id, ret;
-       int i = drm_plane_index(plane);
        bool mode_changed = needs_modeset(crtc_state);
        bool was_crtc_enabled = crtc->state->active;
        bool is_crtc_enabled = crtc_state->active;
@@ -11872,6 +11821,9 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
        if (!was_visible && !visible)
                return 0;
 
+       if (fb != old_plane_state->base.fb)
+               pipe_config->fb_changed = true;
+
        turn_off = was_visible && (!visible || mode_changed);
        turn_on = visible && (!was_visible || mode_changed);
 
@@ -11886,11 +11838,8 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
                pipe_config->wm_changed = true;
 
                /* must disable cxsr around plane enable/disable */
-               if (plane->type != DRM_PLANE_TYPE_CURSOR) {
-                       if (is_crtc_enabled)
-                               intel_crtc->atomic.wait_vblank = true;
+               if (plane->type != DRM_PLANE_TYPE_CURSOR)
                        pipe_config->disable_cxsr = true;
-               }
        } else if (intel_wm_need_update(plane, plane_state)) {
                pipe_config->wm_changed = true;
        }
@@ -11901,49 +11850,9 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
 
        switch (plane->type) {
        case DRM_PLANE_TYPE_PRIMARY:
-               intel_crtc->atomic.pre_disable_primary = turn_off;
                intel_crtc->atomic.post_enable_primary = turn_on;
+               intel_crtc->atomic.update_fbc = true;
 
-               if (turn_off) {
-                       /*
-                        * FIXME: Actually if we will still have any other
-                        * plane enabled on the pipe we could let IPS enabled
-                        * still, but for now lets consider that when we make
-                        * primary invisible by setting DSPCNTR to 0 on
-                        * update_primary_plane function IPS needs to be
-                        * disable.
-                        */
-                       intel_crtc->atomic.disable_ips = true;
-
-                       intel_crtc->atomic.disable_fbc = true;
-               }
-
-               /*
-                * FBC does not work on some platforms for rotated
-                * planes, so disable it when rotation is not 0 and
-                * update it when rotation is set back to 0.
-                *
-                * FIXME: This is redundant with the fbc update done in
-                * the primary plane enable function except that that
-                * one is done too late. We eventually need to unify
-                * this.
-                */
-
-               if (visible &&
-                   INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev) &&
-                   dev_priv->fbc.crtc == intel_crtc &&
-                   plane_state->rotation != BIT(DRM_ROTATE_0))
-                       intel_crtc->atomic.disable_fbc = true;
-
-               /*
-                * BDW signals flip done immediately if the plane
-                * is disabled, even if the plane enable is already
-                * armed to occur at the next vblank :(
-                */
-               if (turn_on && IS_BROADWELL(dev))
-                       intel_crtc->atomic.wait_vblank = true;
-
-               intel_crtc->atomic.update_fbc |= visible || mode_changed;
                break;
        case DRM_PLANE_TYPE_CURSOR:
                break;
@@ -11956,13 +11865,8 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
                 */
                if (IS_IVYBRIDGE(dev) &&
                    needs_scaling(to_intel_plane_state(plane_state)) &&
-                   !needs_scaling(old_plane_state)) {
-                       to_intel_crtc_state(crtc_state)->disable_lp_wm = true;
-               } else if (turn_off && !mode_changed) {
-                       intel_crtc->atomic.wait_vblank = true;
-                       intel_crtc->atomic.update_sprite_watermarks |=
-                               1 << i;
-               }
+                   !needs_scaling(old_plane_state))
+                       pipe_config->disable_lp_wm = true;
 
                break;
        }
@@ -13130,8 +13034,6 @@ static void intel_modeset_clear_plls(struct drm_atomic_state *state)
        struct drm_device *dev = state->dev;
        struct drm_i915_private *dev_priv = to_i915(dev);
        struct intel_shared_dpll_config *shared_dpll = NULL;
-       struct intel_crtc *intel_crtc;
-       struct intel_crtc_state *intel_crtc_state;
        struct drm_crtc *crtc;
        struct drm_crtc_state *crtc_state;
        int i;
@@ -13140,21 +13042,21 @@ static void intel_modeset_clear_plls(struct drm_atomic_state *state)
                return;
 
        for_each_crtc_in_state(state, crtc, crtc_state, i) {
-               int dpll;
-
-               intel_crtc = to_intel_crtc(crtc);
-               intel_crtc_state = to_intel_crtc_state(crtc_state);
-               dpll = intel_crtc_state->shared_dpll;
+               struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+               int old_dpll = to_intel_crtc_state(crtc->state)->shared_dpll;
 
-               if (!needs_modeset(crtc_state) || dpll == DPLL_ID_PRIVATE)
+               if (!needs_modeset(crtc_state))
                        continue;
 
-               intel_crtc_state->shared_dpll = DPLL_ID_PRIVATE;
+               to_intel_crtc_state(crtc_state)->shared_dpll = DPLL_ID_PRIVATE;
+
+               if (old_dpll == DPLL_ID_PRIVATE)
+                       continue;
 
                if (!shared_dpll)
                        shared_dpll = intel_atomic_get_shared_dpll_state(state);
 
-               shared_dpll[dpll].crtc_mask &= ~(1 << intel_crtc->pipe);
+               shared_dpll[old_dpll].crtc_mask &= ~(1 << intel_crtc->pipe);
        }
 }
 
@@ -13290,6 +13192,9 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
 
                if (ret < 0)
                        return ret;
+
+               DRM_DEBUG_KMS("New cdclk calculated to be atomic %u, actual %u\n",
+                             intel_state->cdclk, intel_state->dev_cdclk);
        } else
                to_intel_atomic_state(state)->cdclk = dev_priv->atomic_cdclk_freq;
 
@@ -13348,6 +13253,7 @@ static void calc_watermark_data(struct drm_atomic_state *state)
 static int intel_atomic_check(struct drm_device *dev,
                              struct drm_atomic_state *state)
 {
+       struct drm_i915_private *dev_priv = to_i915(dev);
        struct intel_atomic_state *intel_state = to_intel_atomic_state(state);
        struct drm_crtc *crtc;
        struct drm_crtc_state *crtc_state;
@@ -13390,7 +13296,7 @@ static int intel_atomic_check(struct drm_device *dev,
                        return ret;
 
                if (i915.fastboot &&
-                   intel_pipe_config_compare(state->dev,
+                   intel_pipe_config_compare(dev,
                                        to_intel_crtc_state(crtc->state),
                                        pipe_config, true)) {
                        crtc_state->mode_changed = false;
@@ -13416,12 +13322,13 @@ static int intel_atomic_check(struct drm_device *dev,
                if (ret)
                        return ret;
        } else
-               intel_state->cdclk = to_i915(state->dev)->cdclk_freq;
+               intel_state->cdclk = dev_priv->cdclk_freq;
 
-       ret = drm_atomic_helper_check_planes(state->dev, state);
+       ret = drm_atomic_helper_check_planes(dev, state);
        if (ret)
                return ret;
 
+       intel_fbc_choose_crtc(dev_priv, state);
        calc_watermark_data(state);
 
        return 0;
@@ -13493,6 +13400,71 @@ static int intel_atomic_prepare_commit(struct drm_device *dev,
        return ret;
 }
 
+static void intel_atomic_wait_for_vblanks(struct drm_device *dev,
+                                         struct drm_i915_private *dev_priv,
+                                         unsigned crtc_mask)
+{
+       unsigned last_vblank_count[I915_MAX_PIPES];
+       enum pipe pipe;
+       int ret;
+
+       if (!crtc_mask)
+               return;
+
+       for_each_pipe(dev_priv, pipe) {
+               struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
+
+               if (!((1 << pipe) & crtc_mask))
+                       continue;
+
+               ret = drm_crtc_vblank_get(crtc);
+               if (WARN_ON(ret != 0)) {
+                       crtc_mask &= ~(1 << pipe);
+                       continue;
+               }
+
+               last_vblank_count[pipe] = drm_crtc_vblank_count(crtc);
+       }
+
+       for_each_pipe(dev_priv, pipe) {
+               struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
+               long lret;
+
+               if (!((1 << pipe) & crtc_mask))
+                       continue;
+
+               lret = wait_event_timeout(dev->vblank[pipe].queue,
+                               last_vblank_count[pipe] !=
+                                       drm_crtc_vblank_count(crtc),
+                               msecs_to_jiffies(50));
+
+               WARN_ON(!lret);
+
+               drm_crtc_vblank_put(crtc);
+       }
+}
+
+static bool needs_vblank_wait(struct intel_crtc_state *crtc_state)
+{
+       /* fb updated, need to unpin old fb */
+       if (crtc_state->fb_changed)
+               return true;
+
+       /* wm changes, need vblank before final wm's */
+       if (crtc_state->wm_changed)
+               return true;
+
+       /*
+        * cxsr is re-enabled after vblank.
+        * This is already handled by crtc_state->wm_changed,
+        * but added for clarity.
+        */
+       if (crtc_state->disable_cxsr)
+               return true;
+
+       return false;
+}
+
 /**
  * intel_atomic_commit - commit validated state object
  * @dev: DRM device
@@ -13519,6 +13491,8 @@ static int intel_atomic_commit(struct drm_device *dev,
        struct drm_crtc *crtc;
        int ret = 0, i;
        bool hw_check = intel_state->modeset;
+       unsigned long put_domains[I915_MAX_PIPES] = {};
+       unsigned crtc_vblank_mask = 0;
 
        ret = intel_atomic_prepare_commit(dev, state, async);
        if (ret) {
@@ -13534,20 +13508,32 @@ static int intel_atomic_commit(struct drm_device *dev,
                       sizeof(intel_state->min_pixclk));
                dev_priv->active_crtcs = intel_state->active_crtcs;
                dev_priv->atomic_cdclk_freq = intel_state->cdclk;
+
+               intel_display_power_get(dev_priv, POWER_DOMAIN_MODESET);
        }
 
        for_each_crtc_in_state(state, crtc, crtc_state, i) {
                struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
+               if (needs_modeset(crtc->state) ||
+                   to_intel_crtc_state(crtc->state)->update_pipe) {
+                       hw_check = true;
+
+                       put_domains[to_intel_crtc(crtc)->pipe] =
+                               modeset_get_crtc_power_domains(crtc,
+                                       to_intel_crtc_state(crtc->state));
+               }
+
                if (!needs_modeset(crtc->state))
                        continue;
 
-               intel_pre_plane_update(intel_crtc);
+               intel_pre_plane_update(to_intel_crtc_state(crtc_state));
 
                if (crtc_state->active) {
                        intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
                        dev_priv->display.crtc_disable(crtc);
                        intel_crtc->active = false;
+                       intel_fbc_disable(intel_crtc);
                        intel_disable_shared_dpll(intel_crtc);
 
                        /*
@@ -13570,51 +13556,53 @@ static int intel_atomic_commit(struct drm_device *dev,
                intel_shared_dpll_commit(state);
 
                drm_atomic_helper_update_legacy_modeset_state(state->dev, state);
-               modeset_update_crtc_power_domains(state);
+
+               if (dev_priv->display.modeset_commit_cdclk &&
+                   intel_state->dev_cdclk != dev_priv->cdclk_freq)
+                       dev_priv->display.modeset_commit_cdclk(state);
        }
 
        /* Now enable the clocks, plane, pipe, and connectors that we set up. */
        for_each_crtc_in_state(state, crtc, crtc_state, i) {
                struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
                bool modeset = needs_modeset(crtc->state);
-               bool update_pipe = !modeset &&
-                       to_intel_crtc_state(crtc->state)->update_pipe;
-               unsigned long put_domains = 0;
-
-               if (modeset)
-                       intel_display_power_get(dev_priv, POWER_DOMAIN_MODESET);
+               struct intel_crtc_state *pipe_config =
+                       to_intel_crtc_state(crtc->state);
+               bool update_pipe = !modeset && pipe_config->update_pipe;
 
                if (modeset && crtc->state->active) {
                        update_scanline_offset(to_intel_crtc(crtc));
                        dev_priv->display.crtc_enable(crtc);
                }
 
-               if (update_pipe) {
-                       put_domains = modeset_get_crtc_power_domains(crtc);
-
-                       /* make sure intel_modeset_check_state runs */
-                       hw_check = true;
-               }
-
                if (!modeset)
-                       intel_pre_plane_update(intel_crtc);
+                       intel_pre_plane_update(to_intel_crtc_state(crtc_state));
+
+               if (crtc->state->active && intel_crtc->atomic.update_fbc)
+                       intel_fbc_enable(intel_crtc);
 
                if (crtc->state->active &&
                    (crtc->state->planes_changed || update_pipe))
                        drm_atomic_helper_commit_planes_on_crtc(crtc_state);
 
-               if (put_domains)
-                       modeset_put_power_domains(dev_priv, put_domains);
-
-               intel_post_plane_update(intel_crtc);
-
-               if (modeset)
-                       intel_display_power_put(dev_priv, POWER_DOMAIN_MODESET);
+               if (pipe_config->base.active && needs_vblank_wait(pipe_config))
+                       crtc_vblank_mask |= 1 << i;
        }
 
        /* FIXME: add subpixel order */
 
-       drm_atomic_helper_wait_for_vblanks(dev, state);
+       if (!state->legacy_cursor_update)
+               intel_atomic_wait_for_vblanks(dev, dev_priv, crtc_vblank_mask);
+
+       for_each_crtc_in_state(state, crtc, crtc_state, i) {
+               intel_post_plane_update(to_intel_crtc(crtc));
+
+               if (put_domains[i])
+                       modeset_put_power_domains(dev_priv, put_domains[i]);
+       }
+
+       if (intel_state->modeset)
+               intel_display_power_put(dev_priv, POWER_DOMAIN_MODESET);
 
        mutex_lock(&dev->struct_mutex);
        drm_atomic_helper_cleanup_planes(dev, state);
@@ -13696,7 +13684,7 @@ static bool ibx_pch_dpll_get_hw_state(struct drm_i915_private *dev_priv,
 {
        uint32_t val;
 
-       if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS))
+       if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_PLLS))
                return false;
 
        val = I915_READ(PCH_DPLL(pll->id));
@@ -13704,6 +13692,8 @@ static bool ibx_pch_dpll_get_hw_state(struct drm_i915_private *dev_priv,
        hw_state->fp0 = I915_READ(PCH_FP0(pll->id));
        hw_state->fp1 = I915_READ(PCH_FP1(pll->id));
 
+       intel_display_power_put(dev_priv, POWER_DOMAIN_PLLS);
+
        return val & DPLL_VCO_ENABLE;
 }
 
@@ -14682,10 +14672,12 @@ u32 intel_fb_pitch_limit(struct drm_device *dev, uint64_t fb_modifier,
        u32 gen = INTEL_INFO(dev)->gen;
 
        if (gen >= 9) {
+               int cpp = drm_format_plane_cpp(pixel_format, 0);
+
                /* "The stride in bytes must not exceed the of the size of 8K
                 *  pixels and 32K bytes."
                 */
-                return min(8192*drm_format_plane_cpp(pixel_format, 0), 32768);
+               return min(8192 * cpp, 32768);
        } else if (gen >= 5 && !IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev)) {
                return 32*1024;
        } else if (gen >= 4) {
@@ -15517,6 +15509,17 @@ static bool intel_crtc_has_encoders(struct intel_crtc *crtc)
        return false;
 }
 
+static bool intel_encoder_has_connectors(struct intel_encoder *encoder)
+{
+       struct drm_device *dev = encoder->base.dev;
+       struct intel_connector *connector;
+
+       for_each_connector_on_encoder(dev, &encoder->base, connector)
+               return true;
+
+       return false;
+}
+
 static void intel_sanitize_crtc(struct intel_crtc *crtc)
 {
        struct drm_device *dev = crtc->base.dev;
@@ -15627,7 +15630,6 @@ static void intel_sanitize_encoder(struct intel_encoder *encoder)
 {
        struct intel_connector *connector;
        struct drm_device *dev = encoder->base.dev;
-       bool active = false;
 
        /* We need to check both for a crtc link (meaning that the
         * encoder is active and trying to read from a pipe) and the
@@ -15635,15 +15637,7 @@ static void intel_sanitize_encoder(struct intel_encoder *encoder)
        bool has_active_crtc = encoder->base.crtc &&
                to_intel_crtc(encoder->base.crtc)->active;
 
-       for_each_intel_connector(dev, connector) {
-               if (connector->base.encoder != &encoder->base)
-                       continue;
-
-               active = true;
-               break;
-       }
-
-       if (active && !has_active_crtc) {
+       if (intel_encoder_has_connectors(encoder) && !has_active_crtc) {
                DRM_DEBUG_KMS("[ENCODER:%d:%s] has active connectors but no active pipe!\n",
                              encoder->base.base.id,
                              encoder->base.name);
@@ -15698,10 +15692,12 @@ void i915_redisable_vga(struct drm_device *dev)
         * level, just check if the power well is enabled instead of trying to
         * follow the "don't touch the power well if we don't need it" policy
         * the rest of the driver uses. */
-       if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_VGA))
+       if (!intel_display_power_get_if_enabled(dev_priv, POWER_DOMAIN_VGA))
                return;
 
        i915_redisable_vga_power_on(dev);
+
+       intel_display_power_put(dev_priv, POWER_DOMAIN_VGA);
 }
 
 static bool primary_get_hw_state(struct intel_plane *plane)
@@ -15929,63 +15925,76 @@ intel_modeset_setup_hw_state(struct drm_device *dev)
        for_each_intel_crtc(dev, crtc) {
                unsigned long put_domains;
 
-               put_domains = modeset_get_crtc_power_domains(&crtc->base);
+               put_domains = modeset_get_crtc_power_domains(&crtc->base, crtc->config);
                if (WARN_ON(put_domains))
                        modeset_put_power_domains(dev_priv, put_domains);
        }
        intel_display_set_init_power(dev_priv, false);
+
+       intel_fbc_init_pipe_state(dev_priv);
 }
 
 void intel_display_resume(struct drm_device *dev)
 {
-       struct drm_atomic_state *state = drm_atomic_state_alloc(dev);
-       struct intel_connector *conn;
-       struct intel_plane *plane;
-       struct drm_crtc *crtc;
+       struct drm_i915_private *dev_priv = to_i915(dev);
+       struct drm_atomic_state *state = dev_priv->modeset_restore_state;
+       struct drm_modeset_acquire_ctx ctx;
        int ret;
+       bool setup = false;
 
-       if (!state)
-               return;
-
-       state->acquire_ctx = dev->mode_config.acquire_ctx;
+       dev_priv->modeset_restore_state = NULL;
 
-       /* preserve complete old state, including dpll */
-       intel_atomic_get_shared_dpll_state(state);
+       /*
+        * This is a cludge because with real atomic modeset mode_config.mutex
+        * won't be taken. Unfortunately some probed state like
+        * audio_codec_enable is still protected by mode_config.mutex, so lock
+        * it here for now.
+        */
+       mutex_lock(&dev->mode_config.mutex);
+       drm_modeset_acquire_init(&ctx, 0);
 
-       for_each_crtc(dev, crtc) {
-               struct drm_crtc_state *crtc_state =
-                       drm_atomic_get_crtc_state(state, crtc);
+retry:
+       ret = drm_modeset_lock_all_ctx(dev, &ctx);
 
-               ret = PTR_ERR_OR_ZERO(crtc_state);
-               if (ret)
-                       goto err;
+       if (ret == 0 && !setup) {
+               setup = true;
 
-               /* force a restore */
-               crtc_state->mode_changed = true;
+               intel_modeset_setup_hw_state(dev);
+               i915_redisable_vga(dev);
        }
 
-       for_each_intel_plane(dev, plane) {
-               ret = PTR_ERR_OR_ZERO(drm_atomic_get_plane_state(state, &plane->base));
-               if (ret)
-                       goto err;
-       }
+       if (ret == 0 && state) {
+               struct drm_crtc_state *crtc_state;
+               struct drm_crtc *crtc;
+               int i;
 
-       for_each_intel_connector(dev, conn) {
-               ret = PTR_ERR_OR_ZERO(drm_atomic_get_connector_state(state, &conn->base));
-               if (ret)
-                       goto err;
+               state->acquire_ctx = &ctx;
+
+               for_each_crtc_in_state(state, crtc, crtc_state, i) {
+                       /*
+                        * Force recalculation even if we restore
+                        * current state. With fast modeset this may not result
+                        * in a modeset when the state is compatible.
+                        */
+                       crtc_state->mode_changed = true;
+               }
+
+               ret = drm_atomic_commit(state);
        }
 
-       intel_modeset_setup_hw_state(dev);
+       if (ret == -EDEADLK) {
+               drm_modeset_backoff(&ctx);
+               goto retry;
+       }
 
-       i915_redisable_vga(dev);
-       ret = drm_atomic_commit(state);
-       if (!ret)
-               return;
+       drm_modeset_drop_locks(&ctx);
+       drm_modeset_acquire_fini(&ctx);
+       mutex_unlock(&dev->mode_config.mutex);
 
-err:
-       DRM_ERROR("Restoring old state failed with %i\n", ret);
-       drm_atomic_state_free(state);
+       if (ret) {
+               DRM_ERROR("Restoring old state failed with %i\n", ret);
+               drm_atomic_state_free(state);
+       }
 }
 
 void intel_modeset_gem_init(struct drm_device *dev)
@@ -15994,9 +16003,7 @@ void intel_modeset_gem_init(struct drm_device *dev)
        struct drm_i915_gem_object *obj;
        int ret;
 
-       mutex_lock(&dev->struct_mutex);
        intel_init_gt_powersave(dev);
-       mutex_unlock(&dev->struct_mutex);
 
        intel_modeset_init_hw(dev);
 
@@ -16063,7 +16070,7 @@ void intel_modeset_cleanup(struct drm_device *dev)
 
        intel_unregister_dsm_handler();
 
-       intel_fbc_disable(dev_priv);
+       intel_fbc_global_disable(dev_priv);
 
        /* flush any delayed tasks or pending work */
        flush_scheduled_work();
@@ -16076,9 +16083,7 @@ void intel_modeset_cleanup(struct drm_device *dev)
 
        intel_cleanup_overlay(dev);
 
-       mutex_lock(&dev->struct_mutex);
        intel_cleanup_gt_powersave(dev);
-       mutex_unlock(&dev->struct_mutex);
 
        intel_teardown_gmbus(dev);
 }
index da704c6..f069a82 100644 (file)
@@ -203,6 +203,7 @@ intel_dp_mode_valid(struct drm_connector *connector,
        struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
        int target_clock = mode->clock;
        int max_rate, mode_rate, max_lanes, max_link_clock;
+       int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
 
        if (is_edp(intel_dp) && fixed_mode) {
                if (mode->hdisplay > fixed_mode->hdisplay)
@@ -220,7 +221,7 @@ intel_dp_mode_valid(struct drm_connector *connector,
        max_rate = intel_dp_max_data_rate(max_link_clock, max_lanes);
        mode_rate = intel_dp_link_required(target_clock, 18);
 
-       if (mode_rate > max_rate)
+       if (mode_rate > max_rate || target_clock > max_dotclk)
                return MODE_CLOCK_HIGH;
 
        if (mode->clock < 10000)
@@ -979,7 +980,10 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
                if (WARN_ON(txsize > 20))
                        return -E2BIG;
 
-               memcpy(txbuf + HEADER_SIZE, msg->buffer, msg->size);
+               if (msg->buffer)
+                       memcpy(txbuf + HEADER_SIZE, msg->buffer, msg->size);
+               else
+                       WARN_ON(msg->size);
 
                ret = intel_dp_aux_ch(intel_dp, txbuf, txsize, rxbuf, rxsize);
                if (ret > 0) {
@@ -1798,12 +1802,21 @@ static void wait_panel_off(struct intel_dp *intel_dp)
 
 static void wait_panel_power_cycle(struct intel_dp *intel_dp)
 {
+       ktime_t panel_power_on_time;
+       s64 panel_power_off_duration;
+
        DRM_DEBUG_KMS("Wait for panel power cycle\n");
 
+       /* take the difference of currrent time and panel power off time
+        * and then make panel wait for t11_t12 if needed. */
+       panel_power_on_time = ktime_get_boottime();
+       panel_power_off_duration = ktime_ms_delta(panel_power_on_time, intel_dp->panel_power_off_time);
+
        /* When we disable the VDD override bit last we have to do the manual
         * wait. */
-       wait_remaining_ms_from_jiffies(intel_dp->last_power_cycle,
-                                      intel_dp->panel_power_cycle_delay);
+       if (panel_power_off_duration < (s64)intel_dp->panel_power_cycle_delay)
+               wait_remaining_ms_from_jiffies(jiffies,
+                                      intel_dp->panel_power_cycle_delay - panel_power_off_duration);
 
        wait_panel_status(intel_dp, IDLE_CYCLE_MASK, IDLE_CYCLE_VALUE);
 }
@@ -1955,7 +1968,7 @@ static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp)
        I915_READ(pp_stat_reg), I915_READ(pp_ctrl_reg));
 
        if ((pp & POWER_TARGET_ON) == 0)
-               intel_dp->last_power_cycle = jiffies;
+               intel_dp->panel_power_off_time = ktime_get_boottime();
 
        power_domain = intel_display_port_aux_power_domain(intel_encoder);
        intel_display_power_put(dev_priv, power_domain);
@@ -2104,7 +2117,7 @@ static void edp_panel_off(struct intel_dp *intel_dp)
        I915_WRITE(pp_ctrl_reg, pp);
        POSTING_READ(pp_ctrl_reg);
 
-       intel_dp->last_power_cycle = jiffies;
+       intel_dp->panel_power_off_time = ktime_get_boottime();
        wait_panel_off(intel_dp);
 
        /* We got a reference when we enabled the VDD. */
@@ -2343,15 +2356,18 @@ static bool intel_dp_get_hw_state(struct intel_encoder *encoder,
        struct drm_i915_private *dev_priv = dev->dev_private;
        enum intel_display_power_domain power_domain;
        u32 tmp;
+       bool ret;
 
        power_domain = intel_display_port_power_domain(encoder);
-       if (!intel_display_power_is_enabled(dev_priv, power_domain))
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                return false;
 
+       ret = false;
+
        tmp = I915_READ(intel_dp->output_reg);
 
        if (!(tmp & DP_PORT_EN))
-               return false;
+               goto out;
 
        if (IS_GEN7(dev) && port == PORT_A) {
                *pipe = PORT_TO_PIPE_CPT(tmp);
@@ -2362,7 +2378,9 @@ static bool intel_dp_get_hw_state(struct intel_encoder *encoder,
                        u32 trans_dp = I915_READ(TRANS_DP_CTL(p));
                        if (TRANS_DP_PIPE_TO_PORT(trans_dp) == port) {
                                *pipe = p;
-                               return true;
+                               ret = true;
+
+                               goto out;
                        }
                }
 
@@ -2374,7 +2392,12 @@ static bool intel_dp_get_hw_state(struct intel_encoder *encoder,
                *pipe = PORT_TO_PIPE(tmp);
        }
 
-       return true;
+       ret = true;
+
+out:
+       intel_display_power_put(dev_priv, power_domain);
+
+       return ret;
 }
 
 static void intel_dp_get_config(struct intel_encoder *encoder,
@@ -3995,7 +4018,7 @@ static int intel_dp_sink_crc_stop(struct intel_dp *intel_dp)
        } while (--attempts && count);
 
        if (attempts == 0) {
-               DRM_ERROR("TIMEOUT: Sink CRC counter is not zeroed\n");
+               DRM_DEBUG_KMS("TIMEOUT: Sink CRC counter is not zeroed after calculation is stopped\n");
                ret = -ETIMEDOUT;
        }
 
@@ -4474,20 +4497,20 @@ static bool g4x_digital_port_connected(struct drm_i915_private *dev_priv,
        return I915_READ(PORT_HOTPLUG_STAT) & bit;
 }
 
-static bool vlv_digital_port_connected(struct drm_i915_private *dev_priv,
-                                      struct intel_digital_port *port)
+static bool gm45_digital_port_connected(struct drm_i915_private *dev_priv,
+                                       struct intel_digital_port *port)
 {
        u32 bit;
 
        switch (port->port) {
        case PORT_B:
-               bit = PORTB_HOTPLUG_LIVE_STATUS_VLV;
+               bit = PORTB_HOTPLUG_LIVE_STATUS_GM45;
                break;
        case PORT_C:
-               bit = PORTC_HOTPLUG_LIVE_STATUS_VLV;
+               bit = PORTC_HOTPLUG_LIVE_STATUS_GM45;
                break;
        case PORT_D:
-               bit = PORTD_HOTPLUG_LIVE_STATUS_VLV;
+               bit = PORTD_HOTPLUG_LIVE_STATUS_GM45;
                break;
        default:
                MISSING_CASE(port->port);
@@ -4535,12 +4558,12 @@ bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
 {
        if (HAS_PCH_IBX(dev_priv))
                return ibx_digital_port_connected(dev_priv, port);
-       if (HAS_PCH_SPLIT(dev_priv))
+       else if (HAS_PCH_SPLIT(dev_priv))
                return cpt_digital_port_connected(dev_priv, port);
        else if (IS_BROXTON(dev_priv))
                return bxt_digital_port_connected(dev_priv, port);
-       else if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
-               return vlv_digital_port_connected(dev_priv, port);
+       else if (IS_GM45(dev_priv))
+               return gm45_digital_port_connected(dev_priv, port);
        else
                return g4x_digital_port_connected(dev_priv, port);
 }
@@ -5102,7 +5125,7 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *connect
 
 static void intel_dp_init_panel_power_timestamps(struct intel_dp *intel_dp)
 {
-       intel_dp->last_power_cycle = jiffies;
+       intel_dp->panel_power_off_time = ktime_get_boottime();
        intel_dp->last_power_on = jiffies;
        intel_dp->last_backlight_off = jiffies;
 }
@@ -6020,7 +6043,6 @@ intel_dp_init(struct drm_device *dev,
        }
 
        intel_dig_port->port = port;
-       dev_priv->dig_port_map[port] = intel_encoder;
        intel_dig_port->dp.output_reg = output_reg;
        intel_dig_port->max_lanes = 4;
 
index 8888793..0b8eefc 100644 (file)
@@ -215,27 +215,46 @@ intel_dp_link_training_clock_recovery(struct intel_dp *intel_dp)
        }
 }
 
-static void
-intel_dp_link_training_channel_equalization(struct intel_dp *intel_dp)
+/*
+ * Pick training pattern for channel equalization. Training Pattern 3 for HBR2
+ * or 1.2 devices that support it, Training Pattern 2 otherwise.
+ */
+static u32 intel_dp_training_pattern(struct intel_dp *intel_dp)
 {
-       bool channel_eq = false;
-       int tries, cr_tries;
-       uint32_t training_pattern = DP_TRAINING_PATTERN_2;
+       u32 training_pattern = DP_TRAINING_PATTERN_2;
+       bool source_tps3, sink_tps3;
 
        /*
-        * Training Pattern 3 for HBR2 or 1.2 devices that support it.
-        *
         * Intel platforms that support HBR2 also support TPS3. TPS3 support is
-        * also mandatory for downstream devices that support HBR2.
+        * also mandatory for downstream devices that support HBR2. However, not
+        * all sinks follow the spec.
         *
         * Due to WaDisableHBR2 SKL < B0 is the only exception where TPS3 is
-        * supported but still not enabled.
+        * supported in source but still not enabled.
         */
-       if (intel_dp_source_supports_hbr2(intel_dp) &&
-           drm_dp_tps3_supported(intel_dp->dpcd))
+       source_tps3 = intel_dp_source_supports_hbr2(intel_dp);
+       sink_tps3 = drm_dp_tps3_supported(intel_dp->dpcd);
+
+       if (source_tps3 && sink_tps3) {
                training_pattern = DP_TRAINING_PATTERN_3;
-       else if (intel_dp->link_rate == 540000)
-               DRM_ERROR("5.4 Gbps link rate without HBR2/TPS3 support\n");
+       } else if (intel_dp->link_rate == 540000) {
+               if (!source_tps3)
+                       DRM_DEBUG_KMS("5.4 Gbps link rate without source HBR2/TPS3 support\n");
+               if (!sink_tps3)
+                       DRM_DEBUG_KMS("5.4 Gbps link rate without sink TPS3 support\n");
+       }
+
+       return training_pattern;
+}
+
+static void
+intel_dp_link_training_channel_equalization(struct intel_dp *intel_dp)
+{
+       bool channel_eq = false;
+       int tries, cr_tries;
+       u32 training_pattern;
+
+       training_pattern = intel_dp_training_pattern(intel_dp);
 
        /* channel equalization */
        if (!intel_dp_set_link_train(intel_dp,
index 2a2ab30..a2bd698 100644 (file)
@@ -371,6 +371,8 @@ static enum drm_mode_status
 intel_dp_mst_mode_valid(struct drm_connector *connector,
                        struct drm_display_mode *mode)
 {
+       int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
+
        /* TODO - validate mode against available PBN for link */
        if (mode->clock < 10000)
                return MODE_CLOCK_LOW;
@@ -378,6 +380,9 @@ intel_dp_mst_mode_valid(struct drm_connector *connector,
        if (mode->flags & DRM_MODE_FLAG_DBLCLK)
                return MODE_H_ILLEGAL;
 
+       if (mode->clock > max_dotclk)
+               return MODE_CLOCK_HIGH;
+
        return MODE_OK;
 }
 
index bf6f981..4c027d6 100644 (file)
@@ -379,6 +379,7 @@ struct intel_crtc_state {
        bool update_pipe; /* can a fast modeset be performed? */
        bool disable_cxsr;
        bool wm_changed; /* watermarks are updated */
+       bool fb_changed; /* fb on any of the planes is changed */
 
        /* Pipe source size (ie. panel fitter input size)
         * All planes will be positioned inside this space,
@@ -492,6 +493,8 @@ struct intel_crtc_state {
 
        bool ips_enabled;
 
+       bool enable_fbc;
+
        bool double_wide;
 
        bool dp_encoder_is_mst;
@@ -542,16 +545,13 @@ struct intel_mmio_flip {
  */
 struct intel_crtc_atomic_commit {
        /* Sleepable operations to perform before commit */
-       bool disable_fbc;
-       bool disable_ips;
-       bool pre_disable_primary;
 
        /* Sleepable operations to perform after commit */
        unsigned fb_bits;
-       bool wait_vblank;
-       bool update_fbc;
        bool post_enable_primary;
-       unsigned update_sprite_watermarks;
+
+       /* Sleepable operations to perform before and after commit */
+       bool update_fbc;
 };
 
 struct intel_crtc {
@@ -575,7 +575,7 @@ struct intel_crtc {
        /* Display surface base address adjustement for pageflips. Note that on
         * gen4+ this only adjusts up to a tile, offsets within a tile are
         * handled in the hw itself (with the TILEOFF register). */
-       unsigned long dspaddr_offset;
+       u32 dspaddr_offset;
        int adjusted_x;
        int adjusted_y;
 
@@ -770,9 +770,9 @@ struct intel_dp {
        int backlight_off_delay;
        struct delayed_work panel_vdd_work;
        bool want_panel_vdd;
-       unsigned long last_power_cycle;
        unsigned long last_power_on;
        unsigned long last_backlight_off;
+       ktime_t panel_power_off_time;
 
        struct notifier_block edp_notifier;
 
@@ -909,9 +909,7 @@ struct intel_unpin_work {
 };
 
 struct intel_load_detect_pipe {
-       struct drm_framebuffer *release_fb;
-       bool load_detect_temp;
-       int dpms_mode;
+       struct drm_atomic_state *restore_state;
 };
 
 static inline struct intel_encoder *
@@ -994,6 +992,8 @@ static inline bool intel_irqs_enabled(struct drm_i915_private *dev_priv)
 int intel_get_crtc_scanline(struct intel_crtc *crtc);
 void gen8_irq_power_well_post_enable(struct drm_i915_private *dev_priv,
                                     unsigned int pipe_mask);
+void gen8_irq_power_well_pre_disable(struct drm_i915_private *dev_priv,
+                                    unsigned int pipe_mask);
 
 /* intel_crt.c */
 void intel_crt_init(struct drm_device *dev);
@@ -1172,11 +1172,11 @@ void assert_fdi_rx_pll(struct drm_i915_private *dev_priv,
 void assert_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, bool state);
 #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
-unsigned long intel_compute_tile_offset(struct drm_i915_private *dev_priv,
-                                       int *x, int *y,
-                                       uint64_t fb_modifier,
-                                       unsigned int cpp,
-                                       unsigned int pitch);
+u32 intel_compute_tile_offset(struct drm_i915_private *dev_priv,
+                             int *x, int *y,
+                             uint64_t fb_modifier,
+                             unsigned int cpp,
+                             unsigned int pitch);
 void intel_prepare_reset(struct drm_device *dev);
 void intel_finish_reset(struct drm_device *dev);
 void hsw_enable_pc8(struct drm_i915_private *dev_priv);
@@ -1226,7 +1226,7 @@ u32 skl_plane_ctl_rotation(unsigned int rotation);
 
 /* intel_csr.c */
 void intel_csr_ucode_init(struct drm_i915_private *);
-void intel_csr_load_program(struct drm_i915_private *);
+bool intel_csr_load_program(struct drm_i915_private *);
 void intel_csr_ucode_fini(struct drm_i915_private *);
 
 /* intel_dp.c */
@@ -1327,13 +1327,16 @@ static inline void intel_fbdev_restore_mode(struct drm_device *dev)
 #endif
 
 /* intel_fbc.c */
+void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
+                          struct drm_atomic_state *state);
 bool intel_fbc_is_active(struct drm_i915_private *dev_priv);
-void intel_fbc_deactivate(struct intel_crtc *crtc);
-void intel_fbc_update(struct intel_crtc *crtc);
+void intel_fbc_pre_update(struct intel_crtc *crtc);
+void intel_fbc_post_update(struct intel_crtc *crtc);
 void intel_fbc_init(struct drm_i915_private *dev_priv);
+void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv);
 void intel_fbc_enable(struct intel_crtc *crtc);
-void intel_fbc_disable(struct drm_i915_private *dev_priv);
-void intel_fbc_disable_crtc(struct intel_crtc *crtc);
+void intel_fbc_disable(struct intel_crtc *crtc);
+void intel_fbc_global_disable(struct drm_i915_private *dev_priv);
 void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
                          unsigned int frontbuffer_bits,
                          enum fb_op_origin origin);
@@ -1432,6 +1435,8 @@ bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
                                      enum intel_display_power_domain domain);
 void intel_display_power_get(struct drm_i915_private *dev_priv,
                             enum intel_display_power_domain domain);
+bool intel_display_power_get_if_enabled(struct drm_i915_private *dev_priv,
+                                       enum intel_display_power_domain domain);
 void intel_display_power_put(struct drm_i915_private *dev_priv,
                             enum intel_display_power_domain domain);
 
@@ -1518,6 +1523,7 @@ enable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
        enable_rpm_wakeref_asserts(dev_priv)
 
 void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
+bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv);
 void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
 void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
 
@@ -1559,6 +1565,7 @@ void skl_wm_get_hw_state(struct drm_device *dev);
 void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
                          struct skl_ddb_allocation *ddb /* out */);
 uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config);
+int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6);
 
 /* intel_sdvo.c */
 bool intel_sdvo_init(struct drm_device *dev,
index 91cef35..01b8e9f 100644 (file)
@@ -478,8 +478,8 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
 
        DRM_DEBUG_KMS("\n");
 
-       intel_dsi_prepare(encoder);
        intel_enable_dsi_pll(encoder);
+       intel_dsi_prepare(encoder);
 
        /* Panel Enable over CRC PMIC */
        if (intel_dsi->gpio_panel)
@@ -634,7 +634,6 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 {
        struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
        struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
-       u32 val;
 
        DRM_DEBUG_KMS("\n");
 
@@ -642,9 +641,13 @@ static void intel_dsi_post_disable(struct intel_encoder *encoder)
 
        intel_dsi_clear_device_ready(encoder);
 
-       val = I915_READ(DSPCLK_GATE_D);
-       val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
-       I915_WRITE(DSPCLK_GATE_D, val);
+       if (!IS_BROXTON(dev_priv)) {
+               u32 val;
+
+               val = I915_READ(DSPCLK_GATE_D);
+               val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
+               I915_WRITE(DSPCLK_GATE_D, val);
+       }
 
        drm_panel_unprepare(intel_dsi->panel);
 
@@ -664,13 +667,16 @@ static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
        struct drm_device *dev = encoder->base.dev;
        enum intel_display_power_domain power_domain;
        enum port port;
+       bool ret;
 
        DRM_DEBUG_KMS("\n");
 
        power_domain = intel_display_port_power_domain(encoder);
-       if (!intel_display_power_is_enabled(dev_priv, power_domain))
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                return false;
 
+       ret = false;
+
        /* XXX: this only works for one DSI output */
        for_each_dsi_port(port, intel_dsi->ports) {
                i915_reg_t ctrl_reg = IS_BROXTON(dev) ?
@@ -691,12 +697,16 @@ static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
                if (dpi_enabled || (func & CMD_MODE_DATA_WIDTH_MASK)) {
                        if (I915_READ(MIPI_DEVICE_READY(port)) & DEVICE_READY) {
                                *pipe = port == PORT_A ? PIPE_A : PIPE_B;
-                               return true;
+                               ret = true;
+
+                               goto out;
                        }
                }
        }
+out:
+       intel_display_power_put(dev_priv, power_domain);
 
-       return false;
+       return ret;
 }
 
 static void intel_dsi_get_config(struct intel_encoder *encoder,
@@ -775,10 +785,9 @@ static void set_dsi_timings(struct drm_encoder *encoder,
 {
        struct drm_device *dev = encoder->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
-       struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
        struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
        enum port port;
-       unsigned int bpp = intel_crtc->config->pipe_bpp;
+       unsigned int bpp = dsi_pixel_format_bpp(intel_dsi->pixel_format);
        unsigned int lane_count = intel_dsi->lane_count;
 
        u16 hactive, hfp, hsync, hbp, vfp, vsync, vbp;
@@ -849,7 +858,7 @@ static void intel_dsi_prepare(struct intel_encoder *intel_encoder)
        struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
        const struct drm_display_mode *adjusted_mode = &intel_crtc->config->base.adjusted_mode;
        enum port port;
-       unsigned int bpp = intel_crtc->config->pipe_bpp;
+       unsigned int bpp = dsi_pixel_format_bpp(intel_dsi->pixel_format);
        u32 val, tmp;
        u16 mode_hdisplay;
 
index de7be7f..92f3922 100644 (file)
@@ -34,6 +34,8 @@
 #define DSI_DUAL_LINK_FRONT_BACK       1
 #define DSI_DUAL_LINK_PIXEL_ALT                2
 
+int dsi_pixel_format_bpp(int pixel_format);
+
 struct intel_dsi_host;
 
 struct intel_dsi {
index 1d43e6f..7f145b4 100644 (file)
@@ -204,10 +204,28 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
        struct drm_device *dev = intel_dsi->base.base.dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
 
+       if (dev_priv->vbt.dsi.seq_version >= 3)
+               data++;
+
        gpio = *data++;
 
        /* pull up/down */
-       action = *data++;
+       action = *data++ & 1;
+
+       if (gpio >= ARRAY_SIZE(gtable)) {
+               DRM_DEBUG_KMS("unknown gpio %u\n", gpio);
+               goto out;
+       }
+
+       if (!IS_VALLEYVIEW(dev_priv)) {
+               DRM_DEBUG_KMS("GPIO element not supported on this platform\n");
+               goto out;
+       }
+
+       if (dev_priv->vbt.dsi.seq_version >= 3) {
+               DRM_DEBUG_KMS("GPIO element v3 not supported\n");
+               goto out;
+       }
 
        function = gtable[gpio].function_reg;
        pad = gtable[gpio].pad_reg;
@@ -216,16 +234,18 @@ static const u8 *mipi_exec_gpio(struct intel_dsi *intel_dsi, const u8 *data)
        if (!gtable[gpio].init) {
                /* program the function */
                /* FIXME: remove constant below */
-               vlv_gpio_nc_write(dev_priv, function, 0x2000CC00);
+               vlv_iosf_sb_write(dev_priv, IOSF_PORT_GPIO_NC, function,
+                                 0x2000CC00);
                gtable[gpio].init = 1;
        }
 
        val = 0x4 | action;
 
        /* pull up/down */
-       vlv_gpio_nc_write(dev_priv, pad, val);
+       vlv_iosf_sb_write(dev_priv, IOSF_PORT_GPIO_NC, pad, val);
        mutex_unlock(&dev_priv->sb_lock);
 
+out:
        return data;
 }
 
@@ -420,10 +440,7 @@ struct drm_panel *vbt_panel_init(struct intel_dsi *intel_dsi, u16 panel_id)
        intel_dsi->dual_link = mipi_config->dual_link;
        intel_dsi->pixel_overlap = mipi_config->pixel_overlap;
 
-       if (intel_dsi->pixel_format == VID_MODE_FORMAT_RGB666)
-               bits_per_pixel = 18;
-       else if (intel_dsi->pixel_format == VID_MODE_FORMAT_RGB565)
-               bits_per_pixel = 16;
+       bits_per_pixel = dsi_pixel_format_bpp(intel_dsi->pixel_format);
 
        intel_dsi->operation_mode = mipi_config->is_cmd_mode;
        intel_dsi->video_mode_format = mipi_config->video_transfer_mode;
index bb5e95a..70883c5 100644 (file)
@@ -30,7 +30,7 @@
 #include "i915_drv.h"
 #include "intel_dsi.h"
 
-static int dsi_pixel_format_bpp(int pixel_format)
+int dsi_pixel_format_bpp(int pixel_format)
 {
        int bpp;
 
index a1988a4..0f0492f 100644 (file)
@@ -43,7 +43,7 @@
 
 static inline bool fbc_supported(struct drm_i915_private *dev_priv)
 {
-       return dev_priv->fbc.activate != NULL;
+       return HAS_FBC(dev_priv);
 }
 
 static inline bool fbc_on_pipe_a_only(struct drm_i915_private *dev_priv)
@@ -56,6 +56,11 @@ static inline bool fbc_on_plane_a_only(struct drm_i915_private *dev_priv)
        return INTEL_INFO(dev_priv)->gen < 4;
 }
 
+static inline bool no_fbc_on_multiple_pipes(struct drm_i915_private *dev_priv)
+{
+       return INTEL_INFO(dev_priv)->gen <= 3;
+}
+
 /*
  * In some platforms where the CRTC's x:0/y:0 coordinates doesn't match the
  * frontbuffer's x:0/y:0 coordinates we lie to the hardware about the plane's
@@ -74,19 +79,17 @@ static unsigned int get_crtc_fence_y_offset(struct intel_crtc *crtc)
  * write to the PLANE_SIZE register. For BDW-, the hardware looks at the value
  * we wrote to PIPESRC.
  */
-static void intel_fbc_get_plane_source_size(struct intel_crtc *crtc,
+static void intel_fbc_get_plane_source_size(struct intel_fbc_state_cache *cache,
                                            int *width, int *height)
 {
-       struct intel_plane_state *plane_state =
-                       to_intel_plane_state(crtc->base.primary->state);
        int w, h;
 
-       if (intel_rotation_90_or_270(plane_state->base.rotation)) {
-               w = drm_rect_height(&plane_state->src) >> 16;
-               h = drm_rect_width(&plane_state->src) >> 16;
+       if (intel_rotation_90_or_270(cache->plane.rotation)) {
+               w = cache->plane.src_h;
+               h = cache->plane.src_w;
        } else {
-               w = drm_rect_width(&plane_state->src) >> 16;
-               h = drm_rect_height(&plane_state->src) >> 16;
+               w = cache->plane.src_w;
+               h = cache->plane.src_h;
        }
 
        if (width)
@@ -95,26 +98,23 @@ static void intel_fbc_get_plane_source_size(struct intel_crtc *crtc,
                *height = h;
 }
 
-static int intel_fbc_calculate_cfb_size(struct intel_crtc *crtc,
-                                       struct drm_framebuffer *fb)
+static int intel_fbc_calculate_cfb_size(struct drm_i915_private *dev_priv,
+                                       struct intel_fbc_state_cache *cache)
 {
-       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
        int lines;
 
-       intel_fbc_get_plane_source_size(crtc, NULL, &lines);
+       intel_fbc_get_plane_source_size(cache, NULL, &lines);
        if (INTEL_INFO(dev_priv)->gen >= 7)
                lines = min(lines, 2048);
 
        /* Hardware needs the full buffer stride, not just the active area. */
-       return lines * fb->pitches[0];
+       return lines * cache->fb.stride;
 }
 
 static void i8xx_fbc_deactivate(struct drm_i915_private *dev_priv)
 {
        u32 fbc_ctl;
 
-       dev_priv->fbc.active = false;
-
        /* Disable compression */
        fbc_ctl = I915_READ(FBC_CONTROL);
        if ((fbc_ctl & FBC_CTL_EN) == 0)
@@ -130,21 +130,17 @@ static void i8xx_fbc_deactivate(struct drm_i915_private *dev_priv)
        }
 }
 
-static void i8xx_fbc_activate(struct intel_crtc *crtc)
+static void i8xx_fbc_activate(struct drm_i915_private *dev_priv)
 {
-       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
-       struct drm_framebuffer *fb = crtc->base.primary->fb;
-       struct drm_i915_gem_object *obj = intel_fb_obj(fb);
+       struct intel_fbc_reg_params *params = &dev_priv->fbc.params;
        int cfb_pitch;
        int i;
        u32 fbc_ctl;
 
-       dev_priv->fbc.active = true;
-
        /* Note: fbc.threshold == 1 for i8xx */
-       cfb_pitch = intel_fbc_calculate_cfb_size(crtc, fb) / FBC_LL_SIZE;
-       if (fb->pitches[0] < cfb_pitch)
-               cfb_pitch = fb->pitches[0];
+       cfb_pitch = params->cfb_size / FBC_LL_SIZE;
+       if (params->fb.stride < cfb_pitch)
+               cfb_pitch = params->fb.stride;
 
        /* FBC_CTL wants 32B or 64B units */
        if (IS_GEN2(dev_priv))
@@ -161,9 +157,9 @@ static void i8xx_fbc_activate(struct intel_crtc *crtc)
 
                /* Set it up... */
                fbc_ctl2 = FBC_CTL_FENCE_DBL | FBC_CTL_IDLE_IMM | FBC_CTL_CPU_FENCE;
-               fbc_ctl2 |= FBC_CTL_PLANE(crtc->plane);
+               fbc_ctl2 |= FBC_CTL_PLANE(params->crtc.plane);
                I915_WRITE(FBC_CONTROL2, fbc_ctl2);
-               I915_WRITE(FBC_FENCE_OFF, get_crtc_fence_y_offset(crtc));
+               I915_WRITE(FBC_FENCE_OFF, params->crtc.fence_y_offset);
        }
 
        /* enable it... */
@@ -173,7 +169,7 @@ static void i8xx_fbc_activate(struct intel_crtc *crtc)
        if (IS_I945GM(dev_priv))
                fbc_ctl |= FBC_CTL_C3_IDLE; /* 945 needs special SR handling */
        fbc_ctl |= (cfb_pitch & 0xff) << FBC_CTL_STRIDE_SHIFT;
-       fbc_ctl |= obj->fence_reg;
+       fbc_ctl |= params->fb.fence_reg;
        I915_WRITE(FBC_CONTROL, fbc_ctl);
 }
 
@@ -182,23 +178,19 @@ static bool i8xx_fbc_is_active(struct drm_i915_private *dev_priv)
        return I915_READ(FBC_CONTROL) & FBC_CTL_EN;
 }
 
-static void g4x_fbc_activate(struct intel_crtc *crtc)
+static void g4x_fbc_activate(struct drm_i915_private *dev_priv)
 {
-       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
-       struct drm_framebuffer *fb = crtc->base.primary->fb;
-       struct drm_i915_gem_object *obj = intel_fb_obj(fb);
+       struct intel_fbc_reg_params *params = &dev_priv->fbc.params;
        u32 dpfc_ctl;
 
-       dev_priv->fbc.active = true;
-
-       dpfc_ctl = DPFC_CTL_PLANE(crtc->plane) | DPFC_SR_EN;
-       if (drm_format_plane_cpp(fb->pixel_format, 0) == 2)
+       dpfc_ctl = DPFC_CTL_PLANE(params->crtc.plane) | DPFC_SR_EN;
+       if (drm_format_plane_cpp(params->fb.pixel_format, 0) == 2)
                dpfc_ctl |= DPFC_CTL_LIMIT_2X;
        else
                dpfc_ctl |= DPFC_CTL_LIMIT_1X;
-       dpfc_ctl |= DPFC_CTL_FENCE_EN | obj->fence_reg;
+       dpfc_ctl |= DPFC_CTL_FENCE_EN | params->fb.fence_reg;
 
-       I915_WRITE(DPFC_FENCE_YOFF, get_crtc_fence_y_offset(crtc));
+       I915_WRITE(DPFC_FENCE_YOFF, params->crtc.fence_y_offset);
 
        /* enable it... */
        I915_WRITE(DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN);
@@ -208,8 +200,6 @@ static void g4x_fbc_deactivate(struct drm_i915_private *dev_priv)
 {
        u32 dpfc_ctl;
 
-       dev_priv->fbc.active = false;
-
        /* Disable compression */
        dpfc_ctl = I915_READ(DPFC_CONTROL);
        if (dpfc_ctl & DPFC_CTL_EN) {
@@ -230,19 +220,14 @@ static void intel_fbc_recompress(struct drm_i915_private *dev_priv)
        POSTING_READ(MSG_FBC_REND_STATE);
 }
 
-static void ilk_fbc_activate(struct intel_crtc *crtc)
+static void ilk_fbc_activate(struct drm_i915_private *dev_priv)
 {
-       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
-       struct drm_framebuffer *fb = crtc->base.primary->fb;
-       struct drm_i915_gem_object *obj = intel_fb_obj(fb);
+       struct intel_fbc_reg_params *params = &dev_priv->fbc.params;
        u32 dpfc_ctl;
        int threshold = dev_priv->fbc.threshold;
-       unsigned int y_offset;
 
-       dev_priv->fbc.active = true;
-
-       dpfc_ctl = DPFC_CTL_PLANE(crtc->plane);
-       if (drm_format_plane_cpp(fb->pixel_format, 0) == 2)
+       dpfc_ctl = DPFC_CTL_PLANE(params->crtc.plane);
+       if (drm_format_plane_cpp(params->fb.pixel_format, 0) == 2)
                threshold++;
 
        switch (threshold) {
@@ -259,18 +244,17 @@ static void ilk_fbc_activate(struct intel_crtc *crtc)
        }
        dpfc_ctl |= DPFC_CTL_FENCE_EN;
        if (IS_GEN5(dev_priv))
-               dpfc_ctl |= obj->fence_reg;
+               dpfc_ctl |= params->fb.fence_reg;
 
-       y_offset = get_crtc_fence_y_offset(crtc);
-       I915_WRITE(ILK_DPFC_FENCE_YOFF, y_offset);
-       I915_WRITE(ILK_FBC_RT_BASE, i915_gem_obj_ggtt_offset(obj) | ILK_FBC_RT_VALID);
+       I915_WRITE(ILK_DPFC_FENCE_YOFF, params->crtc.fence_y_offset);
+       I915_WRITE(ILK_FBC_RT_BASE, params->fb.ggtt_offset | ILK_FBC_RT_VALID);
        /* enable it... */
        I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN);
 
        if (IS_GEN6(dev_priv)) {
                I915_WRITE(SNB_DPFC_CTL_SA,
-                          SNB_CPU_FENCE_ENABLE | obj->fence_reg);
-               I915_WRITE(DPFC_CPU_FENCE_OFFSET, y_offset);
+                          SNB_CPU_FENCE_ENABLE | params->fb.fence_reg);
+               I915_WRITE(DPFC_CPU_FENCE_OFFSET, params->crtc.fence_y_offset);
        }
 
        intel_fbc_recompress(dev_priv);
@@ -280,8 +264,6 @@ static void ilk_fbc_deactivate(struct drm_i915_private *dev_priv)
 {
        u32 dpfc_ctl;
 
-       dev_priv->fbc.active = false;
-
        /* Disable compression */
        dpfc_ctl = I915_READ(ILK_DPFC_CONTROL);
        if (dpfc_ctl & DPFC_CTL_EN) {
@@ -295,21 +277,17 @@ static bool ilk_fbc_is_active(struct drm_i915_private *dev_priv)
        return I915_READ(ILK_DPFC_CONTROL) & DPFC_CTL_EN;
 }
 
-static void gen7_fbc_activate(struct intel_crtc *crtc)
+static void gen7_fbc_activate(struct drm_i915_private *dev_priv)
 {
-       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
-       struct drm_framebuffer *fb = crtc->base.primary->fb;
-       struct drm_i915_gem_object *obj = intel_fb_obj(fb);
+       struct intel_fbc_reg_params *params = &dev_priv->fbc.params;
        u32 dpfc_ctl;
        int threshold = dev_priv->fbc.threshold;
 
-       dev_priv->fbc.active = true;
-
        dpfc_ctl = 0;
        if (IS_IVYBRIDGE(dev_priv))
-               dpfc_ctl |= IVB_DPFC_CTL_PLANE(crtc->plane);
+               dpfc_ctl |= IVB_DPFC_CTL_PLANE(params->crtc.plane);
 
-       if (drm_format_plane_cpp(fb->pixel_format, 0) == 2)
+       if (drm_format_plane_cpp(params->fb.pixel_format, 0) == 2)
                threshold++;
 
        switch (threshold) {
@@ -337,20 +315,60 @@ static void gen7_fbc_activate(struct intel_crtc *crtc)
                           ILK_FBCQ_DIS);
        } else if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) {
                /* WaFbcAsynchFlipDisableFbcQueue:hsw,bdw */
-               I915_WRITE(CHICKEN_PIPESL_1(crtc->pipe),
-                          I915_READ(CHICKEN_PIPESL_1(crtc->pipe)) |
+               I915_WRITE(CHICKEN_PIPESL_1(params->crtc.pipe),
+                          I915_READ(CHICKEN_PIPESL_1(params->crtc.pipe)) |
                           HSW_FBCQ_DIS);
        }
 
        I915_WRITE(ILK_DPFC_CONTROL, dpfc_ctl | DPFC_CTL_EN);
 
        I915_WRITE(SNB_DPFC_CTL_SA,
-                  SNB_CPU_FENCE_ENABLE | obj->fence_reg);
-       I915_WRITE(DPFC_CPU_FENCE_OFFSET, get_crtc_fence_y_offset(crtc));
+                  SNB_CPU_FENCE_ENABLE | params->fb.fence_reg);
+       I915_WRITE(DPFC_CPU_FENCE_OFFSET, params->crtc.fence_y_offset);
 
        intel_fbc_recompress(dev_priv);
 }
 
+static bool intel_fbc_hw_is_active(struct drm_i915_private *dev_priv)
+{
+       if (INTEL_INFO(dev_priv)->gen >= 5)
+               return ilk_fbc_is_active(dev_priv);
+       else if (IS_GM45(dev_priv))
+               return g4x_fbc_is_active(dev_priv);
+       else
+               return i8xx_fbc_is_active(dev_priv);
+}
+
+static void intel_fbc_hw_activate(struct drm_i915_private *dev_priv)
+{
+       struct intel_fbc *fbc = &dev_priv->fbc;
+
+       fbc->active = true;
+
+       if (INTEL_INFO(dev_priv)->gen >= 7)
+               gen7_fbc_activate(dev_priv);
+       else if (INTEL_INFO(dev_priv)->gen >= 5)
+               ilk_fbc_activate(dev_priv);
+       else if (IS_GM45(dev_priv))
+               g4x_fbc_activate(dev_priv);
+       else
+               i8xx_fbc_activate(dev_priv);
+}
+
+static void intel_fbc_hw_deactivate(struct drm_i915_private *dev_priv)
+{
+       struct intel_fbc *fbc = &dev_priv->fbc;
+
+       fbc->active = false;
+
+       if (INTEL_INFO(dev_priv)->gen >= 5)
+               ilk_fbc_deactivate(dev_priv);
+       else if (IS_GM45(dev_priv))
+               g4x_fbc_deactivate(dev_priv);
+       else
+               i8xx_fbc_deactivate(dev_priv);
+}
+
 /**
  * intel_fbc_is_active - Is FBC active?
  * @dev_priv: i915 device instance
@@ -364,24 +382,24 @@ bool intel_fbc_is_active(struct drm_i915_private *dev_priv)
        return dev_priv->fbc.active;
 }
 
-static void intel_fbc_activate(const struct drm_framebuffer *fb)
-{
-       struct drm_i915_private *dev_priv = fb->dev->dev_private;
-       struct intel_crtc *crtc = dev_priv->fbc.crtc;
-
-       dev_priv->fbc.activate(crtc);
-
-       dev_priv->fbc.fb_id = fb->base.id;
-       dev_priv->fbc.y = crtc->base.y;
-}
-
 static void intel_fbc_work_fn(struct work_struct *__work)
 {
        struct drm_i915_private *dev_priv =
                container_of(__work, struct drm_i915_private, fbc.work.work);
-       struct intel_fbc_work *work = &dev_priv->fbc.work;
-       struct intel_crtc *crtc = dev_priv->fbc.crtc;
-       int delay_ms = 50;
+       struct intel_fbc *fbc = &dev_priv->fbc;
+       struct intel_fbc_work *work = &fbc->work;
+       struct intel_crtc *crtc = fbc->crtc;
+       struct drm_vblank_crtc *vblank = &dev_priv->dev->vblank[crtc->pipe];
+
+       if (drm_crtc_vblank_get(&crtc->base)) {
+               DRM_ERROR("vblank not available for FBC on pipe %c\n",
+                         pipe_name(crtc->pipe));
+
+               mutex_lock(&fbc->lock);
+               work->scheduled = false;
+               mutex_unlock(&fbc->lock);
+               return;
+       }
 
 retry:
        /* Delay the actual enabling to let pageflipping cease and the
@@ -390,142 +408,97 @@ retry:
         * vblank to pass after disabling the FBC before we attempt
         * to modify the control registers.
         *
-        * A more complicated solution would involve tracking vblanks
-        * following the termination of the page-flipping sequence
-        * and indeed performing the enable as a co-routine and not
-        * waiting synchronously upon the vblank.
-        *
         * WaFbcWaitForVBlankBeforeEnable:ilk,snb
+        *
+        * It is also worth mentioning that since work->scheduled_vblank can be
+        * updated multiple times by the other threads, hitting the timeout is
+        * not an error condition. We'll just end up hitting the "goto retry"
+        * case below.
         */
-       wait_remaining_ms_from_jiffies(work->enable_jiffies, delay_ms);
+       wait_event_timeout(vblank->queue,
+               drm_crtc_vblank_count(&crtc->base) != work->scheduled_vblank,
+               msecs_to_jiffies(50));
 
-       mutex_lock(&dev_priv->fbc.lock);
+       mutex_lock(&fbc->lock);
 
        /* Were we cancelled? */
        if (!work->scheduled)
                goto out;
 
        /* Were we delayed again while this function was sleeping? */
-       if (time_after(work->enable_jiffies + msecs_to_jiffies(delay_ms),
-                      jiffies)) {
-               mutex_unlock(&dev_priv->fbc.lock);
+       if (drm_crtc_vblank_count(&crtc->base) == work->scheduled_vblank) {
+               mutex_unlock(&fbc->lock);
                goto retry;
        }
 
-       if (crtc->base.primary->fb == work->fb)
-               intel_fbc_activate(work->fb);
+       intel_fbc_hw_activate(dev_priv);
 
        work->scheduled = false;
 
 out:
-       mutex_unlock(&dev_priv->fbc.lock);
-}
-
-static void intel_fbc_cancel_work(struct drm_i915_private *dev_priv)
-{
-       WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock));
-       dev_priv->fbc.work.scheduled = false;
+       mutex_unlock(&fbc->lock);
+       drm_crtc_vblank_put(&crtc->base);
 }
 
 static void intel_fbc_schedule_activation(struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
-       struct intel_fbc_work *work = &dev_priv->fbc.work;
+       struct intel_fbc *fbc = &dev_priv->fbc;
+       struct intel_fbc_work *work = &fbc->work;
+
+       WARN_ON(!mutex_is_locked(&fbc->lock));
 
-       WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock));
+       if (drm_crtc_vblank_get(&crtc->base)) {
+               DRM_ERROR("vblank not available for FBC on pipe %c\n",
+                         pipe_name(crtc->pipe));
+               return;
+       }
 
-       /* It is useless to call intel_fbc_cancel_work() in this function since
-        * we're not releasing fbc.lock, so it won't have an opportunity to grab
-        * it to discover that it was cancelled. So we just update the expected
-        * jiffy count. */
-       work->fb = crtc->base.primary->fb;
+       /* It is useless to call intel_fbc_cancel_work() or cancel_work() in
+        * this function since we're not releasing fbc.lock, so it won't have an
+        * opportunity to grab it to discover that it was cancelled. So we just
+        * update the expected jiffy count. */
        work->scheduled = true;
-       work->enable_jiffies = jiffies;
+       work->scheduled_vblank = drm_crtc_vblank_count(&crtc->base);
+       drm_crtc_vblank_put(&crtc->base);
 
        schedule_work(&work->work);
 }
 
-static void __intel_fbc_deactivate(struct drm_i915_private *dev_priv)
+static void intel_fbc_deactivate(struct drm_i915_private *dev_priv)
 {
-       WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock));
-
-       intel_fbc_cancel_work(dev_priv);
-
-       if (dev_priv->fbc.active)
-               dev_priv->fbc.deactivate(dev_priv);
-}
-
-/*
- * intel_fbc_deactivate - deactivate FBC if it's associated with crtc
- * @crtc: the CRTC
- *
- * This function deactivates FBC if it's associated with the provided CRTC.
- */
-void intel_fbc_deactivate(struct intel_crtc *crtc)
-{
-       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
-
-       if (!fbc_supported(dev_priv))
-               return;
+       struct intel_fbc *fbc = &dev_priv->fbc;
 
-       mutex_lock(&dev_priv->fbc.lock);
-       if (dev_priv->fbc.crtc == crtc)
-               __intel_fbc_deactivate(dev_priv);
-       mutex_unlock(&dev_priv->fbc.lock);
-}
+       WARN_ON(!mutex_is_locked(&fbc->lock));
 
-static void set_no_fbc_reason(struct drm_i915_private *dev_priv,
-                             const char *reason)
-{
-       if (dev_priv->fbc.no_fbc_reason == reason)
-               return;
+       /* Calling cancel_work() here won't help due to the fact that the work
+        * function grabs fbc->lock. Just set scheduled to false so the work
+        * function can know it was cancelled. */
+       fbc->work.scheduled = false;
 
-       dev_priv->fbc.no_fbc_reason = reason;
-       DRM_DEBUG_KMS("Disabling FBC: %s\n", reason);
+       if (fbc->active)
+               intel_fbc_hw_deactivate(dev_priv);
 }
 
-static bool crtc_can_fbc(struct intel_crtc *crtc)
+static bool multiple_pipes_ok(struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+       struct drm_plane *primary = crtc->base.primary;
+       struct intel_fbc *fbc = &dev_priv->fbc;
+       enum pipe pipe = crtc->pipe;
 
-       if (fbc_on_pipe_a_only(dev_priv) && crtc->pipe != PIPE_A)
-               return false;
-
-       if (fbc_on_plane_a_only(dev_priv) && crtc->plane != PLANE_A)
-               return false;
-
-       return true;
-}
-
-static bool crtc_is_valid(struct intel_crtc *crtc)
-{
-       if (!intel_crtc_active(&crtc->base))
-               return false;
-
-       if (!to_intel_plane_state(crtc->base.primary->state)->visible)
-               return false;
-
-       return true;
-}
-
-static bool multiple_pipes_ok(struct drm_i915_private *dev_priv)
-{
-       enum pipe pipe;
-       int n_pipes = 0;
-       struct drm_crtc *crtc;
-
-       if (INTEL_INFO(dev_priv)->gen > 4)
+       /* Don't even bother tracking anything we don't need. */
+       if (!no_fbc_on_multiple_pipes(dev_priv))
                return true;
 
-       for_each_pipe(dev_priv, pipe) {
-               crtc = dev_priv->pipe_to_crtc_mapping[pipe];
+       WARN_ON(!drm_modeset_is_locked(&primary->mutex));
 
-               if (intel_crtc_active(crtc) &&
-                   to_intel_plane_state(crtc->primary->state)->visible)
-                       n_pipes++;
-       }
+       if (to_intel_plane_state(primary->state)->visible)
+               fbc->visible_pipes_mask |= (1 << pipe);
+       else
+               fbc->visible_pipes_mask &= ~(1 << pipe);
 
-       return (n_pipes < 2);
+       return (fbc->visible_pipes_mask & ~(1 << pipe)) != 0;
 }
 
 static int find_compression_threshold(struct drm_i915_private *dev_priv,
@@ -581,16 +554,16 @@ again:
 static int intel_fbc_alloc_cfb(struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
-       struct drm_framebuffer *fb = crtc->base.primary->state->fb;
+       struct intel_fbc *fbc = &dev_priv->fbc;
        struct drm_mm_node *uninitialized_var(compressed_llb);
        int size, fb_cpp, ret;
 
-       WARN_ON(drm_mm_node_allocated(&dev_priv->fbc.compressed_fb));
+       WARN_ON(drm_mm_node_allocated(&fbc->compressed_fb));
 
-       size = intel_fbc_calculate_cfb_size(crtc, fb);
-       fb_cpp = drm_format_plane_cpp(fb->pixel_format, 0);
+       size = intel_fbc_calculate_cfb_size(dev_priv, &fbc->state_cache);
+       fb_cpp = drm_format_plane_cpp(fbc->state_cache.fb.pixel_format, 0);
 
-       ret = find_compression_threshold(dev_priv, &dev_priv->fbc.compressed_fb,
+       ret = find_compression_threshold(dev_priv, &fbc->compressed_fb,
                                         size, fb_cpp);
        if (!ret)
                goto err_llb;
@@ -599,12 +572,12 @@ static int intel_fbc_alloc_cfb(struct intel_crtc *crtc)
 
        }
 
-       dev_priv->fbc.threshold = ret;
+       fbc->threshold = ret;
 
        if (INTEL_INFO(dev_priv)->gen >= 5)
-               I915_WRITE(ILK_DPFC_CB_BASE, dev_priv->fbc.compressed_fb.start);
+               I915_WRITE(ILK_DPFC_CB_BASE, fbc->compressed_fb.start);
        else if (IS_GM45(dev_priv)) {
-               I915_WRITE(DPFC_CB_BASE, dev_priv->fbc.compressed_fb.start);
+               I915_WRITE(DPFC_CB_BASE, fbc->compressed_fb.start);
        } else {
                compressed_llb = kzalloc(sizeof(*compressed_llb), GFP_KERNEL);
                if (!compressed_llb)
@@ -615,23 +588,22 @@ static int intel_fbc_alloc_cfb(struct intel_crtc *crtc)
                if (ret)
                        goto err_fb;
 
-               dev_priv->fbc.compressed_llb = compressed_llb;
+               fbc->compressed_llb = compressed_llb;
 
                I915_WRITE(FBC_CFB_BASE,
-                          dev_priv->mm.stolen_base + dev_priv->fbc.compressed_fb.start);
+                          dev_priv->mm.stolen_base + fbc->compressed_fb.start);
                I915_WRITE(FBC_LL_BASE,
                           dev_priv->mm.stolen_base + compressed_llb->start);
        }
 
        DRM_DEBUG_KMS("reserved %llu bytes of contiguous stolen space for FBC, threshold: %d\n",
-                     dev_priv->fbc.compressed_fb.size,
-                     dev_priv->fbc.threshold);
+                     fbc->compressed_fb.size, fbc->threshold);
 
        return 0;
 
 err_fb:
        kfree(compressed_llb);
-       i915_gem_stolen_remove_node(dev_priv, &dev_priv->fbc.compressed_fb);
+       i915_gem_stolen_remove_node(dev_priv, &fbc->compressed_fb);
 err_llb:
        pr_info_once("drm: not enough stolen space for compressed buffer (need %d more bytes), disabling. Hint: you may be able to increase stolen memory size in the BIOS to avoid this.\n", size);
        return -ENOSPC;
@@ -639,25 +611,27 @@ err_llb:
 
 static void __intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv)
 {
-       if (drm_mm_node_allocated(&dev_priv->fbc.compressed_fb))
-               i915_gem_stolen_remove_node(dev_priv,
-                                           &dev_priv->fbc.compressed_fb);
-
-       if (dev_priv->fbc.compressed_llb) {
-               i915_gem_stolen_remove_node(dev_priv,
-                                           dev_priv->fbc.compressed_llb);
-               kfree(dev_priv->fbc.compressed_llb);
+       struct intel_fbc *fbc = &dev_priv->fbc;
+
+       if (drm_mm_node_allocated(&fbc->compressed_fb))
+               i915_gem_stolen_remove_node(dev_priv, &fbc->compressed_fb);
+
+       if (fbc->compressed_llb) {
+               i915_gem_stolen_remove_node(dev_priv, fbc->compressed_llb);
+               kfree(fbc->compressed_llb);
        }
 }
 
 void intel_fbc_cleanup_cfb(struct drm_i915_private *dev_priv)
 {
+       struct intel_fbc *fbc = &dev_priv->fbc;
+
        if (!fbc_supported(dev_priv))
                return;
 
-       mutex_lock(&dev_priv->fbc.lock);
+       mutex_lock(&fbc->lock);
        __intel_fbc_cleanup_cfb(dev_priv);
-       mutex_unlock(&dev_priv->fbc.lock);
+       mutex_unlock(&fbc->lock);
 }
 
 static bool stride_is_valid(struct drm_i915_private *dev_priv,
@@ -681,19 +655,17 @@ static bool stride_is_valid(struct drm_i915_private *dev_priv,
        return true;
 }
 
-static bool pixel_format_is_valid(struct drm_framebuffer *fb)
+static bool pixel_format_is_valid(struct drm_i915_private *dev_priv,
+                                 uint32_t pixel_format)
 {
-       struct drm_device *dev = fb->dev;
-       struct drm_i915_private *dev_priv = dev->dev_private;
-
-       switch (fb->pixel_format) {
+       switch (pixel_format) {
        case DRM_FORMAT_XRGB8888:
        case DRM_FORMAT_XBGR8888:
                return true;
        case DRM_FORMAT_XRGB1555:
        case DRM_FORMAT_RGB565:
                /* 16bpp not supported on gen2 */
-               if (IS_GEN2(dev))
+               if (IS_GEN2(dev_priv))
                        return false;
                /* WaFbcOnly1to1Ratio:ctg */
                if (IS_G4X(dev_priv))
@@ -713,6 +685,7 @@ static bool pixel_format_is_valid(struct drm_framebuffer *fb)
 static bool intel_fbc_hw_tracking_covers_screen(struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+       struct intel_fbc *fbc = &dev_priv->fbc;
        unsigned int effective_w, effective_h, max_w, max_h;
 
        if (INTEL_INFO(dev_priv)->gen >= 8 || IS_HASWELL(dev_priv)) {
@@ -726,87 +699,105 @@ static bool intel_fbc_hw_tracking_covers_screen(struct intel_crtc *crtc)
                max_h = 1536;
        }
 
-       intel_fbc_get_plane_source_size(crtc, &effective_w, &effective_h);
+       intel_fbc_get_plane_source_size(&fbc->state_cache, &effective_w,
+                                       &effective_h);
        effective_w += crtc->adjusted_x;
        effective_h += crtc->adjusted_y;
 
        return effective_w <= max_w && effective_h <= max_h;
 }
 
-/**
- * __intel_fbc_update - activate/deactivate FBC as needed, unlocked
- * @crtc: the CRTC that triggered the update
- *
- * This function completely reevaluates the status of FBC, then activates,
- * deactivates or maintains it on the same state.
- */
-static void __intel_fbc_update(struct intel_crtc *crtc)
+static void intel_fbc_update_state_cache(struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
-       struct drm_framebuffer *fb;
+       struct intel_fbc *fbc = &dev_priv->fbc;
+       struct intel_fbc_state_cache *cache = &fbc->state_cache;
+       struct intel_crtc_state *crtc_state =
+               to_intel_crtc_state(crtc->base.state);
+       struct intel_plane_state *plane_state =
+               to_intel_plane_state(crtc->base.primary->state);
+       struct drm_framebuffer *fb = plane_state->base.fb;
        struct drm_i915_gem_object *obj;
-       const struct drm_display_mode *adjusted_mode;
 
-       WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock));
+       WARN_ON(!drm_modeset_is_locked(&crtc->base.mutex));
+       WARN_ON(!drm_modeset_is_locked(&crtc->base.primary->mutex));
 
-       if (!multiple_pipes_ok(dev_priv)) {
-               set_no_fbc_reason(dev_priv, "more than one pipe active");
-               goto out_disable;
-       }
+       cache->crtc.mode_flags = crtc_state->base.adjusted_mode.flags;
+       if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
+               cache->crtc.hsw_bdw_pixel_rate =
+                       ilk_pipe_pixel_rate(crtc_state);
 
-       if (!dev_priv->fbc.enabled || dev_priv->fbc.crtc != crtc)
-               return;
+       cache->plane.rotation = plane_state->base.rotation;
+       cache->plane.src_w = drm_rect_width(&plane_state->src) >> 16;
+       cache->plane.src_h = drm_rect_height(&plane_state->src) >> 16;
+       cache->plane.visible = plane_state->visible;
 
-       if (!crtc_is_valid(crtc)) {
-               set_no_fbc_reason(dev_priv, "no output");
-               goto out_disable;
-       }
+       if (!cache->plane.visible)
+               return;
 
-       fb = crtc->base.primary->fb;
        obj = intel_fb_obj(fb);
-       adjusted_mode = &crtc->config->base.adjusted_mode;
 
-       if ((adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) ||
-           (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN)) {
-               set_no_fbc_reason(dev_priv, "incompatible mode");
-               goto out_disable;
+       /* FIXME: We lack the proper locking here, so only run this on the
+        * platforms that need. */
+       if (INTEL_INFO(dev_priv)->gen >= 5 && INTEL_INFO(dev_priv)->gen < 7)
+               cache->fb.ilk_ggtt_offset = i915_gem_obj_ggtt_offset(obj);
+       cache->fb.pixel_format = fb->pixel_format;
+       cache->fb.stride = fb->pitches[0];
+       cache->fb.fence_reg = obj->fence_reg;
+       cache->fb.tiling_mode = obj->tiling_mode;
+}
+
+static bool intel_fbc_can_activate(struct intel_crtc *crtc)
+{
+       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+       struct intel_fbc *fbc = &dev_priv->fbc;
+       struct intel_fbc_state_cache *cache = &fbc->state_cache;
+
+       if (!cache->plane.visible) {
+               fbc->no_fbc_reason = "primary plane not visible";
+               return false;
+       }
+
+       if ((cache->crtc.mode_flags & DRM_MODE_FLAG_INTERLACE) ||
+           (cache->crtc.mode_flags & DRM_MODE_FLAG_DBLSCAN)) {
+               fbc->no_fbc_reason = "incompatible mode";
+               return false;
        }
 
        if (!intel_fbc_hw_tracking_covers_screen(crtc)) {
-               set_no_fbc_reason(dev_priv, "mode too large for compression");
-               goto out_disable;
+               fbc->no_fbc_reason = "mode too large for compression";
+               return false;
        }
 
        /* The use of a CPU fence is mandatory in order to detect writes
         * by the CPU to the scanout and trigger updates to the FBC.
         */
-       if (obj->tiling_mode != I915_TILING_X ||
-           obj->fence_reg == I915_FENCE_REG_NONE) {
-               set_no_fbc_reason(dev_priv, "framebuffer not tiled or fenced");
-               goto out_disable;
+       if (cache->fb.tiling_mode != I915_TILING_X ||
+           cache->fb.fence_reg == I915_FENCE_REG_NONE) {
+               fbc->no_fbc_reason = "framebuffer not tiled or fenced";
+               return false;
        }
        if (INTEL_INFO(dev_priv)->gen <= 4 && !IS_G4X(dev_priv) &&
-           crtc->base.primary->state->rotation != BIT(DRM_ROTATE_0)) {
-               set_no_fbc_reason(dev_priv, "rotation unsupported");
-               goto out_disable;
+           cache->plane.rotation != BIT(DRM_ROTATE_0)) {
+               fbc->no_fbc_reason = "rotation unsupported";
+               return false;
        }
 
-       if (!stride_is_valid(dev_priv, fb->pitches[0])) {
-               set_no_fbc_reason(dev_priv, "framebuffer stride not supported");
-               goto out_disable;
+       if (!stride_is_valid(dev_priv, cache->fb.stride)) {
+               fbc->no_fbc_reason = "framebuffer stride not supported";
+               return false;
        }
 
-       if (!pixel_format_is_valid(fb)) {
-               set_no_fbc_reason(dev_priv, "pixel format is invalid");
-               goto out_disable;
+       if (!pixel_format_is_valid(dev_priv, cache->fb.pixel_format)) {
+               fbc->no_fbc_reason = "pixel format is invalid";
+               return false;
        }
 
        /* WaFbcExceedCdClockThreshold:hsw,bdw */
        if ((IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) &&
-           ilk_pipe_pixel_rate(crtc->config) >=
-           dev_priv->cdclk_freq * 95 / 100) {
-               set_no_fbc_reason(dev_priv, "pixel rate is too big");
-               goto out_disable;
+           cache->crtc.hsw_bdw_pixel_rate >= dev_priv->cdclk_freq * 95 / 100) {
+               fbc->no_fbc_reason = "pixel rate is too big";
+               return false;
        }
 
        /* It is possible for the required CFB size change without a
@@ -819,189 +810,322 @@ static void __intel_fbc_update(struct intel_crtc *crtc)
         * we didn't get any invalidate/deactivate calls, but this would require
         * a lot of tracking just for a specific case. If we conclude it's an
         * important case, we can implement it later. */
-       if (intel_fbc_calculate_cfb_size(crtc, fb) >
-           dev_priv->fbc.compressed_fb.size * dev_priv->fbc.threshold) {
-               set_no_fbc_reason(dev_priv, "CFB requirements changed");
-               goto out_disable;
+       if (intel_fbc_calculate_cfb_size(dev_priv, &fbc->state_cache) >
+           fbc->compressed_fb.size * fbc->threshold) {
+               fbc->no_fbc_reason = "CFB requirements changed";
+               return false;
        }
 
+       return true;
+}
+
+static bool intel_fbc_can_choose(struct intel_crtc *crtc)
+{
+       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+       struct intel_fbc *fbc = &dev_priv->fbc;
+       bool enable_by_default = IS_HASWELL(dev_priv) ||
+                                IS_BROADWELL(dev_priv);
+
+       if (intel_vgpu_active(dev_priv->dev)) {
+               fbc->no_fbc_reason = "VGPU is active";
+               return false;
+       }
+
+       if (i915.enable_fbc < 0 && !enable_by_default) {
+               fbc->no_fbc_reason = "disabled per chip default";
+               return false;
+       }
+
+       if (!i915.enable_fbc) {
+               fbc->no_fbc_reason = "disabled per module param";
+               return false;
+       }
+
+       if (fbc_on_pipe_a_only(dev_priv) && crtc->pipe != PIPE_A) {
+               fbc->no_fbc_reason = "no enabled pipes can have FBC";
+               return false;
+       }
+
+       if (fbc_on_plane_a_only(dev_priv) && crtc->plane != PLANE_A) {
+               fbc->no_fbc_reason = "no enabled planes can have FBC";
+               return false;
+       }
+
+       return true;
+}
+
+static void intel_fbc_get_reg_params(struct intel_crtc *crtc,
+                                    struct intel_fbc_reg_params *params)
+{
+       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+       struct intel_fbc *fbc = &dev_priv->fbc;
+       struct intel_fbc_state_cache *cache = &fbc->state_cache;
+
+       /* Since all our fields are integer types, use memset here so the
+        * comparison function can rely on memcmp because the padding will be
+        * zero. */
+       memset(params, 0, sizeof(*params));
+
+       params->crtc.pipe = crtc->pipe;
+       params->crtc.plane = crtc->plane;
+       params->crtc.fence_y_offset = get_crtc_fence_y_offset(crtc);
+
+       params->fb.pixel_format = cache->fb.pixel_format;
+       params->fb.stride = cache->fb.stride;
+       params->fb.fence_reg = cache->fb.fence_reg;
+
+       params->cfb_size = intel_fbc_calculate_cfb_size(dev_priv, cache);
+
+       params->fb.ggtt_offset = cache->fb.ilk_ggtt_offset;
+}
+
+static bool intel_fbc_reg_params_equal(struct intel_fbc_reg_params *params1,
+                                      struct intel_fbc_reg_params *params2)
+{
+       /* We can use this since intel_fbc_get_reg_params() does a memset. */
+       return memcmp(params1, params2, sizeof(*params1)) == 0;
+}
+
+void intel_fbc_pre_update(struct intel_crtc *crtc)
+{
+       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+       struct intel_fbc *fbc = &dev_priv->fbc;
+
+       if (!fbc_supported(dev_priv))
+               return;
+
+       mutex_lock(&fbc->lock);
+
+       if (!multiple_pipes_ok(crtc)) {
+               fbc->no_fbc_reason = "more than one pipe active";
+               goto deactivate;
+       }
+
+       if (!fbc->enabled || fbc->crtc != crtc)
+               goto unlock;
+
+       intel_fbc_update_state_cache(crtc);
+
+deactivate:
+       intel_fbc_deactivate(dev_priv);
+unlock:
+       mutex_unlock(&fbc->lock);
+}
+
+static void __intel_fbc_post_update(struct intel_crtc *crtc)
+{
+       struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+       struct intel_fbc *fbc = &dev_priv->fbc;
+       struct intel_fbc_reg_params old_params;
+
+       WARN_ON(!mutex_is_locked(&fbc->lock));
+
+       if (!fbc->enabled || fbc->crtc != crtc)
+               return;
+
+       if (!intel_fbc_can_activate(crtc)) {
+               WARN_ON(fbc->active);
+               return;
+       }
+
+       old_params = fbc->params;
+       intel_fbc_get_reg_params(crtc, &fbc->params);
+
        /* If the scanout has not changed, don't modify the FBC settings.
         * Note that we make the fundamental assumption that the fb->obj
         * cannot be unpinned (and have its GTT offset and fence revoked)
         * without first being decoupled from the scanout and FBC disabled.
         */
-       if (dev_priv->fbc.crtc == crtc &&
-           dev_priv->fbc.fb_id == fb->base.id &&
-           dev_priv->fbc.y == crtc->base.y &&
-           dev_priv->fbc.active)
+       if (fbc->active &&
+           intel_fbc_reg_params_equal(&old_params, &fbc->params))
                return;
 
-       if (intel_fbc_is_active(dev_priv)) {
-               /* We update FBC along two paths, after changing fb/crtc
-                * configuration (modeswitching) and after page-flipping
-                * finishes. For the latter, we know that not only did
-                * we disable the FBC at the start of the page-flip
-                * sequence, but also more than one vblank has passed.
-                *
-                * For the former case of modeswitching, it is possible
-                * to switch between two FBC valid configurations
-                * instantaneously so we do need to disable the FBC
-                * before we can modify its control registers. We also
-                * have to wait for the next vblank for that to take
-                * effect. However, since we delay enabling FBC we can
-                * assume that a vblank has passed since disabling and
-                * that we can safely alter the registers in the deferred
-                * callback.
-                *
-                * In the scenario that we go from a valid to invalid
-                * and then back to valid FBC configuration we have
-                * no strict enforcement that a vblank occurred since
-                * disabling the FBC. However, along all current pipe
-                * disabling paths we do need to wait for a vblank at
-                * some point. And we wait before enabling FBC anyway.
-                */
-               DRM_DEBUG_KMS("deactivating FBC for update\n");
-               __intel_fbc_deactivate(dev_priv);
-       }
-
+       intel_fbc_deactivate(dev_priv);
        intel_fbc_schedule_activation(crtc);
-       dev_priv->fbc.no_fbc_reason = "FBC enabled (not necessarily active)";
-       return;
-
-out_disable:
-       /* Multiple disables should be harmless */
-       if (intel_fbc_is_active(dev_priv)) {
-               DRM_DEBUG_KMS("unsupported config, deactivating FBC\n");
-               __intel_fbc_deactivate(dev_priv);
-       }
+       fbc->no_fbc_reason = "FBC enabled (active or scheduled)";
 }
 
-/*
- * intel_fbc_update - activate/deactivate FBC as needed
- * @crtc: the CRTC that triggered the update
- *
- * This function reevaluates the overall state and activates or deactivates FBC.
- */
-void intel_fbc_update(struct intel_crtc *crtc)
+void intel_fbc_post_update(struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+       struct intel_fbc *fbc = &dev_priv->fbc;
 
        if (!fbc_supported(dev_priv))
                return;
 
-       mutex_lock(&dev_priv->fbc.lock);
-       __intel_fbc_update(crtc);
-       mutex_unlock(&dev_priv->fbc.lock);
+       mutex_lock(&fbc->lock);
+       __intel_fbc_post_update(crtc);
+       mutex_unlock(&fbc->lock);
+}
+
+static unsigned int intel_fbc_get_frontbuffer_bit(struct intel_fbc *fbc)
+{
+       if (fbc->enabled)
+               return to_intel_plane(fbc->crtc->base.primary)->frontbuffer_bit;
+       else
+               return fbc->possible_framebuffer_bits;
 }
 
 void intel_fbc_invalidate(struct drm_i915_private *dev_priv,
                          unsigned int frontbuffer_bits,
                          enum fb_op_origin origin)
 {
-       unsigned int fbc_bits;
+       struct intel_fbc *fbc = &dev_priv->fbc;
 
        if (!fbc_supported(dev_priv))
                return;
 
-       if (origin == ORIGIN_GTT)
+       if (origin == ORIGIN_GTT || origin == ORIGIN_FLIP)
                return;
 
-       mutex_lock(&dev_priv->fbc.lock);
+       mutex_lock(&fbc->lock);
 
-       if (dev_priv->fbc.enabled)
-               fbc_bits = INTEL_FRONTBUFFER_PRIMARY(dev_priv->fbc.crtc->pipe);
-       else
-               fbc_bits = dev_priv->fbc.possible_framebuffer_bits;
-
-       dev_priv->fbc.busy_bits |= (fbc_bits & frontbuffer_bits);
+       fbc->busy_bits |= intel_fbc_get_frontbuffer_bit(fbc) & frontbuffer_bits;
 
-       if (dev_priv->fbc.busy_bits)
-               __intel_fbc_deactivate(dev_priv);
+       if (fbc->enabled && fbc->busy_bits)
+               intel_fbc_deactivate(dev_priv);
 
-       mutex_unlock(&dev_priv->fbc.lock);
+       mutex_unlock(&fbc->lock);
 }
 
 void intel_fbc_flush(struct drm_i915_private *dev_priv,
                     unsigned int frontbuffer_bits, enum fb_op_origin origin)
 {
+       struct intel_fbc *fbc = &dev_priv->fbc;
+
        if (!fbc_supported(dev_priv))
                return;
 
-       if (origin == ORIGIN_GTT)
+       if (origin == ORIGIN_GTT || origin == ORIGIN_FLIP)
                return;
 
-       mutex_lock(&dev_priv->fbc.lock);
+       mutex_lock(&fbc->lock);
 
-       dev_priv->fbc.busy_bits &= ~frontbuffer_bits;
+       fbc->busy_bits &= ~frontbuffer_bits;
 
-       if (!dev_priv->fbc.busy_bits && dev_priv->fbc.enabled) {
-               if (origin != ORIGIN_FLIP && dev_priv->fbc.active) {
+       if (!fbc->busy_bits && fbc->enabled &&
+           (frontbuffer_bits & intel_fbc_get_frontbuffer_bit(fbc))) {
+               if (fbc->active)
                        intel_fbc_recompress(dev_priv);
-               } else {
-                       __intel_fbc_deactivate(dev_priv);
-                       __intel_fbc_update(dev_priv->fbc.crtc);
+               else
+                       __intel_fbc_post_update(fbc->crtc);
+       }
+
+       mutex_unlock(&fbc->lock);
+}
+
+/**
+ * intel_fbc_choose_crtc - select a CRTC to enable FBC on
+ * @dev_priv: i915 device instance
+ * @state: the atomic state structure
+ *
+ * This function looks at the proposed state for CRTCs and planes, then chooses
+ * which pipe is going to have FBC by setting intel_crtc_state->enable_fbc to
+ * true.
+ *
+ * Later, intel_fbc_enable is going to look for state->enable_fbc and then maybe
+ * enable FBC for the chosen CRTC. If it does, it will set dev_priv->fbc.crtc.
+ */
+void intel_fbc_choose_crtc(struct drm_i915_private *dev_priv,
+                          struct drm_atomic_state *state)
+{
+       struct intel_fbc *fbc = &dev_priv->fbc;
+       struct drm_crtc *crtc;
+       struct drm_crtc_state *crtc_state;
+       struct drm_plane *plane;
+       struct drm_plane_state *plane_state;
+       bool fbc_crtc_present = false;
+       int i, j;
+
+       mutex_lock(&fbc->lock);
+
+       for_each_crtc_in_state(state, crtc, crtc_state, i) {
+               if (fbc->crtc == to_intel_crtc(crtc)) {
+                       fbc_crtc_present = true;
+                       break;
+               }
+       }
+       /* This atomic commit doesn't involve the CRTC currently tied to FBC. */
+       if (!fbc_crtc_present && fbc->crtc != NULL)
+               goto out;
+
+       /* Simply choose the first CRTC that is compatible and has a visible
+        * plane. We could go for fancier schemes such as checking the plane
+        * size, but this would just affect the few platforms that don't tie FBC
+        * to pipe or plane A. */
+       for_each_plane_in_state(state, plane, plane_state, i) {
+               struct intel_plane_state *intel_plane_state =
+                       to_intel_plane_state(plane_state);
+
+               if (!intel_plane_state->visible)
+                       continue;
+
+               for_each_crtc_in_state(state, crtc, crtc_state, j) {
+                       struct intel_crtc_state *intel_crtc_state =
+                               to_intel_crtc_state(crtc_state);
+
+                       if (plane_state->crtc != crtc)
+                               continue;
+
+                       if (!intel_fbc_can_choose(to_intel_crtc(crtc)))
+                               break;
+
+                       intel_crtc_state->enable_fbc = true;
+                       goto out;
                }
        }
 
-       mutex_unlock(&dev_priv->fbc.lock);
+out:
+       mutex_unlock(&fbc->lock);
 }
 
 /**
  * intel_fbc_enable: tries to enable FBC on the CRTC
  * @crtc: the CRTC
  *
- * This function checks if it's possible to enable FBC on the following CRTC,
- * then enables it. Notice that it doesn't activate FBC.
+ * This function checks if the given CRTC was chosen for FBC, then enables it if
+ * possible. Notice that it doesn't activate FBC. It is valid to call
+ * intel_fbc_enable multiple times for the same pipe without an
+ * intel_fbc_disable in the middle, as long as it is deactivated.
  */
 void intel_fbc_enable(struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+       struct intel_fbc *fbc = &dev_priv->fbc;
 
        if (!fbc_supported(dev_priv))
                return;
 
-       mutex_lock(&dev_priv->fbc.lock);
-
-       if (dev_priv->fbc.enabled) {
-               WARN_ON(dev_priv->fbc.crtc == crtc);
-               goto out;
-       }
-
-       WARN_ON(dev_priv->fbc.active);
-       WARN_ON(dev_priv->fbc.crtc != NULL);
+       mutex_lock(&fbc->lock);
 
-       if (intel_vgpu_active(dev_priv->dev)) {
-               set_no_fbc_reason(dev_priv, "VGPU is active");
-               goto out;
-       }
-
-       if (i915.enable_fbc < 0) {
-               set_no_fbc_reason(dev_priv, "disabled per chip default");
+       if (fbc->enabled) {
+               WARN_ON(fbc->crtc == NULL);
+               if (fbc->crtc == crtc) {
+                       WARN_ON(!crtc->config->enable_fbc);
+                       WARN_ON(fbc->active);
+               }
                goto out;
        }
 
-       if (!i915.enable_fbc) {
-               set_no_fbc_reason(dev_priv, "disabled per module param");
+       if (!crtc->config->enable_fbc)
                goto out;
-       }
 
-       if (!crtc_can_fbc(crtc)) {
-               set_no_fbc_reason(dev_priv, "no enabled pipes can have FBC");
-               goto out;
-       }
+       WARN_ON(fbc->active);
+       WARN_ON(fbc->crtc != NULL);
 
+       intel_fbc_update_state_cache(crtc);
        if (intel_fbc_alloc_cfb(crtc)) {
-               set_no_fbc_reason(dev_priv, "not enough stolen memory");
+               fbc->no_fbc_reason = "not enough stolen memory";
                goto out;
        }
 
        DRM_DEBUG_KMS("Enabling FBC on pipe %c\n", pipe_name(crtc->pipe));
-       dev_priv->fbc.no_fbc_reason = "FBC enabled but not active yet\n";
+       fbc->no_fbc_reason = "FBC enabled but not active yet\n";
 
-       dev_priv->fbc.enabled = true;
-       dev_priv->fbc.crtc = crtc;
+       fbc->enabled = true;
+       fbc->crtc = crtc;
 out:
-       mutex_unlock(&dev_priv->fbc.lock);
+       mutex_unlock(&fbc->lock);
 }
 
 /**
@@ -1013,58 +1137,88 @@ out:
  */
 static void __intel_fbc_disable(struct drm_i915_private *dev_priv)
 {
-       struct intel_crtc *crtc = dev_priv->fbc.crtc;
+       struct intel_fbc *fbc = &dev_priv->fbc;
+       struct intel_crtc *crtc = fbc->crtc;
 
-       WARN_ON(!mutex_is_locked(&dev_priv->fbc.lock));
-       WARN_ON(!dev_priv->fbc.enabled);
-       WARN_ON(dev_priv->fbc.active);
-       assert_pipe_disabled(dev_priv, crtc->pipe);
+       WARN_ON(!mutex_is_locked(&fbc->lock));
+       WARN_ON(!fbc->enabled);
+       WARN_ON(fbc->active);
+       WARN_ON(crtc->active);
 
        DRM_DEBUG_KMS("Disabling FBC on pipe %c\n", pipe_name(crtc->pipe));
 
        __intel_fbc_cleanup_cfb(dev_priv);
 
-       dev_priv->fbc.enabled = false;
-       dev_priv->fbc.crtc = NULL;
+       fbc->enabled = false;
+       fbc->crtc = NULL;
 }
 
 /**
- * intel_fbc_disable_crtc - disable FBC if it's associated with crtc
+ * intel_fbc_disable - disable FBC if it's associated with crtc
  * @crtc: the CRTC
  *
  * This function disables FBC if it's associated with the provided CRTC.
  */
-void intel_fbc_disable_crtc(struct intel_crtc *crtc)
+void intel_fbc_disable(struct intel_crtc *crtc)
 {
        struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+       struct intel_fbc *fbc = &dev_priv->fbc;
 
        if (!fbc_supported(dev_priv))
                return;
 
-       mutex_lock(&dev_priv->fbc.lock);
-       if (dev_priv->fbc.crtc == crtc) {
-               WARN_ON(!dev_priv->fbc.enabled);
-               WARN_ON(dev_priv->fbc.active);
+       mutex_lock(&fbc->lock);
+       if (fbc->crtc == crtc) {
+               WARN_ON(!fbc->enabled);
+               WARN_ON(fbc->active);
                __intel_fbc_disable(dev_priv);
        }
-       mutex_unlock(&dev_priv->fbc.lock);
+       mutex_unlock(&fbc->lock);
+
+       cancel_work_sync(&fbc->work.work);
 }
 
 /**
- * intel_fbc_disable - globally disable FBC
+ * intel_fbc_global_disable - globally disable FBC
  * @dev_priv: i915 device instance
  *
  * This function disables FBC regardless of which CRTC is associated with it.
  */
-void intel_fbc_disable(struct drm_i915_private *dev_priv)
+void intel_fbc_global_disable(struct drm_i915_private *dev_priv)
 {
+       struct intel_fbc *fbc = &dev_priv->fbc;
+
        if (!fbc_supported(dev_priv))
                return;
 
-       mutex_lock(&dev_priv->fbc.lock);
-       if (dev_priv->fbc.enabled)
+       mutex_lock(&fbc->lock);
+       if (fbc->enabled)
                __intel_fbc_disable(dev_priv);
-       mutex_unlock(&dev_priv->fbc.lock);
+       mutex_unlock(&fbc->lock);
+
+       cancel_work_sync(&fbc->work.work);
+}
+
+/**
+ * intel_fbc_init_pipe_state - initialize FBC's CRTC visibility tracking
+ * @dev_priv: i915 device instance
+ *
+ * The FBC code needs to track CRTC visibility since the older platforms can't
+ * have FBC enabled while multiple pipes are used. This function does the
+ * initial setup at driver load to make sure FBC is matching the real hardware.
+ */
+void intel_fbc_init_pipe_state(struct drm_i915_private *dev_priv)
+{
+       struct intel_crtc *crtc;
+
+       /* Don't even bother tracking anything if we don't need. */
+       if (!no_fbc_on_multiple_pipes(dev_priv))
+               return;
+
+       for_each_intel_crtc(dev_priv->dev, crtc)
+               if (intel_crtc_active(&crtc->base) &&
+                   to_intel_plane_state(crtc->base.primary->state)->visible)
+                       dev_priv->fbc.visible_pipes_mask |= (1 << crtc->pipe);
 }
 
 /**
@@ -1075,51 +1229,35 @@ void intel_fbc_disable(struct drm_i915_private *dev_priv)
  */
 void intel_fbc_init(struct drm_i915_private *dev_priv)
 {
+       struct intel_fbc *fbc = &dev_priv->fbc;
        enum pipe pipe;
 
-       INIT_WORK(&dev_priv->fbc.work.work, intel_fbc_work_fn);
-       mutex_init(&dev_priv->fbc.lock);
-       dev_priv->fbc.enabled = false;
-       dev_priv->fbc.active = false;
-       dev_priv->fbc.work.scheduled = false;
+       INIT_WORK(&fbc->work.work, intel_fbc_work_fn);
+       mutex_init(&fbc->lock);
+       fbc->enabled = false;
+       fbc->active = false;
+       fbc->work.scheduled = false;
 
        if (!HAS_FBC(dev_priv)) {
-               dev_priv->fbc.no_fbc_reason = "unsupported by this chipset";
+               fbc->no_fbc_reason = "unsupported by this chipset";
                return;
        }
 
        for_each_pipe(dev_priv, pipe) {
-               dev_priv->fbc.possible_framebuffer_bits |=
+               fbc->possible_framebuffer_bits |=
                                INTEL_FRONTBUFFER_PRIMARY(pipe);
 
                if (fbc_on_pipe_a_only(dev_priv))
                        break;
        }
 
-       if (INTEL_INFO(dev_priv)->gen >= 7) {
-               dev_priv->fbc.is_active = ilk_fbc_is_active;
-               dev_priv->fbc.activate = gen7_fbc_activate;
-               dev_priv->fbc.deactivate = ilk_fbc_deactivate;
-       } else if (INTEL_INFO(dev_priv)->gen >= 5) {
-               dev_priv->fbc.is_active = ilk_fbc_is_active;
-               dev_priv->fbc.activate = ilk_fbc_activate;
-               dev_priv->fbc.deactivate = ilk_fbc_deactivate;
-       } else if (IS_GM45(dev_priv)) {
-               dev_priv->fbc.is_active = g4x_fbc_is_active;
-               dev_priv->fbc.activate = g4x_fbc_activate;
-               dev_priv->fbc.deactivate = g4x_fbc_deactivate;
-       } else {
-               dev_priv->fbc.is_active = i8xx_fbc_is_active;
-               dev_priv->fbc.activate = i8xx_fbc_activate;
-               dev_priv->fbc.deactivate = i8xx_fbc_deactivate;
-
-               /* This value was pulled out of someone's hat */
+       /* This value was pulled out of someone's hat */
+       if (INTEL_INFO(dev_priv)->gen <= 4 && !IS_GM45(dev_priv))
                I915_WRITE(FBC_CONTROL, 500 << FBC_CTL_INTERVAL_SHIFT);
-       }
 
        /* We still don't have any sort of hardware state readout for FBC, so
         * deactivate it in case the BIOS activated it to make sure software
         * matches the hardware state. */
-       if (dev_priv->fbc.is_active(dev_priv))
-               dev_priv->fbc.deactivate(dev_priv);
+       if (intel_fbc_hw_is_active(dev_priv))
+               intel_fbc_hw_deactivate(dev_priv);
 }
index 09840f4..97a91e6 100644 (file)
@@ -406,8 +406,8 @@ retry:
                        continue;
                }
 
-               encoder = connector->encoder;
-               if (!encoder || WARN_ON(!encoder->crtc)) {
+               encoder = connector->state->best_encoder;
+               if (!encoder || WARN_ON(!connector->state->crtc)) {
                        if (connector->force > DRM_FORCE_OFF)
                                goto bail;
 
@@ -420,7 +420,7 @@ retry:
 
                num_connectors_enabled++;
 
-               new_crtc = intel_fb_helper_crtc(fb_helper, encoder->crtc);
+               new_crtc = intel_fb_helper_crtc(fb_helper, connector->state->crtc);
 
                /*
                 * Make sure we're not trying to drive multiple connectors
@@ -466,17 +466,22 @@ retry:
                         * usually contains. But since our current
                         * code puts a mode derived from the post-pfit timings
                         * into crtc->mode this works out correctly.
+                        *
+                        * This is crtc->mode and not crtc->state->mode for the
+                        * fastboot check to work correctly. crtc_state->mode has
+                        * I915_MODE_FLAG_INHERITED, which we clear to force check
+                        * state.
                         */
                        DRM_DEBUG_KMS("looking for current mode on connector %s\n",
                                      connector->name);
-                       modes[i] = &encoder->crtc->mode;
+                       modes[i] = &connector->state->crtc->mode;
                }
                crtcs[i] = new_crtc;
 
                DRM_DEBUG_KMS("connector %s on pipe %c [CRTC:%d]: %dx%d%s\n",
                              connector->name,
-                             pipe_name(to_intel_crtc(encoder->crtc)->pipe),
-                             encoder->crtc->base.id,
+                             pipe_name(to_intel_crtc(connector->state->crtc)->pipe),
+                             connector->state->crtc->base.id,
                              modes[i]->hdisplay, modes[i]->vdisplay,
                              modes[i]->flags & DRM_MODE_FLAG_INTERLACE ? "i" :"");
 
index 045b149..73002e9 100644 (file)
@@ -46,7 +46,7 @@ struct i915_guc_client {
        uint32_t wq_head;
 
        /* GuC submission statistics & status */
-       uint64_t submissions[I915_NUM_RINGS];
+       uint64_t submissions[GUC_MAX_ENGINES_NUM];
        uint32_t q_fail;
        uint32_t b_fail;
        int retcode;
@@ -106,8 +106,8 @@ struct intel_guc {
        uint32_t action_fail;           /* Total number of failures     */
        int32_t action_err;             /* Last error code              */
 
-       uint64_t submissions[I915_NUM_RINGS];
-       uint32_t last_seqno[I915_NUM_RINGS];
+       uint64_t submissions[GUC_MAX_ENGINES_NUM];
+       uint32_t last_seqno[GUC_MAX_ENGINES_NUM];
 };
 
 /* intel_guc_loader.c */
index 1856a47..2de57ff 100644 (file)
 #define GUC_MAX_GPU_CONTEXTS           1024
 #define        GUC_INVALID_CTX_ID              GUC_MAX_GPU_CONTEXTS
 
+#define GUC_RENDER_ENGINE              0
+#define GUC_VIDEO_ENGINE               1
+#define GUC_BLITTER_ENGINE             2
+#define GUC_VIDEOENHANCE_ENGINE                3
+#define GUC_VIDEO_ENGINE2              4
+#define GUC_MAX_ENGINES_NUM            (GUC_VIDEO_ENGINE2 + 1)
+
 /* Work queue item header definitions */
 #define WQ_STATUS_ACTIVE               1
 #define WQ_STATUS_SUSPENDED            2
@@ -285,7 +292,7 @@ struct guc_context_desc {
        u64 db_trigger_phy;
        u16 db_id;
 
-       struct guc_execlist_context lrc[I915_NUM_RINGS];
+       struct guc_execlist_context lrc[GUC_MAX_ENGINES_NUM];
 
        u8 attribute;
 
@@ -344,7 +351,7 @@ struct guc_policy {
 } __packed;
 
 struct guc_policies {
-       struct guc_policy policy[GUC_CTX_PRIORITY_NUM][I915_NUM_RINGS];
+       struct guc_policy policy[GUC_CTX_PRIORITY_NUM][GUC_MAX_ENGINES_NUM];
 
        /* In micro seconds. How much time to allow before DPC processing is
         * called back via interrupt (to prevent DPC queue drain starving).
@@ -388,14 +395,14 @@ struct guc_mmio_regset {
 
 struct guc_mmio_reg_state {
        struct guc_mmio_regset global_reg;
-       struct guc_mmio_regset engine_reg[I915_NUM_RINGS];
+       struct guc_mmio_regset engine_reg[GUC_MAX_ENGINES_NUM];
 
        /* MMIO registers that are set as non privileged */
        struct __packed {
                u32 mmio_start;
                u32 offsets[GUC_MMIO_WHITE_LIST_MAX];
                u32 count;
-       } mmio_white_list[I915_NUM_RINGS];
+       } mmio_white_list[GUC_MAX_ENGINES_NUM];
 } __packed;
 
 /* GuC Additional Data Struct */
@@ -406,7 +413,7 @@ struct guc_ads {
        u32 golden_context_lrca;
        u32 scheduler_policies;
        u32 reserved0[3];
-       u32 eng_state_size[I915_NUM_RINGS];
+       u32 eng_state_size[GUC_MAX_ENGINES_NUM];
        u32 reserved2[4];
 } __packed;
 
index 3accd91..82a3c03 100644 (file)
@@ -199,7 +199,7 @@ static void set_guc_init_params(struct drm_i915_private *dev_priv)
  * the value matches either of two values representing completion
  * of the GuC boot process.
  *
- * This is used for polling the GuC status in a wait_for_atomic()
+ * This is used for polling the GuC status in a wait_for()
  * loop below.
  */
 static inline bool guc_ucode_response(struct drm_i915_private *dev_priv,
@@ -259,14 +259,14 @@ static int guc_ucode_xfer_dma(struct drm_i915_private *dev_priv)
        I915_WRITE(DMA_CTRL, _MASKED_BIT_ENABLE(UOS_MOVE | START_DMA));
 
        /*
-        * Spin-wait for the DMA to complete & the GuC to start up.
+        * Wait for the DMA to complete & the GuC to start up.
         * NB: Docs recommend not using the interrupt for completion.
         * Measurements indicate this should take no more than 20ms, so a
         * timeout here indicates that the GuC has failed and is unusable.
         * (Higher levels of the driver will attempt to fall back to
         * execlist mode if this happens.)
         */
-       ret = wait_for_atomic(guc_ucode_response(dev_priv, &status), 100);
+       ret = wait_for(guc_ucode_response(dev_priv, &status), 100);
 
        DRM_DEBUG_DRIVER("DMA status 0x%x, GuC status 0x%x\n",
                        I915_READ(DMA_CTRL), status);
old mode 100755 (executable)
new mode 100644 (file)
index 8698a64..a0d8dae
@@ -880,15 +880,18 @@ static bool intel_hdmi_get_hw_state(struct intel_encoder *encoder,
        struct intel_hdmi *intel_hdmi = enc_to_intel_hdmi(&encoder->base);
        enum intel_display_power_domain power_domain;
        u32 tmp;
+       bool ret;
 
        power_domain = intel_display_port_power_domain(encoder);
-       if (!intel_display_power_is_enabled(dev_priv, power_domain))
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                return false;
 
+       ret = false;
+
        tmp = I915_READ(intel_hdmi->hdmi_reg);
 
        if (!(tmp & SDVO_ENABLE))
-               return false;
+               goto out;
 
        if (HAS_PCH_CPT(dev))
                *pipe = PORT_TO_PIPE_CPT(tmp);
@@ -897,7 +900,12 @@ static bool intel_hdmi_get_hw_state(struct intel_encoder *encoder,
        else
                *pipe = PORT_TO_PIPE(tmp);
 
-       return true;
+       ret = true;
+
+out:
+       intel_display_power_put(dev_priv, power_domain);
+
+       return ret;
 }
 
 static void intel_hdmi_get_config(struct intel_encoder *encoder,
@@ -1202,11 +1210,19 @@ intel_hdmi_mode_valid(struct drm_connector *connector,
        struct drm_device *dev = intel_hdmi_to_dev(hdmi);
        enum drm_mode_status status;
        int clock;
+       int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
 
        if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
                return MODE_NO_DBLESCAN;
 
        clock = mode->clock;
+
+       if ((mode->flags & DRM_MODE_FLAG_3D_MASK) == DRM_MODE_FLAG_3D_FRAME_PACKING)
+               clock *= 2;
+
+       if (clock > max_dotclk)
+               return MODE_CLOCK_HIGH;
+
        if (mode->flags & DRM_MODE_FLAG_DBLCLK)
                clock *= 2;
 
@@ -2151,7 +2167,6 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
 void intel_hdmi_init(struct drm_device *dev,
                     i915_reg_t hdmi_reg, enum port port)
 {
-       struct drm_i915_private *dev_priv = dev->dev_private;
        struct intel_digital_port *intel_dig_port;
        struct intel_encoder *intel_encoder;
        struct intel_connector *intel_connector;
@@ -2220,7 +2235,6 @@ void intel_hdmi_init(struct drm_device *dev,
                intel_encoder->cloneable |= 1 << INTEL_OUTPUT_HDMI;
 
        intel_dig_port->port = port;
-       dev_priv->dig_port_map[port] = intel_encoder;
        intel_dig_port->hdmi.hdmi_reg = hdmi_reg;
        intel_dig_port->dp.output_reg = INVALID_MMIO_REG;
        intel_dig_port->max_lanes = 4;
index 25254b5..52fbe53 100644 (file)
@@ -664,6 +664,12 @@ int intel_setup_gmbus(struct drm_device *dev)
 
                bus->adapter.algo = &gmbus_algorithm;
 
+               /*
+                * We wish to retry with bit banging
+                * after a timed out GMBUS attempt.
+                */
+               bus->adapter.retries = 1;
+
                /* By default use a conservative clock rate */
                bus->reg0 = pin | GMBUS_RATE_100KHZ;
 
@@ -683,7 +689,7 @@ int intel_setup_gmbus(struct drm_device *dev)
        return 0;
 
 err:
-       while (--pin) {
+       while (pin--) {
                if (!intel_gmbus_is_valid_pin(dev_priv, pin))
                        continue;
 
index 73d4347..6a978ce 100644 (file)
@@ -223,9 +223,11 @@ enum {
        FAULT_AND_CONTINUE /* Unsupported */
 };
 #define GEN8_CTX_ID_SHIFT 32
-#define CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT  0x17
+#define GEN8_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT       0x17
+#define GEN9_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT       0x26
 
-static int intel_lr_context_pin(struct drm_i915_gem_request *rq);
+static int intel_lr_context_pin(struct intel_context *ctx,
+                               struct intel_engine_cs *engine);
 static void lrc_setup_hardware_status_page(struct intel_engine_cs *ring,
                struct drm_i915_gem_object *default_ctx_obj);
 
@@ -393,7 +395,6 @@ static int execlists_update_context(struct drm_i915_gem_request *rq)
        uint32_t *reg_state = rq->ctx->engine[ring->id].lrc_reg_state;
 
        reg_state[CTX_RING_TAIL+1] = rq->tail;
-       reg_state[CTX_RING_BUFFER_START+1] = rq->ringbuf->vma->node.start;
 
        if (ppgtt && !USES_FULL_48BIT_PPGTT(ppgtt->base.dev)) {
                /* True 32b PPGTT with dynamic page allocation: update PDP
@@ -599,7 +600,7 @@ static int execlists_context_queue(struct drm_i915_gem_request *request)
        int num_elements = 0;
 
        if (request->ctx != request->i915->kernel_context)
-               intel_lr_context_pin(request);
+               intel_lr_context_pin(request->ctx, ring);
 
        i915_gem_request_reference(request);
 
@@ -704,7 +705,7 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request
        }
 
        if (request->ctx != request->i915->kernel_context)
-               ret = intel_lr_context_pin(request);
+               ret = intel_lr_context_pin(request->ctx, request->ring);
 
        return ret;
 }
@@ -765,6 +766,7 @@ intel_logical_ring_advance_and_submit(struct drm_i915_gem_request *request)
 {
        struct intel_ringbuffer *ringbuf = request->ringbuf;
        struct drm_i915_private *dev_priv = request->i915;
+       struct intel_engine_cs *engine = request->ring;
 
        intel_logical_ring_advance(ringbuf);
        request->tail = ringbuf->tail;
@@ -779,9 +781,20 @@ intel_logical_ring_advance_and_submit(struct drm_i915_gem_request *request)
        intel_logical_ring_emit(ringbuf, MI_NOOP);
        intel_logical_ring_advance(ringbuf);
 
-       if (intel_ring_stopped(request->ring))
+       if (intel_ring_stopped(engine))
                return 0;
 
+       if (engine->last_context != request->ctx) {
+               if (engine->last_context)
+                       intel_lr_context_unpin(engine->last_context, engine);
+               if (request->ctx != request->i915->kernel_context) {
+                       intel_lr_context_pin(request->ctx, engine);
+                       engine->last_context = request->ctx;
+               } else {
+                       engine->last_context = NULL;
+               }
+       }
+
        if (dev_priv->guc.execbuf_client)
                i915_guc_submit(dev_priv->guc.execbuf_client, request);
        else
@@ -1015,7 +1028,8 @@ void intel_execlists_retire_requests(struct intel_engine_cs *ring)
                                ctx->engine[ring->id].state;
 
                if (ctx_obj && (ctx != req->i915->kernel_context))
-                       intel_lr_context_unpin(req);
+                       intel_lr_context_unpin(ctx, ring);
+
                list_del(&req->execlist_link);
                i915_gem_request_unreference(req);
        }
@@ -1059,14 +1073,15 @@ int logical_ring_flush_all_caches(struct drm_i915_gem_request *req)
        return 0;
 }
 
-static int intel_lr_context_do_pin(struct intel_engine_cs *ring,
-                                  struct intel_context *ctx)
+static int intel_lr_context_do_pin(struct intel_context *ctx,
+                                  struct intel_engine_cs *ring)
 {
        struct drm_device *dev = ring->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        struct drm_i915_gem_object *ctx_obj = ctx->engine[ring->id].state;
        struct intel_ringbuffer *ringbuf = ctx->engine[ring->id].ringbuf;
        struct page *lrc_state_page;
+       uint32_t *lrc_reg_state;
        int ret;
 
        WARN_ON(!mutex_is_locked(&ring->dev->struct_mutex));
@@ -1088,7 +1103,9 @@ static int intel_lr_context_do_pin(struct intel_engine_cs *ring,
 
        ctx->engine[ring->id].lrc_vma = i915_gem_obj_to_ggtt(ctx_obj);
        intel_lr_context_descriptor_update(ctx, ring);
-       ctx->engine[ring->id].lrc_reg_state = kmap(lrc_state_page);
+       lrc_reg_state = kmap(lrc_state_page);
+       lrc_reg_state[CTX_RING_BUFFER_START+1] = ringbuf->vma->node.start;
+       ctx->engine[ring->id].lrc_reg_state = lrc_reg_state;
        ctx_obj->dirty = true;
 
        /* Invalidate GuC TLB. */
@@ -1103,41 +1120,40 @@ unpin_ctx_obj:
        return ret;
 }
 
-static int intel_lr_context_pin(struct drm_i915_gem_request *rq)
+static int intel_lr_context_pin(struct intel_context *ctx,
+                               struct intel_engine_cs *engine)
 {
        int ret = 0;
-       struct intel_engine_cs *ring = rq->ring;
 
-       if (rq->ctx->engine[ring->id].pin_count++ == 0) {
-               ret = intel_lr_context_do_pin(ring, rq->ctx);
+       if (ctx->engine[engine->id].pin_count++ == 0) {
+               ret = intel_lr_context_do_pin(ctx, engine);
                if (ret)
                        goto reset_pin_count;
+
+               i915_gem_context_reference(ctx);
        }
        return ret;
 
 reset_pin_count:
-       rq->ctx->engine[ring->id].pin_count = 0;
+       ctx->engine[engine->id].pin_count = 0;
        return ret;
 }
 
-void intel_lr_context_unpin(struct drm_i915_gem_request *rq)
+void intel_lr_context_unpin(struct intel_context *ctx,
+                           struct intel_engine_cs *engine)
 {
-       struct intel_engine_cs *ring = rq->ring;
-       struct drm_i915_gem_object *ctx_obj = rq->ctx->engine[ring->id].state;
-       struct intel_ringbuffer *ringbuf = rq->ringbuf;
+       struct drm_i915_gem_object *ctx_obj = ctx->engine[engine->id].state;
 
-       WARN_ON(!mutex_is_locked(&ring->dev->struct_mutex));
-
-       if (!ctx_obj)
-               return;
-
-       if (--rq->ctx->engine[ring->id].pin_count == 0) {
-               kunmap(kmap_to_page(rq->ctx->engine[ring->id].lrc_reg_state));
-               intel_unpin_ringbuffer_obj(ringbuf);
+       WARN_ON(!mutex_is_locked(&ctx->i915->dev->struct_mutex));
+       if (--ctx->engine[engine->id].pin_count == 0) {
+               kunmap(kmap_to_page(ctx->engine[engine->id].lrc_reg_state));
+               intel_unpin_ringbuffer_obj(ctx->engine[engine->id].ringbuf);
                i915_gem_object_ggtt_unpin(ctx_obj);
-               rq->ctx->engine[ring->id].lrc_vma = NULL;
-               rq->ctx->engine[ring->id].lrc_desc = 0;
-               rq->ctx->engine[ring->id].lrc_reg_state = NULL;
+               ctx->engine[engine->id].lrc_vma = NULL;
+               ctx->engine[engine->id].lrc_desc = 0;
+               ctx->engine[engine->id].lrc_reg_state = NULL;
+
+               i915_gem_context_unreference(ctx);
        }
 }
 
@@ -2062,7 +2078,7 @@ logical_ring_init(struct drm_device *dev, struct intel_engine_cs *ring)
                goto error;
 
        /* As this is the default context, always pin it */
-       ret = intel_lr_context_do_pin(ring, dctx);
+       ret = intel_lr_context_do_pin(dctx, ring);
        if (ret) {
                DRM_ERROR(
                        "Failed to pin and map ringbuffer %s: %d\n",
@@ -2086,6 +2102,7 @@ static int logical_render_ring_init(struct drm_device *dev)
        ring->name = "render ring";
        ring->id = RCS;
        ring->exec_id = I915_EXEC_RENDER;
+       ring->guc_id = GUC_RENDER_ENGINE;
        ring->mmio_base = RENDER_RING_BASE;
 
        logical_ring_default_irqs(ring, GEN8_RCS_IRQ_SHIFT);
@@ -2137,6 +2154,7 @@ static int logical_bsd_ring_init(struct drm_device *dev)
        ring->name = "bsd ring";
        ring->id = VCS;
        ring->exec_id = I915_EXEC_BSD;
+       ring->guc_id = GUC_VIDEO_ENGINE;
        ring->mmio_base = GEN6_BSD_RING_BASE;
 
        logical_ring_default_irqs(ring, GEN8_VCS1_IRQ_SHIFT);
@@ -2153,6 +2171,7 @@ static int logical_bsd2_ring_init(struct drm_device *dev)
        ring->name = "bsd2 ring";
        ring->id = VCS2;
        ring->exec_id = I915_EXEC_BSD;
+       ring->guc_id = GUC_VIDEO_ENGINE2;
        ring->mmio_base = GEN8_BSD2_RING_BASE;
 
        logical_ring_default_irqs(ring, GEN8_VCS2_IRQ_SHIFT);
@@ -2169,6 +2188,7 @@ static int logical_blt_ring_init(struct drm_device *dev)
        ring->name = "blitter ring";
        ring->id = BCS;
        ring->exec_id = I915_EXEC_BLT;
+       ring->guc_id = GUC_BLITTER_ENGINE;
        ring->mmio_base = BLT_RING_BASE;
 
        logical_ring_default_irqs(ring, GEN8_BCS_IRQ_SHIFT);
@@ -2185,6 +2205,7 @@ static int logical_vebox_ring_init(struct drm_device *dev)
        ring->name = "video enhancement ring";
        ring->id = VECS;
        ring->exec_id = I915_EXEC_VEBOX;
+       ring->guc_id = GUC_VIDEOENHANCE_ENGINE;
        ring->mmio_base = VEBOX_RING_BASE;
 
        logical_ring_default_irqs(ring, GEN8_VECS_IRQ_SHIFT);
@@ -2293,6 +2314,27 @@ make_rpcs(struct drm_device *dev)
        return rpcs;
 }
 
+static u32 intel_lr_indirect_ctx_offset(struct intel_engine_cs *ring)
+{
+       u32 indirect_ctx_offset;
+
+       switch (INTEL_INFO(ring->dev)->gen) {
+       default:
+               MISSING_CASE(INTEL_INFO(ring->dev)->gen);
+               /* fall through */
+       case 9:
+               indirect_ctx_offset =
+                       GEN9_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT;
+               break;
+       case 8:
+               indirect_ctx_offset =
+                       GEN8_CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT;
+               break;
+       }
+
+       return indirect_ctx_offset;
+}
+
 static int
 populate_lr_context(struct intel_context *ctx, struct drm_i915_gem_object *ctx_obj,
                    struct intel_engine_cs *ring, struct intel_ringbuffer *ringbuf)
@@ -2336,7 +2378,8 @@ populate_lr_context(struct intel_context *ctx, struct drm_i915_gem_object *ctx_o
        ASSIGN_CTX_REG(reg_state, CTX_CONTEXT_CONTROL, RING_CONTEXT_CONTROL(ring),
                       _MASKED_BIT_ENABLE(CTX_CTRL_INHIBIT_SYN_CTX_SWITCH |
                                          CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT |
-                                         CTX_CTRL_RS_CTX_ENABLE));
+                                         (HAS_RESOURCE_STREAMER(dev) ?
+                                           CTX_CTRL_RS_CTX_ENABLE : 0)));
        ASSIGN_CTX_REG(reg_state, CTX_RING_HEAD, RING_HEAD(ring->mmio_base), 0);
        ASSIGN_CTX_REG(reg_state, CTX_RING_TAIL, RING_TAIL(ring->mmio_base), 0);
        /* Ring buffer start address is not known until the buffer is pinned.
@@ -2365,7 +2408,7 @@ populate_lr_context(struct intel_context *ctx, struct drm_i915_gem_object *ctx_o
                                (wa_ctx->indirect_ctx.size / CACHELINE_DWORDS);
 
                        reg_state[CTX_RCS_INDIRECT_CTX_OFFSET+1] =
-                               CTX_RCS_INDIRECT_CTX_OFFSET_DEFAULT << 6;
+                               intel_lr_indirect_ctx_offset(ring) << 6;
 
                        reg_state[CTX_BB_PER_CTX_PTR+1] =
                                (ggtt_offset + wa_ctx->per_ctx.offset * sizeof(uint32_t)) |
index 49af638..e6cda3e 100644 (file)
@@ -101,7 +101,8 @@ void intel_lr_context_free(struct intel_context *ctx);
 uint32_t intel_lr_context_size(struct intel_engine_cs *ring);
 int intel_lr_context_deferred_alloc(struct intel_context *ctx,
                                    struct intel_engine_cs *ring);
-void intel_lr_context_unpin(struct drm_i915_gem_request *req);
+void intel_lr_context_unpin(struct intel_context *ctx,
+                           struct intel_engine_cs *engine);
 void intel_lr_context_reset(struct drm_device *dev,
                        struct intel_context *ctx);
 uint64_t intel_lr_context_descriptor(struct intel_context *ctx,
index 811ddf7..30a8403 100644 (file)
@@ -76,22 +76,30 @@ static bool intel_lvds_get_hw_state(struct intel_encoder *encoder,
        struct intel_lvds_encoder *lvds_encoder = to_lvds_encoder(&encoder->base);
        enum intel_display_power_domain power_domain;
        u32 tmp;
+       bool ret;
 
        power_domain = intel_display_port_power_domain(encoder);
-       if (!intel_display_power_is_enabled(dev_priv, power_domain))
+       if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                return false;
 
+       ret = false;
+
        tmp = I915_READ(lvds_encoder->reg);
 
        if (!(tmp & LVDS_PORT_EN))
-               return false;
+               goto out;
 
        if (HAS_PCH_CPT(dev))
                *pipe = PORT_TO_PIPE_CPT(tmp);
        else
                *pipe = PORT_TO_PIPE(tmp);
 
-       return true;
+       ret = true;
+
+out:
+       intel_display_power_put(dev_priv, power_domain);
+
+       return ret;
 }
 
 static void intel_lvds_get_config(struct intel_encoder *encoder,
index 20bf854..347d4df 100644 (file)
@@ -548,7 +548,7 @@ static const struct intel_watermark_params i845_wm_info = {
  * intel_calculate_wm - calculate watermark level
  * @clock_in_khz: pixel clock
  * @wm: chip FIFO params
- * @pixel_size: display pixel size
+ * @cpp: bytes per pixel
  * @latency_ns: memory latency for the platform
  *
  * Calculate the watermark level (the level at which the display plane will
@@ -564,8 +564,7 @@ static const struct intel_watermark_params i845_wm_info = {
  */
 static unsigned long intel_calculate_wm(unsigned long clock_in_khz,
                                        const struct intel_watermark_params *wm,
-                                       int fifo_size,
-                                       int pixel_size,
+                                       int fifo_size, int cpp,
                                        unsigned long latency_ns)
 {
        long entries_required, wm_size;
@@ -576,7 +575,7 @@ static unsigned long intel_calculate_wm(unsigned long clock_in_khz,
         * clocks go from a few thousand to several hundred thousand.
         * latency is usually a few thousand
         */
-       entries_required = ((clock_in_khz / 1000) * pixel_size * latency_ns) /
+       entries_required = ((clock_in_khz / 1000) * cpp * latency_ns) /
                1000;
        entries_required = DIV_ROUND_UP(entries_required, wm->cacheline_size);
 
@@ -640,13 +639,13 @@ static void pineview_update_wm(struct drm_crtc *unused_crtc)
        crtc = single_enabled_crtc(dev);
        if (crtc) {
                const struct drm_display_mode *adjusted_mode = &to_intel_crtc(crtc)->config->base.adjusted_mode;
-               int pixel_size = crtc->primary->state->fb->bits_per_pixel / 8;
+               int cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0);
                int clock = adjusted_mode->crtc_clock;
 
                /* Display SR */
                wm = intel_calculate_wm(clock, &pineview_display_wm,
                                        pineview_display_wm.fifo_size,
-                                       pixel_size, latency->display_sr);
+                                       cpp, latency->display_sr);
                reg = I915_READ(DSPFW1);
                reg &= ~DSPFW_SR_MASK;
                reg |= FW_WM(wm, SR);
@@ -656,7 +655,7 @@ static void pineview_update_wm(struct drm_crtc *unused_crtc)
                /* cursor SR */
                wm = intel_calculate_wm(clock, &pineview_cursor_wm,
                                        pineview_display_wm.fifo_size,
-                                       pixel_size, latency->cursor_sr);
+                                       cpp, latency->cursor_sr);
                reg = I915_READ(DSPFW3);
                reg &= ~DSPFW_CURSOR_SR_MASK;
                reg |= FW_WM(wm, CURSOR_SR);
@@ -665,7 +664,7 @@ static void pineview_update_wm(struct drm_crtc *unused_crtc)
                /* Display HPLL off SR */
                wm = intel_calculate_wm(clock, &pineview_display_hplloff_wm,
                                        pineview_display_hplloff_wm.fifo_size,
-                                       pixel_size, latency->display_hpll_disable);
+                                       cpp, latency->display_hpll_disable);
                reg = I915_READ(DSPFW3);
                reg &= ~DSPFW_HPLL_SR_MASK;
                reg |= FW_WM(wm, HPLL_SR);
@@ -674,7 +673,7 @@ static void pineview_update_wm(struct drm_crtc *unused_crtc)
                /* cursor HPLL off SR */
                wm = intel_calculate_wm(clock, &pineview_cursor_hplloff_wm,
                                        pineview_display_hplloff_wm.fifo_size,
-                                       pixel_size, latency->cursor_hpll_disable);
+                                       cpp, latency->cursor_hpll_disable);
                reg = I915_READ(DSPFW3);
                reg &= ~DSPFW_HPLL_CURSOR_MASK;
                reg |= FW_WM(wm, HPLL_CURSOR);
@@ -698,7 +697,7 @@ static bool g4x_compute_wm0(struct drm_device *dev,
 {
        struct drm_crtc *crtc;
        const struct drm_display_mode *adjusted_mode;
-       int htotal, hdisplay, clock, pixel_size;
+       int htotal, hdisplay, clock, cpp;
        int line_time_us, line_count;
        int entries, tlb_miss;
 
@@ -713,10 +712,10 @@ static bool g4x_compute_wm0(struct drm_device *dev,
        clock = adjusted_mode->crtc_clock;
        htotal = adjusted_mode->crtc_htotal;
        hdisplay = to_intel_crtc(crtc)->config->pipe_src_w;
-       pixel_size = crtc->primary->state->fb->bits_per_pixel / 8;
+       cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0);
 
        /* Use the small buffer method to calculate plane watermark */
-       entries = ((clock * pixel_size / 1000) * display_latency_ns) / 1000;
+       entries = ((clock * cpp / 1000) * display_latency_ns) / 1000;
        tlb_miss = display->fifo_size*display->cacheline_size - hdisplay * 8;
        if (tlb_miss > 0)
                entries += tlb_miss;
@@ -728,7 +727,7 @@ static bool g4x_compute_wm0(struct drm_device *dev,
        /* Use the large buffer method to calculate cursor watermark */
        line_time_us = max(htotal * 1000 / clock, 1);
        line_count = (cursor_latency_ns / line_time_us + 1000) / 1000;
-       entries = line_count * crtc->cursor->state->crtc_w * pixel_size;
+       entries = line_count * crtc->cursor->state->crtc_w * cpp;
        tlb_miss = cursor->fifo_size*cursor->cacheline_size - hdisplay * 8;
        if (tlb_miss > 0)
                entries += tlb_miss;
@@ -784,7 +783,7 @@ static bool g4x_compute_srwm(struct drm_device *dev,
 {
        struct drm_crtc *crtc;
        const struct drm_display_mode *adjusted_mode;
-       int hdisplay, htotal, pixel_size, clock;
+       int hdisplay, htotal, cpp, clock;
        unsigned long line_time_us;
        int line_count, line_size;
        int small, large;
@@ -800,21 +799,21 @@ static bool g4x_compute_srwm(struct drm_device *dev,
        clock = adjusted_mode->crtc_clock;
        htotal = adjusted_mode->crtc_htotal;
        hdisplay = to_intel_crtc(crtc)->config->pipe_src_w;
-       pixel_size = crtc->primary->state->fb->bits_per_pixel / 8;
+       cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0);
 
        line_time_us = max(htotal * 1000 / clock, 1);
        line_count = (latency_ns / line_time_us + 1000) / 1000;
-       line_size = hdisplay * pixel_size;
+       line_size = hdisplay * cpp;
 
        /* Use the minimum of the small and large buffer method for primary */
-       small = ((clock * pixel_size / 1000) * latency_ns) / 1000;
+       small = ((clock * cpp / 1000) * latency_ns) / 1000;
        large = line_count * line_size;
 
        entries = DIV_ROUND_UP(min(small, large), display->cacheline_size);
        *display_wm = entries + display->guard_size;
 
        /* calculate the self-refresh watermark for display cursor */
-       entries = line_count * pixel_size * crtc->cursor->state->crtc_w;
+       entries = line_count * cpp * crtc->cursor->state->crtc_w;
        entries = DIV_ROUND_UP(entries, cursor->cacheline_size);
        *cursor_wm = entries + cursor->guard_size;
 
@@ -906,13 +905,13 @@ enum vlv_wm_level {
 static unsigned int vlv_wm_method2(unsigned int pixel_rate,
                                   unsigned int pipe_htotal,
                                   unsigned int horiz_pixels,
-                                  unsigned int bytes_per_pixel,
+                                  unsigned int cpp,
                                   unsigned int latency)
 {
        unsigned int ret;
 
        ret = (latency * pixel_rate) / (pipe_htotal * 10000);
-       ret = (ret + 1) * horiz_pixels * bytes_per_pixel;
+       ret = (ret + 1) * horiz_pixels * cpp;
        ret = DIV_ROUND_UP(ret, 64);
 
        return ret;
@@ -941,7 +940,7 @@ static uint16_t vlv_compute_wm_level(struct intel_plane *plane,
                                     int level)
 {
        struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
-       int clock, htotal, pixel_size, width, wm;
+       int clock, htotal, cpp, width, wm;
 
        if (dev_priv->wm.pri_latency[level] == 0)
                return USHRT_MAX;
@@ -949,7 +948,7 @@ static uint16_t vlv_compute_wm_level(struct intel_plane *plane,
        if (!state->visible)
                return 0;
 
-       pixel_size = drm_format_plane_cpp(state->base.fb->pixel_format, 0);
+       cpp = drm_format_plane_cpp(state->base.fb->pixel_format, 0);
        clock = crtc->config->base.adjusted_mode.crtc_clock;
        htotal = crtc->config->base.adjusted_mode.crtc_htotal;
        width = crtc->config->pipe_src_w;
@@ -965,7 +964,7 @@ static uint16_t vlv_compute_wm_level(struct intel_plane *plane,
                 */
                wm = 63;
        } else {
-               wm = vlv_wm_method2(clock, htotal, width, pixel_size,
+               wm = vlv_wm_method2(clock, htotal, width, cpp,
                                    dev_priv->wm.pri_latency[level] * 10);
        }
 
@@ -1439,7 +1438,7 @@ static void i965_update_wm(struct drm_crtc *unused_crtc)
                int clock = adjusted_mode->crtc_clock;
                int htotal = adjusted_mode->crtc_htotal;
                int hdisplay = to_intel_crtc(crtc)->config->pipe_src_w;
-               int pixel_size = crtc->primary->state->fb->bits_per_pixel / 8;
+               int cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0);
                unsigned long line_time_us;
                int entries;
 
@@ -1447,7 +1446,7 @@ static void i965_update_wm(struct drm_crtc *unused_crtc)
 
                /* Use ns/us then divide to preserve precision */
                entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
-                       pixel_size * hdisplay;
+                       cpp * hdisplay;
                entries = DIV_ROUND_UP(entries, I915_FIFO_LINE_SIZE);
                srwm = I965_FIFO_SIZE - entries;
                if (srwm < 0)
@@ -1457,7 +1456,7 @@ static void i965_update_wm(struct drm_crtc *unused_crtc)
                              entries, srwm);
 
                entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
-                       pixel_size * crtc->cursor->state->crtc_w;
+                       cpp * crtc->cursor->state->crtc_w;
                entries = DIV_ROUND_UP(entries,
                                          i965_cursor_wm_info.cacheline_size);
                cursor_sr = i965_cursor_wm_info.fifo_size -
@@ -1518,7 +1517,7 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc)
        crtc = intel_get_crtc_for_plane(dev, 0);
        if (intel_crtc_active(crtc)) {
                const struct drm_display_mode *adjusted_mode;
-               int cpp = crtc->primary->state->fb->bits_per_pixel / 8;
+               int cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0);
                if (IS_GEN2(dev))
                        cpp = 4;
 
@@ -1540,7 +1539,7 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc)
        crtc = intel_get_crtc_for_plane(dev, 1);
        if (intel_crtc_active(crtc)) {
                const struct drm_display_mode *adjusted_mode;
-               int cpp = crtc->primary->state->fb->bits_per_pixel / 8;
+               int cpp = drm_format_plane_cpp(crtc->primary->state->fb->pixel_format, 0);
                if (IS_GEN2(dev))
                        cpp = 4;
 
@@ -1586,7 +1585,7 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc)
                int clock = adjusted_mode->crtc_clock;
                int htotal = adjusted_mode->crtc_htotal;
                int hdisplay = to_intel_crtc(enabled)->config->pipe_src_w;
-               int pixel_size = enabled->primary->state->fb->bits_per_pixel / 8;
+               int cpp = drm_format_plane_cpp(enabled->primary->state->fb->pixel_format, 0);
                unsigned long line_time_us;
                int entries;
 
@@ -1594,7 +1593,7 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc)
 
                /* Use ns/us then divide to preserve precision */
                entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
-                       pixel_size * hdisplay;
+                       cpp * hdisplay;
                entries = DIV_ROUND_UP(entries, wm_info->cacheline_size);
                DRM_DEBUG_KMS("self-refresh entries: %d\n", entries);
                srwm = wm_info->fifo_size - entries;
@@ -1685,15 +1684,14 @@ uint32_t ilk_pipe_pixel_rate(const struct intel_crtc_state *pipe_config)
 }
 
 /* latency must be in 0.1us units. */
-static uint32_t ilk_wm_method1(uint32_t pixel_rate, uint8_t bytes_per_pixel,
-                              uint32_t latency)
+static uint32_t ilk_wm_method1(uint32_t pixel_rate, uint8_t cpp, uint32_t latency)
 {
        uint64_t ret;
 
        if (WARN(latency == 0, "Latency value missing\n"))
                return UINT_MAX;
 
-       ret = (uint64_t) pixel_rate * bytes_per_pixel * latency;
+       ret = (uint64_t) pixel_rate * cpp * latency;
        ret = DIV_ROUND_UP_ULL(ret, 64 * 10000) + 2;
 
        return ret;
@@ -1701,7 +1699,7 @@ static uint32_t ilk_wm_method1(uint32_t pixel_rate, uint8_t bytes_per_pixel,
 
 /* latency must be in 0.1us units. */
 static uint32_t ilk_wm_method2(uint32_t pixel_rate, uint32_t pipe_htotal,
-                              uint32_t horiz_pixels, uint8_t bytes_per_pixel,
+                              uint32_t horiz_pixels, uint8_t cpp,
                               uint32_t latency)
 {
        uint32_t ret;
@@ -1712,13 +1710,13 @@ static uint32_t ilk_wm_method2(uint32_t pixel_rate, uint32_t pipe_htotal,
                return UINT_MAX;
 
        ret = (latency * pixel_rate) / (pipe_htotal * 10000);
-       ret = (ret + 1) * horiz_pixels * bytes_per_pixel;
+       ret = (ret + 1) * horiz_pixels * cpp;
        ret = DIV_ROUND_UP(ret, 64) + 2;
        return ret;
 }
 
 static uint32_t ilk_wm_fbc(uint32_t pri_val, uint32_t horiz_pixels,
-                          uint8_t bytes_per_pixel)
+                          uint8_t cpp)
 {
        /*
         * Neither of these should be possible since this function shouldn't be
@@ -1726,12 +1724,12 @@ static uint32_t ilk_wm_fbc(uint32_t pri_val, uint32_t horiz_pixels,
         * extra paranoid to avoid a potential divide-by-zero if we screw up
         * elsewhere in the driver.
         */
-       if (WARN_ON(!bytes_per_pixel))
+       if (WARN_ON(!cpp))
                return 0;
        if (WARN_ON(!horiz_pixels))
                return 0;
 
-       return DIV_ROUND_UP(pri_val * 64, horiz_pixels * bytes_per_pixel) + 2;
+       return DIV_ROUND_UP(pri_val * 64, horiz_pixels * cpp) + 2;
 }
 
 struct ilk_wm_maximums {
@@ -1750,13 +1748,14 @@ static uint32_t ilk_compute_pri_wm(const struct intel_crtc_state *cstate,
                                   uint32_t mem_value,
                                   bool is_lp)
 {
-       int bpp = pstate->base.fb ? pstate->base.fb->bits_per_pixel / 8 : 0;
+       int cpp = pstate->base.fb ?
+               drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
        uint32_t method1, method2;
 
        if (!cstate->base.active || !pstate->visible)
                return 0;
 
-       method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), bpp, mem_value);
+       method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
 
        if (!is_lp)
                return method1;
@@ -1764,8 +1763,7 @@ static uint32_t ilk_compute_pri_wm(const struct intel_crtc_state *cstate,
        method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate),
                                 cstate->base.adjusted_mode.crtc_htotal,
                                 drm_rect_width(&pstate->dst),
-                                bpp,
-                                mem_value);
+                                cpp, mem_value);
 
        return min(method1, method2);
 }
@@ -1778,18 +1776,18 @@ static uint32_t ilk_compute_spr_wm(const struct intel_crtc_state *cstate,
                                   const struct intel_plane_state *pstate,
                                   uint32_t mem_value)
 {
-       int bpp = pstate->base.fb ? pstate->base.fb->bits_per_pixel / 8 : 0;
+       int cpp = pstate->base.fb ?
+               drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
        uint32_t method1, method2;
 
        if (!cstate->base.active || !pstate->visible)
                return 0;
 
-       method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), bpp, mem_value);
+       method1 = ilk_wm_method1(ilk_pipe_pixel_rate(cstate), cpp, mem_value);
        method2 = ilk_wm_method2(ilk_pipe_pixel_rate(cstate),
                                 cstate->base.adjusted_mode.crtc_htotal,
                                 drm_rect_width(&pstate->dst),
-                                bpp,
-                                mem_value);
+                                cpp, mem_value);
        return min(method1, method2);
 }
 
@@ -1801,16 +1799,20 @@ static uint32_t ilk_compute_cur_wm(const struct intel_crtc_state *cstate,
                                   const struct intel_plane_state *pstate,
                                   uint32_t mem_value)
 {
-       int bpp = pstate->base.fb ? pstate->base.fb->bits_per_pixel / 8 : 0;
+       /*
+        * We treat the cursor plane as always-on for the purposes of watermark
+        * calculation.  Until we have two-stage watermark programming merged,
+        * this is necessary to avoid flickering.
+        */
+       int cpp = 4;
+       int width = pstate->visible ? pstate->base.crtc_w : 64;
 
-       if (!cstate->base.active || !pstate->visible)
+       if (!cstate->base.active)
                return 0;
 
        return ilk_wm_method2(ilk_pipe_pixel_rate(cstate),
                              cstate->base.adjusted_mode.crtc_htotal,
-                             drm_rect_width(&pstate->dst),
-                             bpp,
-                             mem_value);
+                             width, cpp, mem_value);
 }
 
 /* Only for WM_LP. */
@@ -1818,12 +1820,13 @@ static uint32_t ilk_compute_fbc_wm(const struct intel_crtc_state *cstate,
                                   const struct intel_plane_state *pstate,
                                   uint32_t pri_val)
 {
-       int bpp = pstate->base.fb ? pstate->base.fb->bits_per_pixel / 8 : 0;
+       int cpp = pstate->base.fb ?
+               drm_format_plane_cpp(pstate->base.fb->pixel_format, 0) : 0;
 
        if (!cstate->base.active || !pstate->visible)
                return 0;
 
-       return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->dst), bpp);
+       return ilk_wm_fbc(pri_val, drm_rect_width(&pstate->dst), cpp);
 }
 
 static unsigned int ilk_display_fifo_size(const struct drm_device *dev)
@@ -2848,7 +2851,10 @@ void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
        memset(ddb, 0, sizeof(*ddb));
 
        for_each_pipe(dev_priv, pipe) {
-               if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PIPE(pipe)))
+               enum intel_display_power_domain power_domain;
+
+               power_domain = POWER_DOMAIN_PIPE(pipe);
+               if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
                        continue;
 
                for_each_plane(dev_priv, pipe, plane) {
@@ -2860,6 +2866,8 @@ void skl_ddb_get_hw_state(struct drm_i915_private *dev_priv,
                val = I915_READ(CUR_BUF_CFG(pipe));
                skl_ddb_entry_init_from_hw(&ddb->plane[pipe][PLANE_CURSOR],
                                           val);
+
+               intel_display_power_put(dev_priv, power_domain);
        }
 }
 
@@ -3042,26 +3050,25 @@ static uint32_t skl_pipe_pixel_rate(const struct intel_crtc_state *config)
 
 /*
  * The max latency should be 257 (max the punit can code is 255 and we add 2us
- * for the read latency) and bytes_per_pixel should always be <= 8, so that
+ * for the read latency) and cpp should always be <= 8, so that
  * should allow pixel_rate up to ~2 GHz which seems sufficient since max
  * 2xcdclk is 1350 MHz and the pixel rate should never exceed that.
 */
-static uint32_t skl_wm_method1(uint32_t pixel_rate, uint8_t bytes_per_pixel,
-                              uint32_t latency)
+static uint32_t skl_wm_method1(uint32_t pixel_rate, uint8_t cpp, uint32_t latency)
 {
        uint32_t wm_intermediate_val, ret;
 
        if (latency == 0)
                return UINT_MAX;
 
-       wm_intermediate_val = latency * pixel_rate * bytes_per_pixel / 512;
+       wm_intermediate_val = latency * pixel_rate * cpp / 512;
        ret = DIV_ROUND_UP(wm_intermediate_val, 1000);
 
        return ret;
 }
 
 static uint32_t skl_wm_method2(uint32_t pixel_rate, uint32_t pipe_htotal,
-                              uint32_t horiz_pixels, uint8_t bytes_per_pixel,
+                              uint32_t horiz_pixels, uint8_t cpp,
                               uint64_t tiling, uint32_t latency)
 {
        uint32_t ret;
@@ -3071,7 +3078,7 @@ static uint32_t skl_wm_method2(uint32_t pixel_rate, uint32_t pipe_htotal,
        if (latency == 0)
                return UINT_MAX;
 
-       plane_bytes_per_line = horiz_pixels * bytes_per_pixel;
+       plane_bytes_per_line = horiz_pixels * cpp;
 
        if (tiling == I915_FORMAT_MOD_Y_TILED ||
            tiling == I915_FORMAT_MOD_Yf_TILED) {
@@ -3121,23 +3128,21 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
        uint32_t plane_bytes_per_line, plane_blocks_per_line;
        uint32_t res_blocks, res_lines;
        uint32_t selected_result;
-       uint8_t bytes_per_pixel;
+       uint8_t cpp;
 
        if (latency == 0 || !cstate->base.active || !fb)
                return false;
 
-       bytes_per_pixel = drm_format_plane_cpp(fb->pixel_format, 0);
+       cpp = drm_format_plane_cpp(fb->pixel_format, 0);
        method1 = skl_wm_method1(skl_pipe_pixel_rate(cstate),
-                                bytes_per_pixel,
-                                latency);
+                                cpp, latency);
        method2 = skl_wm_method2(skl_pipe_pixel_rate(cstate),
                                 cstate->base.adjusted_mode.crtc_htotal,
                                 cstate->pipe_src_w,
-                                bytes_per_pixel,
-                                fb->modifier[0],
+                                cpp, fb->modifier[0],
                                 latency);
 
-       plane_bytes_per_line = cstate->pipe_src_w * bytes_per_pixel;
+       plane_bytes_per_line = cstate->pipe_src_w * cpp;
        plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512);
 
        if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
@@ -3145,11 +3150,11 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
                uint32_t min_scanlines = 4;
                uint32_t y_tile_minimum;
                if (intel_rotation_90_or_270(plane->state->rotation)) {
-                       int bpp = (fb->pixel_format == DRM_FORMAT_NV12) ?
+                       int cpp = (fb->pixel_format == DRM_FORMAT_NV12) ?
                                drm_format_plane_cpp(fb->pixel_format, 1) :
                                drm_format_plane_cpp(fb->pixel_format, 0);
 
-                       switch (bpp) {
+                       switch (cpp) {
                        case 1:
                                min_scanlines = 16;
                                break;
@@ -4116,11 +4121,13 @@ bool ironlake_set_drps(struct drm_device *dev, u8 val)
 static void ironlake_enable_drps(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
-       u32 rgvmodectl = I915_READ(MEMMODECTL);
+       u32 rgvmodectl;
        u8 fmax, fmin, fstart, vstart;
 
        spin_lock_irq(&mchdev_lock);
 
+       rgvmodectl = I915_READ(MEMMODECTL);
+
        /* Enable temp reporting */
        I915_WRITE16(PMMISC, I915_READ(PMMISC) | MCPPCE_EN);
        I915_WRITE16(TSC1, I915_READ(TSC1) | TSE);
@@ -4562,12 +4569,62 @@ static void intel_print_rc6_info(struct drm_device *dev, u32 mode)
                              onoff(mode & GEN6_RC_CTL_RC6_ENABLE));
 }
 
-static int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
+static bool bxt_check_bios_rc6_setup(const struct drm_device *dev)
+{
+       struct drm_i915_private *dev_priv = dev->dev_private;
+       bool enable_rc6 = true;
+       unsigned long rc6_ctx_base;
+
+       if (!(I915_READ(RC6_LOCATION) & RC6_CTX_IN_DRAM)) {
+               DRM_DEBUG_KMS("RC6 Base location not set properly.\n");
+               enable_rc6 = false;
+       }
+
+       /*
+        * The exact context size is not known for BXT, so assume a page size
+        * for this check.
+        */
+       rc6_ctx_base = I915_READ(RC6_CTX_BASE) & RC6_CTX_BASE_MASK;
+       if (!((rc6_ctx_base >= dev_priv->gtt.stolen_reserved_base) &&
+             (rc6_ctx_base + PAGE_SIZE <= dev_priv->gtt.stolen_reserved_base +
+                                       dev_priv->gtt.stolen_reserved_size))) {
+               DRM_DEBUG_KMS("RC6 Base address not as expected.\n");
+               enable_rc6 = false;
+       }
+
+       if (!(((I915_READ(PWRCTX_MAXCNT_RCSUNIT) & IDLE_TIME_MASK) > 1) &&
+             ((I915_READ(PWRCTX_MAXCNT_VCSUNIT0) & IDLE_TIME_MASK) > 1) &&
+             ((I915_READ(PWRCTX_MAXCNT_BCSUNIT) & IDLE_TIME_MASK) > 1) &&
+             ((I915_READ(PWRCTX_MAXCNT_VECSUNIT) & IDLE_TIME_MASK) > 1))) {
+               DRM_DEBUG_KMS("Engine Idle wait time not set properly.\n");
+               enable_rc6 = false;
+       }
+
+       if (!(I915_READ(GEN6_RC_CONTROL) & (GEN6_RC_CTL_RC6_ENABLE |
+                                           GEN6_RC_CTL_HW_ENABLE)) &&
+           ((I915_READ(GEN6_RC_CONTROL) & GEN6_RC_CTL_HW_ENABLE) ||
+            !(I915_READ(GEN6_RC_STATE) & RC6_STATE))) {
+               DRM_DEBUG_KMS("HW/SW RC6 is not enabled by BIOS.\n");
+               enable_rc6 = false;
+       }
+
+       return enable_rc6;
+}
+
+int sanitize_rc6_option(const struct drm_device *dev, int enable_rc6)
 {
        /* No RC6 before Ironlake and code is gone for ilk. */
        if (INTEL_INFO(dev)->gen < 6)
                return 0;
 
+       if (!enable_rc6)
+               return 0;
+
+       if (IS_BROXTON(dev) && !bxt_check_bios_rc6_setup(dev)) {
+               DRM_INFO("RC6 disabled by BIOS\n");
+               return 0;
+       }
+
        /* Respect the kernel parameter if it is set */
        if (enable_rc6 >= 0) {
                int mask;
@@ -5179,8 +5236,6 @@ static void cherryview_setup_pctx(struct drm_device *dev)
        u32 pcbr;
        int pctx_size = 32*1024;
 
-       WARN_ON(!mutex_is_locked(&dev->struct_mutex));
-
        pcbr = I915_READ(VLV_PCBR);
        if ((pcbr >> VLV_PCBR_ADDR_SHIFT) == 0) {
                DRM_DEBUG_DRIVER("BIOS didn't set up PCBR, fixing up\n");
@@ -5202,7 +5257,7 @@ static void valleyview_setup_pctx(struct drm_device *dev)
        u32 pcbr;
        int pctx_size = 24*1024;
 
-       WARN_ON(!mutex_is_locked(&dev->struct_mutex));
+       mutex_lock(&dev->struct_mutex);
 
        pcbr = I915_READ(VLV_PCBR);
        if (pcbr) {
@@ -5230,7 +5285,7 @@ static void valleyview_setup_pctx(struct drm_device *dev)
        pctx = i915_gem_object_create_stolen(dev, pctx_size);
        if (!pctx) {
                DRM_DEBUG("not enough stolen space for PCTX, disabling\n");
-               return;
+               goto out;
        }
 
        pctx_paddr = dev_priv->mm.stolen_base + pctx->stolen->start;
@@ -5239,6 +5294,7 @@ static void valleyview_setup_pctx(struct drm_device *dev)
 out:
        DRM_DEBUG_DRIVER("PCBR: 0x%08x\n", I915_READ(VLV_PCBR));
        dev_priv->vlv_pctx = pctx;
+       mutex_unlock(&dev->struct_mutex);
 }
 
 static void valleyview_cleanup_pctx(struct drm_device *dev)
@@ -5248,7 +5304,7 @@ static void valleyview_cleanup_pctx(struct drm_device *dev)
        if (WARN_ON(!dev_priv->vlv_pctx))
                return;
 
-       drm_gem_object_unreference(&dev_priv->vlv_pctx->base);
+       drm_gem_object_unreference_unlocked(&dev_priv->vlv_pctx->base);
        dev_priv->vlv_pctx = NULL;
 }
 
@@ -6057,7 +6113,6 @@ void intel_init_gt_powersave(struct drm_device *dev)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
 
-       i915.enable_rc6 = sanitize_rc6_option(dev, i915.enable_rc6);
        /*
         * RPM depends on RC6 to save restore the GT HW context, so make RC6 a
         * requirement.
@@ -6192,8 +6247,8 @@ void intel_enable_gt_powersave(struct drm_device *dev)
                return;
 
        if (IS_IRONLAKE_M(dev)) {
-               mutex_lock(&dev->struct_mutex);
                ironlake_enable_drps(dev);
+               mutex_lock(&dev->struct_mutex);
                intel_init_emon(dev);
                mutex_unlock(&dev->struct_mutex);
        } else if (INTEL_INFO(dev)->gen >= 6) {
@@ -7189,9 +7244,10 @@ static int chv_gpu_freq(struct drm_i915_private *dev_priv, int val)
 {
        int div, czclk_freq = DIV_ROUND_CLOSEST(dev_priv->czclk_freq, 1000);
 
-       div = vlv_gpu_freq_div(czclk_freq) / 2;
+       div = vlv_gpu_freq_div(czclk_freq);
        if (div < 0)
                return div;
+       div /= 2;
 
        return DIV_ROUND_CLOSEST(czclk_freq * val, 2 * div) / 2;
 }
@@ -7200,9 +7256,10 @@ static int chv_freq_opcode(struct drm_i915_private *dev_priv, int val)
 {
        int mul, czclk_freq = DIV_ROUND_CLOSEST(dev_priv->czclk_freq, 1000);
 
-       mul = vlv_gpu_freq_div(czclk_freq) / 2;
+       mul = vlv_gpu_freq_div(czclk_freq);
        if (mul < 0)
                return mul;
+       mul /= 2;
 
        /* CHV needs even values */
        return DIV_ROUND_CLOSEST(val * 2 * mul, czclk_freq) * 2;
index 9ccff30..0b42ada 100644 (file)
@@ -225,7 +225,12 @@ static void hsw_psr_enable_sink(struct intel_dp *intel_dp)
                   (aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT));
        }
 
-       drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG, DP_PSR_ENABLE);
+       if (dev_priv->psr.link_standby)
+               drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG,
+                                  DP_PSR_ENABLE | DP_PSR_MAIN_LINK_ACTIVE);
+       else
+               drm_dp_dpcd_writeb(&intel_dp->aux, DP_PSR_EN_CFG,
+                                  DP_PSR_ENABLE);
 }
 
 static void vlv_psr_enable_source(struct intel_dp *intel_dp)
@@ -280,6 +285,9 @@ static void hsw_psr_enable_source(struct intel_dp *intel_dp)
        if (IS_HASWELL(dev))
                val |= EDP_PSR_MIN_LINK_ENTRY_TIME_8_LINES;
 
+       if (dev_priv->psr.link_standby)
+               val |= EDP_PSR_LINK_STANDBY;
+
        I915_WRITE(EDP_PSR_CTL, val |
                   max_sleep_time << EDP_PSR_MAX_SLEEP_TIME_SHIFT |
                   idle_frames << EDP_PSR_IDLE_FRAME_SHIFT |
@@ -304,8 +312,15 @@ static bool intel_psr_match_conditions(struct intel_dp *intel_dp)
 
        dev_priv->psr.source_ok = false;
 
-       if (IS_HASWELL(dev) && dig_port->port != PORT_A) {
-               DRM_DEBUG_KMS("HSW ties PSR to DDI A (eDP)\n");
+       /*
+        * HSW spec explicitly says PSR is tied to port A.
+        * BDW+ platforms with DDI implementation of PSR have different
+        * PSR registers per transcoder and we only implement transcoder EDP
+        * ones. Since by Display design transcoder EDP is tied to port A
+        * we can safely escape based on the port A.
+        */
+       if (HAS_DDI(dev) && dig_port->port != PORT_A) {
+               DRM_DEBUG_KMS("PSR condition failed: Port not supported\n");
                return false;
        }
 
@@ -314,6 +329,12 @@ static bool intel_psr_match_conditions(struct intel_dp *intel_dp)
                return false;
        }
 
+       if ((IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) &&
+           !dev_priv->psr.link_standby) {
+               DRM_ERROR("PSR condition failed: Link off requested but not supported on this platform\n");
+               return false;
+       }
+
        if (IS_HASWELL(dev) &&
            I915_READ(HSW_STEREO_3D_CTL(intel_crtc->config->cpu_transcoder)) &
                      S3D_ENABLE) {
@@ -327,12 +348,6 @@ static bool intel_psr_match_conditions(struct intel_dp *intel_dp)
                return false;
        }
 
-       if (!IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev) &&
-           ((dev_priv->vbt.psr.full_link) || (dig_port->port != PORT_A))) {
-               DRM_DEBUG_KMS("PSR condition failed: Link Standby requested/needed but not supported on this platform\n");
-               return false;
-       }
-
        dev_priv->psr.source_ok = true;
        return true;
 }
@@ -763,6 +778,36 @@ void intel_psr_init(struct drm_device *dev)
        dev_priv->psr_mmio_base = IS_HASWELL(dev_priv) ?
                HSW_EDP_PSR_BASE : BDW_EDP_PSR_BASE;
 
+       /* Per platform default */
+       if (i915.enable_psr == -1) {
+               if (IS_HASWELL(dev) || IS_BROADWELL(dev) ||
+                   IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
+                       i915.enable_psr = 1;
+               else
+                       i915.enable_psr = 0;
+       }
+
+       /* Set link_standby x link_off defaults */
+       if (IS_HASWELL(dev) || IS_BROADWELL(dev))
+               /* HSW and BDW require workarounds that we don't implement. */
+               dev_priv->psr.link_standby = false;
+       else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
+               /* On VLV and CHV only standby mode is supported. */
+               dev_priv->psr.link_standby = true;
+       else
+               /* For new platforms let's respect VBT back again */
+               dev_priv->psr.link_standby = dev_priv->vbt.psr.full_link;
+
+       /* Override link_standby x link_off defaults */
+       if (i915.enable_psr == 2 && !dev_priv->psr.link_standby) {
+               DRM_DEBUG_KMS("PSR: Forcing link standby\n");
+               dev_priv->psr.link_standby = true;
+       }
+       if (i915.enable_psr == 3 && dev_priv->psr.link_standby) {
+               DRM_DEBUG_KMS("PSR: Forcing main link off\n");
+               dev_priv->psr.link_standby = false;
+       }
+
        INIT_DELAYED_WORK(&dev_priv->psr.work, intel_psr_work);
        mutex_init(&dev_priv->psr.lock);
 }
index 9030e2b..45ce45a 100644 (file)
@@ -746,9 +746,9 @@ static int intel_rcs_ctx_init(struct drm_i915_gem_request *req)
 
        ret = i915_gem_render_state_init(req);
        if (ret)
-               DRM_ERROR("init render state: %d\n", ret);
+               return ret;
 
-       return ret;
+       return 0;
 }
 
 static int wa_add(struct drm_i915_private *dev_priv,
@@ -789,6 +789,22 @@ static int wa_add(struct drm_i915_private *dev_priv,
 
 #define WA_WRITE(addr, val) WA_REG(addr, 0xffffffff, val)
 
+static int wa_ring_whitelist_reg(struct intel_engine_cs *ring, i915_reg_t reg)
+{
+       struct drm_i915_private *dev_priv = ring->dev->dev_private;
+       struct i915_workarounds *wa = &dev_priv->workarounds;
+       const uint32_t index = wa->hw_whitelist_count[ring->id];
+
+       if (WARN_ON(index >= RING_MAX_NONPRIV_SLOTS))
+               return -EINVAL;
+
+       WA_WRITE(RING_FORCE_TO_NONPRIV(ring->mmio_base, index),
+                i915_mmio_reg_offset(reg));
+       wa->hw_whitelist_count[ring->id]++;
+
+       return 0;
+}
+
 static int gen8_init_workarounds(struct intel_engine_cs *ring)
 {
        struct drm_device *dev = ring->dev;
@@ -894,6 +910,7 @@ static int gen9_init_workarounds(struct intel_engine_cs *ring)
        struct drm_device *dev = ring->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        uint32_t tmp;
+       int ret;
 
        /* WaEnableLbsSlaRetryTimerDecrement:skl */
        I915_WRITE(BDW_SCRATCH1, I915_READ(BDW_SCRATCH1) |
@@ -964,6 +981,20 @@ static int gen9_init_workarounds(struct intel_engine_cs *ring)
        /* WaDisableSTUnitPowerOptimization:skl,bxt */
        WA_SET_BIT_MASKED(HALF_SLICE_CHICKEN2, GEN8_ST_PO_DISABLE);
 
+       /* WaOCLCoherentLineFlush:skl,bxt */
+       I915_WRITE(GEN8_L3SQCREG4, (I915_READ(GEN8_L3SQCREG4) |
+                                   GEN8_LQSC_FLUSH_COHERENT_LINES));
+
+       /* WaEnablePreemptionGranularityControlByUMD:skl,bxt */
+       ret= wa_ring_whitelist_reg(ring, GEN8_CS_CHICKEN1);
+       if (ret)
+               return ret;
+
+       /* WaAllowUMDToModifyHDCChicken1:skl,bxt */
+       ret = wa_ring_whitelist_reg(ring, GEN8_HDC_CHICKEN1);
+       if (ret)
+               return ret;
+
        return 0;
 }
 
@@ -1019,6 +1050,16 @@ static int skl_init_workarounds(struct intel_engine_cs *ring)
        if (ret)
                return ret;
 
+       /*
+        * Actual WA is to disable percontext preemption granularity control
+        * until D0 which is the default case so this is equivalent to
+        * !WaDisablePerCtxtPreemptionGranularityControl:skl
+        */
+       if (IS_SKL_REVID(dev, SKL_REVID_E0, REVID_FOREVER)) {
+               I915_WRITE(GEN7_FF_SLICE_CS_CHICKEN1,
+                          _MASKED_BIT_ENABLE(GEN9_FFSC_PERCTX_PREEMPT_CTRL));
+       }
+
        if (IS_SKL_REVID(dev, 0, SKL_REVID_D0)) {
                /* WaDisableChickenBitTSGBarrierAckForFFSliceCS:skl */
                I915_WRITE(FF_SLICE_CS_CHICKEN2,
@@ -1071,6 +1112,11 @@ static int skl_init_workarounds(struct intel_engine_cs *ring)
                        GEN7_HALF_SLICE_CHICKEN1,
                        GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE);
 
+       /* WaDisableLSQCROPERFforOCL:skl */
+       ret = wa_ring_whitelist_reg(ring, GEN8_L3SQCREG4);
+       if (ret)
+               return ret;
+
        return skl_tune_iz_hashing(ring);
 }
 
@@ -1106,6 +1152,20 @@ static int bxt_init_workarounds(struct intel_engine_cs *ring)
                        GEN7_SBE_SS_CACHE_DISPATCH_PORT_SHARING_DISABLE);
        }
 
+       /* WaDisableObjectLevelPreemptionForTrifanOrPolygon:bxt */
+       /* WaDisableObjectLevelPreemptionForInstancedDraw:bxt */
+       /* WaDisableObjectLevelPreemtionForInstanceId:bxt */
+       /* WaDisableLSQCROPERFforOCL:bxt */
+       if (IS_BXT_REVID(dev, 0, BXT_REVID_A1)) {
+               ret = wa_ring_whitelist_reg(ring, GEN9_CS_DEBUG_MODE1);
+               if (ret)
+                       return ret;
+
+               ret = wa_ring_whitelist_reg(ring, GEN8_L3SQCREG4);
+               if (ret)
+                       return ret;
+       }
+
        return 0;
 }
 
@@ -1117,6 +1177,7 @@ int init_workarounds_ring(struct intel_engine_cs *ring)
        WARN_ON(ring->id != RCS);
 
        dev_priv->workarounds.count = 0;
+       dev_priv->workarounds.hw_whitelist_count[RCS] = 0;
 
        if (IS_BROADWELL(dev))
                return bdw_init_workarounds(ring);
@@ -2058,6 +2119,9 @@ int intel_pin_and_map_ringbuffer_obj(struct drm_device *dev,
                        return ret;
                }
 
+               /* Access through the GTT requires the device to be awake. */
+               assert_rpm_wakelock_held(dev_priv);
+
                ringbuf->virtual_start = ioremap_wc(dev_priv->gtt.mappable_base +
                                                    i915_gem_obj_ggtt_offset(obj), ringbuf->size);
                if (ringbuf->virtual_start == NULL) {
index b12f2aa..566b0ae 100644 (file)
@@ -158,6 +158,7 @@ struct  intel_engine_cs {
 #define I915_NUM_RINGS 5
 #define _VCS(n) (VCS + (n))
        unsigned int exec_id;
+       unsigned int guc_id;
        u32             mmio_base;
        struct          drm_device *dev;
        struct intel_ringbuffer *buffer;
index bbca527..6e54d97 100644 (file)
@@ -284,6 +284,13 @@ static void hsw_power_well_post_enable(struct drm_i915_private *dev_priv)
                                                1 << PIPE_C | 1 << PIPE_B);
 }
 
+static void hsw_power_well_pre_disable(struct drm_i915_private *dev_priv)
+{
+       if (IS_BROADWELL(dev_priv))
+               gen8_irq_power_well_pre_disable(dev_priv,
+                                               1 << PIPE_C | 1 << PIPE_B);
+}
+
 static void skl_power_well_post_enable(struct drm_i915_private *dev_priv,
                                       struct i915_power_well *power_well)
 {
@@ -309,6 +316,14 @@ static void skl_power_well_post_enable(struct drm_i915_private *dev_priv,
        }
 }
 
+static void skl_power_well_pre_disable(struct drm_i915_private *dev_priv,
+                                      struct i915_power_well *power_well)
+{
+       if (power_well->data == SKL_DISP_PW_2)
+               gen8_irq_power_well_pre_disable(dev_priv,
+                                               1 << PIPE_C | 1 << PIPE_B);
+}
+
 static void hsw_set_power_well(struct drm_i915_private *dev_priv,
                               struct i915_power_well *power_well, bool enable)
 {
@@ -334,6 +349,7 @@ static void hsw_set_power_well(struct drm_i915_private *dev_priv,
 
        } else {
                if (enable_requested) {
+                       hsw_power_well_pre_disable(dev_priv);
                        I915_WRITE(HSW_PWR_WELL_DRIVER, 0);
                        POSTING_READ(HSW_PWR_WELL_DRIVER);
                        DRM_DEBUG_KMS("Requesting to disable the power well\n");
@@ -456,20 +472,61 @@ static void assert_can_disable_dc9(struct drm_i915_private *dev_priv)
          */
 }
 
-static void gen9_set_dc_state_debugmask_memory_up(
-                       struct drm_i915_private *dev_priv)
+static void gen9_set_dc_state_debugmask(struct drm_i915_private *dev_priv)
 {
-       uint32_t val;
+       uint32_t val, mask;
+
+       mask = DC_STATE_DEBUG_MASK_MEMORY_UP;
+
+       if (IS_BROXTON(dev_priv))
+               mask |= DC_STATE_DEBUG_MASK_CORES;
 
        /* The below bit doesn't need to be cleared ever afterwards */
        val = I915_READ(DC_STATE_DEBUG);
-       if (!(val & DC_STATE_DEBUG_MASK_MEMORY_UP)) {
-               val |= DC_STATE_DEBUG_MASK_MEMORY_UP;
+       if ((val & mask) != mask) {
+               val |= mask;
                I915_WRITE(DC_STATE_DEBUG, val);
                POSTING_READ(DC_STATE_DEBUG);
        }
 }
 
+static void gen9_write_dc_state(struct drm_i915_private *dev_priv,
+                               u32 state)
+{
+       int rewrites = 0;
+       int rereads = 0;
+       u32 v;
+
+       I915_WRITE(DC_STATE_EN, state);
+
+       /* It has been observed that disabling the dc6 state sometimes
+        * doesn't stick and dmc keeps returning old value. Make sure
+        * the write really sticks enough times and also force rewrite until
+        * we are confident that state is exactly what we want.
+        */
+       do  {
+               v = I915_READ(DC_STATE_EN);
+
+               if (v != state) {
+                       I915_WRITE(DC_STATE_EN, state);
+                       rewrites++;
+                       rereads = 0;
+               } else if (rereads++ > 5) {
+                       break;
+               }
+
+       } while (rewrites < 100);
+
+       if (v != state)
+               DRM_ERROR("Writing dc state to 0x%x failed, now 0x%x\n",
+                         state, v);
+
+       /* Most of the times we need one retry, avoid spam */
+       if (rewrites > 1)
+               DRM_DEBUG_KMS("Rewrote dc state to 0x%x %d times\n",
+                             state, rewrites);
+}
+
 static void gen9_set_dc_state(struct drm_i915_private *dev_priv, uint32_t state)
 {
        uint32_t val;
@@ -488,16 +545,21 @@ static void gen9_set_dc_state(struct drm_i915_private *dev_priv, uint32_t state)
        else if (i915.enable_dc == 1 && state > DC_STATE_EN_UPTO_DC5)
                state = DC_STATE_EN_UPTO_DC5;
 
-       if (state & DC_STATE_EN_UPTO_DC5_DC6_MASK)
-               gen9_set_dc_state_debugmask_memory_up(dev_priv);
-
        val = I915_READ(DC_STATE_EN);
        DRM_DEBUG_KMS("Setting DC state from %02x to %02x\n",
                      val & mask, state);
+
+       /* Check if DMC is ignoring our DC state requests */
+       if ((val & mask) != dev_priv->csr.dc_state)
+               DRM_ERROR("DC state mismatch (0x%x -> 0x%x)\n",
+                         dev_priv->csr.dc_state, val & mask);
+
        val &= ~mask;
        val |= state;
-       I915_WRITE(DC_STATE_EN, val);
-       POSTING_READ(DC_STATE_EN);
+
+       gen9_write_dc_state(dev_priv, val);
+
+       dev_priv->csr.dc_state = val & mask;
 }
 
 void bxt_enable_dc9(struct drm_i915_private *dev_priv)
@@ -663,6 +725,9 @@ static void skl_set_power_well(struct drm_i915_private *dev_priv,
        state_mask = SKL_POWER_WELL_STATE(power_well->data);
        is_enabled = tmp & state_mask;
 
+       if (!enable && enable_requested)
+               skl_power_well_pre_disable(dev_priv, power_well);
+
        if (enable) {
                if (!enable_requested) {
                        WARN((tmp & state_mask) &&
@@ -941,6 +1006,9 @@ static void vlv_display_power_well_deinit(struct drm_i915_private *dev_priv)
        valleyview_disable_display_irqs(dev_priv);
        spin_unlock_irq(&dev_priv->irq_lock);
 
+       /* make sure we're done processing display irqs */
+       synchronize_irq(dev_priv->dev->irq);
+
        vlv_power_sequencer_reset(dev_priv);
 }
 
@@ -1435,6 +1503,22 @@ static void chv_pipe_power_well_disable(struct drm_i915_private *dev_priv,
        chv_set_pipe_power_well(dev_priv, power_well, false);
 }
 
+static void
+__intel_display_power_get_domain(struct drm_i915_private *dev_priv,
+                                enum intel_display_power_domain domain)
+{
+       struct i915_power_domains *power_domains = &dev_priv->power_domains;
+       struct i915_power_well *power_well;
+       int i;
+
+       for_each_power_well(i, power_well, BIT(domain), power_domains) {
+               if (!power_well->count++)
+                       intel_power_well_enable(dev_priv, power_well);
+       }
+
+       power_domains->domain_use_count[domain]++;
+}
+
 /**
  * intel_display_power_get - grab a power domain reference
  * @dev_priv: i915 device instance
@@ -1450,24 +1534,53 @@ static void chv_pipe_power_well_disable(struct drm_i915_private *dev_priv,
 void intel_display_power_get(struct drm_i915_private *dev_priv,
                             enum intel_display_power_domain domain)
 {
-       struct i915_power_domains *power_domains;
-       struct i915_power_well *power_well;
-       int i;
+       struct i915_power_domains *power_domains = &dev_priv->power_domains;
 
        intel_runtime_pm_get(dev_priv);
 
-       power_domains = &dev_priv->power_domains;
+       mutex_lock(&power_domains->lock);
+
+       __intel_display_power_get_domain(dev_priv, domain);
+
+       mutex_unlock(&power_domains->lock);
+}
+
+/**
+ * intel_display_power_get_if_enabled - grab a reference for an enabled display power domain
+ * @dev_priv: i915 device instance
+ * @domain: power domain to reference
+ *
+ * This function grabs a power domain reference for @domain and ensures that the
+ * power domain and all its parents are powered up. Therefore users should only
+ * grab a reference to the innermost power domain they need.
+ *
+ * Any power domain reference obtained by this function must have a symmetric
+ * call to intel_display_power_put() to release the reference again.
+ */
+bool intel_display_power_get_if_enabled(struct drm_i915_private *dev_priv,
+                                       enum intel_display_power_domain domain)
+{
+       struct i915_power_domains *power_domains = &dev_priv->power_domains;
+       bool is_enabled;
+
+       if (!intel_runtime_pm_get_if_in_use(dev_priv))
+               return false;
 
        mutex_lock(&power_domains->lock);
 
-       for_each_power_well(i, power_well, BIT(domain), power_domains) {
-               if (!power_well->count++)
-                       intel_power_well_enable(dev_priv, power_well);
+       if (__intel_display_power_is_enabled(dev_priv, domain)) {
+               __intel_display_power_get_domain(dev_priv, domain);
+               is_enabled = true;
+       } else {
+               is_enabled = false;
        }
 
-       power_domains->domain_use_count[domain]++;
-
        mutex_unlock(&power_domains->lock);
+
+       if (!is_enabled)
+               intel_runtime_pm_put(dev_priv);
+
+       return is_enabled;
 }
 
 /**
@@ -2028,8 +2141,8 @@ static void skl_display_core_init(struct drm_i915_private *dev_priv,
 
        skl_init_cdclk(dev_priv);
 
-       if (dev_priv->csr.dmc_payload)
-               intel_csr_load_program(dev_priv);
+       if (dev_priv->csr.dmc_payload && intel_csr_load_program(dev_priv))
+               gen9_set_dc_state_debugmask(dev_priv);
 }
 
 static void skl_display_core_uninit(struct drm_i915_private *dev_priv)
@@ -2206,15 +2319,15 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume)
  */
 void intel_power_domains_suspend(struct drm_i915_private *dev_priv)
 {
-       if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
-               skl_display_core_uninit(dev_priv);
-
        /*
         * Even if power well support was disabled we still want to disable
         * power wells while we are system suspended.
         */
        if (!i915.disable_power_well)
                intel_display_power_put(dev_priv, POWER_DOMAIN_INIT);
+
+       if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv))
+               skl_display_core_uninit(dev_priv);
 }
 
 /**
@@ -2239,6 +2352,41 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)
 }
 
 /**
+ * intel_runtime_pm_get_if_in_use - grab a runtime pm reference if device in use
+ * @dev_priv: i915 device instance
+ *
+ * This function grabs a device-level runtime pm reference if the device is
+ * already in use and ensures that it is powered up.
+ *
+ * Any runtime pm reference obtained by this function must have a symmetric
+ * call to intel_runtime_pm_put() to release the reference again.
+ */
+bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv)
+{
+       struct drm_device *dev = dev_priv->dev;
+       struct device *device = &dev->pdev->dev;
+
+       if (IS_ENABLED(CONFIG_PM)) {
+               int ret = pm_runtime_get_if_in_use(device);
+
+               /*
+                * In cases runtime PM is disabled by the RPM core and we get
+                * an -EINVAL return value we are not supposed to call this
+                * function, since the power state is undefined. This applies
+                * atm to the late/early system suspend/resume handlers.
+                */
+               WARN_ON_ONCE(ret < 0);
+               if (ret <= 0)
+                       return false;
+       }
+
+       atomic_inc(&dev_priv->pm.wakeref_count);
+       assert_rpm_wakelock_held(dev_priv);
+
+       return true;
+}
+
+/**
  * intel_runtime_pm_get_noresume - grab a runtime pm reference
  * @dev_priv: i915 device instance
  *
index 2e1da06..4ecc076 100644 (file)
@@ -1527,6 +1527,7 @@ intel_sdvo_mode_valid(struct drm_connector *connector,
                      struct drm_display_mode *mode)
 {
        struct intel_sdvo *intel_sdvo = intel_attached_sdvo(connector);
+       int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
 
        if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
                return MODE_NO_DBLESCAN;
@@ -1537,6 +1538,9 @@ intel_sdvo_mode_valid(struct drm_connector *connector,
        if (intel_sdvo->pixel_clock_max < mode->clock)
                return MODE_CLOCK_HIGH;
 
+       if (mode->clock > max_dotclk)
+               return MODE_CLOCK_HIGH;
+
        if (intel_sdvo->is_lvds) {
                if (mode->hdisplay > intel_sdvo->sdvo_lvds_fixed_mode->hdisplay)
                        return MODE_PANEL;
index 8831fc5..c399818 100644 (file)
@@ -129,17 +129,18 @@ u32 vlv_nc_read(struct drm_i915_private *dev_priv, u8 addr)
        return val;
 }
 
-u32 vlv_gpio_nc_read(struct drm_i915_private *dev_priv, u32 reg)
+u32 vlv_iosf_sb_read(struct drm_i915_private *dev_priv, u8 port, u32 reg)
 {
        u32 val = 0;
-       vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_GPIO_NC,
+       vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), port,
                        SB_CRRDDA_NP, reg, &val);
        return val;
 }
 
-void vlv_gpio_nc_write(struct drm_i915_private *dev_priv, u32 reg, u32 val)
+void vlv_iosf_sb_write(struct drm_i915_private *dev_priv,
+                      u8 port, u32 reg, u32 val)
 {
-       vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_GPIO_NC,
+       vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), port,
                        SB_CRWRDA_NP, reg, &val);
 }
 
@@ -171,20 +172,6 @@ void vlv_ccu_write(struct drm_i915_private *dev_priv, u32 reg, u32 val)
                        SB_CRWRDA_NP, reg, &val);
 }
 
-u32 vlv_gps_core_read(struct drm_i915_private *dev_priv, u32 reg)
-{
-       u32 val = 0;
-       vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_GPS_CORE,
-                       SB_CRRDDA_NP, reg, &val);
-       return val;
-}
-
-void vlv_gps_core_write(struct drm_i915_private *dev_priv, u32 reg, u32 val)
-{
-       vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_GPS_CORE,
-                       SB_CRWRDA_NP, reg, &val);
-}
-
 u32 vlv_dpio_read(struct drm_i915_private *dev_priv, enum pipe pipe, int reg)
 {
        u32 val = 0;
index 0875c8e..a2582c4 100644 (file)
@@ -350,8 +350,8 @@ vlv_update_plane(struct drm_plane *dplane,
        int pipe = intel_plane->pipe;
        int plane = intel_plane->plane;
        u32 sprctl;
-       unsigned long sprsurf_offset, linear_offset;
-       int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
+       u32 sprsurf_offset, linear_offset;
+       int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
        const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
        int crtc_x = plane_state->dst.x1;
        int crtc_y = plane_state->dst.y1;
@@ -422,10 +422,9 @@ vlv_update_plane(struct drm_plane *dplane,
        crtc_w--;
        crtc_h--;
 
-       linear_offset = y * fb->pitches[0] + x * pixel_size;
+       linear_offset = y * fb->pitches[0] + x * cpp;
        sprsurf_offset = intel_compute_tile_offset(dev_priv, &x, &y,
-                                                  fb->modifier[0],
-                                                  pixel_size,
+                                                  fb->modifier[0], cpp,
                                                   fb->pitches[0]);
        linear_offset -= sprsurf_offset;
 
@@ -434,7 +433,7 @@ vlv_update_plane(struct drm_plane *dplane,
 
                x += src_w;
                y += src_h;
-               linear_offset += src_h * fb->pitches[0] + src_w * pixel_size;
+               linear_offset += src_h * fb->pitches[0] + src_w * cpp;
        }
 
        if (key->flags) {
@@ -493,8 +492,8 @@ ivb_update_plane(struct drm_plane *plane,
        struct drm_i915_gem_object *obj = intel_fb_obj(fb);
        enum pipe pipe = intel_plane->pipe;
        u32 sprctl, sprscale = 0;
-       unsigned long sprsurf_offset, linear_offset;
-       int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
+       u32 sprsurf_offset, linear_offset;
+       int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
        const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
        int crtc_x = plane_state->dst.x1;
        int crtc_y = plane_state->dst.y1;
@@ -556,10 +555,9 @@ ivb_update_plane(struct drm_plane *plane,
        if (crtc_w != src_w || crtc_h != src_h)
                sprscale = SPRITE_SCALE_ENABLE | (src_w << 16) | src_h;
 
-       linear_offset = y * fb->pitches[0] + x * pixel_size;
+       linear_offset = y * fb->pitches[0] + x * cpp;
        sprsurf_offset = intel_compute_tile_offset(dev_priv, &x, &y,
-                                                  fb->modifier[0],
-                                                  pixel_size,
+                                                  fb->modifier[0], cpp,
                                                   fb->pitches[0]);
        linear_offset -= sprsurf_offset;
 
@@ -570,8 +568,7 @@ ivb_update_plane(struct drm_plane *plane,
                if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) {
                        x += src_w;
                        y += src_h;
-                       linear_offset += src_h * fb->pitches[0] +
-                               src_w * pixel_size;
+                       linear_offset += src_h * fb->pitches[0] + src_w * cpp;
                }
        }
 
@@ -635,9 +632,9 @@ ilk_update_plane(struct drm_plane *plane,
        struct drm_framebuffer *fb = plane_state->base.fb;
        struct drm_i915_gem_object *obj = intel_fb_obj(fb);
        int pipe = intel_plane->pipe;
-       unsigned long dvssurf_offset, linear_offset;
        u32 dvscntr, dvsscale;
-       int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
+       u32 dvssurf_offset, linear_offset;
+       int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
        const struct drm_intel_sprite_colorkey *key = &plane_state->ckey;
        int crtc_x = plane_state->dst.x1;
        int crtc_y = plane_state->dst.y1;
@@ -695,10 +692,9 @@ ilk_update_plane(struct drm_plane *plane,
        if (crtc_w != src_w || crtc_h != src_h)
                dvsscale = DVS_SCALE_ENABLE | (src_w << 16) | src_h;
 
-       linear_offset = y * fb->pitches[0] + x * pixel_size;
+       linear_offset = y * fb->pitches[0] + x * cpp;
        dvssurf_offset = intel_compute_tile_offset(dev_priv, &x, &y,
-                                                  fb->modifier[0],
-                                                  pixel_size,
+                                                  fb->modifier[0], cpp,
                                                   fb->pitches[0]);
        linear_offset -= dvssurf_offset;
 
@@ -707,7 +703,7 @@ ilk_update_plane(struct drm_plane *plane,
 
                x += src_w;
                y += src_h;
-               linear_offset += src_h * fb->pitches[0] + src_w * pixel_size;
+               linear_offset += src_h * fb->pitches[0] + src_w * cpp;
        }
 
        if (key->flags) {
@@ -772,7 +768,6 @@ intel_check_sprite_plane(struct drm_plane *plane,
        int hscale, vscale;
        int max_scale, min_scale;
        bool can_scale;
-       int pixel_size;
 
        if (!fb) {
                state->visible = false;
@@ -894,6 +889,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
        /* Check size restrictions when scaling */
        if (state->visible && (src_w != crtc_w || src_h != crtc_h)) {
                unsigned int width_bytes;
+               int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
 
                WARN_ON(!can_scale);
 
@@ -905,9 +901,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
                if (src_w < 3 || src_h < 3)
                        state->visible = false;
 
-               pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
-               width_bytes = ((src_x * pixel_size) & 63) +
-                                       src_w * pixel_size;
+               width_bytes = ((src_x * cpp) & 63) + src_w * cpp;
 
                if (INTEL_INFO(dev)->gen < 9 && (src_w > 2048 || src_h > 2048 ||
                    width_bytes > 4096 || fb->pitches[0] > 4096)) {
index 948cbff..6745bad 100644 (file)
@@ -897,6 +897,10 @@ intel_tv_mode_valid(struct drm_connector *connector,
 {
        struct intel_tv *intel_tv = intel_attached_tv(connector);
        const struct tv_mode *tv_mode = intel_tv_mode_find(intel_tv);
+       int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
+
+       if (mode->clock > max_dotclk)
+               return MODE_CLOCK_HIGH;
 
        /* Ensure TV refresh is close to desired refresh */
        if (tv_mode && abs(tv_mode->refresh - drm_mode_vrefresh(mode) * 1000)
@@ -1178,10 +1182,9 @@ static int
 intel_tv_detect_type(struct intel_tv *intel_tv,
                      struct drm_connector *connector)
 {
-       struct drm_encoder *encoder = &intel_tv->base.base;
-       struct drm_crtc *crtc = encoder->crtc;
+       struct drm_crtc *crtc = connector->state->crtc;
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-       struct drm_device *dev = encoder->dev;
+       struct drm_device *dev = connector->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
        u32 tv_ctl, save_tv_ctl;
        u32 tv_dac, save_tv_dac;
@@ -1230,8 +1233,7 @@ intel_tv_detect_type(struct intel_tv *intel_tv,
        I915_WRITE(TV_DAC, tv_dac);
        POSTING_READ(TV_DAC);
 
-       intel_wait_for_vblank(intel_tv->base.base.dev,
-                             to_intel_crtc(intel_tv->base.base.crtc)->pipe);
+       intel_wait_for_vblank(dev, intel_crtc->pipe);
 
        type = -1;
        tv_dac = I915_READ(TV_DAC);
@@ -1261,8 +1263,7 @@ intel_tv_detect_type(struct intel_tv *intel_tv,
        POSTING_READ(TV_CTL);
 
        /* For unknown reasons the hw barfs if we don't do this vblank wait. */
-       intel_wait_for_vblank(intel_tv->base.base.dev,
-                             to_intel_crtc(intel_tv->base.base.crtc)->pipe);
+       intel_wait_for_vblank(dev, intel_crtc->pipe);
 
        /* Restore interrupt config */
        if (connector->polled & DRM_CONNECTOR_POLL_HPD) {
@@ -1420,6 +1421,7 @@ intel_tv_get_modes(struct drm_connector *connector)
                if (!mode_ptr)
                        continue;
                strncpy(mode_ptr->name, input->name, DRM_DISPLAY_MODE_LEN);
+               mode_ptr->name[DRM_DISPLAY_MODE_LEN - 1] = '\0';
 
                mode_ptr->hdisplay = hactive_s;
                mode_ptr->hsync_start = hactive_s + 1;
index bfa79e5..436d8f2 100644 (file)
@@ -400,6 +400,8 @@ void intel_uncore_early_sanitize(struct drm_device *dev, bool restore_forcewake)
 
 void intel_uncore_sanitize(struct drm_device *dev)
 {
+       i915.enable_rc6 = sanitize_rc6_option(dev, i915.enable_rc6);
+
        /* BIOS often leaves RC6 enabled, but disable it for hw init */
        intel_disable_gt_powersave(dev);
 }
index 21d6158..2a95d10 100644 (file)
@@ -118,7 +118,7 @@ static void dw_hdmi_imx_encoder_mode_set(struct drm_encoder *encoder,
 static void dw_hdmi_imx_encoder_commit(struct drm_encoder *encoder)
 {
        struct imx_hdmi *hdmi = container_of(encoder, struct imx_hdmi, encoder);
-       int mux = imx_drm_encoder_get_mux_id(hdmi->dev->of_node, encoder);
+       int mux = drm_of_encoder_active_port_id(hdmi->dev->of_node, encoder);
 
        regmap_update_bits(hdmi->regmap, IOMUXC_GPR3,
                           IMX6Q_GPR3_HDMI_MUX_CTL_MASK,
index 7c4d125..9876e0f 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/device.h>
 #include <linux/fb.h>
 #include <linux/module.h>
-#include <linux/of_graph.h>
 #include <linux/platform_device.h>
 #include <drm/drmP.h>
 #include <drm/drm_fb_helper.h>
@@ -412,36 +411,6 @@ int imx_drm_encoder_parse_of(struct drm_device *drm,
 }
 EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of);
 
-/*
- * @node: device tree node containing encoder input ports
- * @encoder: drm_encoder
- */
-int imx_drm_encoder_get_mux_id(struct device_node *node,
-                              struct drm_encoder *encoder)
-{
-       struct imx_drm_crtc *imx_crtc = imx_drm_find_crtc(encoder->crtc);
-       struct device_node *ep;
-       struct of_endpoint endpoint;
-       struct device_node *port;
-       int ret;
-
-       if (!node || !imx_crtc)
-               return -EINVAL;
-
-       for_each_endpoint_of_node(node, ep) {
-               port = of_graph_get_remote_port(ep);
-               of_node_put(port);
-               if (port == imx_crtc->crtc->port) {
-                       ret = of_graph_parse_endpoint(ep, &endpoint);
-                       of_node_put(ep);
-                       return ret ? ret : endpoint.port;
-               }
-       }
-
-       return -EINVAL;
-}
-EXPORT_SYMBOL_GPL(imx_drm_encoder_get_mux_id);
-
 static const struct drm_ioctl_desc imx_drm_ioctls[] = {
        /* none so far */
 };
index 71cf6d9..b0241b9 100644 (file)
@@ -46,8 +46,6 @@ int imx_drm_set_bus_format_pins(struct drm_encoder *encoder,
 int imx_drm_set_bus_format(struct drm_encoder *encoder,
                u32 bus_format);
 
-int imx_drm_encoder_get_mux_id(struct device_node *node,
-               struct drm_encoder *encoder);
 int imx_drm_encoder_parse_of(struct drm_device *drm,
        struct drm_encoder *encoder, struct device_node *np);
 
index 024d613..a58eee5 100644 (file)
@@ -19,6 +19,7 @@
 #include <drm/drmP.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_of.h>
 #include <drm/drm_panel.h>
 #include <linux/mfd/syscon.h>
 #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
@@ -208,7 +209,7 @@ static void imx_ldb_encoder_commit(struct drm_encoder *encoder)
        struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder);
        struct imx_ldb *ldb = imx_ldb_ch->ldb;
        int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
-       int mux = imx_drm_encoder_get_mux_id(imx_ldb_ch->child, encoder);
+       int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder);
 
        drm_panel_prepare(imx_ldb_ch->panel);
 
@@ -258,7 +259,7 @@ static void imx_ldb_encoder_mode_set(struct drm_encoder *encoder,
        int dual = ldb->ldb_ctrl & LDB_SPLIT_MODE_EN;
        unsigned long serial_clk;
        unsigned long di_clk = mode->clock * 1000;
-       int mux = imx_drm_encoder_get_mux_id(imx_ldb_ch->child, encoder);
+       int mux = drm_of_encoder_active_port_id(imx_ldb_ch->child, encoder);
 
        if (mode->clock > 170000) {
                dev_warn(ldb->dev,
index 846b5f5..dee8e8b 100644 (file)
@@ -22,6 +22,8 @@
 #include <linux/fb.h>
 #include <linux/clk.h>
 #include <linux/errno.h>
+#include <linux/reservation.h>
+#include <linux/dma-buf.h>
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_fb_cma_helper.h>
 
 
 #define DRIVER_DESC            "i.MX IPUv3 Graphics"
 
+enum ipu_flip_status {
+       IPU_FLIP_NONE,
+       IPU_FLIP_PENDING,
+       IPU_FLIP_SUBMITTED,
+};
+
+struct ipu_flip_work {
+       struct work_struct              unref_work;
+       struct drm_gem_object           *bo;
+       struct drm_pending_vblank_event *page_flip_event;
+       struct work_struct              fence_work;
+       struct ipu_crtc                 *crtc;
+       struct fence                    *excl;
+       unsigned                        shared_count;
+       struct fence                    **shared;
+};
+
 struct ipu_crtc {
        struct device           *dev;
        struct drm_crtc         base;
@@ -42,8 +61,9 @@ struct ipu_crtc {
        struct ipu_dc           *dc;
        struct ipu_di           *di;
        int                     enabled;
-       struct drm_pending_vblank_event *page_flip_event;
-       struct drm_framebuffer  *newfb;
+       enum ipu_flip_status    flip_state;
+       struct workqueue_struct *flip_queue;
+       struct ipu_flip_work    *flip_work;
        int                     irq;
        u32                     bus_format;
        int                     di_hsync_pin;
@@ -64,6 +84,7 @@ static void ipu_fb_enable(struct ipu_crtc *ipu_crtc)
        /* Start DC channel and DI after IDMAC */
        ipu_dc_enable_channel(ipu_crtc->dc);
        ipu_di_enable(ipu_crtc->di);
+       drm_crtc_vblank_on(&ipu_crtc->base);
 
        ipu_crtc->enabled = 1;
 }
@@ -80,6 +101,7 @@ static void ipu_fb_disable(struct ipu_crtc *ipu_crtc)
        ipu_di_disable(ipu_crtc->di);
        ipu_plane_disable(ipu_crtc->plane[0]);
        ipu_dc_disable(ipu);
+       drm_crtc_vblank_off(&ipu_crtc->base);
 
        ipu_crtc->enabled = 0;
 }
@@ -102,15 +124,45 @@ static void ipu_crtc_dpms(struct drm_crtc *crtc, int mode)
        }
 }
 
+static void ipu_flip_unref_work_func(struct work_struct *__work)
+{
+       struct ipu_flip_work *work =
+                       container_of(__work, struct ipu_flip_work, unref_work);
+
+       drm_gem_object_unreference_unlocked(work->bo);
+       kfree(work);
+}
+
+static void ipu_flip_fence_work_func(struct work_struct *__work)
+{
+       struct ipu_flip_work *work =
+                       container_of(__work, struct ipu_flip_work, fence_work);
+       int i;
+
+       /* wait for all fences attached to the FB obj to signal */
+       if (work->excl) {
+               fence_wait(work->excl, false);
+               fence_put(work->excl);
+       }
+       for (i = 0; i < work->shared_count; i++) {
+               fence_wait(work->shared[i], false);
+               fence_put(work->shared[i]);
+       }
+
+       work->crtc->flip_state = IPU_FLIP_SUBMITTED;
+}
+
 static int ipu_page_flip(struct drm_crtc *crtc,
                struct drm_framebuffer *fb,
                struct drm_pending_vblank_event *event,
                uint32_t page_flip_flags)
 {
+       struct drm_gem_cma_object *cma_obj = drm_fb_cma_get_gem_obj(fb, 0);
        struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
+       struct ipu_flip_work *flip_work;
        int ret;
 
-       if (ipu_crtc->newfb)
+       if (ipu_crtc->flip_state != IPU_FLIP_NONE)
                return -EBUSY;
 
        ret = imx_drm_crtc_vblank_get(ipu_crtc->imx_crtc);
@@ -121,11 +173,58 @@ static int ipu_page_flip(struct drm_crtc *crtc,
                return ret;
        }
 
-       ipu_crtc->newfb = fb;
-       ipu_crtc->page_flip_event = event;
-       crtc->primary->fb = fb;
+       flip_work = kzalloc(sizeof *flip_work, GFP_KERNEL);
+       if (!flip_work) {
+               ret = -ENOMEM;
+               goto put_vblank;
+       }
+       INIT_WORK(&flip_work->unref_work, ipu_flip_unref_work_func);
+       flip_work->page_flip_event = event;
+
+       /* get BO backing the old framebuffer and take a reference */
+       flip_work->bo = &drm_fb_cma_get_gem_obj(crtc->primary->fb, 0)->base;
+       drm_gem_object_reference(flip_work->bo);
+
+       ipu_crtc->flip_work = flip_work;
+       /*
+        * If the object has a DMABUF attached, we need to wait on its fences
+        * if there are any.
+        */
+       if (cma_obj->base.dma_buf) {
+               INIT_WORK(&flip_work->fence_work, ipu_flip_fence_work_func);
+               flip_work->crtc = ipu_crtc;
+
+               ret = reservation_object_get_fences_rcu(
+                               cma_obj->base.dma_buf->resv, &flip_work->excl,
+                               &flip_work->shared_count, &flip_work->shared);
+
+               if (unlikely(ret)) {
+                       DRM_ERROR("failed to get fences for buffer\n");
+                       goto free_flip_work;
+               }
+
+               /* No need to queue the worker if the are no fences */
+               if (!flip_work->excl && !flip_work->shared_count) {
+                       ipu_crtc->flip_state = IPU_FLIP_SUBMITTED;
+               } else {
+                       ipu_crtc->flip_state = IPU_FLIP_PENDING;
+                       queue_work(ipu_crtc->flip_queue,
+                                  &flip_work->fence_work);
+               }
+       } else {
+               ipu_crtc->flip_state = IPU_FLIP_SUBMITTED;
+       }
 
        return 0;
+
+free_flip_work:
+       drm_gem_object_unreference_unlocked(flip_work->bo);
+       kfree(flip_work);
+       ipu_crtc->flip_work = NULL;
+put_vblank:
+       imx_drm_crtc_vblank_put(ipu_crtc->imx_crtc);
+
+       return ret;
 }
 
 static const struct drm_crtc_funcs ipu_crtc_funcs = {
@@ -209,12 +308,12 @@ static void ipu_crtc_handle_pageflip(struct ipu_crtc *ipu_crtc)
 {
        unsigned long flags;
        struct drm_device *drm = ipu_crtc->base.dev;
+       struct ipu_flip_work *work = ipu_crtc->flip_work;
 
        spin_lock_irqsave(&drm->event_lock, flags);
-       if (ipu_crtc->page_flip_event)
+       if (work->page_flip_event)
                drm_crtc_send_vblank_event(&ipu_crtc->base,
-                                          ipu_crtc->page_flip_event);
-       ipu_crtc->page_flip_event = NULL;
+                                          work->page_flip_event);
        imx_drm_crtc_vblank_put(ipu_crtc->imx_crtc);
        spin_unlock_irqrestore(&drm->event_lock, flags);
 }
@@ -225,13 +324,15 @@ static irqreturn_t ipu_irq_handler(int irq, void *dev_id)
 
        imx_drm_handle_vblank(ipu_crtc->imx_crtc);
 
-       if (ipu_crtc->newfb) {
+       if (ipu_crtc->flip_state == IPU_FLIP_SUBMITTED) {
                struct ipu_plane *plane = ipu_crtc->plane[0];
 
-               ipu_crtc->newfb = NULL;
                ipu_plane_set_base(plane, ipu_crtc->base.primary->fb,
                                   plane->x, plane->y);
                ipu_crtc_handle_pageflip(ipu_crtc);
+               queue_work(ipu_crtc->flip_queue,
+                          &ipu_crtc->flip_work->unref_work);
+               ipu_crtc->flip_state = IPU_FLIP_NONE;
        }
 
        return IRQ_HANDLED;
@@ -280,11 +381,18 @@ static const struct drm_crtc_helper_funcs ipu_helper_funcs = {
 
 static int ipu_enable_vblank(struct drm_crtc *crtc)
 {
+       struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
+
+       enable_irq(ipu_crtc->irq);
+
        return 0;
 }
 
 static void ipu_disable_vblank(struct drm_crtc *crtc)
 {
+       struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc);
+
+       disable_irq_nosync(ipu_crtc->irq);
 }
 
 static int ipu_set_interface_pix_fmt(struct drm_crtc *crtc,
@@ -395,6 +503,10 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc,
                dev_err(ipu_crtc->dev, "irq request failed with %d.\n", ret);
                goto err_put_plane_res;
        }
+       /* Only enable IRQ when we actually need it to trigger work. */
+       disable_irq(ipu_crtc->irq);
+
+       ipu_crtc->flip_queue = create_singlethread_workqueue("ipu-crtc-flip");
 
        return 0;
 
@@ -437,6 +549,7 @@ static void ipu_drm_unbind(struct device *dev, struct device *master,
 
        imx_drm_remove_crtc(ipu_crtc->imx_crtc);
 
+       destroy_workqueue(ipu_crtc->flip_queue);
        ipu_plane_put_resources(ipu_crtc->plane[0]);
        ipu_put_resources(ipu_crtc);
 }
index 591ba2f..5888278 100644 (file)
@@ -42,6 +42,7 @@ static const uint32_t ipu_plane_formats[] = {
        DRM_FORMAT_YVYU,
        DRM_FORMAT_YUV420,
        DRM_FORMAT_YVU420,
+       DRM_FORMAT_RGB565,
 };
 
 int ipu_plane_irq(struct ipu_plane *ipu_plane)
@@ -338,7 +339,7 @@ static int ipu_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
        }
 
        if (crtc != plane->crtc)
-               dev_info(plane->dev->dev, "crtc change: %p -> %p\n",
+               dev_dbg(plane->dev->dev, "crtc change: %p -> %p\n",
                                plane->crtc, crtc);
        plane->crtc = crtc;
 
index af8b4c1..14e64e0 100644 (file)
@@ -92,18 +92,6 @@ static inline void mga_wait_busy(struct mga_device *mdev)
        } while ((status & 0x01) && time_before(jiffies, timeout));
 }
 
-/*
- * The core passes the desired mode to the CRTC code to see whether any
- * CRTC-specific modifications need to be made to it. We're in a position
- * to just pass that straight through, so this does nothing
- */
-static bool mga_crtc_mode_fixup(struct drm_crtc *crtc,
-                               const struct drm_display_mode *mode,
-                               struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 #define P_ARRAY_SIZE 9
 
 static int mga_g200se_set_plls(struct mga_device *mdev, long clock)
@@ -1410,7 +1398,6 @@ static const struct drm_crtc_funcs mga_crtc_funcs = {
 static const struct drm_crtc_helper_funcs mga_helper_funcs = {
        .disable = mga_crtc_disable,
        .dpms = mga_crtc_dpms,
-       .mode_fixup = mga_crtc_mode_fixup,
        .mode_set = mga_crtc_mode_set,
        .mode_set_base = mga_crtc_mode_set_base,
        .prepare = mga_crtc_prepare,
index 065ad41..ddb4c9d 100644 (file)
@@ -12,6 +12,7 @@ msm-y := \
        hdmi/hdmi_connector.o \
        hdmi/hdmi_hdcp.o \
        hdmi/hdmi_i2c.o \
+       hdmi/hdmi_phy.o \
        hdmi/hdmi_phy_8960.o \
        hdmi/hdmi_phy_8x60.o \
        hdmi/hdmi_phy_8x74.o \
@@ -52,6 +53,8 @@ msm-y := \
 
 msm-$(CONFIG_DRM_FBDEV_EMULATION) += msm_fbdev.o
 msm-$(CONFIG_COMMON_CLK) += mdp/mdp4/mdp4_lvds_pll.o
+msm-$(CONFIG_COMMON_CLK) += hdmi/hdmi_pll_8960.o
+msm-$(CONFIG_COMMON_CLK) += hdmi/hdmi_phy_8996.o
 
 msm-$(CONFIG_DRM_MSM_DSI) += dsi/dsi.o \
                        mdp/mdp4/mdp4_dsi_encoder.o \
index 9e2aceb..fee2429 100644 (file)
@@ -9,16 +9,17 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/adreno.xml               (    398 bytes, from 2015-09-24 17:25:31)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml  (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml  (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml          (  32901 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml (  10755 bytes, from 2015-09-14 20:46:55)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml    (  14968 bytes, from 2015-05-20 20:12:27)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml          (  67771 bytes, from 2015-09-14 20:46:55)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml          (  63970 bytes, from 2015-09-14 20:50:12)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml (  11518 bytes, from 2016-02-10 21:03:25)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml    (  16166 bytes, from 2016-02-11 21:20:31)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml          (  83967 bytes, from 2016-02-10 17:07:21)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml          ( 109916 bytes, from 2016-02-20 18:44:48)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno/ocmem.xml         (   1773 bytes, from 2015-09-24 17:30:00)
 
 Copyright (C) 2013-2015 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
index 97dc1c6..27dabd5 100644 (file)
@@ -9,16 +9,17 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/adreno.xml               (    398 bytes, from 2015-09-24 17:25:31)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml  (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml  (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml          (  32901 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml (  10755 bytes, from 2015-09-14 20:46:55)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml    (  14968 bytes, from 2015-05-20 20:12:27)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml          (  67771 bytes, from 2015-09-14 20:46:55)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml          (  63970 bytes, from 2015-09-14 20:50:12)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml (  11518 bytes, from 2016-02-10 21:03:25)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml    (  16166 bytes, from 2016-02-11 21:20:31)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml          (  83967 bytes, from 2016-02-10 17:07:21)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml          ( 109916 bytes, from 2016-02-20 18:44:48)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno/ocmem.xml         (   1773 bytes, from 2015-09-24 17:30:00)
 
-Copyright (C) 2013-2015 by the following authors:
+Copyright (C) 2013-2016 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
@@ -111,10 +112,14 @@ enum a3xx_vtx_fmt {
        VFMT_8_8_SNORM = 53,
        VFMT_8_8_8_SNORM = 54,
        VFMT_8_8_8_8_SNORM = 55,
-       VFMT_10_10_10_2_UINT = 60,
-       VFMT_10_10_10_2_UNORM = 61,
-       VFMT_10_10_10_2_SINT = 62,
-       VFMT_10_10_10_2_SNORM = 63,
+       VFMT_10_10_10_2_UINT = 56,
+       VFMT_10_10_10_2_UNORM = 57,
+       VFMT_10_10_10_2_SINT = 58,
+       VFMT_10_10_10_2_SNORM = 59,
+       VFMT_2_10_10_10_UINT = 60,
+       VFMT_2_10_10_10_UNORM = 61,
+       VFMT_2_10_10_10_SINT = 62,
+       VFMT_2_10_10_10_SNORM = 63,
 };
 
 enum a3xx_tex_fmt {
@@ -138,10 +143,12 @@ enum a3xx_tex_fmt {
        TFMT_DXT1 = 36,
        TFMT_DXT3 = 37,
        TFMT_DXT5 = 38,
+       TFMT_2_10_10_10_UNORM = 40,
        TFMT_10_10_10_2_UNORM = 41,
        TFMT_9_9_9_E5_FLOAT = 42,
        TFMT_11_11_10_FLOAT = 43,
        TFMT_A8_UNORM = 44,
+       TFMT_L8_UNORM = 45,
        TFMT_L8_A8_UNORM = 47,
        TFMT_8_UNORM = 48,
        TFMT_8_8_UNORM = 49,
@@ -183,6 +190,8 @@ enum a3xx_tex_fmt {
        TFMT_32_SINT = 92,
        TFMT_32_32_SINT = 93,
        TFMT_32_32_32_32_SINT = 95,
+       TFMT_2_10_10_10_UINT = 96,
+       TFMT_10_10_10_2_UINT = 97,
        TFMT_ETC2_RG11_SNORM = 112,
        TFMT_ETC2_RG11_UNORM = 113,
        TFMT_ETC2_R11_SNORM = 114,
@@ -215,6 +224,9 @@ enum a3xx_color_fmt {
        RB_R8_UINT = 14,
        RB_R8_SINT = 15,
        RB_R10G10B10A2_UNORM = 16,
+       RB_A2R10G10B10_UNORM = 17,
+       RB_R10G10B10A2_UINT = 18,
+       RB_A2R10G10B10_UINT = 19,
        RB_A8_UNORM = 20,
        RB_R8_UNORM = 21,
        RB_R16_FLOAT = 24,
@@ -244,30 +256,273 @@ enum a3xx_color_fmt {
        RB_R32G32B32A32_UINT = 59,
 };
 
+enum a3xx_cp_perfcounter_select {
+       CP_ALWAYS_COUNT = 0,
+       CP_AHB_PFPTRANS_WAIT = 3,
+       CP_AHB_NRTTRANS_WAIT = 6,
+       CP_CSF_NRT_READ_WAIT = 8,
+       CP_CSF_I1_FIFO_FULL = 9,
+       CP_CSF_I2_FIFO_FULL = 10,
+       CP_CSF_ST_FIFO_FULL = 11,
+       CP_RESERVED_12 = 12,
+       CP_CSF_RING_ROQ_FULL = 13,
+       CP_CSF_I1_ROQ_FULL = 14,
+       CP_CSF_I2_ROQ_FULL = 15,
+       CP_CSF_ST_ROQ_FULL = 16,
+       CP_RESERVED_17 = 17,
+       CP_MIU_TAG_MEM_FULL = 18,
+       CP_MIU_NRT_WRITE_STALLED = 22,
+       CP_MIU_NRT_READ_STALLED = 23,
+       CP_ME_REGS_RB_DONE_FIFO_FULL = 26,
+       CP_ME_REGS_VS_EVENT_FIFO_FULL = 27,
+       CP_ME_REGS_PS_EVENT_FIFO_FULL = 28,
+       CP_ME_REGS_CF_EVENT_FIFO_FULL = 29,
+       CP_ME_MICRO_RB_STARVED = 30,
+       CP_AHB_RBBM_DWORD_SENT = 40,
+       CP_ME_BUSY_CLOCKS = 41,
+       CP_ME_WAIT_CONTEXT_AVAIL = 42,
+       CP_PFP_TYPE0_PACKET = 43,
+       CP_PFP_TYPE3_PACKET = 44,
+       CP_CSF_RB_WPTR_NEQ_RPTR = 45,
+       CP_CSF_I1_SIZE_NEQ_ZERO = 46,
+       CP_CSF_I2_SIZE_NEQ_ZERO = 47,
+       CP_CSF_RBI1I2_FETCHING = 48,
+};
+
+enum a3xx_gras_tse_perfcounter_select {
+       GRAS_TSEPERF_INPUT_PRIM = 0,
+       GRAS_TSEPERF_INPUT_NULL_PRIM = 1,
+       GRAS_TSEPERF_TRIVAL_REJ_PRIM = 2,
+       GRAS_TSEPERF_CLIPPED_PRIM = 3,
+       GRAS_TSEPERF_NEW_PRIM = 4,
+       GRAS_TSEPERF_ZERO_AREA_PRIM = 5,
+       GRAS_TSEPERF_FACENESS_CULLED_PRIM = 6,
+       GRAS_TSEPERF_ZERO_PIXEL_PRIM = 7,
+       GRAS_TSEPERF_OUTPUT_NULL_PRIM = 8,
+       GRAS_TSEPERF_OUTPUT_VISIBLE_PRIM = 9,
+       GRAS_TSEPERF_PRE_CLIP_PRIM = 10,
+       GRAS_TSEPERF_POST_CLIP_PRIM = 11,
+       GRAS_TSEPERF_WORKING_CYCLES = 12,
+       GRAS_TSEPERF_PC_STARVE = 13,
+       GRAS_TSERASPERF_STALL = 14,
+};
+
+enum a3xx_gras_ras_perfcounter_select {
+       GRAS_RASPERF_16X16_TILES = 0,
+       GRAS_RASPERF_8X8_TILES = 1,
+       GRAS_RASPERF_4X4_TILES = 2,
+       GRAS_RASPERF_WORKING_CYCLES = 3,
+       GRAS_RASPERF_STALL_CYCLES_BY_RB = 4,
+       GRAS_RASPERF_STALL_CYCLES_BY_VSC = 5,
+       GRAS_RASPERF_STARVE_CYCLES_BY_TSE = 6,
+};
+
+enum a3xx_hlsq_perfcounter_select {
+       HLSQ_PERF_SP_VS_CONSTANT = 0,
+       HLSQ_PERF_SP_VS_INSTRUCTIONS = 1,
+       HLSQ_PERF_SP_FS_CONSTANT = 2,
+       HLSQ_PERF_SP_FS_INSTRUCTIONS = 3,
+       HLSQ_PERF_TP_STATE = 4,
+       HLSQ_PERF_QUADS = 5,
+       HLSQ_PERF_PIXELS = 6,
+       HLSQ_PERF_VERTICES = 7,
+       HLSQ_PERF_FS8_THREADS = 8,
+       HLSQ_PERF_FS16_THREADS = 9,
+       HLSQ_PERF_FS32_THREADS = 10,
+       HLSQ_PERF_VS8_THREADS = 11,
+       HLSQ_PERF_VS16_THREADS = 12,
+       HLSQ_PERF_SP_VS_DATA_BYTES = 13,
+       HLSQ_PERF_SP_FS_DATA_BYTES = 14,
+       HLSQ_PERF_ACTIVE_CYCLES = 15,
+       HLSQ_PERF_STALL_CYCLES_SP_STATE = 16,
+       HLSQ_PERF_STALL_CYCLES_SP_VS = 17,
+       HLSQ_PERF_STALL_CYCLES_SP_FS = 18,
+       HLSQ_PERF_STALL_CYCLES_UCHE = 19,
+       HLSQ_PERF_RBBM_LOAD_CYCLES = 20,
+       HLSQ_PERF_DI_TO_VS_START_SP0 = 21,
+       HLSQ_PERF_DI_TO_FS_START_SP0 = 22,
+       HLSQ_PERF_VS_START_TO_DONE_SP0 = 23,
+       HLSQ_PERF_FS_START_TO_DONE_SP0 = 24,
+       HLSQ_PERF_SP_STATE_COPY_CYCLES_VS = 25,
+       HLSQ_PERF_SP_STATE_COPY_CYCLES_FS = 26,
+       HLSQ_PERF_UCHE_LATENCY_CYCLES = 27,
+       HLSQ_PERF_UCHE_LATENCY_COUNT = 28,
+};
+
+enum a3xx_pc_perfcounter_select {
+       PC_PCPERF_VISIBILITY_STREAMS = 0,
+       PC_PCPERF_TOTAL_INSTANCES = 1,
+       PC_PCPERF_PRIMITIVES_PC_VPC = 2,
+       PC_PCPERF_PRIMITIVES_KILLED_BY_VS = 3,
+       PC_PCPERF_PRIMITIVES_VISIBLE_BY_VS = 4,
+       PC_PCPERF_DRAWCALLS_KILLED_BY_VS = 5,
+       PC_PCPERF_DRAWCALLS_VISIBLE_BY_VS = 6,
+       PC_PCPERF_VERTICES_TO_VFD = 7,
+       PC_PCPERF_REUSED_VERTICES = 8,
+       PC_PCPERF_CYCLES_STALLED_BY_VFD = 9,
+       PC_PCPERF_CYCLES_STALLED_BY_TSE = 10,
+       PC_PCPERF_CYCLES_STALLED_BY_VBIF = 11,
+       PC_PCPERF_CYCLES_IS_WORKING = 12,
+};
+
+enum a3xx_rb_perfcounter_select {
+       RB_RBPERF_ACTIVE_CYCLES_ANY = 0,
+       RB_RBPERF_ACTIVE_CYCLES_ALL = 1,
+       RB_RBPERF_STARVE_CYCLES_BY_SP = 2,
+       RB_RBPERF_STARVE_CYCLES_BY_RAS = 3,
+       RB_RBPERF_STARVE_CYCLES_BY_MARB = 4,
+       RB_RBPERF_STALL_CYCLES_BY_MARB = 5,
+       RB_RBPERF_STALL_CYCLES_BY_HLSQ = 6,
+       RB_RBPERF_RB_MARB_DATA = 7,
+       RB_RBPERF_SP_RB_QUAD = 8,
+       RB_RBPERF_RAS_EARLY_Z_QUADS = 9,
+       RB_RBPERF_GMEM_CH0_READ = 10,
+       RB_RBPERF_GMEM_CH1_READ = 11,
+       RB_RBPERF_GMEM_CH0_WRITE = 12,
+       RB_RBPERF_GMEM_CH1_WRITE = 13,
+       RB_RBPERF_CP_CONTEXT_DONE = 14,
+       RB_RBPERF_CP_CACHE_FLUSH = 15,
+       RB_RBPERF_CP_ZPASS_DONE = 16,
+};
+
+enum a3xx_rbbm_perfcounter_select {
+       RBBM_ALAWYS_ON = 0,
+       RBBM_VBIF_BUSY = 1,
+       RBBM_TSE_BUSY = 2,
+       RBBM_RAS_BUSY = 3,
+       RBBM_PC_DCALL_BUSY = 4,
+       RBBM_PC_VSD_BUSY = 5,
+       RBBM_VFD_BUSY = 6,
+       RBBM_VPC_BUSY = 7,
+       RBBM_UCHE_BUSY = 8,
+       RBBM_VSC_BUSY = 9,
+       RBBM_HLSQ_BUSY = 10,
+       RBBM_ANY_RB_BUSY = 11,
+       RBBM_ANY_TEX_BUSY = 12,
+       RBBM_ANY_USP_BUSY = 13,
+       RBBM_ANY_MARB_BUSY = 14,
+       RBBM_ANY_ARB_BUSY = 15,
+       RBBM_AHB_STATUS_BUSY = 16,
+       RBBM_AHB_STATUS_STALLED = 17,
+       RBBM_AHB_STATUS_TXFR = 18,
+       RBBM_AHB_STATUS_TXFR_SPLIT = 19,
+       RBBM_AHB_STATUS_TXFR_ERROR = 20,
+       RBBM_AHB_STATUS_LONG_STALL = 21,
+       RBBM_RBBM_STATUS_MASKED = 22,
+};
+
 enum a3xx_sp_perfcounter_select {
+       SP_LM_LOAD_INSTRUCTIONS = 0,
+       SP_LM_STORE_INSTRUCTIONS = 1,
+       SP_LM_ATOMICS = 2,
+       SP_UCHE_LOAD_INSTRUCTIONS = 3,
+       SP_UCHE_STORE_INSTRUCTIONS = 4,
+       SP_UCHE_ATOMICS = 5,
+       SP_VS_TEX_INSTRUCTIONS = 6,
+       SP_VS_CFLOW_INSTRUCTIONS = 7,
+       SP_VS_EFU_INSTRUCTIONS = 8,
+       SP_VS_FULL_ALU_INSTRUCTIONS = 9,
+       SP_VS_HALF_ALU_INSTRUCTIONS = 10,
+       SP_FS_TEX_INSTRUCTIONS = 11,
        SP_FS_CFLOW_INSTRUCTIONS = 12,
+       SP_FS_EFU_INSTRUCTIONS = 13,
        SP_FS_FULL_ALU_INSTRUCTIONS = 14,
-       SP0_ICL1_MISSES = 26,
+       SP_FS_HALF_ALU_INSTRUCTIONS = 15,
+       SP_FS_BARY_INSTRUCTIONS = 16,
+       SP_VS_INSTRUCTIONS = 17,
+       SP_FS_INSTRUCTIONS = 18,
+       SP_ADDR_LOCK_COUNT = 19,
+       SP_UCHE_READ_TRANS = 20,
+       SP_UCHE_WRITE_TRANS = 21,
+       SP_EXPORT_VPC_TRANS = 22,
+       SP_EXPORT_RB_TRANS = 23,
+       SP_PIXELS_KILLED = 24,
+       SP_ICL1_REQUESTS = 25,
+       SP_ICL1_MISSES = 26,
+       SP_ICL0_REQUESTS = 27,
+       SP_ICL0_MISSES = 28,
        SP_ALU_ACTIVE_CYCLES = 29,
+       SP_EFU_ACTIVE_CYCLES = 30,
+       SP_STALL_CYCLES_BY_VPC = 31,
+       SP_STALL_CYCLES_BY_TP = 32,
+       SP_STALL_CYCLES_BY_UCHE = 33,
+       SP_STALL_CYCLES_BY_RB = 34,
+       SP_ACTIVE_CYCLES_ANY = 35,
+       SP_ACTIVE_CYCLES_ALL = 36,
+};
+
+enum a3xx_tp_perfcounter_select {
+       TPL1_TPPERF_L1_REQUESTS = 0,
+       TPL1_TPPERF_TP0_L1_REQUESTS = 1,
+       TPL1_TPPERF_TP0_L1_MISSES = 2,
+       TPL1_TPPERF_TP1_L1_REQUESTS = 3,
+       TPL1_TPPERF_TP1_L1_MISSES = 4,
+       TPL1_TPPERF_TP2_L1_REQUESTS = 5,
+       TPL1_TPPERF_TP2_L1_MISSES = 6,
+       TPL1_TPPERF_TP3_L1_REQUESTS = 7,
+       TPL1_TPPERF_TP3_L1_MISSES = 8,
+       TPL1_TPPERF_OUTPUT_TEXELS_POINT = 9,
+       TPL1_TPPERF_OUTPUT_TEXELS_BILINEAR = 10,
+       TPL1_TPPERF_OUTPUT_TEXELS_MIP = 11,
+       TPL1_TPPERF_OUTPUT_TEXELS_ANISO = 12,
+       TPL1_TPPERF_BILINEAR_OPS = 13,
+       TPL1_TPPERF_QUADSQUADS_OFFSET = 14,
+       TPL1_TPPERF_QUADQUADS_SHADOW = 15,
+       TPL1_TPPERF_QUADS_ARRAY = 16,
+       TPL1_TPPERF_QUADS_PROJECTION = 17,
+       TPL1_TPPERF_QUADS_GRADIENT = 18,
+       TPL1_TPPERF_QUADS_1D2D = 19,
+       TPL1_TPPERF_QUADS_3DCUBE = 20,
+       TPL1_TPPERF_ZERO_LOD = 21,
+       TPL1_TPPERF_OUTPUT_TEXELS = 22,
+       TPL1_TPPERF_ACTIVE_CYCLES_ANY = 23,
+       TPL1_TPPERF_ACTIVE_CYCLES_ALL = 24,
+       TPL1_TPPERF_STALL_CYCLES_BY_ARB = 25,
+       TPL1_TPPERF_LATENCY = 26,
+       TPL1_TPPERF_LATENCY_TRANS = 27,
 };
 
-enum a3xx_rop_code {
-       ROP_CLEAR = 0,
-       ROP_NOR = 1,
-       ROP_AND_INVERTED = 2,
-       ROP_COPY_INVERTED = 3,
-       ROP_AND_REVERSE = 4,
-       ROP_INVERT = 5,
-       ROP_XOR = 6,
-       ROP_NAND = 7,
-       ROP_AND = 8,
-       ROP_EQUIV = 9,
-       ROP_NOOP = 10,
-       ROP_OR_INVERTED = 11,
-       ROP_COPY = 12,
-       ROP_OR_REVERSE = 13,
-       ROP_OR = 14,
-       ROP_SET = 15,
+enum a3xx_vfd_perfcounter_select {
+       VFD_PERF_UCHE_BYTE_FETCHED = 0,
+       VFD_PERF_UCHE_TRANS = 1,
+       VFD_PERF_VPC_BYPASS_COMPONENTS = 2,
+       VFD_PERF_FETCH_INSTRUCTIONS = 3,
+       VFD_PERF_DECODE_INSTRUCTIONS = 4,
+       VFD_PERF_ACTIVE_CYCLES = 5,
+       VFD_PERF_STALL_CYCLES_UCHE = 6,
+       VFD_PERF_STALL_CYCLES_HLSQ = 7,
+       VFD_PERF_STALL_CYCLES_VPC_BYPASS = 8,
+       VFD_PERF_STALL_CYCLES_VPC_ALLOC = 9,
+};
+
+enum a3xx_vpc_perfcounter_select {
+       VPC_PERF_SP_LM_PRIMITIVES = 0,
+       VPC_PERF_COMPONENTS_FROM_SP = 1,
+       VPC_PERF_SP_LM_COMPONENTS = 2,
+       VPC_PERF_ACTIVE_CYCLES = 3,
+       VPC_PERF_STALL_CYCLES_LM = 4,
+       VPC_PERF_STALL_CYCLES_RAS = 5,
+};
+
+enum a3xx_uche_perfcounter_select {
+       UCHE_UCHEPERF_VBIF_READ_BEATS_TP = 0,
+       UCHE_UCHEPERF_VBIF_READ_BEATS_VFD = 1,
+       UCHE_UCHEPERF_VBIF_READ_BEATS_HLSQ = 2,
+       UCHE_UCHEPERF_VBIF_READ_BEATS_MARB = 3,
+       UCHE_UCHEPERF_VBIF_READ_BEATS_SP = 4,
+       UCHE_UCHEPERF_READ_REQUESTS_TP = 8,
+       UCHE_UCHEPERF_READ_REQUESTS_VFD = 9,
+       UCHE_UCHEPERF_READ_REQUESTS_HLSQ = 10,
+       UCHE_UCHEPERF_READ_REQUESTS_MARB = 11,
+       UCHE_UCHEPERF_READ_REQUESTS_SP = 12,
+       UCHE_UCHEPERF_WRITE_REQUESTS_MARB = 13,
+       UCHE_UCHEPERF_WRITE_REQUESTS_SP = 14,
+       UCHE_UCHEPERF_TAG_CHECK_FAILS = 15,
+       UCHE_UCHEPERF_EVICTS = 16,
+       UCHE_UCHEPERF_FLUSHES = 17,
+       UCHE_UCHEPERF_VBIF_LATENCY_CYCLES = 18,
+       UCHE_UCHEPERF_VBIF_LATENCY_SAMPLES = 19,
+       UCHE_UCHEPERF_ACTIVE_CYCLES = 20,
 };
 
 enum a3xx_rb_blend_opcode {
@@ -1429,15 +1684,23 @@ static inline uint32_t A3XX_PC_PRIM_VTX_CNTL_POLYMODE_BACK_PTYPE(enum adreno_pa_
 #define REG_A3XX_PC_RESTART_INDEX                              0x000021ed
 
 #define REG_A3XX_HLSQ_CONTROL_0_REG                            0x00002200
-#define A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__MASK             0x00000010
+#define A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__MASK             0x00000030
 #define A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__SHIFT            4
 static inline uint32_t A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE(enum a3xx_threadsize val)
 {
        return ((val) << A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__SHIFT) & A3XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__MASK;
 }
 #define A3XX_HLSQ_CONTROL_0_REG_FSSUPERTHREADENABLE            0x00000040
+#define A3XX_HLSQ_CONTROL_0_REG_COMPUTEMODE                    0x00000100
 #define A3XX_HLSQ_CONTROL_0_REG_SPSHADERRESTART                        0x00000200
 #define A3XX_HLSQ_CONTROL_0_REG_RESERVED2                      0x00000400
+#define A3XX_HLSQ_CONTROL_0_REG_CYCLETIMEOUTLIMITVPC__MASK     0x00fff000
+#define A3XX_HLSQ_CONTROL_0_REG_CYCLETIMEOUTLIMITVPC__SHIFT    12
+static inline uint32_t A3XX_HLSQ_CONTROL_0_REG_CYCLETIMEOUTLIMITVPC(uint32_t val)
+{
+       return ((val) << A3XX_HLSQ_CONTROL_0_REG_CYCLETIMEOUTLIMITVPC__SHIFT) & A3XX_HLSQ_CONTROL_0_REG_CYCLETIMEOUTLIMITVPC__MASK;
+}
+#define A3XX_HLSQ_CONTROL_0_REG_FSONLYTEX                      0x02000000
 #define A3XX_HLSQ_CONTROL_0_REG_CHUNKDISABLE                   0x04000000
 #define A3XX_HLSQ_CONTROL_0_REG_CONSTMODE__MASK                        0x08000000
 #define A3XX_HLSQ_CONTROL_0_REG_CONSTMODE__SHIFT               27
@@ -1451,17 +1714,39 @@ static inline uint32_t A3XX_HLSQ_CONTROL_0_REG_CONSTMODE(uint32_t val)
 #define A3XX_HLSQ_CONTROL_0_REG_SINGLECONTEXT                  0x80000000
 
 #define REG_A3XX_HLSQ_CONTROL_1_REG                            0x00002201
-#define A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE__MASK             0x00000040
+#define A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE__MASK             0x000000c0
 #define A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE__SHIFT            6
 static inline uint32_t A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE(enum a3xx_threadsize val)
 {
        return ((val) << A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE__SHIFT) & A3XX_HLSQ_CONTROL_1_REG_VSTHREADSIZE__MASK;
 }
 #define A3XX_HLSQ_CONTROL_1_REG_VSSUPERTHREADENABLE            0x00000100
-#define A3XX_HLSQ_CONTROL_1_REG_RESERVED1                      0x00000200
-#define A3XX_HLSQ_CONTROL_1_REG_ZWCOORD                                0x02000000
+#define A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDXYREGID__MASK         0x00ff0000
+#define A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDXYREGID__SHIFT                16
+static inline uint32_t A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDXYREGID(uint32_t val)
+{
+       return ((val) << A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDXYREGID__SHIFT) & A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDXYREGID__MASK;
+}
+#define A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDZWREGID__MASK         0xff000000
+#define A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDZWREGID__SHIFT                24
+static inline uint32_t A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDZWREGID(uint32_t val)
+{
+       return ((val) << A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDZWREGID__SHIFT) & A3XX_HLSQ_CONTROL_1_REG_FRAGCOORDZWREGID__MASK;
+}
 
 #define REG_A3XX_HLSQ_CONTROL_2_REG                            0x00002202
+#define A3XX_HLSQ_CONTROL_2_REG_FACENESSREGID__MASK            0x000003fc
+#define A3XX_HLSQ_CONTROL_2_REG_FACENESSREGID__SHIFT           2
+static inline uint32_t A3XX_HLSQ_CONTROL_2_REG_FACENESSREGID(uint32_t val)
+{
+       return ((val) << A3XX_HLSQ_CONTROL_2_REG_FACENESSREGID__SHIFT) & A3XX_HLSQ_CONTROL_2_REG_FACENESSREGID__MASK;
+}
+#define A3XX_HLSQ_CONTROL_2_REG_COVVALUEREGID__MASK            0x03fc0000
+#define A3XX_HLSQ_CONTROL_2_REG_COVVALUEREGID__SHIFT           18
+static inline uint32_t A3XX_HLSQ_CONTROL_2_REG_COVVALUEREGID(uint32_t val)
+{
+       return ((val) << A3XX_HLSQ_CONTROL_2_REG_COVVALUEREGID__SHIFT) & A3XX_HLSQ_CONTROL_2_REG_COVVALUEREGID__MASK;
+}
 #define A3XX_HLSQ_CONTROL_2_REG_PRIMALLOCTHRESHOLD__MASK       0xfc000000
 #define A3XX_HLSQ_CONTROL_2_REG_PRIMALLOCTHRESHOLD__SHIFT      26
 static inline uint32_t A3XX_HLSQ_CONTROL_2_REG_PRIMALLOCTHRESHOLD(uint32_t val)
@@ -1478,13 +1763,13 @@ static inline uint32_t A3XX_HLSQ_CONTROL_3_REG_REGID(uint32_t val)
 }
 
 #define REG_A3XX_HLSQ_VS_CONTROL_REG                           0x00002204
-#define A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH__MASK             0x00000fff
+#define A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH__MASK             0x000003ff
 #define A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH__SHIFT            0
 static inline uint32_t A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH(uint32_t val)
 {
        return ((val) << A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH__SHIFT) & A3XX_HLSQ_VS_CONTROL_REG_CONSTLENGTH__MASK;
 }
-#define A3XX_HLSQ_VS_CONTROL_REG_CONSTSTARTOFFSET__MASK                0x00fff000
+#define A3XX_HLSQ_VS_CONTROL_REG_CONSTSTARTOFFSET__MASK                0x001ff000
 #define A3XX_HLSQ_VS_CONTROL_REG_CONSTSTARTOFFSET__SHIFT       12
 static inline uint32_t A3XX_HLSQ_VS_CONTROL_REG_CONSTSTARTOFFSET(uint32_t val)
 {
@@ -1498,13 +1783,13 @@ static inline uint32_t A3XX_HLSQ_VS_CONTROL_REG_INSTRLENGTH(uint32_t val)
 }
 
 #define REG_A3XX_HLSQ_FS_CONTROL_REG                           0x00002205
-#define A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH__MASK             0x00000fff
+#define A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH__MASK             0x000003ff
 #define A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH__SHIFT            0
 static inline uint32_t A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH(uint32_t val)
 {
        return ((val) << A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH__SHIFT) & A3XX_HLSQ_FS_CONTROL_REG_CONSTLENGTH__MASK;
 }
-#define A3XX_HLSQ_FS_CONTROL_REG_CONSTSTARTOFFSET__MASK                0x00fff000
+#define A3XX_HLSQ_FS_CONTROL_REG_CONSTSTARTOFFSET__MASK                0x001ff000
 #define A3XX_HLSQ_FS_CONTROL_REG_CONSTSTARTOFFSET__SHIFT       12
 static inline uint32_t A3XX_HLSQ_FS_CONTROL_REG_CONSTSTARTOFFSET(uint32_t val)
 {
@@ -1518,13 +1803,13 @@ static inline uint32_t A3XX_HLSQ_FS_CONTROL_REG_INSTRLENGTH(uint32_t val)
 }
 
 #define REG_A3XX_HLSQ_CONST_VSPRESV_RANGE_REG                  0x00002206
-#define A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY__MASK     0x0000ffff
+#define A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY__MASK     0x000001ff
 #define A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY__SHIFT    0
 static inline uint32_t A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY(uint32_t val)
 {
        return ((val) << A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY__SHIFT) & A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_STARTENTRY__MASK;
 }
-#define A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_ENDENTRY__MASK       0xffff0000
+#define A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_ENDENTRY__MASK       0x01ff0000
 #define A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_ENDENTRY__SHIFT      16
 static inline uint32_t A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_ENDENTRY(uint32_t val)
 {
@@ -1532,13 +1817,13 @@ static inline uint32_t A3XX_HLSQ_CONST_VSPRESV_RANGE_REG_ENDENTRY(uint32_t val)
 }
 
 #define REG_A3XX_HLSQ_CONST_FSPRESV_RANGE_REG                  0x00002207
-#define A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY__MASK     0x0000ffff
+#define A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY__MASK     0x000001ff
 #define A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY__SHIFT    0
 static inline uint32_t A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY(uint32_t val)
 {
        return ((val) << A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY__SHIFT) & A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_STARTENTRY__MASK;
 }
-#define A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_ENDENTRY__MASK       0xffff0000
+#define A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_ENDENTRY__MASK       0x01ff0000
 #define A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_ENDENTRY__SHIFT      16
 static inline uint32_t A3XX_HLSQ_CONST_FSPRESV_RANGE_REG_ENDENTRY(uint32_t val)
 {
@@ -1620,12 +1905,24 @@ static inline uint32_t A3XX_VFD_CONTROL_0_STRMFETCHINSTRCNT(uint32_t val)
 }
 
 #define REG_A3XX_VFD_CONTROL_1                                 0x00002241
-#define A3XX_VFD_CONTROL_1_MAXSTORAGE__MASK                    0x0000ffff
+#define A3XX_VFD_CONTROL_1_MAXSTORAGE__MASK                    0x0000000f
 #define A3XX_VFD_CONTROL_1_MAXSTORAGE__SHIFT                   0
 static inline uint32_t A3XX_VFD_CONTROL_1_MAXSTORAGE(uint32_t val)
 {
        return ((val) << A3XX_VFD_CONTROL_1_MAXSTORAGE__SHIFT) & A3XX_VFD_CONTROL_1_MAXSTORAGE__MASK;
 }
+#define A3XX_VFD_CONTROL_1_MAXTHRESHOLD__MASK                  0x000000f0
+#define A3XX_VFD_CONTROL_1_MAXTHRESHOLD__SHIFT                 4
+static inline uint32_t A3XX_VFD_CONTROL_1_MAXTHRESHOLD(uint32_t val)
+{
+       return ((val) << A3XX_VFD_CONTROL_1_MAXTHRESHOLD__SHIFT) & A3XX_VFD_CONTROL_1_MAXTHRESHOLD__MASK;
+}
+#define A3XX_VFD_CONTROL_1_MINTHRESHOLD__MASK                  0x00000f00
+#define A3XX_VFD_CONTROL_1_MINTHRESHOLD__SHIFT                 8
+static inline uint32_t A3XX_VFD_CONTROL_1_MINTHRESHOLD(uint32_t val)
+{
+       return ((val) << A3XX_VFD_CONTROL_1_MINTHRESHOLD__SHIFT) & A3XX_VFD_CONTROL_1_MINTHRESHOLD__MASK;
+}
 #define A3XX_VFD_CONTROL_1_REGID4VTX__MASK                     0x00ff0000
 #define A3XX_VFD_CONTROL_1_REGID4VTX__SHIFT                    16
 static inline uint32_t A3XX_VFD_CONTROL_1_REGID4VTX(uint32_t val)
@@ -2008,24 +2305,19 @@ static inline uint32_t A3XX_SP_VS_CTRL_REG0_INSTRBUFFERMODE(enum a3xx_instrbuffe
        return ((val) << A3XX_SP_VS_CTRL_REG0_INSTRBUFFERMODE__SHIFT) & A3XX_SP_VS_CTRL_REG0_INSTRBUFFERMODE__MASK;
 }
 #define A3XX_SP_VS_CTRL_REG0_CACHEINVALID                      0x00000004
+#define A3XX_SP_VS_CTRL_REG0_ALUSCHMODE                                0x00000008
 #define A3XX_SP_VS_CTRL_REG0_HALFREGFOOTPRINT__MASK            0x000003f0
 #define A3XX_SP_VS_CTRL_REG0_HALFREGFOOTPRINT__SHIFT           4
 static inline uint32_t A3XX_SP_VS_CTRL_REG0_HALFREGFOOTPRINT(uint32_t val)
 {
        return ((val) << A3XX_SP_VS_CTRL_REG0_HALFREGFOOTPRINT__SHIFT) & A3XX_SP_VS_CTRL_REG0_HALFREGFOOTPRINT__MASK;
 }
-#define A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT__MASK            0x0003fc00
+#define A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT__MASK            0x0000fc00
 #define A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT__SHIFT           10
 static inline uint32_t A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT(uint32_t val)
 {
        return ((val) << A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT__SHIFT) & A3XX_SP_VS_CTRL_REG0_FULLREGFOOTPRINT__MASK;
 }
-#define A3XX_SP_VS_CTRL_REG0_INOUTREGOVERLAP__MASK             0x000c0000
-#define A3XX_SP_VS_CTRL_REG0_INOUTREGOVERLAP__SHIFT            18
-static inline uint32_t A3XX_SP_VS_CTRL_REG0_INOUTREGOVERLAP(uint32_t val)
-{
-       return ((val) << A3XX_SP_VS_CTRL_REG0_INOUTREGOVERLAP__SHIFT) & A3XX_SP_VS_CTRL_REG0_INOUTREGOVERLAP__MASK;
-}
 #define A3XX_SP_VS_CTRL_REG0_THREADSIZE__MASK                  0x00100000
 #define A3XX_SP_VS_CTRL_REG0_THREADSIZE__SHIFT                 20
 static inline uint32_t A3XX_SP_VS_CTRL_REG0_THREADSIZE(enum a3xx_threadsize val)
@@ -2033,8 +2325,6 @@ static inline uint32_t A3XX_SP_VS_CTRL_REG0_THREADSIZE(enum a3xx_threadsize val)
        return ((val) << A3XX_SP_VS_CTRL_REG0_THREADSIZE__SHIFT) & A3XX_SP_VS_CTRL_REG0_THREADSIZE__MASK;
 }
 #define A3XX_SP_VS_CTRL_REG0_SUPERTHREADMODE                   0x00200000
-#define A3XX_SP_VS_CTRL_REG0_PIXLODENABLE                      0x00400000
-#define A3XX_SP_VS_CTRL_REG0_COMPUTEMODE                       0x00800000
 #define A3XX_SP_VS_CTRL_REG0_LENGTH__MASK                      0xff000000
 #define A3XX_SP_VS_CTRL_REG0_LENGTH__SHIFT                     24
 static inline uint32_t A3XX_SP_VS_CTRL_REG0_LENGTH(uint32_t val)
@@ -2075,7 +2365,8 @@ static inline uint32_t A3XX_SP_VS_PARAM_REG_PSIZEREGID(uint32_t val)
 {
        return ((val) << A3XX_SP_VS_PARAM_REG_PSIZEREGID__SHIFT) & A3XX_SP_VS_PARAM_REG_PSIZEREGID__MASK;
 }
-#define A3XX_SP_VS_PARAM_REG_TOTALVSOUTVAR__MASK               0xfff00000
+#define A3XX_SP_VS_PARAM_REG_POS2DMODE                         0x00010000
+#define A3XX_SP_VS_PARAM_REG_TOTALVSOUTVAR__MASK               0x01f00000
 #define A3XX_SP_VS_PARAM_REG_TOTALVSOUTVAR__SHIFT              20
 static inline uint32_t A3XX_SP_VS_PARAM_REG_TOTALVSOUTVAR(uint32_t val)
 {
@@ -2085,24 +2376,26 @@ static inline uint32_t A3XX_SP_VS_PARAM_REG_TOTALVSOUTVAR(uint32_t val)
 static inline uint32_t REG_A3XX_SP_VS_OUT(uint32_t i0) { return 0x000022c7 + 0x1*i0; }
 
 static inline uint32_t REG_A3XX_SP_VS_OUT_REG(uint32_t i0) { return 0x000022c7 + 0x1*i0; }
-#define A3XX_SP_VS_OUT_REG_A_REGID__MASK                       0x000001ff
+#define A3XX_SP_VS_OUT_REG_A_REGID__MASK                       0x000000ff
 #define A3XX_SP_VS_OUT_REG_A_REGID__SHIFT                      0
 static inline uint32_t A3XX_SP_VS_OUT_REG_A_REGID(uint32_t val)
 {
        return ((val) << A3XX_SP_VS_OUT_REG_A_REGID__SHIFT) & A3XX_SP_VS_OUT_REG_A_REGID__MASK;
 }
+#define A3XX_SP_VS_OUT_REG_A_HALF                              0x00000100
 #define A3XX_SP_VS_OUT_REG_A_COMPMASK__MASK                    0x00001e00
 #define A3XX_SP_VS_OUT_REG_A_COMPMASK__SHIFT                   9
 static inline uint32_t A3XX_SP_VS_OUT_REG_A_COMPMASK(uint32_t val)
 {
        return ((val) << A3XX_SP_VS_OUT_REG_A_COMPMASK__SHIFT) & A3XX_SP_VS_OUT_REG_A_COMPMASK__MASK;
 }
-#define A3XX_SP_VS_OUT_REG_B_REGID__MASK                       0x01ff0000
+#define A3XX_SP_VS_OUT_REG_B_REGID__MASK                       0x00ff0000
 #define A3XX_SP_VS_OUT_REG_B_REGID__SHIFT                      16
 static inline uint32_t A3XX_SP_VS_OUT_REG_B_REGID(uint32_t val)
 {
        return ((val) << A3XX_SP_VS_OUT_REG_B_REGID__SHIFT) & A3XX_SP_VS_OUT_REG_B_REGID__MASK;
 }
+#define A3XX_SP_VS_OUT_REG_B_HALF                              0x01000000
 #define A3XX_SP_VS_OUT_REG_B_COMPMASK__MASK                    0x1e000000
 #define A3XX_SP_VS_OUT_REG_B_COMPMASK__SHIFT                   25
 static inline uint32_t A3XX_SP_VS_OUT_REG_B_COMPMASK(uint32_t val)
@@ -2113,25 +2406,25 @@ static inline uint32_t A3XX_SP_VS_OUT_REG_B_COMPMASK(uint32_t val)
 static inline uint32_t REG_A3XX_SP_VS_VPC_DST(uint32_t i0) { return 0x000022d0 + 0x1*i0; }
 
 static inline uint32_t REG_A3XX_SP_VS_VPC_DST_REG(uint32_t i0) { return 0x000022d0 + 0x1*i0; }
-#define A3XX_SP_VS_VPC_DST_REG_OUTLOC0__MASK                   0x000000ff
+#define A3XX_SP_VS_VPC_DST_REG_OUTLOC0__MASK                   0x0000007f
 #define A3XX_SP_VS_VPC_DST_REG_OUTLOC0__SHIFT                  0
 static inline uint32_t A3XX_SP_VS_VPC_DST_REG_OUTLOC0(uint32_t val)
 {
        return ((val) << A3XX_SP_VS_VPC_DST_REG_OUTLOC0__SHIFT) & A3XX_SP_VS_VPC_DST_REG_OUTLOC0__MASK;
 }
-#define A3XX_SP_VS_VPC_DST_REG_OUTLOC1__MASK                   0x0000ff00
+#define A3XX_SP_VS_VPC_DST_REG_OUTLOC1__MASK                   0x00007f00
 #define A3XX_SP_VS_VPC_DST_REG_OUTLOC1__SHIFT                  8
 static inline uint32_t A3XX_SP_VS_VPC_DST_REG_OUTLOC1(uint32_t val)
 {
        return ((val) << A3XX_SP_VS_VPC_DST_REG_OUTLOC1__SHIFT) & A3XX_SP_VS_VPC_DST_REG_OUTLOC1__MASK;
 }
-#define A3XX_SP_VS_VPC_DST_REG_OUTLOC2__MASK                   0x00ff0000
+#define A3XX_SP_VS_VPC_DST_REG_OUTLOC2__MASK                   0x007f0000
 #define A3XX_SP_VS_VPC_DST_REG_OUTLOC2__SHIFT                  16
 static inline uint32_t A3XX_SP_VS_VPC_DST_REG_OUTLOC2(uint32_t val)
 {
        return ((val) << A3XX_SP_VS_VPC_DST_REG_OUTLOC2__SHIFT) & A3XX_SP_VS_VPC_DST_REG_OUTLOC2__MASK;
 }
-#define A3XX_SP_VS_VPC_DST_REG_OUTLOC3__MASK                   0xff000000
+#define A3XX_SP_VS_VPC_DST_REG_OUTLOC3__MASK                   0x7f000000
 #define A3XX_SP_VS_VPC_DST_REG_OUTLOC3__SHIFT                  24
 static inline uint32_t A3XX_SP_VS_VPC_DST_REG_OUTLOC3(uint32_t val)
 {
@@ -2139,6 +2432,12 @@ static inline uint32_t A3XX_SP_VS_VPC_DST_REG_OUTLOC3(uint32_t val)
 }
 
 #define REG_A3XX_SP_VS_OBJ_OFFSET_REG                          0x000022d4
+#define A3XX_SP_VS_OBJ_OFFSET_REG_FIRSTEXECINSTROFFSET__MASK   0x0000ffff
+#define A3XX_SP_VS_OBJ_OFFSET_REG_FIRSTEXECINSTROFFSET__SHIFT  0
+static inline uint32_t A3XX_SP_VS_OBJ_OFFSET_REG_FIRSTEXECINSTROFFSET(uint32_t val)
+{
+       return ((val) << A3XX_SP_VS_OBJ_OFFSET_REG_FIRSTEXECINSTROFFSET__SHIFT) & A3XX_SP_VS_OBJ_OFFSET_REG_FIRSTEXECINSTROFFSET__MASK;
+}
 #define A3XX_SP_VS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__MASK      0x01ff0000
 #define A3XX_SP_VS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__SHIFT     16
 static inline uint32_t A3XX_SP_VS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET(uint32_t val)
@@ -2155,8 +2454,38 @@ static inline uint32_t A3XX_SP_VS_OBJ_OFFSET_REG_SHADEROBJOFFSET(uint32_t val)
 #define REG_A3XX_SP_VS_OBJ_START_REG                           0x000022d5
 
 #define REG_A3XX_SP_VS_PVT_MEM_PARAM_REG                       0x000022d6
+#define A3XX_SP_VS_PVT_MEM_PARAM_REG_MEMSIZEPERITEM__MASK      0x000000ff
+#define A3XX_SP_VS_PVT_MEM_PARAM_REG_MEMSIZEPERITEM__SHIFT     0
+static inline uint32_t A3XX_SP_VS_PVT_MEM_PARAM_REG_MEMSIZEPERITEM(uint32_t val)
+{
+       return ((val) << A3XX_SP_VS_PVT_MEM_PARAM_REG_MEMSIZEPERITEM__SHIFT) & A3XX_SP_VS_PVT_MEM_PARAM_REG_MEMSIZEPERITEM__MASK;
+}
+#define A3XX_SP_VS_PVT_MEM_PARAM_REG_HWSTACKOFFSET__MASK       0x00ffff00
+#define A3XX_SP_VS_PVT_MEM_PARAM_REG_HWSTACKOFFSET__SHIFT      8
+static inline uint32_t A3XX_SP_VS_PVT_MEM_PARAM_REG_HWSTACKOFFSET(uint32_t val)
+{
+       return ((val) << A3XX_SP_VS_PVT_MEM_PARAM_REG_HWSTACKOFFSET__SHIFT) & A3XX_SP_VS_PVT_MEM_PARAM_REG_HWSTACKOFFSET__MASK;
+}
+#define A3XX_SP_VS_PVT_MEM_PARAM_REG_HWSTACKSIZEPERTHREAD__MASK        0xff000000
+#define A3XX_SP_VS_PVT_MEM_PARAM_REG_HWSTACKSIZEPERTHREAD__SHIFT       24
+static inline uint32_t A3XX_SP_VS_PVT_MEM_PARAM_REG_HWSTACKSIZEPERTHREAD(uint32_t val)
+{
+       return ((val) << A3XX_SP_VS_PVT_MEM_PARAM_REG_HWSTACKSIZEPERTHREAD__SHIFT) & A3XX_SP_VS_PVT_MEM_PARAM_REG_HWSTACKSIZEPERTHREAD__MASK;
+}
 
 #define REG_A3XX_SP_VS_PVT_MEM_ADDR_REG                                0x000022d7
+#define A3XX_SP_VS_PVT_MEM_ADDR_REG_BURSTLEN__MASK             0x0000001f
+#define A3XX_SP_VS_PVT_MEM_ADDR_REG_BURSTLEN__SHIFT            0
+static inline uint32_t A3XX_SP_VS_PVT_MEM_ADDR_REG_BURSTLEN(uint32_t val)
+{
+       return ((val) << A3XX_SP_VS_PVT_MEM_ADDR_REG_BURSTLEN__SHIFT) & A3XX_SP_VS_PVT_MEM_ADDR_REG_BURSTLEN__MASK;
+}
+#define A3XX_SP_VS_PVT_MEM_ADDR_REG_SHADERSTARTADDRESS__MASK   0xffffffe0
+#define A3XX_SP_VS_PVT_MEM_ADDR_REG_SHADERSTARTADDRESS__SHIFT  5
+static inline uint32_t A3XX_SP_VS_PVT_MEM_ADDR_REG_SHADERSTARTADDRESS(uint32_t val)
+{
+       return ((val >> 5) << A3XX_SP_VS_PVT_MEM_ADDR_REG_SHADERSTARTADDRESS__SHIFT) & A3XX_SP_VS_PVT_MEM_ADDR_REG_SHADERSTARTADDRESS__MASK;
+}
 
 #define REG_A3XX_SP_VS_PVT_MEM_SIZE_REG                                0x000022d8
 
@@ -2182,24 +2511,22 @@ static inline uint32_t A3XX_SP_FS_CTRL_REG0_INSTRBUFFERMODE(enum a3xx_instrbuffe
        return ((val) << A3XX_SP_FS_CTRL_REG0_INSTRBUFFERMODE__SHIFT) & A3XX_SP_FS_CTRL_REG0_INSTRBUFFERMODE__MASK;
 }
 #define A3XX_SP_FS_CTRL_REG0_CACHEINVALID                      0x00000004
+#define A3XX_SP_FS_CTRL_REG0_ALUSCHMODE                                0x00000008
 #define A3XX_SP_FS_CTRL_REG0_HALFREGFOOTPRINT__MASK            0x000003f0
 #define A3XX_SP_FS_CTRL_REG0_HALFREGFOOTPRINT__SHIFT           4
 static inline uint32_t A3XX_SP_FS_CTRL_REG0_HALFREGFOOTPRINT(uint32_t val)
 {
        return ((val) << A3XX_SP_FS_CTRL_REG0_HALFREGFOOTPRINT__SHIFT) & A3XX_SP_FS_CTRL_REG0_HALFREGFOOTPRINT__MASK;
 }
-#define A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT__MASK            0x0003fc00
+#define A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT__MASK            0x0000fc00
 #define A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT__SHIFT           10
 static inline uint32_t A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT(uint32_t val)
 {
        return ((val) << A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT__SHIFT) & A3XX_SP_FS_CTRL_REG0_FULLREGFOOTPRINT__MASK;
 }
-#define A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP__MASK             0x000c0000
-#define A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP__SHIFT            18
-static inline uint32_t A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP(uint32_t val)
-{
-       return ((val) << A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP__SHIFT) & A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP__MASK;
-}
+#define A3XX_SP_FS_CTRL_REG0_FSBYPASSENABLE                    0x00020000
+#define A3XX_SP_FS_CTRL_REG0_INOUTREGOVERLAP                   0x00040000
+#define A3XX_SP_FS_CTRL_REG0_OUTORDERED                                0x00080000
 #define A3XX_SP_FS_CTRL_REG0_THREADSIZE__MASK                  0x00100000
 #define A3XX_SP_FS_CTRL_REG0_THREADSIZE__SHIFT                 20
 static inline uint32_t A3XX_SP_FS_CTRL_REG0_THREADSIZE(enum a3xx_threadsize val)
@@ -2235,7 +2562,7 @@ static inline uint32_t A3XX_SP_FS_CTRL_REG1_INITIALOUTSTANDING(uint32_t val)
 {
        return ((val) << A3XX_SP_FS_CTRL_REG1_INITIALOUTSTANDING__SHIFT) & A3XX_SP_FS_CTRL_REG1_INITIALOUTSTANDING__MASK;
 }
-#define A3XX_SP_FS_CTRL_REG1_HALFPRECVAROFFSET__MASK           0x3f000000
+#define A3XX_SP_FS_CTRL_REG1_HALFPRECVAROFFSET__MASK           0x7f000000
 #define A3XX_SP_FS_CTRL_REG1_HALFPRECVAROFFSET__SHIFT          24
 static inline uint32_t A3XX_SP_FS_CTRL_REG1_HALFPRECVAROFFSET(uint32_t val)
 {
@@ -2243,6 +2570,12 @@ static inline uint32_t A3XX_SP_FS_CTRL_REG1_HALFPRECVAROFFSET(uint32_t val)
 }
 
 #define REG_A3XX_SP_FS_OBJ_OFFSET_REG                          0x000022e2
+#define A3XX_SP_FS_OBJ_OFFSET_REG_FIRSTEXECINSTROFFSET__MASK   0x0000ffff
+#define A3XX_SP_FS_OBJ_OFFSET_REG_FIRSTEXECINSTROFFSET__SHIFT  0
+static inline uint32_t A3XX_SP_FS_OBJ_OFFSET_REG_FIRSTEXECINSTROFFSET(uint32_t val)
+{
+       return ((val) << A3XX_SP_FS_OBJ_OFFSET_REG_FIRSTEXECINSTROFFSET__SHIFT) & A3XX_SP_FS_OBJ_OFFSET_REG_FIRSTEXECINSTROFFSET__MASK;
+}
 #define A3XX_SP_FS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__MASK      0x01ff0000
 #define A3XX_SP_FS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET__SHIFT     16
 static inline uint32_t A3XX_SP_FS_OBJ_OFFSET_REG_CONSTOBJECTOFFSET(uint32_t val)
@@ -2259,8 +2592,38 @@ static inline uint32_t A3XX_SP_FS_OBJ_OFFSET_REG_SHADEROBJOFFSET(uint32_t val)
 #define REG_A3XX_SP_FS_OBJ_START_REG                           0x000022e3
 
 #define REG_A3XX_SP_FS_PVT_MEM_PARAM_REG                       0x000022e4
+#define A3XX_SP_FS_PVT_MEM_PARAM_REG_MEMSIZEPERITEM__MASK      0x000000ff
+#define A3XX_SP_FS_PVT_MEM_PARAM_REG_MEMSIZEPERITEM__SHIFT     0
+static inline uint32_t A3XX_SP_FS_PVT_MEM_PARAM_REG_MEMSIZEPERITEM(uint32_t val)
+{
+       return ((val) << A3XX_SP_FS_PVT_MEM_PARAM_REG_MEMSIZEPERITEM__SHIFT) & A3XX_SP_FS_PVT_MEM_PARAM_REG_MEMSIZEPERITEM__MASK;
+}
+#define A3XX_SP_FS_PVT_MEM_PARAM_REG_HWSTACKOFFSET__MASK       0x00ffff00
+#define A3XX_SP_FS_PVT_MEM_PARAM_REG_HWSTACKOFFSET__SHIFT      8
+static inline uint32_t A3XX_SP_FS_PVT_MEM_PARAM_REG_HWSTACKOFFSET(uint32_t val)
+{
+       return ((val) << A3XX_SP_FS_PVT_MEM_PARAM_REG_HWSTACKOFFSET__SHIFT) & A3XX_SP_FS_PVT_MEM_PARAM_REG_HWSTACKOFFSET__MASK;
+}
+#define A3XX_SP_FS_PVT_MEM_PARAM_REG_HWSTACKSIZEPERTHREAD__MASK        0xff000000
+#define A3XX_SP_FS_PVT_MEM_PARAM_REG_HWSTACKSIZEPERTHREAD__SHIFT       24
+static inline uint32_t A3XX_SP_FS_PVT_MEM_PARAM_REG_HWSTACKSIZEPERTHREAD(uint32_t val)
+{
+       return ((val) << A3XX_SP_FS_PVT_MEM_PARAM_REG_HWSTACKSIZEPERTHREAD__SHIFT) & A3XX_SP_FS_PVT_MEM_PARAM_REG_HWSTACKSIZEPERTHREAD__MASK;
+}
 
 #define REG_A3XX_SP_FS_PVT_MEM_ADDR_REG                                0x000022e5
+#define A3XX_SP_FS_PVT_MEM_ADDR_REG_BURSTLEN__MASK             0x0000001f
+#define A3XX_SP_FS_PVT_MEM_ADDR_REG_BURSTLEN__SHIFT            0
+static inline uint32_t A3XX_SP_FS_PVT_MEM_ADDR_REG_BURSTLEN(uint32_t val)
+{
+       return ((val) << A3XX_SP_FS_PVT_MEM_ADDR_REG_BURSTLEN__SHIFT) & A3XX_SP_FS_PVT_MEM_ADDR_REG_BURSTLEN__MASK;
+}
+#define A3XX_SP_FS_PVT_MEM_ADDR_REG_SHADERSTARTADDRESS__MASK   0xffffffe0
+#define A3XX_SP_FS_PVT_MEM_ADDR_REG_SHADERSTARTADDRESS__SHIFT  5
+static inline uint32_t A3XX_SP_FS_PVT_MEM_ADDR_REG_SHADERSTARTADDRESS(uint32_t val)
+{
+       return ((val >> 5) << A3XX_SP_FS_PVT_MEM_ADDR_REG_SHADERSTARTADDRESS__SHIFT) & A3XX_SP_FS_PVT_MEM_ADDR_REG_SHADERSTARTADDRESS__MASK;
+}
 
 #define REG_A3XX_SP_FS_PVT_MEM_SIZE_REG                                0x000022e6
 
index 99de827..3220b91 100644 (file)
@@ -9,16 +9,17 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/adreno.xml               (    398 bytes, from 2015-09-24 17:25:31)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml  (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml  (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml          (  32901 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml (  10755 bytes, from 2015-09-14 20:46:55)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml    (  14968 bytes, from 2015-05-20 20:12:27)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml          (  67771 bytes, from 2015-09-14 20:46:55)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml          (  63970 bytes, from 2015-09-14 20:50:12)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml (  11518 bytes, from 2016-02-10 21:03:25)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml    (  16166 bytes, from 2016-02-11 21:20:31)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml          (  83967 bytes, from 2016-02-10 17:07:21)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml          ( 109916 bytes, from 2016-02-20 18:44:48)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno/ocmem.xml         (   1773 bytes, from 2015-09-24 17:30:00)
 
-Copyright (C) 2013-2015 by the following authors:
+Copyright (C) 2013-2016 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
@@ -47,11 +48,13 @@ enum a4xx_color_fmt {
        RB4_R8_UNORM = 2,
        RB4_R4G4B4A4_UNORM = 8,
        RB4_R5G5B5A1_UNORM = 10,
-       RB4_R5G6R5_UNORM = 14,
+       RB4_R5G6B5_UNORM = 14,
        RB4_R8G8_UNORM = 15,
        RB4_R8G8_SNORM = 16,
        RB4_R8G8_UINT = 17,
        RB4_R8G8_SINT = 18,
+       RB4_R16_UNORM = 19,
+       RB4_R16_SNORM = 20,
        RB4_R16_FLOAT = 21,
        RB4_R16_UINT = 22,
        RB4_R16_SINT = 23,
@@ -63,12 +66,16 @@ enum a4xx_color_fmt {
        RB4_R10G10B10A2_UNORM = 31,
        RB4_R10G10B10A2_UINT = 34,
        RB4_R11G11B10_FLOAT = 39,
+       RB4_R16G16_UNORM = 40,
+       RB4_R16G16_SNORM = 41,
        RB4_R16G16_FLOAT = 42,
        RB4_R16G16_UINT = 43,
        RB4_R16G16_SINT = 44,
        RB4_R32_FLOAT = 45,
        RB4_R32_UINT = 46,
        RB4_R32_SINT = 47,
+       RB4_R16G16B16A16_UNORM = 52,
+       RB4_R16G16B16A16_SNORM = 53,
        RB4_R16G16B16A16_FLOAT = 54,
        RB4_R16G16B16A16_UINT = 55,
        RB4_R16G16B16A16_SINT = 56,
@@ -106,6 +113,7 @@ enum a4xx_vtx_fmt {
        VFMT4_32_32_FIXED = 10,
        VFMT4_32_32_32_FIXED = 11,
        VFMT4_32_32_32_32_FIXED = 12,
+       VFMT4_11_11_10_FLOAT = 13,
        VFMT4_16_SINT = 16,
        VFMT4_16_16_SINT = 17,
        VFMT4_16_16_16_SINT = 18,
@@ -146,52 +154,76 @@ enum a4xx_vtx_fmt {
        VFMT4_8_8_SNORM = 53,
        VFMT4_8_8_8_SNORM = 54,
        VFMT4_8_8_8_8_SNORM = 55,
-       VFMT4_10_10_10_2_UINT = 60,
-       VFMT4_10_10_10_2_UNORM = 61,
-       VFMT4_10_10_10_2_SINT = 62,
-       VFMT4_10_10_10_2_SNORM = 63,
+       VFMT4_10_10_10_2_UINT = 56,
+       VFMT4_10_10_10_2_UNORM = 57,
+       VFMT4_10_10_10_2_SINT = 58,
+       VFMT4_10_10_10_2_SNORM = 59,
+       VFMT4_2_10_10_10_UINT = 60,
+       VFMT4_2_10_10_10_UNORM = 61,
+       VFMT4_2_10_10_10_SINT = 62,
+       VFMT4_2_10_10_10_SNORM = 63,
 };
 
 enum a4xx_tex_fmt {
-       TFMT4_5_6_5_UNORM = 11,
-       TFMT4_5_5_5_1_UNORM = 10,
-       TFMT4_4_4_4_4_UNORM = 8,
-       TFMT4_X8Z24_UNORM = 71,
-       TFMT4_10_10_10_2_UNORM = 33,
        TFMT4_A8_UNORM = 3,
-       TFMT4_L8_A8_UNORM = 13,
        TFMT4_8_UNORM = 4,
-       TFMT4_8_8_UNORM = 14,
-       TFMT4_8_8_8_8_UNORM = 28,
        TFMT4_8_SNORM = 5,
-       TFMT4_8_8_SNORM = 15,
-       TFMT4_8_8_8_8_SNORM = 29,
        TFMT4_8_UINT = 6,
-       TFMT4_8_8_UINT = 16,
-       TFMT4_8_8_8_8_UINT = 30,
        TFMT4_8_SINT = 7,
+       TFMT4_4_4_4_4_UNORM = 8,
+       TFMT4_5_5_5_1_UNORM = 9,
+       TFMT4_5_6_5_UNORM = 11,
+       TFMT4_L8_A8_UNORM = 13,
+       TFMT4_8_8_UNORM = 14,
+       TFMT4_8_8_SNORM = 15,
+       TFMT4_8_8_UINT = 16,
        TFMT4_8_8_SINT = 17,
-       TFMT4_8_8_8_8_SINT = 31,
+       TFMT4_16_UNORM = 18,
+       TFMT4_16_SNORM = 19,
+       TFMT4_16_FLOAT = 20,
        TFMT4_16_UINT = 21,
-       TFMT4_16_16_UINT = 41,
-       TFMT4_16_16_16_16_UINT = 54,
        TFMT4_16_SINT = 22,
+       TFMT4_8_8_8_8_UNORM = 28,
+       TFMT4_8_8_8_8_SNORM = 29,
+       TFMT4_8_8_8_8_UINT = 30,
+       TFMT4_8_8_8_8_SINT = 31,
+       TFMT4_9_9_9_E5_FLOAT = 32,
+       TFMT4_10_10_10_2_UNORM = 33,
+       TFMT4_10_10_10_2_UINT = 34,
+       TFMT4_11_11_10_FLOAT = 37,
+       TFMT4_16_16_UNORM = 38,
+       TFMT4_16_16_SNORM = 39,
+       TFMT4_16_16_FLOAT = 40,
+       TFMT4_16_16_UINT = 41,
        TFMT4_16_16_SINT = 42,
-       TFMT4_16_16_16_16_SINT = 55,
+       TFMT4_32_FLOAT = 43,
        TFMT4_32_UINT = 44,
-       TFMT4_32_32_UINT = 57,
-       TFMT4_32_32_32_32_UINT = 64,
        TFMT4_32_SINT = 45,
-       TFMT4_32_32_SINT = 58,
-       TFMT4_32_32_32_32_SINT = 65,
-       TFMT4_16_FLOAT = 20,
-       TFMT4_16_16_FLOAT = 40,
+       TFMT4_16_16_16_16_UNORM = 51,
+       TFMT4_16_16_16_16_SNORM = 52,
        TFMT4_16_16_16_16_FLOAT = 53,
-       TFMT4_32_FLOAT = 43,
+       TFMT4_16_16_16_16_UINT = 54,
+       TFMT4_16_16_16_16_SINT = 55,
        TFMT4_32_32_FLOAT = 56,
+       TFMT4_32_32_UINT = 57,
+       TFMT4_32_32_SINT = 58,
+       TFMT4_32_32_32_FLOAT = 59,
+       TFMT4_32_32_32_UINT = 60,
+       TFMT4_32_32_32_SINT = 61,
        TFMT4_32_32_32_32_FLOAT = 63,
-       TFMT4_9_9_9_E5_FLOAT = 32,
-       TFMT4_11_11_10_FLOAT = 37,
+       TFMT4_32_32_32_32_UINT = 64,
+       TFMT4_32_32_32_32_SINT = 65,
+       TFMT4_X8Z24_UNORM = 71,
+       TFMT4_DXT1 = 86,
+       TFMT4_DXT3 = 87,
+       TFMT4_DXT5 = 88,
+       TFMT4_RGTC1_UNORM = 90,
+       TFMT4_RGTC1_SNORM = 91,
+       TFMT4_RGTC2_UNORM = 94,
+       TFMT4_RGTC2_SNORM = 95,
+       TFMT4_BPTC_UFLOAT = 97,
+       TFMT4_BPTC_FLOAT = 98,
+       TFMT4_BPTC = 99,
        TFMT4_ATC_RGB = 100,
        TFMT4_ATC_RGBA_EXPLICIT = 101,
        TFMT4_ATC_RGBA_INTERPOLATED = 102,
@@ -240,6 +272,545 @@ enum a4xx_tess_spacing {
        EVEN_SPACING = 3,
 };
 
+enum a4xx_ccu_perfcounter_select {
+       CCU_BUSY_CYCLES = 0,
+       CCU_RB_DEPTH_RETURN_STALL = 2,
+       CCU_RB_COLOR_RETURN_STALL = 3,
+       CCU_DEPTH_BLOCKS = 6,
+       CCU_COLOR_BLOCKS = 7,
+       CCU_DEPTH_BLOCK_HIT = 8,
+       CCU_COLOR_BLOCK_HIT = 9,
+       CCU_DEPTH_FLAG1_COUNT = 10,
+       CCU_DEPTH_FLAG2_COUNT = 11,
+       CCU_DEPTH_FLAG3_COUNT = 12,
+       CCU_DEPTH_FLAG4_COUNT = 13,
+       CCU_COLOR_FLAG1_COUNT = 14,
+       CCU_COLOR_FLAG2_COUNT = 15,
+       CCU_COLOR_FLAG3_COUNT = 16,
+       CCU_COLOR_FLAG4_COUNT = 17,
+       CCU_PARTIAL_BLOCK_READ = 18,
+};
+
+enum a4xx_cp_perfcounter_select {
+       CP_ALWAYS_COUNT = 0,
+       CP_BUSY = 1,
+       CP_PFP_IDLE = 2,
+       CP_PFP_BUSY_WORKING = 3,
+       CP_PFP_STALL_CYCLES_ANY = 4,
+       CP_PFP_STARVE_CYCLES_ANY = 5,
+       CP_PFP_STARVED_PER_LOAD_ADDR = 6,
+       CP_PFP_STALLED_PER_STORE_ADDR = 7,
+       CP_PFP_PC_PROFILE = 8,
+       CP_PFP_MATCH_PM4_PKT_PROFILE = 9,
+       CP_PFP_COND_INDIRECT_DISCARDED = 10,
+       CP_LONG_RESUMPTIONS = 11,
+       CP_RESUME_CYCLES = 12,
+       CP_RESUME_TO_BOUNDARY_CYCLES = 13,
+       CP_LONG_PREEMPTIONS = 14,
+       CP_PREEMPT_CYCLES = 15,
+       CP_PREEMPT_TO_BOUNDARY_CYCLES = 16,
+       CP_ME_FIFO_EMPTY_PFP_IDLE = 17,
+       CP_ME_FIFO_EMPTY_PFP_BUSY = 18,
+       CP_ME_FIFO_NOT_EMPTY_NOT_FULL = 19,
+       CP_ME_FIFO_FULL_ME_BUSY = 20,
+       CP_ME_FIFO_FULL_ME_NON_WORKING = 21,
+       CP_ME_WAITING_FOR_PACKETS = 22,
+       CP_ME_BUSY_WORKING = 23,
+       CP_ME_STARVE_CYCLES_ANY = 24,
+       CP_ME_STARVE_CYCLES_PER_PROFILE = 25,
+       CP_ME_STALL_CYCLES_PER_PROFILE = 26,
+       CP_ME_PC_PROFILE = 27,
+       CP_RCIU_FIFO_EMPTY = 28,
+       CP_RCIU_FIFO_NOT_EMPTY_NOT_FULL = 29,
+       CP_RCIU_FIFO_FULL = 30,
+       CP_RCIU_FIFO_FULL_NO_CONTEXT = 31,
+       CP_RCIU_FIFO_FULL_AHB_MASTER = 32,
+       CP_RCIU_FIFO_FULL_OTHER = 33,
+       CP_AHB_IDLE = 34,
+       CP_AHB_STALL_ON_GRANT_NO_SPLIT = 35,
+       CP_AHB_STALL_ON_GRANT_SPLIT = 36,
+       CP_AHB_STALL_ON_GRANT_SPLIT_PROFILE = 37,
+       CP_AHB_BUSY_WORKING = 38,
+       CP_AHB_BUSY_STALL_ON_HRDY = 39,
+       CP_AHB_BUSY_STALL_ON_HRDY_PROFILE = 40,
+};
+
+enum a4xx_gras_ras_perfcounter_select {
+       RAS_SUPER_TILES = 0,
+       RAS_8X8_TILES = 1,
+       RAS_4X4_TILES = 2,
+       RAS_BUSY_CYCLES = 3,
+       RAS_STALL_CYCLES_BY_RB = 4,
+       RAS_STALL_CYCLES_BY_VSC = 5,
+       RAS_STARVE_CYCLES_BY_TSE = 6,
+       RAS_SUPERTILE_CYCLES = 7,
+       RAS_TILE_CYCLES = 8,
+       RAS_FULLY_COVERED_SUPER_TILES = 9,
+       RAS_FULLY_COVERED_8X8_TILES = 10,
+       RAS_4X4_PRIM = 11,
+       RAS_8X4_4X8_PRIM = 12,
+       RAS_8X8_PRIM = 13,
+};
+
+enum a4xx_gras_tse_perfcounter_select {
+       TSE_INPUT_PRIM = 0,
+       TSE_INPUT_NULL_PRIM = 1,
+       TSE_TRIVAL_REJ_PRIM = 2,
+       TSE_CLIPPED_PRIM = 3,
+       TSE_NEW_PRIM = 4,
+       TSE_ZERO_AREA_PRIM = 5,
+       TSE_FACENESS_CULLED_PRIM = 6,
+       TSE_ZERO_PIXEL_PRIM = 7,
+       TSE_OUTPUT_NULL_PRIM = 8,
+       TSE_OUTPUT_VISIBLE_PRIM = 9,
+       TSE_PRE_CLIP_PRIM = 10,
+       TSE_POST_CLIP_PRIM = 11,
+       TSE_BUSY_CYCLES = 12,
+       TSE_PC_STARVE = 13,
+       TSE_RAS_STALL = 14,
+       TSE_STALL_BARYPLANE_FIFO_FULL = 15,
+       TSE_STALL_ZPLANE_FIFO_FULL = 16,
+};
+
+enum a4xx_hlsq_perfcounter_select {
+       HLSQ_SP_VS_STAGE_CONSTANT = 0,
+       HLSQ_SP_VS_STAGE_INSTRUCTIONS = 1,
+       HLSQ_SP_FS_STAGE_CONSTANT = 2,
+       HLSQ_SP_FS_STAGE_INSTRUCTIONS = 3,
+       HLSQ_TP_STATE = 4,
+       HLSQ_QUADS = 5,
+       HLSQ_PIXELS = 6,
+       HLSQ_VERTICES = 7,
+       HLSQ_SP_VS_STAGE_DATA_BYTES = 13,
+       HLSQ_SP_FS_STAGE_DATA_BYTES = 14,
+       HLSQ_BUSY_CYCLES = 15,
+       HLSQ_STALL_CYCLES_SP_STATE = 16,
+       HLSQ_STALL_CYCLES_SP_VS_STAGE = 17,
+       HLSQ_STALL_CYCLES_SP_FS_STAGE = 18,
+       HLSQ_STALL_CYCLES_UCHE = 19,
+       HLSQ_RBBM_LOAD_CYCLES = 20,
+       HLSQ_DI_TO_VS_START_SP = 21,
+       HLSQ_DI_TO_FS_START_SP = 22,
+       HLSQ_VS_STAGE_START_TO_DONE_SP = 23,
+       HLSQ_FS_STAGE_START_TO_DONE_SP = 24,
+       HLSQ_SP_STATE_COPY_CYCLES_VS_STAGE = 25,
+       HLSQ_SP_STATE_COPY_CYCLES_FS_STAGE = 26,
+       HLSQ_UCHE_LATENCY_CYCLES = 27,
+       HLSQ_UCHE_LATENCY_COUNT = 28,
+       HLSQ_STARVE_CYCLES_VFD = 29,
+};
+
+enum a4xx_pc_perfcounter_select {
+       PC_VIS_STREAMS_LOADED = 0,
+       PC_VPC_PRIMITIVES = 2,
+       PC_DEAD_PRIM = 3,
+       PC_LIVE_PRIM = 4,
+       PC_DEAD_DRAWCALLS = 5,
+       PC_LIVE_DRAWCALLS = 6,
+       PC_VERTEX_MISSES = 7,
+       PC_STALL_CYCLES_VFD = 9,
+       PC_STALL_CYCLES_TSE = 10,
+       PC_STALL_CYCLES_UCHE = 11,
+       PC_WORKING_CYCLES = 12,
+       PC_IA_VERTICES = 13,
+       PC_GS_PRIMITIVES = 14,
+       PC_HS_INVOCATIONS = 15,
+       PC_DS_INVOCATIONS = 16,
+       PC_DS_PRIMITIVES = 17,
+       PC_STARVE_CYCLES_FOR_INDEX = 20,
+       PC_STARVE_CYCLES_FOR_TESS_FACTOR = 21,
+       PC_STARVE_CYCLES_FOR_VIZ_STREAM = 22,
+       PC_STALL_CYCLES_TESS = 23,
+       PC_STARVE_CYCLES_FOR_POSITION = 24,
+       PC_MODE0_DRAWCALL = 25,
+       PC_MODE1_DRAWCALL = 26,
+       PC_MODE2_DRAWCALL = 27,
+       PC_MODE3_DRAWCALL = 28,
+       PC_MODE4_DRAWCALL = 29,
+       PC_PREDICATED_DEAD_DRAWCALL = 30,
+       PC_STALL_CYCLES_BY_TSE_ONLY = 31,
+       PC_STALL_CYCLES_BY_VPC_ONLY = 32,
+       PC_VPC_POS_DATA_TRANSACTION = 33,
+       PC_BUSY_CYCLES = 34,
+       PC_STARVE_CYCLES_DI = 35,
+       PC_STALL_CYCLES_VPC = 36,
+       TESS_WORKING_CYCLES = 37,
+       TESS_NUM_CYCLES_SETUP_WORKING = 38,
+       TESS_NUM_CYCLES_PTGEN_WORKING = 39,
+       TESS_NUM_CYCLES_CONNGEN_WORKING = 40,
+       TESS_BUSY_CYCLES = 41,
+       TESS_STARVE_CYCLES_PC = 42,
+       TESS_STALL_CYCLES_PC = 43,
+};
+
+enum a4xx_pwr_perfcounter_select {
+       PWR_CORE_CLOCK_CYCLES = 0,
+       PWR_BUSY_CLOCK_CYCLES = 1,
+};
+
+enum a4xx_rb_perfcounter_select {
+       RB_BUSY_CYCLES = 0,
+       RB_BUSY_CYCLES_BINNING = 1,
+       RB_BUSY_CYCLES_RENDERING = 2,
+       RB_BUSY_CYCLES_RESOLVE = 3,
+       RB_STARVE_CYCLES_BY_SP = 4,
+       RB_STARVE_CYCLES_BY_RAS = 5,
+       RB_STARVE_CYCLES_BY_MARB = 6,
+       RB_STALL_CYCLES_BY_MARB = 7,
+       RB_STALL_CYCLES_BY_HLSQ = 8,
+       RB_RB_RB_MARB_DATA = 9,
+       RB_SP_RB_QUAD = 10,
+       RB_RAS_RB_Z_QUADS = 11,
+       RB_GMEM_CH0_READ = 12,
+       RB_GMEM_CH1_READ = 13,
+       RB_GMEM_CH0_WRITE = 14,
+       RB_GMEM_CH1_WRITE = 15,
+       RB_CP_CONTEXT_DONE = 16,
+       RB_CP_CACHE_FLUSH = 17,
+       RB_CP_ZPASS_DONE = 18,
+       RB_STALL_FIFO0_FULL = 19,
+       RB_STALL_FIFO1_FULL = 20,
+       RB_STALL_FIFO2_FULL = 21,
+       RB_STALL_FIFO3_FULL = 22,
+       RB_RB_HLSQ_TRANSACTIONS = 23,
+       RB_Z_READ = 24,
+       RB_Z_WRITE = 25,
+       RB_C_READ = 26,
+       RB_C_WRITE = 27,
+       RB_C_READ_LATENCY = 28,
+       RB_Z_READ_LATENCY = 29,
+       RB_STALL_BY_UCHE = 30,
+       RB_MARB_UCHE_TRANSACTIONS = 31,
+       RB_CACHE_STALL_MISS = 32,
+       RB_CACHE_STALL_FIFO_FULL = 33,
+       RB_8BIT_BLENDER_UNITS_ACTIVE = 34,
+       RB_16BIT_BLENDER_UNITS_ACTIVE = 35,
+       RB_SAMPLER_UNITS_ACTIVE = 36,
+       RB_TOTAL_PASS = 38,
+       RB_Z_PASS = 39,
+       RB_Z_FAIL = 40,
+       RB_S_FAIL = 41,
+       RB_POWER0 = 42,
+       RB_POWER1 = 43,
+       RB_POWER2 = 44,
+       RB_POWER3 = 45,
+       RB_POWER4 = 46,
+       RB_POWER5 = 47,
+       RB_POWER6 = 48,
+       RB_POWER7 = 49,
+};
+
+enum a4xx_rbbm_perfcounter_select {
+       RBBM_ALWAYS_ON = 0,
+       RBBM_VBIF_BUSY = 1,
+       RBBM_TSE_BUSY = 2,
+       RBBM_RAS_BUSY = 3,
+       RBBM_PC_DCALL_BUSY = 4,
+       RBBM_PC_VSD_BUSY = 5,
+       RBBM_VFD_BUSY = 6,
+       RBBM_VPC_BUSY = 7,
+       RBBM_UCHE_BUSY = 8,
+       RBBM_VSC_BUSY = 9,
+       RBBM_HLSQ_BUSY = 10,
+       RBBM_ANY_RB_BUSY = 11,
+       RBBM_ANY_TPL1_BUSY = 12,
+       RBBM_ANY_SP_BUSY = 13,
+       RBBM_ANY_MARB_BUSY = 14,
+       RBBM_ANY_ARB_BUSY = 15,
+       RBBM_AHB_STATUS_BUSY = 16,
+       RBBM_AHB_STATUS_STALLED = 17,
+       RBBM_AHB_STATUS_TXFR = 18,
+       RBBM_AHB_STATUS_TXFR_SPLIT = 19,
+       RBBM_AHB_STATUS_TXFR_ERROR = 20,
+       RBBM_AHB_STATUS_LONG_STALL = 21,
+       RBBM_STATUS_MASKED = 22,
+       RBBM_CP_BUSY_GFX_CORE_IDLE = 23,
+       RBBM_TESS_BUSY = 24,
+       RBBM_COM_BUSY = 25,
+       RBBM_DCOM_BUSY = 32,
+       RBBM_ANY_CCU_BUSY = 33,
+       RBBM_DPM_BUSY = 34,
+};
+
+enum a4xx_sp_perfcounter_select {
+       SP_LM_LOAD_INSTRUCTIONS = 0,
+       SP_LM_STORE_INSTRUCTIONS = 1,
+       SP_LM_ATOMICS = 2,
+       SP_GM_LOAD_INSTRUCTIONS = 3,
+       SP_GM_STORE_INSTRUCTIONS = 4,
+       SP_GM_ATOMICS = 5,
+       SP_VS_STAGE_TEX_INSTRUCTIONS = 6,
+       SP_VS_STAGE_CFLOW_INSTRUCTIONS = 7,
+       SP_VS_STAGE_EFU_INSTRUCTIONS = 8,
+       SP_VS_STAGE_FULL_ALU_INSTRUCTIONS = 9,
+       SP_VS_STAGE_HALF_ALU_INSTRUCTIONS = 10,
+       SP_FS_STAGE_TEX_INSTRUCTIONS = 11,
+       SP_FS_STAGE_CFLOW_INSTRUCTIONS = 12,
+       SP_FS_STAGE_EFU_INSTRUCTIONS = 13,
+       SP_FS_STAGE_FULL_ALU_INSTRUCTIONS = 14,
+       SP_FS_STAGE_HALF_ALU_INSTRUCTIONS = 15,
+       SP_VS_INSTRUCTIONS = 17,
+       SP_FS_INSTRUCTIONS = 18,
+       SP_ADDR_LOCK_COUNT = 19,
+       SP_UCHE_READ_TRANS = 20,
+       SP_UCHE_WRITE_TRANS = 21,
+       SP_EXPORT_VPC_TRANS = 22,
+       SP_EXPORT_RB_TRANS = 23,
+       SP_PIXELS_KILLED = 24,
+       SP_ICL1_REQUESTS = 25,
+       SP_ICL1_MISSES = 26,
+       SP_ICL0_REQUESTS = 27,
+       SP_ICL0_MISSES = 28,
+       SP_ALU_WORKING_CYCLES = 29,
+       SP_EFU_WORKING_CYCLES = 30,
+       SP_STALL_CYCLES_BY_VPC = 31,
+       SP_STALL_CYCLES_BY_TP = 32,
+       SP_STALL_CYCLES_BY_UCHE = 33,
+       SP_STALL_CYCLES_BY_RB = 34,
+       SP_BUSY_CYCLES = 35,
+       SP_HS_INSTRUCTIONS = 36,
+       SP_DS_INSTRUCTIONS = 37,
+       SP_GS_INSTRUCTIONS = 38,
+       SP_CS_INSTRUCTIONS = 39,
+       SP_SCHEDULER_NON_WORKING = 40,
+       SP_WAVE_CONTEXTS = 41,
+       SP_WAVE_CONTEXT_CYCLES = 42,
+       SP_POWER0 = 43,
+       SP_POWER1 = 44,
+       SP_POWER2 = 45,
+       SP_POWER3 = 46,
+       SP_POWER4 = 47,
+       SP_POWER5 = 48,
+       SP_POWER6 = 49,
+       SP_POWER7 = 50,
+       SP_POWER8 = 51,
+       SP_POWER9 = 52,
+       SP_POWER10 = 53,
+       SP_POWER11 = 54,
+       SP_POWER12 = 55,
+       SP_POWER13 = 56,
+       SP_POWER14 = 57,
+       SP_POWER15 = 58,
+};
+
+enum a4xx_tp_perfcounter_select {
+       TP_L1_REQUESTS = 0,
+       TP_L1_MISSES = 1,
+       TP_QUADS_OFFSET = 8,
+       TP_QUAD_SHADOW = 9,
+       TP_QUADS_ARRAY = 10,
+       TP_QUADS_GRADIENT = 11,
+       TP_QUADS_1D2D = 12,
+       TP_QUADS_3DCUBE = 13,
+       TP_BUSY_CYCLES = 16,
+       TP_STALL_CYCLES_BY_ARB = 17,
+       TP_STATE_CACHE_REQUESTS = 20,
+       TP_STATE_CACHE_MISSES = 21,
+       TP_POWER0 = 22,
+       TP_POWER1 = 23,
+       TP_POWER2 = 24,
+       TP_POWER3 = 25,
+       TP_POWER4 = 26,
+       TP_POWER5 = 27,
+       TP_POWER6 = 28,
+       TP_POWER7 = 29,
+};
+
+enum a4xx_uche_perfcounter_select {
+       UCHE_VBIF_READ_BEATS_TP = 0,
+       UCHE_VBIF_READ_BEATS_VFD = 1,
+       UCHE_VBIF_READ_BEATS_HLSQ = 2,
+       UCHE_VBIF_READ_BEATS_MARB = 3,
+       UCHE_VBIF_READ_BEATS_SP = 4,
+       UCHE_READ_REQUESTS_TP = 5,
+       UCHE_READ_REQUESTS_VFD = 6,
+       UCHE_READ_REQUESTS_HLSQ = 7,
+       UCHE_READ_REQUESTS_MARB = 8,
+       UCHE_READ_REQUESTS_SP = 9,
+       UCHE_WRITE_REQUESTS_MARB = 10,
+       UCHE_WRITE_REQUESTS_SP = 11,
+       UCHE_TAG_CHECK_FAILS = 12,
+       UCHE_EVICTS = 13,
+       UCHE_FLUSHES = 14,
+       UCHE_VBIF_LATENCY_CYCLES = 15,
+       UCHE_VBIF_LATENCY_SAMPLES = 16,
+       UCHE_BUSY_CYCLES = 17,
+       UCHE_VBIF_READ_BEATS_PC = 18,
+       UCHE_READ_REQUESTS_PC = 19,
+       UCHE_WRITE_REQUESTS_VPC = 20,
+       UCHE_STALL_BY_VBIF = 21,
+       UCHE_WRITE_REQUESTS_VSC = 22,
+       UCHE_POWER0 = 23,
+       UCHE_POWER1 = 24,
+       UCHE_POWER2 = 25,
+       UCHE_POWER3 = 26,
+       UCHE_POWER4 = 27,
+       UCHE_POWER5 = 28,
+       UCHE_POWER6 = 29,
+       UCHE_POWER7 = 30,
+};
+
+enum a4xx_vbif_perfcounter_select {
+       AXI_READ_REQUESTS_ID_0 = 0,
+       AXI_READ_REQUESTS_ID_1 = 1,
+       AXI_READ_REQUESTS_ID_2 = 2,
+       AXI_READ_REQUESTS_ID_3 = 3,
+       AXI_READ_REQUESTS_ID_4 = 4,
+       AXI_READ_REQUESTS_ID_5 = 5,
+       AXI_READ_REQUESTS_ID_6 = 6,
+       AXI_READ_REQUESTS_ID_7 = 7,
+       AXI_READ_REQUESTS_ID_8 = 8,
+       AXI_READ_REQUESTS_ID_9 = 9,
+       AXI_READ_REQUESTS_ID_10 = 10,
+       AXI_READ_REQUESTS_ID_11 = 11,
+       AXI_READ_REQUESTS_ID_12 = 12,
+       AXI_READ_REQUESTS_ID_13 = 13,
+       AXI_READ_REQUESTS_ID_14 = 14,
+       AXI_READ_REQUESTS_ID_15 = 15,
+       AXI0_READ_REQUESTS_TOTAL = 16,
+       AXI1_READ_REQUESTS_TOTAL = 17,
+       AXI2_READ_REQUESTS_TOTAL = 18,
+       AXI3_READ_REQUESTS_TOTAL = 19,
+       AXI_READ_REQUESTS_TOTAL = 20,
+       AXI_WRITE_REQUESTS_ID_0 = 21,
+       AXI_WRITE_REQUESTS_ID_1 = 22,
+       AXI_WRITE_REQUESTS_ID_2 = 23,
+       AXI_WRITE_REQUESTS_ID_3 = 24,
+       AXI_WRITE_REQUESTS_ID_4 = 25,
+       AXI_WRITE_REQUESTS_ID_5 = 26,
+       AXI_WRITE_REQUESTS_ID_6 = 27,
+       AXI_WRITE_REQUESTS_ID_7 = 28,
+       AXI_WRITE_REQUESTS_ID_8 = 29,
+       AXI_WRITE_REQUESTS_ID_9 = 30,
+       AXI_WRITE_REQUESTS_ID_10 = 31,
+       AXI_WRITE_REQUESTS_ID_11 = 32,
+       AXI_WRITE_REQUESTS_ID_12 = 33,
+       AXI_WRITE_REQUESTS_ID_13 = 34,
+       AXI_WRITE_REQUESTS_ID_14 = 35,
+       AXI_WRITE_REQUESTS_ID_15 = 36,
+       AXI0_WRITE_REQUESTS_TOTAL = 37,
+       AXI1_WRITE_REQUESTS_TOTAL = 38,
+       AXI2_WRITE_REQUESTS_TOTAL = 39,
+       AXI3_WRITE_REQUESTS_TOTAL = 40,
+       AXI_WRITE_REQUESTS_TOTAL = 41,
+       AXI_TOTAL_REQUESTS = 42,
+       AXI_READ_DATA_BEATS_ID_0 = 43,
+       AXI_READ_DATA_BEATS_ID_1 = 44,
+       AXI_READ_DATA_BEATS_ID_2 = 45,
+       AXI_READ_DATA_BEATS_ID_3 = 46,
+       AXI_READ_DATA_BEATS_ID_4 = 47,
+       AXI_READ_DATA_BEATS_ID_5 = 48,
+       AXI_READ_DATA_BEATS_ID_6 = 49,
+       AXI_READ_DATA_BEATS_ID_7 = 50,
+       AXI_READ_DATA_BEATS_ID_8 = 51,
+       AXI_READ_DATA_BEATS_ID_9 = 52,
+       AXI_READ_DATA_BEATS_ID_10 = 53,
+       AXI_READ_DATA_BEATS_ID_11 = 54,
+       AXI_READ_DATA_BEATS_ID_12 = 55,
+       AXI_READ_DATA_BEATS_ID_13 = 56,
+       AXI_READ_DATA_BEATS_ID_14 = 57,
+       AXI_READ_DATA_BEATS_ID_15 = 58,
+       AXI0_READ_DATA_BEATS_TOTAL = 59,
+       AXI1_READ_DATA_BEATS_TOTAL = 60,
+       AXI2_READ_DATA_BEATS_TOTAL = 61,
+       AXI3_READ_DATA_BEATS_TOTAL = 62,
+       AXI_READ_DATA_BEATS_TOTAL = 63,
+       AXI_WRITE_DATA_BEATS_ID_0 = 64,
+       AXI_WRITE_DATA_BEATS_ID_1 = 65,
+       AXI_WRITE_DATA_BEATS_ID_2 = 66,
+       AXI_WRITE_DATA_BEATS_ID_3 = 67,
+       AXI_WRITE_DATA_BEATS_ID_4 = 68,
+       AXI_WRITE_DATA_BEATS_ID_5 = 69,
+       AXI_WRITE_DATA_BEATS_ID_6 = 70,
+       AXI_WRITE_DATA_BEATS_ID_7 = 71,
+       AXI_WRITE_DATA_BEATS_ID_8 = 72,
+       AXI_WRITE_DATA_BEATS_ID_9 = 73,
+       AXI_WRITE_DATA_BEATS_ID_10 = 74,
+       AXI_WRITE_DATA_BEATS_ID_11 = 75,
+       AXI_WRITE_DATA_BEATS_ID_12 = 76,
+       AXI_WRITE_DATA_BEATS_ID_13 = 77,
+       AXI_WRITE_DATA_BEATS_ID_14 = 78,
+       AXI_WRITE_DATA_BEATS_ID_15 = 79,
+       AXI0_WRITE_DATA_BEATS_TOTAL = 80,
+       AXI1_WRITE_DATA_BEATS_TOTAL = 81,
+       AXI2_WRITE_DATA_BEATS_TOTAL = 82,
+       AXI3_WRITE_DATA_BEATS_TOTAL = 83,
+       AXI_WRITE_DATA_BEATS_TOTAL = 84,
+       AXI_DATA_BEATS_TOTAL = 85,
+       CYCLES_HELD_OFF_ID_0 = 86,
+       CYCLES_HELD_OFF_ID_1 = 87,
+       CYCLES_HELD_OFF_ID_2 = 88,
+       CYCLES_HELD_OFF_ID_3 = 89,
+       CYCLES_HELD_OFF_ID_4 = 90,
+       CYCLES_HELD_OFF_ID_5 = 91,
+       CYCLES_HELD_OFF_ID_6 = 92,
+       CYCLES_HELD_OFF_ID_7 = 93,
+       CYCLES_HELD_OFF_ID_8 = 94,
+       CYCLES_HELD_OFF_ID_9 = 95,
+       CYCLES_HELD_OFF_ID_10 = 96,
+       CYCLES_HELD_OFF_ID_11 = 97,
+       CYCLES_HELD_OFF_ID_12 = 98,
+       CYCLES_HELD_OFF_ID_13 = 99,
+       CYCLES_HELD_OFF_ID_14 = 100,
+       CYCLES_HELD_OFF_ID_15 = 101,
+       AXI_READ_REQUEST_HELD_OFF = 102,
+       AXI_WRITE_REQUEST_HELD_OFF = 103,
+       AXI_REQUEST_HELD_OFF = 104,
+       AXI_WRITE_DATA_HELD_OFF = 105,
+       OCMEM_AXI_READ_REQUEST_HELD_OFF = 106,
+       OCMEM_AXI_WRITE_REQUEST_HELD_OFF = 107,
+       OCMEM_AXI_REQUEST_HELD_OFF = 108,
+       OCMEM_AXI_WRITE_DATA_HELD_OFF = 109,
+       ELAPSED_CYCLES_DDR = 110,
+       ELAPSED_CYCLES_OCMEM = 111,
+};
+
+enum a4xx_vfd_perfcounter_select {
+       VFD_UCHE_BYTE_FETCHED = 0,
+       VFD_UCHE_TRANS = 1,
+       VFD_FETCH_INSTRUCTIONS = 3,
+       VFD_BUSY_CYCLES = 5,
+       VFD_STALL_CYCLES_UCHE = 6,
+       VFD_STALL_CYCLES_HLSQ = 7,
+       VFD_STALL_CYCLES_VPC_BYPASS = 8,
+       VFD_STALL_CYCLES_VPC_ALLOC = 9,
+       VFD_MODE_0_FIBERS = 13,
+       VFD_MODE_1_FIBERS = 14,
+       VFD_MODE_2_FIBERS = 15,
+       VFD_MODE_3_FIBERS = 16,
+       VFD_MODE_4_FIBERS = 17,
+       VFD_BFIFO_STALL = 18,
+       VFD_NUM_VERTICES_TOTAL = 19,
+       VFD_PACKER_FULL = 20,
+       VFD_UCHE_REQUEST_FIFO_FULL = 21,
+       VFD_STARVE_CYCLES_PC = 22,
+       VFD_STARVE_CYCLES_UCHE = 23,
+};
+
+enum a4xx_vpc_perfcounter_select {
+       VPC_SP_LM_COMPONENTS = 2,
+       VPC_SP0_LM_BYTES = 3,
+       VPC_SP1_LM_BYTES = 4,
+       VPC_SP2_LM_BYTES = 5,
+       VPC_SP3_LM_BYTES = 6,
+       VPC_WORKING_CYCLES = 7,
+       VPC_STALL_CYCLES_LM = 8,
+       VPC_STARVE_CYCLES_RAS = 9,
+       VPC_STREAMOUT_CYCLES = 10,
+       VPC_UCHE_TRANSACTIONS = 12,
+       VPC_STALL_CYCLES_UCHE = 13,
+       VPC_BUSY_CYCLES = 14,
+       VPC_STARVE_CYCLES_SP = 15,
+};
+
+enum a4xx_vsc_perfcounter_select {
+       VSC_BUSY_CYCLES = 0,
+       VSC_WORKING_CYCLES = 1,
+       VSC_STALL_CYCLES_UCHE = 2,
+       VSC_STARVE_CYCLES_RAS = 3,
+       VSC_EOT_NUM = 4,
+};
+
 enum a4xx_tex_filter {
        A4XX_TEX_NEAREST = 0,
        A4XX_TEX_LINEAR = 1,
@@ -326,6 +897,12 @@ static inline uint32_t A4XX_CGC_HLSQ_EARLY_CYC(uint32_t val)
 
 #define REG_A4XX_RB_PERFCTR_RB_SEL_7                           0x00000cce
 
+#define REG_A4XX_RB_PERFCTR_CCU_SEL_0                          0x00000ccf
+
+#define REG_A4XX_RB_PERFCTR_CCU_SEL_1                          0x00000cd0
+
+#define REG_A4XX_RB_PERFCTR_CCU_SEL_2                          0x00000cd1
+
 #define REG_A4XX_RB_PERFCTR_CCU_SEL_3                          0x00000cd2
 
 #define REG_A4XX_RB_FRAME_BUFFER_DIMENSION                     0x00000ce0
@@ -400,8 +977,13 @@ static inline uint32_t REG_A4XX_RB_MRT_CONTROL(uint32_t i0) { return 0x000020a4
 #define A4XX_RB_MRT_CONTROL_READ_DEST_ENABLE                   0x00000008
 #define A4XX_RB_MRT_CONTROL_BLEND                              0x00000010
 #define A4XX_RB_MRT_CONTROL_BLEND2                             0x00000020
-#define A4XX_RB_MRT_CONTROL_FASTCLEAR                          0x00000400
-#define A4XX_RB_MRT_CONTROL_B11                                        0x00000800
+#define A4XX_RB_MRT_CONTROL_ROP_ENABLE                         0x00000040
+#define A4XX_RB_MRT_CONTROL_ROP_CODE__MASK                     0x00000f00
+#define A4XX_RB_MRT_CONTROL_ROP_CODE__SHIFT                    8
+static inline uint32_t A4XX_RB_MRT_CONTROL_ROP_CODE(enum a3xx_rop_code val)
+{
+       return ((val) << A4XX_RB_MRT_CONTROL_ROP_CODE__SHIFT) & A4XX_RB_MRT_CONTROL_ROP_CODE__MASK;
+}
 #define A4XX_RB_MRT_CONTROL_COMPONENT_ENABLE__MASK             0x0f000000
 #define A4XX_RB_MRT_CONTROL_COMPONENT_ENABLE__SHIFT            24
 static inline uint32_t A4XX_RB_MRT_CONTROL_COMPONENT_ENABLE(uint32_t val)
@@ -490,8 +1072,8 @@ static inline uint32_t A4XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR(enum adreno_r
        return ((val) << A4XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR__SHIFT) & A4XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR__MASK;
 }
 
-#define REG_A4XX_RB_BLEND_RED                                  0x000020f3
-#define A4XX_RB_BLEND_RED_UINT__MASK                           0x00007fff
+#define REG_A4XX_RB_BLEND_RED                                  0x000020f0
+#define A4XX_RB_BLEND_RED_UINT__MASK                           0x0000ffff
 #define A4XX_RB_BLEND_RED_UINT__SHIFT                          0
 static inline uint32_t A4XX_RB_BLEND_RED_UINT(uint32_t val)
 {
@@ -504,8 +1086,16 @@ static inline uint32_t A4XX_RB_BLEND_RED_FLOAT(float val)
        return ((util_float_to_half(val)) << A4XX_RB_BLEND_RED_FLOAT__SHIFT) & A4XX_RB_BLEND_RED_FLOAT__MASK;
 }
 
-#define REG_A4XX_RB_BLEND_GREEN                                        0x000020f4
-#define A4XX_RB_BLEND_GREEN_UINT__MASK                         0x00007fff
+#define REG_A4XX_RB_BLEND_RED_F32                              0x000020f1
+#define A4XX_RB_BLEND_RED_F32__MASK                            0xffffffff
+#define A4XX_RB_BLEND_RED_F32__SHIFT                           0
+static inline uint32_t A4XX_RB_BLEND_RED_F32(float val)
+{
+       return ((fui(val)) << A4XX_RB_BLEND_RED_F32__SHIFT) & A4XX_RB_BLEND_RED_F32__MASK;
+}
+
+#define REG_A4XX_RB_BLEND_GREEN                                        0x000020f2
+#define A4XX_RB_BLEND_GREEN_UINT__MASK                         0x0000ffff
 #define A4XX_RB_BLEND_GREEN_UINT__SHIFT                                0
 static inline uint32_t A4XX_RB_BLEND_GREEN_UINT(uint32_t val)
 {
@@ -518,8 +1108,16 @@ static inline uint32_t A4XX_RB_BLEND_GREEN_FLOAT(float val)
        return ((util_float_to_half(val)) << A4XX_RB_BLEND_GREEN_FLOAT__SHIFT) & A4XX_RB_BLEND_GREEN_FLOAT__MASK;
 }
 
-#define REG_A4XX_RB_BLEND_BLUE                                 0x000020f5
-#define A4XX_RB_BLEND_BLUE_UINT__MASK                          0x00007fff
+#define REG_A4XX_RB_BLEND_GREEN_F32                            0x000020f3
+#define A4XX_RB_BLEND_GREEN_F32__MASK                          0xffffffff
+#define A4XX_RB_BLEND_GREEN_F32__SHIFT                         0
+static inline uint32_t A4XX_RB_BLEND_GREEN_F32(float val)
+{
+       return ((fui(val)) << A4XX_RB_BLEND_GREEN_F32__SHIFT) & A4XX_RB_BLEND_GREEN_F32__MASK;
+}
+
+#define REG_A4XX_RB_BLEND_BLUE                                 0x000020f4
+#define A4XX_RB_BLEND_BLUE_UINT__MASK                          0x0000ffff
 #define A4XX_RB_BLEND_BLUE_UINT__SHIFT                         0
 static inline uint32_t A4XX_RB_BLEND_BLUE_UINT(uint32_t val)
 {
@@ -532,8 +1130,16 @@ static inline uint32_t A4XX_RB_BLEND_BLUE_FLOAT(float val)
        return ((util_float_to_half(val)) << A4XX_RB_BLEND_BLUE_FLOAT__SHIFT) & A4XX_RB_BLEND_BLUE_FLOAT__MASK;
 }
 
+#define REG_A4XX_RB_BLEND_BLUE_F32                             0x000020f5
+#define A4XX_RB_BLEND_BLUE_F32__MASK                           0xffffffff
+#define A4XX_RB_BLEND_BLUE_F32__SHIFT                          0
+static inline uint32_t A4XX_RB_BLEND_BLUE_F32(float val)
+{
+       return ((fui(val)) << A4XX_RB_BLEND_BLUE_F32__SHIFT) & A4XX_RB_BLEND_BLUE_F32__MASK;
+}
+
 #define REG_A4XX_RB_BLEND_ALPHA                                        0x000020f6
-#define A4XX_RB_BLEND_ALPHA_UINT__MASK                         0x00007fff
+#define A4XX_RB_BLEND_ALPHA_UINT__MASK                         0x0000ffff
 #define A4XX_RB_BLEND_ALPHA_UINT__SHIFT                                0
 static inline uint32_t A4XX_RB_BLEND_ALPHA_UINT(uint32_t val)
 {
@@ -546,6 +1152,14 @@ static inline uint32_t A4XX_RB_BLEND_ALPHA_FLOAT(float val)
        return ((util_float_to_half(val)) << A4XX_RB_BLEND_ALPHA_FLOAT__SHIFT) & A4XX_RB_BLEND_ALPHA_FLOAT__MASK;
 }
 
+#define REG_A4XX_RB_BLEND_ALPHA_F32                            0x000020f7
+#define A4XX_RB_BLEND_ALPHA_F32__MASK                          0xffffffff
+#define A4XX_RB_BLEND_ALPHA_F32__SHIFT                         0
+static inline uint32_t A4XX_RB_BLEND_ALPHA_F32(float val)
+{
+       return ((fui(val)) << A4XX_RB_BLEND_ALPHA_F32__SHIFT) & A4XX_RB_BLEND_ALPHA_F32__MASK;
+}
+
 #define REG_A4XX_RB_ALPHA_CONTROL                              0x000020f8
 #define A4XX_RB_ALPHA_CONTROL_ALPHA_REF__MASK                  0x000000ff
 #define A4XX_RB_ALPHA_CONTROL_ALPHA_REF__SHIFT                 0
@@ -568,7 +1182,7 @@ static inline uint32_t A4XX_RB_FS_OUTPUT_ENABLE_BLEND(uint32_t val)
 {
        return ((val) << A4XX_RB_FS_OUTPUT_ENABLE_BLEND__SHIFT) & A4XX_RB_FS_OUTPUT_ENABLE_BLEND__MASK;
 }
-#define A4XX_RB_FS_OUTPUT_FAST_CLEAR                           0x00000100
+#define A4XX_RB_FS_OUTPUT_INDEPENDENT_BLEND                    0x00000100
 #define A4XX_RB_FS_OUTPUT_SAMPLE_MASK__MASK                    0xffff0000
 #define A4XX_RB_FS_OUTPUT_SAMPLE_MASK__SHIFT                   16
 static inline uint32_t A4XX_RB_FS_OUTPUT_SAMPLE_MASK(uint32_t val)
@@ -736,6 +1350,7 @@ static inline uint32_t A4XX_RB_DEPTH_CONTROL_ZFUNC(enum adreno_compare_func val)
 }
 #define A4XX_RB_DEPTH_CONTROL_BF_ENABLE                                0x00000080
 #define A4XX_RB_DEPTH_CONTROL_EARLY_Z_DISABLE                  0x00010000
+#define A4XX_RB_DEPTH_CONTROL_FORCE_FRAGZ_TO_FS                        0x00020000
 #define A4XX_RB_DEPTH_CONTROL_Z_TEST_ENABLE                    0x80000000
 
 #define REG_A4XX_RB_DEPTH_CLEAR                                        0x00002102
@@ -996,8 +1611,386 @@ static inline uint32_t REG_A4XX_RBBM_CLOCK_DELAY_TP_REG(uint32_t i0) { return 0x
 
 #define REG_A4XX_RBBM_CFG_DEBBUS_SEL_D                         0x0000004d
 
+#define REG_A4XX_RBBM_POWER_CNTL_IP                            0x00000098
+#define A4XX_RBBM_POWER_CNTL_IP_SW_COLLAPSE                    0x00000001
+#define A4XX_RBBM_POWER_CNTL_IP_SP_TP_PWR_ON                   0x00100000
+
 #define REG_A4XX_RBBM_PERFCTR_CP_0_LO                          0x0000009c
 
+#define REG_A4XX_RBBM_PERFCTR_CP_0_HI                          0x0000009d
+
+#define REG_A4XX_RBBM_PERFCTR_CP_1_LO                          0x0000009e
+
+#define REG_A4XX_RBBM_PERFCTR_CP_1_HI                          0x0000009f
+
+#define REG_A4XX_RBBM_PERFCTR_CP_2_LO                          0x000000a0
+
+#define REG_A4XX_RBBM_PERFCTR_CP_2_HI                          0x000000a1
+
+#define REG_A4XX_RBBM_PERFCTR_CP_3_LO                          0x000000a2
+
+#define REG_A4XX_RBBM_PERFCTR_CP_3_HI                          0x000000a3
+
+#define REG_A4XX_RBBM_PERFCTR_CP_4_LO                          0x000000a4
+
+#define REG_A4XX_RBBM_PERFCTR_CP_4_HI                          0x000000a5
+
+#define REG_A4XX_RBBM_PERFCTR_CP_5_LO                          0x000000a6
+
+#define REG_A4XX_RBBM_PERFCTR_CP_5_HI                          0x000000a7
+
+#define REG_A4XX_RBBM_PERFCTR_CP_6_LO                          0x000000a8
+
+#define REG_A4XX_RBBM_PERFCTR_CP_6_HI                          0x000000a9
+
+#define REG_A4XX_RBBM_PERFCTR_CP_7_LO                          0x000000aa
+
+#define REG_A4XX_RBBM_PERFCTR_CP_7_HI                          0x000000ab
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_0_LO                                0x000000ac
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_0_HI                                0x000000ad
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_1_LO                                0x000000ae
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_1_HI                                0x000000af
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_2_LO                                0x000000b0
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_2_HI                                0x000000b1
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_3_LO                                0x000000b2
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_3_HI                                0x000000b3
+
+#define REG_A4XX_RBBM_PERFCTR_PC_0_LO                          0x000000b4
+
+#define REG_A4XX_RBBM_PERFCTR_PC_0_HI                          0x000000b5
+
+#define REG_A4XX_RBBM_PERFCTR_PC_1_LO                          0x000000b6
+
+#define REG_A4XX_RBBM_PERFCTR_PC_1_HI                          0x000000b7
+
+#define REG_A4XX_RBBM_PERFCTR_PC_2_LO                          0x000000b8
+
+#define REG_A4XX_RBBM_PERFCTR_PC_2_HI                          0x000000b9
+
+#define REG_A4XX_RBBM_PERFCTR_PC_3_LO                          0x000000ba
+
+#define REG_A4XX_RBBM_PERFCTR_PC_3_HI                          0x000000bb
+
+#define REG_A4XX_RBBM_PERFCTR_PC_4_LO                          0x000000bc
+
+#define REG_A4XX_RBBM_PERFCTR_PC_4_HI                          0x000000bd
+
+#define REG_A4XX_RBBM_PERFCTR_PC_5_LO                          0x000000be
+
+#define REG_A4XX_RBBM_PERFCTR_PC_5_HI                          0x000000bf
+
+#define REG_A4XX_RBBM_PERFCTR_PC_6_LO                          0x000000c0
+
+#define REG_A4XX_RBBM_PERFCTR_PC_6_HI                          0x000000c1
+
+#define REG_A4XX_RBBM_PERFCTR_PC_7_LO                          0x000000c2
+
+#define REG_A4XX_RBBM_PERFCTR_PC_7_HI                          0x000000c3
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_0_LO                         0x000000c4
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_0_HI                         0x000000c5
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_1_LO                         0x000000c6
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_1_HI                         0x000000c7
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_2_LO                         0x000000c8
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_2_HI                         0x000000c9
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_3_LO                         0x000000ca
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_3_HI                         0x000000cb
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_4_LO                         0x000000cc
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_4_HI                         0x000000cd
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_5_LO                         0x000000ce
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_5_HI                         0x000000cf
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_6_LO                         0x000000d0
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_6_HI                         0x000000d1
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_7_LO                         0x000000d2
+
+#define REG_A4XX_RBBM_PERFCTR_VFD_7_HI                         0x000000d3
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_0_LO                                0x000000d4
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_0_HI                                0x000000d5
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_1_LO                                0x000000d6
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_1_HI                                0x000000d7
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_2_LO                                0x000000d8
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_2_HI                                0x000000d9
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_3_LO                                0x000000da
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_3_HI                                0x000000db
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_4_LO                                0x000000dc
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_4_HI                                0x000000dd
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_5_LO                                0x000000de
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_5_HI                                0x000000df
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_6_LO                                0x000000e0
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_6_HI                                0x000000e1
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_7_LO                                0x000000e2
+
+#define REG_A4XX_RBBM_PERFCTR_HLSQ_7_HI                                0x000000e3
+
+#define REG_A4XX_RBBM_PERFCTR_VPC_0_LO                         0x000000e4
+
+#define REG_A4XX_RBBM_PERFCTR_VPC_0_HI                         0x000000e5
+
+#define REG_A4XX_RBBM_PERFCTR_VPC_1_LO                         0x000000e6
+
+#define REG_A4XX_RBBM_PERFCTR_VPC_1_HI                         0x000000e7
+
+#define REG_A4XX_RBBM_PERFCTR_VPC_2_LO                         0x000000e8
+
+#define REG_A4XX_RBBM_PERFCTR_VPC_2_HI                         0x000000e9
+
+#define REG_A4XX_RBBM_PERFCTR_VPC_3_LO                         0x000000ea
+
+#define REG_A4XX_RBBM_PERFCTR_VPC_3_HI                         0x000000eb
+
+#define REG_A4XX_RBBM_PERFCTR_CCU_0_LO                         0x000000ec
+
+#define REG_A4XX_RBBM_PERFCTR_CCU_0_HI                         0x000000ed
+
+#define REG_A4XX_RBBM_PERFCTR_CCU_1_LO                         0x000000ee
+
+#define REG_A4XX_RBBM_PERFCTR_CCU_1_HI                         0x000000ef
+
+#define REG_A4XX_RBBM_PERFCTR_CCU_2_LO                         0x000000f0
+
+#define REG_A4XX_RBBM_PERFCTR_CCU_2_HI                         0x000000f1
+
+#define REG_A4XX_RBBM_PERFCTR_CCU_3_LO                         0x000000f2
+
+#define REG_A4XX_RBBM_PERFCTR_CCU_3_HI                         0x000000f3
+
+#define REG_A4XX_RBBM_PERFCTR_TSE_0_LO                         0x000000f4
+
+#define REG_A4XX_RBBM_PERFCTR_TSE_0_HI                         0x000000f5
+
+#define REG_A4XX_RBBM_PERFCTR_TSE_1_LO                         0x000000f6
+
+#define REG_A4XX_RBBM_PERFCTR_TSE_1_HI                         0x000000f7
+
+#define REG_A4XX_RBBM_PERFCTR_TSE_2_LO                         0x000000f8
+
+#define REG_A4XX_RBBM_PERFCTR_TSE_2_HI                         0x000000f9
+
+#define REG_A4XX_RBBM_PERFCTR_TSE_3_LO                         0x000000fa
+
+#define REG_A4XX_RBBM_PERFCTR_TSE_3_HI                         0x000000fb
+
+#define REG_A4XX_RBBM_PERFCTR_RAS_0_LO                         0x000000fc
+
+#define REG_A4XX_RBBM_PERFCTR_RAS_0_HI                         0x000000fd
+
+#define REG_A4XX_RBBM_PERFCTR_RAS_1_LO                         0x000000fe
+
+#define REG_A4XX_RBBM_PERFCTR_RAS_1_HI                         0x000000ff
+
+#define REG_A4XX_RBBM_PERFCTR_RAS_2_LO                         0x00000100
+
+#define REG_A4XX_RBBM_PERFCTR_RAS_2_HI                         0x00000101
+
+#define REG_A4XX_RBBM_PERFCTR_RAS_3_LO                         0x00000102
+
+#define REG_A4XX_RBBM_PERFCTR_RAS_3_HI                         0x00000103
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_0_LO                                0x00000104
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_0_HI                                0x00000105
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_1_LO                                0x00000106
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_1_HI                                0x00000107
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_2_LO                                0x00000108
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_2_HI                                0x00000109
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_3_LO                                0x0000010a
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_3_HI                                0x0000010b
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_4_LO                                0x0000010c
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_4_HI                                0x0000010d
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_5_LO                                0x0000010e
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_5_HI                                0x0000010f
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_6_LO                                0x00000110
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_6_HI                                0x00000111
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_7_LO                                0x00000112
+
+#define REG_A4XX_RBBM_PERFCTR_UCHE_7_HI                                0x00000113
+
+#define REG_A4XX_RBBM_PERFCTR_TP_0_LO                          0x00000114
+
+#define REG_A4XX_RBBM_PERFCTR_TP_0_HI                          0x00000115
+
+#define REG_A4XX_RBBM_PERFCTR_TP_0_LO                          0x00000114
+
+#define REG_A4XX_RBBM_PERFCTR_TP_0_HI                          0x00000115
+
+#define REG_A4XX_RBBM_PERFCTR_TP_1_LO                          0x00000116
+
+#define REG_A4XX_RBBM_PERFCTR_TP_1_HI                          0x00000117
+
+#define REG_A4XX_RBBM_PERFCTR_TP_2_LO                          0x00000118
+
+#define REG_A4XX_RBBM_PERFCTR_TP_2_HI                          0x00000119
+
+#define REG_A4XX_RBBM_PERFCTR_TP_3_LO                          0x0000011a
+
+#define REG_A4XX_RBBM_PERFCTR_TP_3_HI                          0x0000011b
+
+#define REG_A4XX_RBBM_PERFCTR_TP_4_LO                          0x0000011c
+
+#define REG_A4XX_RBBM_PERFCTR_TP_4_HI                          0x0000011d
+
+#define REG_A4XX_RBBM_PERFCTR_TP_5_LO                          0x0000011e
+
+#define REG_A4XX_RBBM_PERFCTR_TP_5_HI                          0x0000011f
+
+#define REG_A4XX_RBBM_PERFCTR_TP_6_LO                          0x00000120
+
+#define REG_A4XX_RBBM_PERFCTR_TP_6_HI                          0x00000121
+
+#define REG_A4XX_RBBM_PERFCTR_TP_7_LO                          0x00000122
+
+#define REG_A4XX_RBBM_PERFCTR_TP_7_HI                          0x00000123
+
+#define REG_A4XX_RBBM_PERFCTR_SP_0_LO                          0x00000124
+
+#define REG_A4XX_RBBM_PERFCTR_SP_0_HI                          0x00000125
+
+#define REG_A4XX_RBBM_PERFCTR_SP_1_LO                          0x00000126
+
+#define REG_A4XX_RBBM_PERFCTR_SP_1_HI                          0x00000127
+
+#define REG_A4XX_RBBM_PERFCTR_SP_2_LO                          0x00000128
+
+#define REG_A4XX_RBBM_PERFCTR_SP_2_HI                          0x00000129
+
+#define REG_A4XX_RBBM_PERFCTR_SP_3_LO                          0x0000012a
+
+#define REG_A4XX_RBBM_PERFCTR_SP_3_HI                          0x0000012b
+
+#define REG_A4XX_RBBM_PERFCTR_SP_4_LO                          0x0000012c
+
+#define REG_A4XX_RBBM_PERFCTR_SP_4_HI                          0x0000012d
+
+#define REG_A4XX_RBBM_PERFCTR_SP_5_LO                          0x0000012e
+
+#define REG_A4XX_RBBM_PERFCTR_SP_5_HI                          0x0000012f
+
+#define REG_A4XX_RBBM_PERFCTR_SP_6_LO                          0x00000130
+
+#define REG_A4XX_RBBM_PERFCTR_SP_6_HI                          0x00000131
+
+#define REG_A4XX_RBBM_PERFCTR_SP_7_LO                          0x00000132
+
+#define REG_A4XX_RBBM_PERFCTR_SP_7_HI                          0x00000133
+
+#define REG_A4XX_RBBM_PERFCTR_SP_8_LO                          0x00000134
+
+#define REG_A4XX_RBBM_PERFCTR_SP_8_HI                          0x00000135
+
+#define REG_A4XX_RBBM_PERFCTR_SP_9_LO                          0x00000136
+
+#define REG_A4XX_RBBM_PERFCTR_SP_9_HI                          0x00000137
+
+#define REG_A4XX_RBBM_PERFCTR_SP_10_LO                         0x00000138
+
+#define REG_A4XX_RBBM_PERFCTR_SP_10_HI                         0x00000139
+
+#define REG_A4XX_RBBM_PERFCTR_SP_11_LO                         0x0000013a
+
+#define REG_A4XX_RBBM_PERFCTR_SP_11_HI                         0x0000013b
+
+#define REG_A4XX_RBBM_PERFCTR_RB_0_LO                          0x0000013c
+
+#define REG_A4XX_RBBM_PERFCTR_RB_0_HI                          0x0000013d
+
+#define REG_A4XX_RBBM_PERFCTR_RB_1_LO                          0x0000013e
+
+#define REG_A4XX_RBBM_PERFCTR_RB_1_HI                          0x0000013f
+
+#define REG_A4XX_RBBM_PERFCTR_RB_2_LO                          0x00000140
+
+#define REG_A4XX_RBBM_PERFCTR_RB_2_HI                          0x00000141
+
+#define REG_A4XX_RBBM_PERFCTR_RB_3_LO                          0x00000142
+
+#define REG_A4XX_RBBM_PERFCTR_RB_3_HI                          0x00000143
+
+#define REG_A4XX_RBBM_PERFCTR_RB_4_LO                          0x00000144
+
+#define REG_A4XX_RBBM_PERFCTR_RB_4_HI                          0x00000145
+
+#define REG_A4XX_RBBM_PERFCTR_RB_5_LO                          0x00000146
+
+#define REG_A4XX_RBBM_PERFCTR_RB_5_HI                          0x00000147
+
+#define REG_A4XX_RBBM_PERFCTR_RB_6_LO                          0x00000148
+
+#define REG_A4XX_RBBM_PERFCTR_RB_6_HI                          0x00000149
+
+#define REG_A4XX_RBBM_PERFCTR_RB_7_LO                          0x0000014a
+
+#define REG_A4XX_RBBM_PERFCTR_RB_7_HI                          0x0000014b
+
+#define REG_A4XX_RBBM_PERFCTR_VSC_0_LO                         0x0000014c
+
+#define REG_A4XX_RBBM_PERFCTR_VSC_0_HI                         0x0000014d
+
+#define REG_A4XX_RBBM_PERFCTR_VSC_1_LO                         0x0000014e
+
+#define REG_A4XX_RBBM_PERFCTR_VSC_1_HI                         0x0000014f
+
+#define REG_A4XX_RBBM_PERFCTR_PWR_0_LO                         0x00000166
+
+#define REG_A4XX_RBBM_PERFCTR_PWR_0_HI                         0x00000167
+
+#define REG_A4XX_RBBM_PERFCTR_PWR_1_LO                         0x00000168
+
+#define REG_A4XX_RBBM_PERFCTR_PWR_1_HI                         0x00000169
+
+#define REG_A4XX_RBBM_ALWAYSON_COUNTER_LO                      0x0000016e
+
+#define REG_A4XX_RBBM_ALWAYSON_COUNTER_HI                      0x0000016f
+
 static inline uint32_t REG_A4XX_RBBM_CLOCK_CTL_SP(uint32_t i0) { return 0x00000068 + 0x1*i0; }
 
 static inline uint32_t REG_A4XX_RBBM_CLOCK_CTL_SP_REG(uint32_t i0) { return 0x00000068 + 0x1*i0; }
@@ -1046,6 +2039,10 @@ static inline uint32_t REG_A4XX_RBBM_CLOCK_DELAY_RB_MARB_CCU_L1(uint32_t i0) { r
 
 static inline uint32_t REG_A4XX_RBBM_CLOCK_DELAY_RB_MARB_CCU_L1_REG(uint32_t i0) { return 0x0000008e + 0x1*i0; }
 
+#define REG_A4XX_RBBM_SP_REGFILE_SLEEP_CNTL_0                  0x00000099
+
+#define REG_A4XX_RBBM_SP_REGFILE_SLEEP_CNTL_1                  0x0000009a
+
 #define REG_A4XX_RBBM_PERFCTR_PWR_1_LO                         0x00000168
 
 #define REG_A4XX_RBBM_PERFCTR_CTL                              0x00000170
@@ -1060,6 +2057,14 @@ static inline uint32_t REG_A4XX_RBBM_CLOCK_DELAY_RB_MARB_CCU_L1_REG(uint32_t i0)
 
 #define REG_A4XX_RBBM_PERFCTR_LOAD_VALUE_HI                    0x00000175
 
+#define REG_A4XX_RBBM_PERFCTR_RBBM_SEL_0                       0x00000176
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_SEL_1                       0x00000177
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_SEL_2                       0x00000178
+
+#define REG_A4XX_RBBM_PERFCTR_RBBM_SEL_3                       0x00000179
+
 #define REG_A4XX_RBBM_GPU_BUSY_MASKED                          0x0000017a
 
 #define REG_A4XX_RBBM_INT_0_STATUS                             0x0000017d
@@ -1099,6 +2104,11 @@ static inline uint32_t REG_A4XX_RBBM_CLOCK_DELAY_RB_MARB_CCU_L1_REG(uint32_t i0)
 
 #define REG_A4XX_RBBM_INTERFACE_RRDY_STATUS5                   0x0000019f
 
+#define REG_A4XX_RBBM_POWER_STATUS                             0x000001b0
+#define A4XX_RBBM_POWER_STATUS_SP_TP_PWR_ON                    0x00100000
+
+#define REG_A4XX_RBBM_WAIT_IDLE_CLOCKS_CTL2                    0x000001b8
+
 #define REG_A4XX_CP_SCRATCH_UMASK                              0x00000228
 
 #define REG_A4XX_CP_SCRATCH_ADDR                               0x00000229
@@ -1191,6 +2201,20 @@ static inline uint32_t REG_A4XX_CP_PROTECT_REG(uint32_t i0) { return 0x00000240
 
 #define REG_A4XX_CP_PERFCTR_CP_SEL_0                           0x00000500
 
+#define REG_A4XX_CP_PERFCTR_CP_SEL_1                           0x00000501
+
+#define REG_A4XX_CP_PERFCTR_CP_SEL_2                           0x00000502
+
+#define REG_A4XX_CP_PERFCTR_CP_SEL_3                           0x00000503
+
+#define REG_A4XX_CP_PERFCTR_CP_SEL_4                           0x00000504
+
+#define REG_A4XX_CP_PERFCTR_CP_SEL_5                           0x00000505
+
+#define REG_A4XX_CP_PERFCTR_CP_SEL_6                           0x00000506
+
+#define REG_A4XX_CP_PERFCTR_CP_SEL_7                           0x00000507
+
 #define REG_A4XX_CP_PERFCOMBINER_SELECT                                0x0000050b
 
 static inline uint32_t REG_A4XX_CP_SCRATCH(uint32_t i0) { return 0x00000578 + 0x1*i0; }
@@ -1201,6 +2225,28 @@ static inline uint32_t REG_A4XX_CP_SCRATCH_REG(uint32_t i0) { return 0x00000578
 
 #define REG_A4XX_SP_MODE_CONTROL                               0x00000ec3
 
+#define REG_A4XX_SP_PERFCTR_SP_SEL_0                           0x00000ec4
+
+#define REG_A4XX_SP_PERFCTR_SP_SEL_1                           0x00000ec5
+
+#define REG_A4XX_SP_PERFCTR_SP_SEL_2                           0x00000ec6
+
+#define REG_A4XX_SP_PERFCTR_SP_SEL_3                           0x00000ec7
+
+#define REG_A4XX_SP_PERFCTR_SP_SEL_4                           0x00000ec8
+
+#define REG_A4XX_SP_PERFCTR_SP_SEL_5                           0x00000ec9
+
+#define REG_A4XX_SP_PERFCTR_SP_SEL_6                           0x00000eca
+
+#define REG_A4XX_SP_PERFCTR_SP_SEL_7                           0x00000ecb
+
+#define REG_A4XX_SP_PERFCTR_SP_SEL_8                           0x00000ecc
+
+#define REG_A4XX_SP_PERFCTR_SP_SEL_9                           0x00000ecd
+
+#define REG_A4XX_SP_PERFCTR_SP_SEL_10                          0x00000ece
+
 #define REG_A4XX_SP_PERFCTR_SP_SEL_11                          0x00000ecf
 
 #define REG_A4XX_SP_SP_CTRL_REG                                        0x000022c0
@@ -1699,6 +2745,12 @@ static inline uint32_t A4XX_SP_GS_OBJ_OFFSET_REG_SHADEROBJOFFSET(uint32_t val)
 
 #define REG_A4XX_VPC_DEBUG_ECO_CONTROL                         0x00000e64
 
+#define REG_A4XX_VPC_PERFCTR_VPC_SEL_0                         0x00000e65
+
+#define REG_A4XX_VPC_PERFCTR_VPC_SEL_1                         0x00000e66
+
+#define REG_A4XX_VPC_PERFCTR_VPC_SEL_2                         0x00000e67
+
 #define REG_A4XX_VPC_PERFCTR_VPC_SEL_3                         0x00000e68
 
 #define REG_A4XX_VPC_ATTR                                      0x00002140
@@ -1811,6 +2863,20 @@ static inline uint32_t REG_A4XX_VSC_PIPE_DATA_LENGTH_REG(uint32_t i0) { return 0
 
 #define REG_A4XX_VFD_DEBUG_CONTROL                             0x00000e40
 
+#define REG_A4XX_VFD_PERFCTR_VFD_SEL_0                         0x00000e43
+
+#define REG_A4XX_VFD_PERFCTR_VFD_SEL_1                         0x00000e44
+
+#define REG_A4XX_VFD_PERFCTR_VFD_SEL_2                         0x00000e45
+
+#define REG_A4XX_VFD_PERFCTR_VFD_SEL_3                         0x00000e46
+
+#define REG_A4XX_VFD_PERFCTR_VFD_SEL_4                         0x00000e47
+
+#define REG_A4XX_VFD_PERFCTR_VFD_SEL_5                         0x00000e48
+
+#define REG_A4XX_VFD_PERFCTR_VFD_SEL_6                         0x00000e49
+
 #define REG_A4XX_VFD_PERFCTR_VFD_SEL_7                         0x00000e4a
 
 #define REG_A4XX_VGT_CL_INITIATOR                              0x000021d0
@@ -1967,6 +3033,20 @@ static inline uint32_t A4XX_VFD_DECODE_INSTR_SHIFTCNT(uint32_t val)
 
 #define REG_A4XX_TPL1_TP_MODE_CONTROL                          0x00000f03
 
+#define REG_A4XX_TPL1_PERFCTR_TP_SEL_0                         0x00000f04
+
+#define REG_A4XX_TPL1_PERFCTR_TP_SEL_1                         0x00000f05
+
+#define REG_A4XX_TPL1_PERFCTR_TP_SEL_2                         0x00000f06
+
+#define REG_A4XX_TPL1_PERFCTR_TP_SEL_3                         0x00000f07
+
+#define REG_A4XX_TPL1_PERFCTR_TP_SEL_4                         0x00000f08
+
+#define REG_A4XX_TPL1_PERFCTR_TP_SEL_5                         0x00000f09
+
+#define REG_A4XX_TPL1_PERFCTR_TP_SEL_6                         0x00000f0a
+
 #define REG_A4XX_TPL1_PERFCTR_TP_SEL_7                         0x00000f0b
 
 #define REG_A4XX_TPL1_TP_TEX_OFFSET                            0x00002380
@@ -2021,9 +3101,23 @@ static inline uint32_t A4XX_TPL1_TP_TEX_COUNT_GS(uint32_t val)
 
 #define REG_A4XX_GRAS_PERFCTR_TSE_SEL_0                                0x00000c88
 
+#define REG_A4XX_GRAS_PERFCTR_TSE_SEL_1                                0x00000c89
+
+#define REG_A4XX_GRAS_PERFCTR_TSE_SEL_2                                0x00000c8a
+
 #define REG_A4XX_GRAS_PERFCTR_TSE_SEL_3                                0x00000c8b
 
+#define REG_A4XX_GRAS_PERFCTR_RAS_SEL_0                                0x00000c8c
+
+#define REG_A4XX_GRAS_PERFCTR_RAS_SEL_1                                0x00000c8d
+
+#define REG_A4XX_GRAS_PERFCTR_RAS_SEL_2                                0x00000c8e
+
+#define REG_A4XX_GRAS_PERFCTR_RAS_SEL_3                                0x00000c8f
+
 #define REG_A4XX_GRAS_CL_CLIP_CNTL                             0x00002000
+#define A4XX_GRAS_CL_CLIP_CNTL_CLIP_DISABLE                    0x00008000
+#define A4XX_GRAS_CL_CLIP_CNTL_ZERO_GB_SCALE_Z                 0x00400000
 
 #define REG_A4XX_GRAS_CLEAR_CNTL                               0x00002003
 #define A4XX_GRAS_CLEAR_CNTL_NOT_FASTCLEAR                     0x00000001
@@ -2114,6 +3208,7 @@ static inline uint32_t A4XX_GRAS_SU_POINT_SIZE(float val)
 
 #define REG_A4XX_GRAS_ALPHA_CONTROL                            0x00002073
 #define A4XX_GRAS_ALPHA_CONTROL_ALPHA_TEST_ENABLE              0x00000004
+#define A4XX_GRAS_ALPHA_CONTROL_FORCE_FRAGZ_TO_FS              0x00000008
 
 #define REG_A4XX_GRAS_SU_POLY_OFFSET_SCALE                     0x00002074
 #define A4XX_GRAS_SU_POLY_OFFSET_SCALE__MASK                   0xffffffff
@@ -2285,6 +3380,20 @@ static inline uint32_t A4XX_GRAS_SC_EXTENT_WINDOW_TL_Y(uint32_t val)
 
 #define REG_A4XX_UCHE_CACHE_WAYS_VFD                           0x00000e8c
 
+#define REG_A4XX_UCHE_PERFCTR_UCHE_SEL_0                       0x00000e8e
+
+#define REG_A4XX_UCHE_PERFCTR_UCHE_SEL_1                       0x00000e8f
+
+#define REG_A4XX_UCHE_PERFCTR_UCHE_SEL_2                       0x00000e90
+
+#define REG_A4XX_UCHE_PERFCTR_UCHE_SEL_3                       0x00000e91
+
+#define REG_A4XX_UCHE_PERFCTR_UCHE_SEL_4                       0x00000e92
+
+#define REG_A4XX_UCHE_PERFCTR_UCHE_SEL_5                       0x00000e93
+
+#define REG_A4XX_UCHE_PERFCTR_UCHE_SEL_6                       0x00000e94
+
 #define REG_A4XX_UCHE_PERFCTR_UCHE_SEL_7                       0x00000e95
 
 #define REG_A4XX_HLSQ_TIMEOUT_THRESHOLD                                0x00000e00
@@ -2295,6 +3404,22 @@ static inline uint32_t A4XX_GRAS_SC_EXTENT_WINDOW_TL_Y(uint32_t val)
 
 #define REG_A4XX_HLSQ_PERF_PIPE_MASK                           0x00000e0e
 
+#define REG_A4XX_HLSQ_PERFCTR_HLSQ_SEL_0                       0x00000e06
+
+#define REG_A4XX_HLSQ_PERFCTR_HLSQ_SEL_1                       0x00000e07
+
+#define REG_A4XX_HLSQ_PERFCTR_HLSQ_SEL_2                       0x00000e08
+
+#define REG_A4XX_HLSQ_PERFCTR_HLSQ_SEL_3                       0x00000e09
+
+#define REG_A4XX_HLSQ_PERFCTR_HLSQ_SEL_4                       0x00000e0a
+
+#define REG_A4XX_HLSQ_PERFCTR_HLSQ_SEL_5                       0x00000e0b
+
+#define REG_A4XX_HLSQ_PERFCTR_HLSQ_SEL_6                       0x00000e0c
+
+#define REG_A4XX_HLSQ_PERFCTR_HLSQ_SEL_7                       0x00000e0d
+
 #define REG_A4XX_HLSQ_CONTROL_0_REG                            0x000023c0
 #define A4XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__MASK             0x00000010
 #define A4XX_HLSQ_CONTROL_0_REG_FSTHREADSIZE__SHIFT            4
@@ -2549,6 +3674,18 @@ static inline uint32_t A4XX_HLSQ_GS_CONTROL_REG_INSTRLENGTH(uint32_t val)
 
 #define REG_A4XX_PC_PERFCTR_PC_SEL_0                           0x00000d10
 
+#define REG_A4XX_PC_PERFCTR_PC_SEL_1                           0x00000d11
+
+#define REG_A4XX_PC_PERFCTR_PC_SEL_2                           0x00000d12
+
+#define REG_A4XX_PC_PERFCTR_PC_SEL_3                           0x00000d13
+
+#define REG_A4XX_PC_PERFCTR_PC_SEL_4                           0x00000d14
+
+#define REG_A4XX_PC_PERFCTR_PC_SEL_5                           0x00000d15
+
+#define REG_A4XX_PC_PERFCTR_PC_SEL_6                           0x00000d16
+
 #define REG_A4XX_PC_PERFCTR_PC_SEL_7                           0x00000d17
 
 #define REG_A4XX_PC_BIN_BASE                                   0x000021c0
@@ -2564,7 +3701,20 @@ static inline uint32_t A4XX_PC_PRIM_VTX_CNTL_VAROUT(uint32_t val)
 #define A4XX_PC_PRIM_VTX_CNTL_PROVOKING_VTX_LAST               0x02000000
 #define A4XX_PC_PRIM_VTX_CNTL_PSIZE                            0x04000000
 
-#define REG_A4XX_UNKNOWN_21C5                                  0x000021c5
+#define REG_A4XX_PC_PRIM_VTX_CNTL2                             0x000021c5
+#define A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE__MASK      0x00000007
+#define A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE__SHIFT     0
+static inline uint32_t A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE(enum adreno_pa_su_sc_draw val)
+{
+       return ((val) << A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE__SHIFT) & A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_FRONT_PTYPE__MASK;
+}
+#define A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE__MASK       0x00000038
+#define A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE__SHIFT      3
+static inline uint32_t A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE(enum adreno_pa_su_sc_draw val)
+{
+       return ((val) << A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE__SHIFT) & A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_BACK_PTYPE__MASK;
+}
+#define A4XX_PC_PRIM_VTX_CNTL2_POLYMODE_ENABLE                 0x00000040
 
 #define REG_A4XX_PC_RESTART_INDEX                              0x000021c6
 
@@ -2646,20 +3796,6 @@ static inline uint32_t A4XX_PC_HS_PARAM_PRIMTYPE(enum adreno_pa_su_sc_draw val)
 
 #define REG_A4XX_UNKNOWN_20EF                                  0x000020ef
 
-#define REG_A4XX_UNKNOWN_20F0                                  0x000020f0
-
-#define REG_A4XX_UNKNOWN_20F1                                  0x000020f1
-
-#define REG_A4XX_UNKNOWN_20F2                                  0x000020f2
-
-#define REG_A4XX_UNKNOWN_20F7                                  0x000020f7
-#define A4XX_UNKNOWN_20F7__MASK                                        0xffffffff
-#define A4XX_UNKNOWN_20F7__SHIFT                               0
-static inline uint32_t A4XX_UNKNOWN_20F7(float val)
-{
-       return ((fui(val)) << A4XX_UNKNOWN_20F7__SHIFT) & A4XX_UNKNOWN_20F7__MASK;
-}
-
 #define REG_A4XX_UNKNOWN_2152                                  0x00002152
 
 #define REG_A4XX_UNKNOWN_2153                                  0x00002153
@@ -2720,6 +3856,12 @@ static inline uint32_t A4XX_TEX_SAMP_0_ANISO(enum a4xx_tex_aniso val)
 {
        return ((val) << A4XX_TEX_SAMP_0_ANISO__SHIFT) & A4XX_TEX_SAMP_0_ANISO__MASK;
 }
+#define A4XX_TEX_SAMP_0_LOD_BIAS__MASK                         0xfff80000
+#define A4XX_TEX_SAMP_0_LOD_BIAS__SHIFT                                19
+static inline uint32_t A4XX_TEX_SAMP_0_LOD_BIAS(float val)
+{
+       return ((((int32_t)(val * 256.0))) << A4XX_TEX_SAMP_0_LOD_BIAS__SHIFT) & A4XX_TEX_SAMP_0_LOD_BIAS__MASK;
+}
 
 #define REG_A4XX_TEX_SAMP_1                                    0x00000001
 #define A4XX_TEX_SAMP_1_COMPARE_FUNC__MASK                     0x0000000e
@@ -2728,6 +3870,7 @@ static inline uint32_t A4XX_TEX_SAMP_1_COMPARE_FUNC(enum adreno_compare_func val
 {
        return ((val) << A4XX_TEX_SAMP_1_COMPARE_FUNC__SHIFT) & A4XX_TEX_SAMP_1_COMPARE_FUNC__MASK;
 }
+#define A4XX_TEX_SAMP_1_CUBEMAPSEAMLESSFILTOFF                 0x00000010
 #define A4XX_TEX_SAMP_1_UNNORM_COORDS                          0x00000020
 #define A4XX_TEX_SAMP_1_MIPFILTER_LINEAR_FAR                   0x00000040
 #define A4XX_TEX_SAMP_1_MAX_LOD__MASK                          0x000fff00
@@ -2796,7 +3939,7 @@ static inline uint32_t A4XX_TEX_CONST_1_HEIGHT(uint32_t val)
 {
        return ((val) << A4XX_TEX_CONST_1_HEIGHT__SHIFT) & A4XX_TEX_CONST_1_HEIGHT__MASK;
 }
-#define A4XX_TEX_CONST_1_WIDTH__MASK                           0x1fff8000
+#define A4XX_TEX_CONST_1_WIDTH__MASK                           0x3fff8000
 #define A4XX_TEX_CONST_1_WIDTH__SHIFT                          15
 static inline uint32_t A4XX_TEX_CONST_1_WIDTH(uint32_t val)
 {
index a53f1be..d0d3c7b 100644 (file)
@@ -102,11 +102,17 @@ static void a4xx_enable_hwcg(struct msm_gpu *gpu)
        gpu_write(gpu, REG_A4XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x00000222);
        gpu_write(gpu, REG_A4XX_RBBM_CLOCK_CTL_HLSQ , 0x00000000);
        gpu_write(gpu, REG_A4XX_RBBM_CLOCK_HYST_HLSQ, 0x00000000);
-       gpu_write(gpu, REG_A4XX_RBBM_CLOCK_DELAY_HLSQ, 0x00020000);
-       gpu_write(gpu, REG_A4XX_RBBM_CLOCK_CTL, 0xAAAAAAAA);
+       gpu_write(gpu, REG_A4XX_RBBM_CLOCK_DELAY_HLSQ, 0x00220000);
+       /* Early A430's have a timing issue with SP/TP power collapse;
+          disabling HW clock gating prevents it. */
+       if (adreno_is_a430(adreno_gpu) && adreno_gpu->rev.patchid < 2)
+               gpu_write(gpu, REG_A4XX_RBBM_CLOCK_CTL, 0);
+       else
+               gpu_write(gpu, REG_A4XX_RBBM_CLOCK_CTL, 0xAAAAAAAA);
        gpu_write(gpu, REG_A4XX_RBBM_CLOCK_CTL2, 0);
 }
 
+
 static void a4xx_me_init(struct msm_gpu *gpu)
 {
        struct msm_ringbuffer *ring = gpu->rb;
@@ -141,7 +147,7 @@ static int a4xx_hw_init(struct msm_gpu *gpu)
        uint32_t *ptr, len;
        int i, ret;
 
-       if (adreno_is_a4xx(adreno_gpu)) {
+       if (adreno_is_a420(adreno_gpu)) {
                gpu_write(gpu, REG_A4XX_VBIF_ABIT_SORT, 0x0001001F);
                gpu_write(gpu, REG_A4XX_VBIF_ABIT_SORT_CONF, 0x000000A4);
                gpu_write(gpu, REG_A4XX_VBIF_GATE_OFF_WRREQ_EN, 0x00000001);
@@ -150,6 +156,13 @@ static int a4xx_hw_init(struct msm_gpu *gpu)
                gpu_write(gpu, REG_A4XX_VBIF_IN_WR_LIM_CONF0, 0x18181818);
                gpu_write(gpu, REG_A4XX_VBIF_IN_WR_LIM_CONF1, 0x00000018);
                gpu_write(gpu, REG_A4XX_VBIF_ROUND_ROBIN_QOS_ARB, 0x00000003);
+       } else if (adreno_is_a430(adreno_gpu)) {
+               gpu_write(gpu, REG_A4XX_VBIF_GATE_OFF_WRREQ_EN, 0x00000001);
+               gpu_write(gpu, REG_A4XX_VBIF_IN_RD_LIM_CONF0, 0x18181818);
+               gpu_write(gpu, REG_A4XX_VBIF_IN_RD_LIM_CONF1, 0x00000018);
+               gpu_write(gpu, REG_A4XX_VBIF_IN_WR_LIM_CONF0, 0x18181818);
+               gpu_write(gpu, REG_A4XX_VBIF_IN_WR_LIM_CONF1, 0x00000018);
+               gpu_write(gpu, REG_A4XX_VBIF_ROUND_ROBIN_QOS_ARB, 0x00000003);
        } else {
                BUG();
        }
@@ -161,6 +174,10 @@ static int a4xx_hw_init(struct msm_gpu *gpu)
        gpu_write(gpu, REG_A4XX_RBBM_SP_HYST_CNT, 0x10);
        gpu_write(gpu, REG_A4XX_RBBM_WAIT_IDLE_CLOCKS_CTL, 0x10);
 
+       if (adreno_is_a430(adreno_gpu)) {
+               gpu_write(gpu, REG_A4XX_RBBM_WAIT_IDLE_CLOCKS_CTL2, 0x30);
+       }
+
         /* Enable the RBBM error reporting bits */
        gpu_write(gpu, REG_A4XX_RBBM_AHB_CTL0, 0x00000001);
 
@@ -183,6 +200,14 @@ static int a4xx_hw_init(struct msm_gpu *gpu)
        /* Turn on performance counters: */
        gpu_write(gpu, REG_A4XX_RBBM_PERFCTR_CTL, 0x01);
 
+       /* use the first CP counter for timestamp queries.. userspace may set
+        * this as well but it selects the same counter/countable:
+        */
+       gpu_write(gpu, REG_A4XX_CP_PERFCTR_CP_SEL_0, CP_ALWAYS_COUNT);
+
+       if (adreno_is_a430(adreno_gpu))
+               gpu_write(gpu, REG_A4XX_UCHE_CACHE_WAYS_VFD, 0x07);
+
        /* Disable L2 bypass to avoid UCHE out of bounds errors */
        gpu_write(gpu, REG_A4XX_UCHE_TRAP_BASE_LO, 0xffff0000);
        gpu_write(gpu, REG_A4XX_UCHE_TRAP_BASE_HI, 0xffff0000);
@@ -190,6 +215,15 @@ static int a4xx_hw_init(struct msm_gpu *gpu)
        gpu_write(gpu, REG_A4XX_CP_DEBUG, (1 << 25) |
                        (adreno_is_a420(adreno_gpu) ? (1 << 29) : 0));
 
+       /* On A430 enable SP regfile sleep for power savings */
+       /* TODO downstream does this for !420, so maybe applies for 405 too? */
+       if (!adreno_is_a420(adreno_gpu)) {
+               gpu_write(gpu, REG_A4XX_RBBM_SP_REGFILE_SLEEP_CNTL_0,
+                       0x00000441);
+               gpu_write(gpu, REG_A4XX_RBBM_SP_REGFILE_SLEEP_CNTL_1,
+                       0x00000441);
+       }
+
        a4xx_enable_hwcg(gpu);
 
        /*
@@ -204,10 +238,6 @@ static int a4xx_hw_init(struct msm_gpu *gpu)
                gpu_write(gpu, REG_A4XX_RBBM_CLOCK_DELAY_HLSQ, val);
        }
 
-       ret = adreno_hw_init(gpu);
-       if (ret)
-               return ret;
-
        /* setup access protection: */
        gpu_write(gpu, REG_A4XX_CP_PROTECT_CTRL, 0x00000007);
 
@@ -263,6 +293,7 @@ static int a4xx_hw_init(struct msm_gpu *gpu)
        gpu_write(gpu, REG_A4XX_CP_ME_CNTL, 0);
 
        a4xx_me_init(gpu);
+
        return 0;
 }
 
@@ -317,6 +348,13 @@ static irqreturn_t a4xx_irq(struct msm_gpu *gpu)
        status = gpu_read(gpu, REG_A4XX_RBBM_INT_0_STATUS);
        DBG("%s: Int status %08x", gpu->name, status);
 
+       if (status & A4XX_INT0_CP_REG_PROTECT_FAULT) {
+               uint32_t reg = gpu_read(gpu, REG_A4XX_CP_PROTECT_STATUS);
+               printk("CP | Protected mode error| %s | addr=%x\n",
+                       reg & (1 << 24) ? "WRITE" : "READ",
+                       (reg & 0xFFFFF) >> 2);
+       }
+
        gpu_write(gpu, REG_A4XX_RBBM_INT_CLEAR_CMD, status);
 
        msm_gpu_retire(gpu);
@@ -512,12 +550,63 @@ static void a4xx_dump(struct msm_gpu *gpu)
        adreno_dump(gpu);
 }
 
+static int a4xx_pm_resume(struct msm_gpu *gpu) {
+       struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
+       int ret;
+
+       ret = msm_gpu_pm_resume(gpu);
+       if (ret)
+               return ret;
+
+       if (adreno_is_a430(adreno_gpu)) {
+               unsigned int reg;
+               /* Set the default register values; set SW_COLLAPSE to 0 */
+               gpu_write(gpu, REG_A4XX_RBBM_POWER_CNTL_IP, 0x778000);
+               do {
+                       udelay(5);
+                       reg = gpu_read(gpu, REG_A4XX_RBBM_POWER_STATUS);
+               } while (!(reg & A4XX_RBBM_POWER_CNTL_IP_SP_TP_PWR_ON));
+       }
+       return 0;
+}
+
+static int a4xx_pm_suspend(struct msm_gpu *gpu) {
+       struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
+       int ret;
+
+       ret = msm_gpu_pm_suspend(gpu);
+       if (ret)
+               return ret;
+
+       if (adreno_is_a430(adreno_gpu)) {
+               /* Set the default register values; set SW_COLLAPSE to 1 */
+               gpu_write(gpu, REG_A4XX_RBBM_POWER_CNTL_IP, 0x778001);
+       }
+       return 0;
+}
+
+static int a4xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value)
+{
+       uint32_t hi, lo, tmp;
+
+       tmp = gpu_read(gpu, REG_A4XX_RBBM_PERFCTR_CP_0_HI);
+       do {
+               hi = tmp;
+               lo = gpu_read(gpu, REG_A4XX_RBBM_PERFCTR_CP_0_LO);
+               tmp = gpu_read(gpu, REG_A4XX_RBBM_PERFCTR_CP_0_HI);
+       } while (tmp != hi);
+
+       *value = (((uint64_t)hi) << 32) | lo;
+
+       return 0;
+}
+
 static const struct adreno_gpu_funcs funcs = {
        .base = {
                .get_param = adreno_get_param,
                .hw_init = a4xx_hw_init,
-               .pm_suspend = msm_gpu_pm_suspend,
-               .pm_resume = msm_gpu_pm_resume,
+               .pm_suspend = a4xx_pm_suspend,
+               .pm_resume = a4xx_pm_resume,
                .recover = a4xx_recover,
                .last_fence = adreno_last_fence,
                .submit = adreno_submit,
@@ -529,6 +618,7 @@ static const struct adreno_gpu_funcs funcs = {
                .show = a4xx_show,
 #endif
        },
+       .get_timestamp = a4xx_get_timestamp,
 };
 
 struct msm_gpu *a4xx_gpu_init(struct drm_device *dev)
index c304468..e81481d 100644 (file)
@@ -9,16 +9,17 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/adreno.xml               (    398 bytes, from 2015-09-24 17:25:31)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml  (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml  (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml          (  32901 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml (  10755 bytes, from 2015-09-14 20:46:55)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml    (  14968 bytes, from 2015-05-20 20:12:27)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml          (  67771 bytes, from 2015-09-14 20:46:55)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml          (  63970 bytes, from 2015-09-14 20:50:12)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml (  11518 bytes, from 2016-02-10 21:03:25)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml    (  16166 bytes, from 2016-02-11 21:20:31)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml          (  83967 bytes, from 2016-02-10 17:07:21)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml          ( 109916 bytes, from 2016-02-20 18:44:48)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno/ocmem.xml         (   1773 bytes, from 2015-09-24 17:30:00)
 
-Copyright (C) 2013-2015 by the following authors:
+Copyright (C) 2013-2016 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
@@ -119,6 +120,23 @@ enum adreno_rb_copy_control_mode {
        RB_COPY_DEPTH_STENCIL = 5,
 };
 
+enum a3xx_rop_code {
+       ROP_CLEAR = 0,
+       ROP_NOR = 1,
+       ROP_AND_INVERTED = 2,
+       ROP_COPY_INVERTED = 3,
+       ROP_AND_REVERSE = 4,
+       ROP_INVERT = 5,
+       ROP_NAND = 7,
+       ROP_AND = 8,
+       ROP_EQUIV = 9,
+       ROP_NOOP = 10,
+       ROP_OR_INVERTED = 11,
+       ROP_OR_REVERSE = 13,
+       ROP_OR = 14,
+       ROP_SET = 15,
+};
+
 enum a3xx_render_mode {
        RB_RENDERING_PASS = 0,
        RB_TILING_PASS = 1,
index 950d27d..5127b75 100644 (file)
@@ -69,6 +69,14 @@ static const struct adreno_info gpulist[] = {
                .pfpfw = "a420_pfp.fw",
                .gmem  = (SZ_1M + SZ_512K),
                .init  = a4xx_gpu_init,
+       }, {
+               .rev   = ADRENO_REV(4, 3, 0, ANY_ID),
+               .revn  = 430,
+               .name  = "A430",
+               .pm4fw = "a420_pm4.fw",
+               .pfpfw = "a420_pfp.fw",
+               .gmem  = (SZ_1M + SZ_512K),
+               .init  = a4xx_gpu_init,
        },
 };
 
index 0e1d0c5..4951172 100644 (file)
@@ -44,6 +44,10 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)
        case MSM_PARAM_MAX_FREQ:
                *value = adreno_gpu->base.fast_rate;
                return 0;
+       case MSM_PARAM_TIMESTAMP:
+               if (adreno_gpu->funcs->get_timestamp)
+                       return adreno_gpu->funcs->get_timestamp(gpu, value);
+               return -EINVAL;
        default:
                DBG("%s: invalid param: %u", gpu->name, param);
                return -EINVAL;
@@ -71,18 +75,15 @@ int adreno_hw_init(struct msm_gpu *gpu)
        adreno_gpu_write(adreno_gpu, REG_ADRENO_CP_RB_CNTL,
                        /* size is log2(quad-words): */
                        AXXX_CP_RB_CNTL_BUFSZ(ilog2(gpu->rb->size / 8)) |
-                       AXXX_CP_RB_CNTL_BLKSZ(ilog2(RB_BLKSIZE / 8)));
+                       AXXX_CP_RB_CNTL_BLKSZ(ilog2(RB_BLKSIZE / 8)) |
+                       (adreno_is_a430(adreno_gpu) ? AXXX_CP_RB_CNTL_NO_UPDATE : 0));
 
        /* Setup ringbuffer address: */
        adreno_gpu_write(adreno_gpu, REG_ADRENO_CP_RB_BASE, gpu->rb_iova);
-       adreno_gpu_write(adreno_gpu, REG_ADRENO_CP_RB_RPTR_ADDR,
-                       rbmemptr(adreno_gpu, rptr));
-
-       /* Setup scratch/timestamp: */
-       adreno_gpu_write(adreno_gpu, REG_ADRENO_SCRATCH_ADDR,
-                       rbmemptr(adreno_gpu, fence));
 
-       adreno_gpu_write(adreno_gpu, REG_ADRENO_SCRATCH_UMSK, 0x1);
+       if (!adreno_is_a430(adreno_gpu))
+               adreno_gpu_write(adreno_gpu, REG_ADRENO_CP_RB_RPTR_ADDR,
+                                               rbmemptr(adreno_gpu, rptr));
 
        return 0;
 }
@@ -92,6 +93,16 @@ static uint32_t get_wptr(struct msm_ringbuffer *ring)
        return ring->cur - ring->start;
 }
 
+/* Use this helper to read rptr, since a430 doesn't update rptr in memory */
+static uint32_t get_rptr(struct adreno_gpu *adreno_gpu)
+{
+       if (adreno_is_a430(adreno_gpu))
+               return adreno_gpu->memptrs->rptr = adreno_gpu_read(
+                       adreno_gpu, REG_ADRENO_CP_RB_RPTR);
+       else
+               return adreno_gpu->memptrs->rptr;
+}
+
 uint32_t adreno_last_fence(struct msm_gpu *gpu)
 {
        struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
@@ -140,7 +151,8 @@ int adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
                        if (priv->lastctx == ctx)
                                break;
                case MSM_SUBMIT_CMD_BUF:
-                       OUT_PKT3(ring, CP_INDIRECT_BUFFER_PFD, 2);
+                       OUT_PKT3(ring, adreno_is_a430(adreno_gpu) ?
+                               CP_INDIRECT_BUFFER_PFE : CP_INDIRECT_BUFFER_PFD, 2);
                        OUT_RING(ring, submit->cmd[i].iova);
                        OUT_RING(ring, submit->cmd[i].size);
                        ibs++;
@@ -219,9 +231,12 @@ void adreno_idle(struct msm_gpu *gpu)
 {
        struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
        uint32_t wptr = get_wptr(gpu->rb);
+       int ret;
 
        /* wait for CP to drain ringbuffer: */
-       if (spin_until(adreno_gpu->memptrs->rptr == wptr))
+       ret = spin_until(get_rptr(adreno_gpu) == wptr);
+
+       if (ret)
                DRM_ERROR("%s: timeout waiting to drain ringbuffer!\n", gpu->name);
 
        /* TODO maybe we need to reset GPU here to recover from hang? */
@@ -240,7 +255,7 @@ void adreno_show(struct msm_gpu *gpu, struct seq_file *m)
 
        seq_printf(m, "fence:    %d/%d\n", adreno_gpu->memptrs->fence,
                        gpu->submitted_fence);
-       seq_printf(m, "rptr:     %d\n", adreno_gpu->memptrs->rptr);
+       seq_printf(m, "rptr:     %d\n", get_rptr(adreno_gpu));
        seq_printf(m, "wptr:     %d\n", adreno_gpu->memptrs->wptr);
        seq_printf(m, "rb wptr:  %d\n", get_wptr(gpu->rb));
 
@@ -281,7 +296,7 @@ void adreno_dump_info(struct msm_gpu *gpu)
 
        printk("fence:    %d/%d\n", adreno_gpu->memptrs->fence,
                        gpu->submitted_fence);
-       printk("rptr:     %d\n", adreno_gpu->memptrs->rptr);
+       printk("rptr:     %d\n", get_rptr(adreno_gpu));
        printk("wptr:     %d\n", adreno_gpu->memptrs->wptr);
        printk("rb wptr:  %d\n", get_wptr(gpu->rb));
 
@@ -316,7 +331,7 @@ static uint32_t ring_freewords(struct msm_gpu *gpu)
        struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
        uint32_t size = gpu->rb->size / 4;
        uint32_t wptr = get_wptr(gpu->rb);
-       uint32_t rptr = adreno_gpu->memptrs->rptr;
+       uint32_t rptr = get_rptr(adreno_gpu);
        return (rptr + (size - 1) - wptr) % size;
 }
 
index 0a312e9..1d07511 100644 (file)
@@ -114,6 +114,7 @@ struct adreno_rev {
 
 struct adreno_gpu_funcs {
        struct msm_gpu_funcs base;
+       int (*get_timestamp)(struct msm_gpu *gpu, uint64_t *value);
 };
 
 struct adreno_info {
@@ -228,6 +229,11 @@ static inline int adreno_is_a420(struct adreno_gpu *gpu)
        return gpu->revn == 420;
 }
 
+static inline int adreno_is_a430(struct adreno_gpu *gpu)
+{
+       return gpu->revn == 430;
+}
+
 int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value);
 int adreno_hw_init(struct msm_gpu *gpu);
 uint32_t adreno_last_fence(struct msm_gpu *gpu);
index a22fef5..d7477ff 100644 (file)
@@ -9,16 +9,17 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/adreno.xml               (    398 bytes, from 2015-09-24 17:25:31)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml  (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml  (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno/a2xx.xml          (  32901 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml (  10755 bytes, from 2015-09-14 20:46:55)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml    (  14968 bytes, from 2015-05-20 20:12:27)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml          (  67771 bytes, from 2015-09-14 20:46:55)
-- /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml          (  63970 bytes, from 2015-09-14 20:50:12)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_common.xml (  11518 bytes, from 2016-02-10 21:03:25)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/adreno_pm4.xml    (  16166 bytes, from 2016-02-11 21:20:31)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/a3xx.xml          (  83967 bytes, from 2016-02-10 17:07:21)
+- /home/robclark/src/freedreno/envytools/rnndb/adreno/a4xx.xml          ( 109916 bytes, from 2016-02-20 18:44:48)
 - /home/robclark/src/freedreno/envytools/rnndb/adreno/ocmem.xml         (   1773 bytes, from 2015-09-24 17:30:00)
 
-Copyright (C) 2013-2015 by the following authors:
+Copyright (C) 2013-2016 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
@@ -172,6 +173,11 @@ enum adreno_pm4_type3_packets {
        CP_UNKNOWN_1A = 26,
        CP_UNKNOWN_4E = 78,
        CP_WIDE_REG_WRITE = 116,
+       CP_SCRATCH_TO_REG = 77,
+       CP_REG_TO_SCRATCH = 74,
+       CP_WAIT_MEM_WRITES = 18,
+       CP_COND_REG_EXEC = 71,
+       CP_MEM_TO_REG = 66,
        IN_IB_PREFETCH_END = 23,
        IN_SUBBLK_PREFETCH = 31,
        IN_INSTR_PREFETCH = 32,
@@ -199,7 +205,11 @@ enum adreno_state_type {
 
 enum adreno_state_src {
        SS_DIRECT = 0,
+       SS_INVALID_ALL_IC = 2,
+       SS_INVALID_PART_IC = 3,
        SS_INDIRECT = 4,
+       SS_INDIRECT_TCM = 5,
+       SS_INDIRECT_STM = 6,
 };
 
 enum a4xx_index_size {
@@ -227,7 +237,7 @@ static inline uint32_t CP_LOAD_STATE_0_STATE_BLOCK(enum adreno_state_block val)
 {
        return ((val) << CP_LOAD_STATE_0_STATE_BLOCK__SHIFT) & CP_LOAD_STATE_0_STATE_BLOCK__MASK;
 }
-#define CP_LOAD_STATE_0_NUM_UNIT__MASK                         0x7fc00000
+#define CP_LOAD_STATE_0_NUM_UNIT__MASK                         0xffc00000
 #define CP_LOAD_STATE_0_NUM_UNIT__SHIFT                                22
 static inline uint32_t CP_LOAD_STATE_0_NUM_UNIT(uint32_t val)
 {
@@ -499,5 +509,29 @@ static inline uint32_t CP_SET_BIN_DATA_1_BIN_SIZE_ADDRESS(uint32_t val)
        return ((val) << CP_SET_BIN_DATA_1_BIN_SIZE_ADDRESS__SHIFT) & CP_SET_BIN_DATA_1_BIN_SIZE_ADDRESS__MASK;
 }
 
+#define REG_CP_REG_TO_MEM_0                                    0x00000000
+#define CP_REG_TO_MEM_0_REG__MASK                              0x0000ffff
+#define CP_REG_TO_MEM_0_REG__SHIFT                             0
+static inline uint32_t CP_REG_TO_MEM_0_REG(uint32_t val)
+{
+       return ((val) << CP_REG_TO_MEM_0_REG__SHIFT) & CP_REG_TO_MEM_0_REG__MASK;
+}
+#define CP_REG_TO_MEM_0_CNT__MASK                              0x3ff80000
+#define CP_REG_TO_MEM_0_CNT__SHIFT                             19
+static inline uint32_t CP_REG_TO_MEM_0_CNT(uint32_t val)
+{
+       return ((val) << CP_REG_TO_MEM_0_CNT__SHIFT) & CP_REG_TO_MEM_0_CNT__MASK;
+}
+#define CP_REG_TO_MEM_0_64B                                    0x40000000
+#define CP_REG_TO_MEM_0_ACCUMULATE                             0x80000000
+
+#define REG_CP_REG_TO_MEM_1                                    0x00000001
+#define CP_REG_TO_MEM_1_DEST__MASK                             0xffffffff
+#define CP_REG_TO_MEM_1_DEST__SHIFT                            0
+static inline uint32_t CP_REG_TO_MEM_1_DEST(uint32_t val)
+{
+       return ((val) << CP_REG_TO_MEM_1_DEST__SHIFT) & CP_REG_TO_MEM_1_DEST__MASK;
+}
+
 
 #endif /* ADRENO_PM4_XML */
index b2b5f3d..4958594 100644 (file)
@@ -9,7 +9,7 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/msm.xml                 (    676 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp4.xml            (  20915 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp_common.xml      (   2849 bytes, from 2015-09-18 12:07:28)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp5.xml            (  37194 bytes, from 2015-09-18 12:07:28)
@@ -17,11 +17,12 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/sfpb.xml            (    602 bytes, from 2015-10-22 16:35:02)
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/mmss_cc.xml         (   1686 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/hdmi/qfprom.xml         (    600 bytes, from 2015-05-20 20:03:07)
-- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  29154 bytes, from 2015-08-10 21:25:43)
+- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  41472 bytes, from 2016-01-22 18:18:18)
 - /home/robclark/src/freedreno/envytools/rnndb/edp/edp.xml             (  10416 bytes, from 2015-05-20 20:03:14)
 
 Copyright (C) 2013-2015 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
index 2a827d8..e58e9b9 100644 (file)
@@ -57,10 +57,9 @@ static const char * const dsi_8916_bus_clk_names[] = {
 static const struct msm_dsi_config msm8916_dsi_cfg = {
        .io_offset = DSI_6G_REG_SHIFT,
        .reg_cfg = {
-               .num = 4,
+               .num = 3,
                .regs = {
                        {"gdsc", -1, -1, -1, -1},
-                       {"vdd", 2850000, 2850000, 100000, 100},
                        {"vdda", 1200000, 1200000, 100000, 100},
                        {"vddio", 1800000, 1800000, 100000, 100},
                },
index 48f9967..4282ec6 100644 (file)
@@ -163,6 +163,10 @@ struct msm_dsi_host {
        enum mipi_dsi_pixel_format format;
        unsigned long mode_flags;
 
+       /* lane data parsed via DT */
+       int dlane_swap;
+       int num_data_lanes;
+
        u32 dma_cmd_ctrl_restore;
 
        bool registered;
@@ -845,19 +849,10 @@ static void dsi_ctrl_config(struct msm_dsi_host *msm_host, bool enable,
        data = DSI_CTRL_CLK_EN;
 
        DBG("lane number=%d", msm_host->lanes);
-       if (msm_host->lanes == 2) {
-               data |= DSI_CTRL_LANE1 | DSI_CTRL_LANE2;
-               /* swap lanes for 2-lane panel for better performance */
-               dsi_write(msm_host, REG_DSI_LANE_SWAP_CTRL,
-                       DSI_LANE_SWAP_CTRL_DLN_SWAP_SEL(LANE_SWAP_1230));
-       } else {
-               /* Take 4 lanes as default */
-               data |= DSI_CTRL_LANE0 | DSI_CTRL_LANE1 | DSI_CTRL_LANE2 |
-                       DSI_CTRL_LANE3;
-               /* Do not swap lanes for 4-lane panel */
-               dsi_write(msm_host, REG_DSI_LANE_SWAP_CTRL,
-                       DSI_LANE_SWAP_CTRL_DLN_SWAP_SEL(LANE_SWAP_0123));
-       }
+       data |= ((DSI_CTRL_LANE0 << msm_host->lanes) - DSI_CTRL_LANE0);
+
+       dsi_write(msm_host, REG_DSI_LANE_SWAP_CTRL,
+                 DSI_LANE_SWAP_CTRL_DLN_SWAP_SEL(msm_host->dlane_swap));
 
        if (!(flags & MIPI_DSI_CLOCK_NON_CONTINUOUS))
                dsi_write(msm_host, REG_DSI_LANE_CTRL,
@@ -1479,13 +1474,14 @@ static int dsi_host_attach(struct mipi_dsi_host *host,
        struct msm_dsi_host *msm_host = to_msm_dsi_host(host);
        int ret;
 
+       if (dsi->lanes > msm_host->num_data_lanes)
+               return -EINVAL;
+
        msm_host->channel = dsi->channel;
        msm_host->lanes = dsi->lanes;
        msm_host->format = dsi->format;
        msm_host->mode_flags = dsi->mode_flags;
 
-       WARN_ON(dsi->dev.of_node != msm_host->device_node);
-
        /* Some gpios defined in panel DT need to be controlled by host */
        ret = dsi_host_init_panel_gpios(msm_host, &dsi->dev);
        if (ret)
@@ -1534,6 +1530,75 @@ static struct mipi_dsi_host_ops dsi_host_ops = {
        .transfer = dsi_host_transfer,
 };
 
+/*
+ * List of supported physical to logical lane mappings.
+ * For example, the 2nd entry represents the following mapping:
+ *
+ * "3012": Logic 3->Phys 0; Logic 0->Phys 1; Logic 1->Phys 2; Logic 2->Phys 3;
+ */
+static const int supported_data_lane_swaps[][4] = {
+       { 0, 1, 2, 3 },
+       { 3, 0, 1, 2 },
+       { 2, 3, 0, 1 },
+       { 1, 2, 3, 0 },
+       { 0, 3, 2, 1 },
+       { 1, 0, 3, 2 },
+       { 2, 1, 0, 3 },
+       { 3, 2, 1, 0 },
+};
+
+static int dsi_host_parse_lane_data(struct msm_dsi_host *msm_host,
+                                   struct device_node *ep)
+{
+       struct device *dev = &msm_host->pdev->dev;
+       struct property *prop;
+       u32 lane_map[4];
+       int ret, i, len, num_lanes;
+
+       prop = of_find_property(ep, "qcom,data-lane-map", &len);
+       if (!prop) {
+               dev_dbg(dev, "failed to find data lane mapping\n");
+               return -EINVAL;
+       }
+
+       num_lanes = len / sizeof(u32);
+
+       if (num_lanes < 1 || num_lanes > 4) {
+               dev_err(dev, "bad number of data lanes\n");
+               return -EINVAL;
+       }
+
+       msm_host->num_data_lanes = num_lanes;
+
+       ret = of_property_read_u32_array(ep, "qcom,data-lane-map", lane_map,
+                                        num_lanes);
+       if (ret) {
+               dev_err(dev, "failed to read lane data\n");
+               return ret;
+       }
+
+       /*
+        * compare DT specified physical-logical lane mappings with the ones
+        * supported by hardware
+        */
+       for (i = 0; i < ARRAY_SIZE(supported_data_lane_swaps); i++) {
+               const int *swap = supported_data_lane_swaps[i];
+               int j;
+
+               for (j = 0; j < num_lanes; j++) {
+                       if (swap[j] != lane_map[j])
+                               break;
+               }
+
+               if (j == num_lanes) {
+                       msm_host->dlane_swap = i;
+                       return 0;
+               }
+       }
+
+       return -EINVAL;
+}
+
 static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
 {
        struct device *dev = &msm_host->pdev->dev;
@@ -1560,17 +1625,21 @@ static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
                return 0;
        }
 
+       ret = dsi_host_parse_lane_data(msm_host, endpoint);
+       if (ret) {
+               dev_err(dev, "%s: invalid lane configuration %d\n",
+                       __func__, ret);
+               goto err;
+       }
+
        /* Get panel node from the output port's endpoint data */
        device_node = of_graph_get_remote_port_parent(endpoint);
        if (!device_node) {
                dev_err(dev, "%s: no valid device\n", __func__);
-               of_node_put(endpoint);
-               return -ENODEV;
+               ret = -ENODEV;
+               goto err;
        }
 
-       of_node_put(endpoint);
-       of_node_put(device_node);
-
        msm_host->device_node = device_node;
 
        if (of_property_read_bool(np, "syscon-sfpb")) {
@@ -1579,11 +1648,16 @@ static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
                if (IS_ERR(msm_host->sfpb)) {
                        dev_err(dev, "%s: failed to get sfpb regmap\n",
                                __func__);
-                       return PTR_ERR(msm_host->sfpb);
+                       ret = PTR_ERR(msm_host->sfpb);
                }
        }
 
-       return 0;
+       of_node_put(device_node);
+
+err:
+       of_node_put(endpoint);
+
+       return ret;
 }
 
 int msm_dsi_host_init(struct msm_dsi *msm_dsi)
index 80ec65e..2d99949 100644 (file)
@@ -9,7 +9,7 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/msm.xml                 (    676 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp4.xml            (  20915 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp_common.xml      (   2849 bytes, from 2015-09-18 12:07:28)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp5.xml            (  37194 bytes, from 2015-09-18 12:07:28)
@@ -17,11 +17,12 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/sfpb.xml            (    602 bytes, from 2015-10-22 16:35:02)
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/mmss_cc.xml         (   1686 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/hdmi/qfprom.xml         (    600 bytes, from 2015-05-20 20:03:07)
-- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  29154 bytes, from 2015-08-10 21:25:43)
+- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  41472 bytes, from 2016-01-22 18:18:18)
 - /home/robclark/src/freedreno/envytools/rnndb/edp/edp.xml             (  10416 bytes, from 2015-05-20 20:03:14)
 
 Copyright (C) 2013-2015 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
index 80b6038..2cf1664 100644 (file)
@@ -97,8 +97,8 @@ static inline struct msm_dsi_pll *msm_dsi_pll_28nm_init(
 struct msm_dsi_pll *msm_dsi_pll_28nm_8960_init(struct platform_device *pdev,
                                               int id);
 #else
-struct msm_dsi_pll *msm_dsi_pll_28nm_8960_init(struct platform_device *pdev,
-                                              int id)
+static inline struct msm_dsi_pll *msm_dsi_pll_28nm_8960_init(
+       struct platform_device *pdev, int id)
 {
        return ERR_PTR(-ENODEV);
 }
index 7d7662e..506434f 100644 (file)
@@ -9,7 +9,7 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/msm.xml                 (    676 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp4.xml            (  20915 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp_common.xml      (   2849 bytes, from 2015-09-18 12:07:28)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp5.xml            (  37194 bytes, from 2015-09-18 12:07:28)
@@ -17,11 +17,12 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/sfpb.xml            (    602 bytes, from 2015-10-22 16:35:02)
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/mmss_cc.xml         (   1686 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/hdmi/qfprom.xml         (    600 bytes, from 2015-05-20 20:03:07)
-- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  29154 bytes, from 2015-08-10 21:25:43)
+- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  41472 bytes, from 2016-01-22 18:18:18)
 - /home/robclark/src/freedreno/envytools/rnndb/edp/edp.xml             (  10416 bytes, from 2015-05-20 20:03:14)
 
 Copyright (C) 2013-2015 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
index 90bf5ed..f1072c1 100644 (file)
@@ -9,7 +9,7 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/msm.xml                 (    676 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp4.xml            (  20915 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp_common.xml      (   2849 bytes, from 2015-09-18 12:07:28)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp5.xml            (  37194 bytes, from 2015-09-18 12:07:28)
@@ -17,11 +17,12 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/sfpb.xml            (    602 bytes, from 2015-10-22 16:35:02)
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/mmss_cc.xml         (   1686 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/hdmi/qfprom.xml         (    600 bytes, from 2015-05-20 20:03:07)
-- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  29154 bytes, from 2015-08-10 21:25:43)
+- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  41472 bytes, from 2016-01-22 18:18:18)
 - /home/robclark/src/freedreno/envytools/rnndb/edp/edp.xml             (  10416 bytes, from 2015-05-20 20:03:14)
 
 Copyright (C) 2013-2015 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
index 9a0989c..51b9ea5 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "hdmi.h"
 
-void hdmi_set_mode(struct hdmi *hdmi, bool power_on)
+void msm_hdmi_set_mode(struct hdmi *hdmi, bool power_on)
 {
        uint32_t ctrl = 0;
        unsigned long flags;
@@ -46,29 +46,27 @@ void hdmi_set_mode(struct hdmi *hdmi, bool power_on)
                        power_on ? "Enable" : "Disable", ctrl);
 }
 
-static irqreturn_t hdmi_irq(int irq, void *dev_id)
+static irqreturn_t msm_hdmi_irq(int irq, void *dev_id)
 {
        struct hdmi *hdmi = dev_id;
 
        /* Process HPD: */
-       hdmi_connector_irq(hdmi->connector);
+       msm_hdmi_connector_irq(hdmi->connector);
 
        /* Process DDC: */
-       hdmi_i2c_irq(hdmi->i2c);
+       msm_hdmi_i2c_irq(hdmi->i2c);
 
        /* Process HDCP: */
        if (hdmi->hdcp_ctrl)
-               hdmi_hdcp_irq(hdmi->hdcp_ctrl);
+               msm_hdmi_hdcp_irq(hdmi->hdcp_ctrl);
 
        /* TODO audio.. */
 
        return IRQ_HANDLED;
 }
 
-static void hdmi_destroy(struct hdmi *hdmi)
+static void msm_hdmi_destroy(struct hdmi *hdmi)
 {
-       struct hdmi_phy *phy = hdmi->phy;
-
        /*
         * at this point, hpd has been disabled,
         * after flush workq, it's safe to deinit hdcp
@@ -77,21 +75,53 @@ static void hdmi_destroy(struct hdmi *hdmi)
                flush_workqueue(hdmi->workq);
                destroy_workqueue(hdmi->workq);
        }
-       hdmi_hdcp_destroy(hdmi);
-       if (phy)
-               phy->funcs->destroy(phy);
+       msm_hdmi_hdcp_destroy(hdmi);
+
+       if (hdmi->phy_dev) {
+               put_device(hdmi->phy_dev);
+               hdmi->phy = NULL;
+               hdmi->phy_dev = NULL;
+       }
 
        if (hdmi->i2c)
-               hdmi_i2c_destroy(hdmi->i2c);
+               msm_hdmi_i2c_destroy(hdmi->i2c);
 
        platform_set_drvdata(hdmi->pdev, NULL);
 }
 
+static int msm_hdmi_get_phy(struct hdmi *hdmi)
+{
+       struct platform_device *pdev = hdmi->pdev;
+       struct platform_device *phy_pdev;
+       struct device_node *phy_node;
+
+       phy_node = of_parse_phandle(pdev->dev.of_node, "phys", 0);
+       if (!phy_node) {
+               dev_err(&pdev->dev, "cannot find phy device\n");
+               return -ENXIO;
+       }
+
+       phy_pdev = of_find_device_by_node(phy_node);
+       if (phy_pdev)
+               hdmi->phy = platform_get_drvdata(phy_pdev);
+
+       of_node_put(phy_node);
+
+       if (!phy_pdev || !hdmi->phy) {
+               dev_err(&pdev->dev, "phy driver is not ready\n");
+               return -EPROBE_DEFER;
+       }
+
+       hdmi->phy_dev = get_device(&phy_pdev->dev);
+
+       return 0;
+}
+
 /* construct hdmi at bind/probe time, grab all the resources.  If
  * we are to EPROBE_DEFER we want to do it here, rather than later
  * at modeset_init() time
  */
-static struct hdmi *hdmi_init(struct platform_device *pdev)
+static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
 {
        struct hdmi_platform_config *config = pdev->dev.platform_data;
        struct hdmi *hdmi = NULL;
@@ -108,18 +138,6 @@ static struct hdmi *hdmi_init(struct platform_device *pdev)
        hdmi->config = config;
        spin_lock_init(&hdmi->reg_lock);
 
-       /* not sure about which phy maps to which msm.. probably I miss some */
-       if (config->phy_init) {
-               hdmi->phy = config->phy_init(hdmi);
-
-               if (IS_ERR(hdmi->phy)) {
-                       ret = PTR_ERR(hdmi->phy);
-                       dev_err(&pdev->dev, "failed to load phy: %d\n", ret);
-                       hdmi->phy = NULL;
-                       goto fail;
-               }
-       }
-
        hdmi->mmio = msm_ioremap(pdev, config->mmio_name, "HDMI");
        if (IS_ERR(hdmi->mmio)) {
                ret = PTR_ERR(hdmi->mmio);
@@ -222,7 +240,7 @@ static struct hdmi *hdmi_init(struct platform_device *pdev)
 
        hdmi->workq = alloc_ordered_workqueue("msm_hdmi", 0);
 
-       hdmi->i2c = hdmi_i2c_init(hdmi);
+       hdmi->i2c = msm_hdmi_i2c_init(hdmi);
        if (IS_ERR(hdmi->i2c)) {
                ret = PTR_ERR(hdmi->i2c);
                dev_err(&pdev->dev, "failed to get i2c: %d\n", ret);
@@ -230,7 +248,13 @@ static struct hdmi *hdmi_init(struct platform_device *pdev)
                goto fail;
        }
 
-       hdmi->hdcp_ctrl = hdmi_hdcp_init(hdmi);
+       ret = msm_hdmi_get_phy(hdmi);
+       if (ret) {
+               dev_err(&pdev->dev, "failed to get phy\n");
+               goto fail;
+       }
+
+       hdmi->hdcp_ctrl = msm_hdmi_hdcp_init(hdmi);
        if (IS_ERR(hdmi->hdcp_ctrl)) {
                dev_warn(&pdev->dev, "failed to init hdcp: disabled\n");
                hdmi->hdcp_ctrl = NULL;
@@ -240,7 +264,7 @@ static struct hdmi *hdmi_init(struct platform_device *pdev)
 
 fail:
        if (hdmi)
-               hdmi_destroy(hdmi);
+               msm_hdmi_destroy(hdmi);
 
        return ERR_PTR(ret);
 }
@@ -250,10 +274,10 @@ fail:
  * driver (not hdmi sub-device's probe/bind!)
  *
  * Any resource (regulator/clk/etc) which could be missing at boot
- * should be handled in hdmi_init() so that failure happens from
+ * should be handled in msm_hdmi_init() so that failure happens from
  * hdmi sub-device's probe.
  */
-int hdmi_modeset_init(struct hdmi *hdmi,
+int msm_hdmi_modeset_init(struct hdmi *hdmi,
                struct drm_device *dev, struct drm_encoder *encoder)
 {
        struct msm_drm_private *priv = dev->dev_private;
@@ -265,7 +289,7 @@ int hdmi_modeset_init(struct hdmi *hdmi,
 
        hdmi_audio_infoframe_init(&hdmi->audio.infoframe);
 
-       hdmi->bridge = hdmi_bridge_init(hdmi);
+       hdmi->bridge = msm_hdmi_bridge_init(hdmi);
        if (IS_ERR(hdmi->bridge)) {
                ret = PTR_ERR(hdmi->bridge);
                dev_err(dev->dev, "failed to create HDMI bridge: %d\n", ret);
@@ -273,7 +297,7 @@ int hdmi_modeset_init(struct hdmi *hdmi,
                goto fail;
        }
 
-       hdmi->connector = hdmi_connector_init(hdmi);
+       hdmi->connector = msm_hdmi_connector_init(hdmi);
        if (IS_ERR(hdmi->connector)) {
                ret = PTR_ERR(hdmi->connector);
                dev_err(dev->dev, "failed to create HDMI connector: %d\n", ret);
@@ -289,7 +313,7 @@ int hdmi_modeset_init(struct hdmi *hdmi,
        }
 
        ret = devm_request_irq(&pdev->dev, hdmi->irq,
-                       hdmi_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+                       msm_hdmi_irq, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
                        "hdmi_isr", hdmi);
        if (ret < 0) {
                dev_err(dev->dev, "failed to request IRQ%u: %d\n",
@@ -309,7 +333,7 @@ int hdmi_modeset_init(struct hdmi *hdmi,
 fail:
        /* bridge is normally destroyed by drm: */
        if (hdmi->bridge) {
-               hdmi_bridge_destroy(hdmi->bridge);
+               msm_hdmi_bridge_destroy(hdmi->bridge);
                hdmi->bridge = NULL;
        }
        if (hdmi->connector) {
@@ -331,15 +355,12 @@ fail:
 static const char *pwr_reg_names_none[] = {};
 static const char *hpd_reg_names_none[] = {};
 
-static struct hdmi_platform_config hdmi_tx_8660_config = {
-               .phy_init = hdmi_phy_8x60_init,
-};
+static struct hdmi_platform_config hdmi_tx_8660_config;
 
 static const char *hpd_reg_names_8960[] = {"core-vdda", "hdmi-mux"};
 static const char *hpd_clk_names_8960[] = {"core_clk", "master_iface_clk", "slave_iface_clk"};
 
 static struct hdmi_platform_config hdmi_tx_8960_config = {
-               .phy_init = hdmi_phy_8960_init,
                HDMI_CFG(hpd_reg, 8960),
                HDMI_CFG(hpd_clk, 8960),
 };
@@ -351,7 +372,6 @@ static const char *hpd_clk_names_8x74[] = {"iface_clk", "core_clk", "mdp_core_cl
 static unsigned long hpd_clk_freq_8x74[] = {0, 19200000, 0};
 
 static struct hdmi_platform_config hdmi_tx_8974_config = {
-               .phy_init = hdmi_phy_8x74_init,
                HDMI_CFG(pwr_reg, 8x74),
                HDMI_CFG(hpd_reg, 8x74),
                HDMI_CFG(pwr_clk, 8x74),
@@ -362,7 +382,6 @@ static struct hdmi_platform_config hdmi_tx_8974_config = {
 static const char *hpd_reg_names_8084[] = {"hpd-gdsc", "hpd-5v", "hpd-5v-en"};
 
 static struct hdmi_platform_config hdmi_tx_8084_config = {
-               .phy_init = hdmi_phy_8x74_init,
                HDMI_CFG(pwr_reg, 8x74),
                HDMI_CFG(hpd_reg, 8084),
                HDMI_CFG(pwr_clk, 8x74),
@@ -371,7 +390,6 @@ static struct hdmi_platform_config hdmi_tx_8084_config = {
 };
 
 static struct hdmi_platform_config hdmi_tx_8994_config = {
-               .phy_init = NULL, /* nothing to do for this HDMI PHY 20nm */
                HDMI_CFG(pwr_reg, 8x74),
                HDMI_CFG(hpd_reg, none),
                HDMI_CFG(pwr_clk, 8x74),
@@ -380,7 +398,6 @@ static struct hdmi_platform_config hdmi_tx_8994_config = {
 };
 
 static struct hdmi_platform_config hdmi_tx_8996_config = {
-               .phy_init = NULL,
                HDMI_CFG(pwr_reg, none),
                HDMI_CFG(hpd_reg, none),
                HDMI_CFG(pwr_clk, 8x74),
@@ -388,7 +405,21 @@ static struct hdmi_platform_config hdmi_tx_8996_config = {
                .hpd_freq      = hpd_clk_freq_8x74,
 };
 
-static int get_gpio(struct device *dev, struct device_node *of_node, const char *name)
+static const struct {
+       const char *name;
+       const bool output;
+       const int value;
+       const char *label;
+} msm_hdmi_gpio_pdata[] = {
+       { "qcom,hdmi-tx-ddc-clk", true, 1, "HDMI_DDC_CLK" },
+       { "qcom,hdmi-tx-ddc-data", true, 1, "HDMI_DDC_DATA" },
+       { "qcom,hdmi-tx-hpd", false, 1, "HDMI_HPD" },
+       { "qcom,hdmi-tx-mux-en", true, 1, "HDMI_MUX_EN" },
+       { "qcom,hdmi-tx-mux-sel", true, 0, "HDMI_MUX_SEL" },
+       { "qcom,hdmi-tx-mux-lpm", true, 1, "HDMI_MUX_LPM" },
+};
+
+static int msm_hdmi_get_gpio(struct device_node *of_node, const char *name)
 {
        int gpio = of_get_named_gpio(of_node, name, 0);
        if (gpio < 0) {
@@ -403,13 +434,14 @@ static int get_gpio(struct device *dev, struct device_node *of_node, const char
        return gpio;
 }
 
-static int hdmi_bind(struct device *dev, struct device *master, void *data)
+static int msm_hdmi_bind(struct device *dev, struct device *master, void *data)
 {
        struct drm_device *drm = dev_get_drvdata(master);
        struct msm_drm_private *priv = drm->dev_private;
        static struct hdmi_platform_config *hdmi_cfg;
        struct hdmi *hdmi;
        struct device_node *of_node = dev->of_node;
+       int i;
 
        hdmi_cfg = (struct hdmi_platform_config *)
                        of_device_get_match_data(dev);
@@ -420,16 +452,18 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
 
        hdmi_cfg->mmio_name     = "core_physical";
        hdmi_cfg->qfprom_mmio_name = "qfprom_physical";
-       hdmi_cfg->ddc_clk_gpio  = get_gpio(dev, of_node, "qcom,hdmi-tx-ddc-clk");
-       hdmi_cfg->ddc_data_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-ddc-data");
-       hdmi_cfg->hpd_gpio      = get_gpio(dev, of_node, "qcom,hdmi-tx-hpd");
-       hdmi_cfg->mux_en_gpio   = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-en");
-       hdmi_cfg->mux_sel_gpio  = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-sel");
-       hdmi_cfg->mux_lpm_gpio  = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-lpm");
+
+       for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
+               hdmi_cfg->gpios[i].num = msm_hdmi_get_gpio(of_node,
+                                               msm_hdmi_gpio_pdata[i].name);
+               hdmi_cfg->gpios[i].output = msm_hdmi_gpio_pdata[i].output;
+               hdmi_cfg->gpios[i].value = msm_hdmi_gpio_pdata[i].value;
+               hdmi_cfg->gpios[i].label = msm_hdmi_gpio_pdata[i].label;
+       }
 
        dev->platform_data = hdmi_cfg;
 
-       hdmi = hdmi_init(to_platform_device(dev));
+       hdmi = msm_hdmi_init(to_platform_device(dev));
        if (IS_ERR(hdmi))
                return PTR_ERR(hdmi);
        priv->hdmi = hdmi;
@@ -437,34 +471,34 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
        return 0;
 }
 
-static void hdmi_unbind(struct device *dev, struct device *master,
+static void msm_hdmi_unbind(struct device *dev, struct device *master,
                void *data)
 {
        struct drm_device *drm = dev_get_drvdata(master);
        struct msm_drm_private *priv = drm->dev_private;
        if (priv->hdmi) {
-               hdmi_destroy(priv->hdmi);
+               msm_hdmi_destroy(priv->hdmi);
                priv->hdmi = NULL;
        }
 }
 
-static const struct component_ops hdmi_ops = {
-               .bind   = hdmi_bind,
-               .unbind = hdmi_unbind,
+static const struct component_ops msm_hdmi_ops = {
+               .bind   = msm_hdmi_bind,
+               .unbind = msm_hdmi_unbind,
 };
 
-static int hdmi_dev_probe(struct platform_device *pdev)
+static int msm_hdmi_dev_probe(struct platform_device *pdev)
 {
-       return component_add(&pdev->dev, &hdmi_ops);
+       return component_add(&pdev->dev, &msm_hdmi_ops);
 }
 
-static int hdmi_dev_remove(struct platform_device *pdev)
+static int msm_hdmi_dev_remove(struct platform_device *pdev)
 {
-       component_del(&pdev->dev, &hdmi_ops);
+       component_del(&pdev->dev, &msm_hdmi_ops);
        return 0;
 }
 
-static const struct of_device_id dt_match[] = {
+static const struct of_device_id msm_hdmi_dt_match[] = {
        { .compatible = "qcom,hdmi-tx-8996", .data = &hdmi_tx_8996_config },
        { .compatible = "qcom,hdmi-tx-8994", .data = &hdmi_tx_8994_config },
        { .compatible = "qcom,hdmi-tx-8084", .data = &hdmi_tx_8084_config },
@@ -474,21 +508,23 @@ static const struct of_device_id dt_match[] = {
        {}
 };
 
-static struct platform_driver hdmi_driver = {
-       .probe = hdmi_dev_probe,
-       .remove = hdmi_dev_remove,
+static struct platform_driver msm_hdmi_driver = {
+       .probe = msm_hdmi_dev_probe,
+       .remove = msm_hdmi_dev_remove,
        .driver = {
                .name = "hdmi_msm",
-               .of_match_table = dt_match,
+               .of_match_table = msm_hdmi_dt_match,
        },
 };
 
-void __init hdmi_register(void)
+void __init msm_hdmi_register(void)
 {
-       platform_driver_register(&hdmi_driver);
+       msm_hdmi_phy_driver_register();
+       platform_driver_register(&msm_hdmi_driver);
 }
 
-void __exit hdmi_unregister(void)
+void __exit msm_hdmi_unregister(void)
 {
-       platform_driver_unregister(&hdmi_driver);
+       platform_driver_unregister(&msm_hdmi_driver);
+       msm_hdmi_phy_driver_unregister();
 }
index d0e6631..b04a646 100644 (file)
 #include "msm_drv.h"
 #include "hdmi.xml.h"
 
+#define HDMI_MAX_NUM_GPIO      6
 
 struct hdmi_phy;
 struct hdmi_platform_config;
 
+struct hdmi_gpio_data {
+       int num;
+       bool output;
+       int value;
+       const char *label;
+};
+
 struct hdmi_audio {
        bool enabled;
        struct hdmi_audio_infoframe infoframe;
@@ -62,6 +70,8 @@ struct hdmi {
        struct clk **pwr_clks;
 
        struct hdmi_phy *phy;
+       struct device *phy_dev;
+
        struct i2c_adapter *i2c;
        struct drm_connector *connector;
        struct drm_bridge *bridge;
@@ -88,7 +98,6 @@ struct hdmi {
 
 /* platform config data (ie. from DT, or pdata) */
 struct hdmi_platform_config {
-       struct hdmi_phy *(*phy_init)(struct hdmi *hdmi);
        const char *mmio_name;
        const char *qfprom_mmio_name;
 
@@ -110,11 +119,10 @@ struct hdmi_platform_config {
        int pwr_clk_cnt;
 
        /* gpio's: */
-       int ddc_clk_gpio, ddc_data_gpio, hpd_gpio, mux_en_gpio, mux_sel_gpio;
-       int mux_lpm_gpio;
+       struct hdmi_gpio_data gpios[HDMI_MAX_NUM_GPIO];
 };
 
-void hdmi_set_mode(struct hdmi *hdmi, bool power_on);
+void msm_hdmi_set_mode(struct hdmi *hdmi, bool power_on);
 
 static inline void hdmi_write(struct hdmi *hdmi, u32 reg, u32 data)
 {
@@ -132,65 +140,113 @@ static inline u32 hdmi_qfprom_read(struct hdmi *hdmi, u32 reg)
 }
 
 /*
- * The phy appears to be different, for example between 8960 and 8x60,
- * so split the phy related functions out and load the correct one at
- * runtime:
+ * hdmi phy:
  */
 
-struct hdmi_phy_funcs {
-       void (*destroy)(struct hdmi_phy *phy);
+enum hdmi_phy_type {
+       MSM_HDMI_PHY_8x60,
+       MSM_HDMI_PHY_8960,
+       MSM_HDMI_PHY_8x74,
+       MSM_HDMI_PHY_8996,
+       MSM_HDMI_PHY_MAX,
+};
+
+struct hdmi_phy_cfg {
+       enum hdmi_phy_type type;
        void (*powerup)(struct hdmi_phy *phy, unsigned long int pixclock);
        void (*powerdown)(struct hdmi_phy *phy);
+       const char * const *reg_names;
+       int num_regs;
+       const char * const *clk_names;
+       int num_clks;
 };
 
+extern const struct hdmi_phy_cfg msm_hdmi_phy_8x60_cfg;
+extern const struct hdmi_phy_cfg msm_hdmi_phy_8960_cfg;
+extern const struct hdmi_phy_cfg msm_hdmi_phy_8x74_cfg;
+extern const struct hdmi_phy_cfg msm_hdmi_phy_8996_cfg;
+
 struct hdmi_phy {
+       struct platform_device *pdev;
+       void __iomem *mmio;
+       struct hdmi_phy_cfg *cfg;
        const struct hdmi_phy_funcs *funcs;
+       struct regulator **regs;
+       struct clk **clks;
 };
 
-struct hdmi_phy *hdmi_phy_8960_init(struct hdmi *hdmi);
-struct hdmi_phy *hdmi_phy_8x60_init(struct hdmi *hdmi);
-struct hdmi_phy *hdmi_phy_8x74_init(struct hdmi *hdmi);
+static inline void hdmi_phy_write(struct hdmi_phy *phy, u32 reg, u32 data)
+{
+       msm_writel(data, phy->mmio + reg);
+}
+
+static inline u32 hdmi_phy_read(struct hdmi_phy *phy, u32 reg)
+{
+       return msm_readl(phy->mmio + reg);
+}
+
+int msm_hdmi_phy_resource_enable(struct hdmi_phy *phy);
+void msm_hdmi_phy_resource_disable(struct hdmi_phy *phy);
+void msm_hdmi_phy_powerup(struct hdmi_phy *phy, unsigned long int pixclock);
+void msm_hdmi_phy_powerdown(struct hdmi_phy *phy);
+void __init msm_hdmi_phy_driver_register(void);
+void __exit msm_hdmi_phy_driver_unregister(void);
+
+#ifdef CONFIG_COMMON_CLK
+int msm_hdmi_pll_8960_init(struct platform_device *pdev);
+int msm_hdmi_pll_8996_init(struct platform_device *pdev);
+#else
+static inline int msm_hdmi_pll_8960_init(struct platform_device *pdev);
+{
+       return -ENODEV;
+}
+
+static inline int msm_hdmi_pll_8996_init(struct platform_device *pdev)
+{
+       return -ENODEV;
+}
+#endif
 
 /*
  * audio:
  */
 
-int hdmi_audio_update(struct hdmi *hdmi);
-int hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled,
+int msm_hdmi_audio_update(struct hdmi *hdmi);
+int msm_hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled,
        uint32_t num_of_channels, uint32_t channel_allocation,
        uint32_t level_shift, bool down_mix);
-void hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate);
+void msm_hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate);
 
 
 /*
  * hdmi bridge:
  */
 
-struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi);
-void hdmi_bridge_destroy(struct drm_bridge *bridge);
+struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi);
+void msm_hdmi_bridge_destroy(struct drm_bridge *bridge);
 
 /*
  * hdmi connector:
  */
 
-void hdmi_connector_irq(struct drm_connector *connector);
-struct drm_connector *hdmi_connector_init(struct hdmi *hdmi);
+void msm_hdmi_connector_irq(struct drm_connector *connector);
+struct drm_connector *msm_hdmi_connector_init(struct hdmi *hdmi);
 
 /*
  * i2c adapter for ddc:
  */
 
-void hdmi_i2c_irq(struct i2c_adapter *i2c);
-void hdmi_i2c_destroy(struct i2c_adapter *i2c);
-struct i2c_adapter *hdmi_i2c_init(struct hdmi *hdmi);
+void msm_hdmi_i2c_irq(struct i2c_adapter *i2c);
+void msm_hdmi_i2c_destroy(struct i2c_adapter *i2c);
+struct i2c_adapter *msm_hdmi_i2c_init(struct hdmi *hdmi);
 
 /*
  * hdcp
  */
-struct hdmi_hdcp_ctrl *hdmi_hdcp_init(struct hdmi *hdmi);
-void hdmi_hdcp_destroy(struct hdmi *hdmi);
-void hdmi_hdcp_on(struct hdmi_hdcp_ctrl *hdcp_ctrl);
-void hdmi_hdcp_off(struct hdmi_hdcp_ctrl *hdcp_ctrl);
-void hdmi_hdcp_irq(struct hdmi_hdcp_ctrl *hdcp_ctrl);
+struct hdmi_hdcp_ctrl *msm_hdmi_hdcp_init(struct hdmi *hdmi);
+void msm_hdmi_hdcp_destroy(struct hdmi *hdmi);
+void msm_hdmi_hdcp_on(struct hdmi_hdcp_ctrl *hdcp_ctrl);
+void msm_hdmi_hdcp_off(struct hdmi_hdcp_ctrl *hdcp_ctrl);
+void msm_hdmi_hdcp_irq(struct hdmi_hdcp_ctrl *hdcp_ctrl);
 
 #endif /* __HDMI_CONNECTOR_H__ */
index 10c4570..34c7df6 100644 (file)
@@ -9,7 +9,7 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/msm.xml                 (    676 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp4.xml            (  20915 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp_common.xml      (   2849 bytes, from 2015-09-18 12:07:28)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp5.xml            (  37194 bytes, from 2015-09-18 12:07:28)
@@ -17,11 +17,12 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/sfpb.xml            (    602 bytes, from 2015-10-22 16:35:02)
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/mmss_cc.xml         (   1686 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/hdmi/qfprom.xml         (    600 bytes, from 2015-05-20 20:03:07)
-- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  29154 bytes, from 2015-08-10 21:25:43)
+- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  41472 bytes, from 2016-01-22 18:18:18)
 - /home/robclark/src/freedreno/envytools/rnndb/edp/edp.xml             (  10416 bytes, from 2015-05-20 20:03:14)
 
-Copyright (C) 2013-2015 by the following authors:
+Copyright (C) 2013-2016 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
@@ -559,7 +560,7 @@ static inline uint32_t HDMI_VSYNC_TOTAL_F2_V_TOTAL(uint32_t val)
 
 #define REG_HDMI_CEC_WR_CHECK_CONFIG                           0x00000370
 
-#define REG_HDMI_8x60_PHY_REG0                                 0x00000300
+#define REG_HDMI_8x60_PHY_REG0                                 0x00000000
 #define HDMI_8x60_PHY_REG0_DESER_DEL_CTRL__MASK                        0x0000001c
 #define HDMI_8x60_PHY_REG0_DESER_DEL_CTRL__SHIFT               2
 static inline uint32_t HDMI_8x60_PHY_REG0_DESER_DEL_CTRL(uint32_t val)
@@ -567,7 +568,7 @@ static inline uint32_t HDMI_8x60_PHY_REG0_DESER_DEL_CTRL(uint32_t val)
        return ((val) << HDMI_8x60_PHY_REG0_DESER_DEL_CTRL__SHIFT) & HDMI_8x60_PHY_REG0_DESER_DEL_CTRL__MASK;
 }
 
-#define REG_HDMI_8x60_PHY_REG1                                 0x00000304
+#define REG_HDMI_8x60_PHY_REG1                                 0x00000004
 #define HDMI_8x60_PHY_REG1_DTEST_MUX_SEL__MASK                 0x000000f0
 #define HDMI_8x60_PHY_REG1_DTEST_MUX_SEL__SHIFT                        4
 static inline uint32_t HDMI_8x60_PHY_REG1_DTEST_MUX_SEL(uint32_t val)
@@ -581,7 +582,7 @@ static inline uint32_t HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL(uint32_t val)
        return ((val) << HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL__SHIFT) & HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL__MASK;
 }
 
-#define REG_HDMI_8x60_PHY_REG2                                 0x00000308
+#define REG_HDMI_8x60_PHY_REG2                                 0x00000008
 #define HDMI_8x60_PHY_REG2_PD_DESER                            0x00000001
 #define HDMI_8x60_PHY_REG2_PD_DRIVE_1                          0x00000002
 #define HDMI_8x60_PHY_REG2_PD_DRIVE_2                          0x00000004
@@ -591,152 +592,152 @@ static inline uint32_t HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL(uint32_t val)
 #define HDMI_8x60_PHY_REG2_PD_PWRGEN                           0x00000040
 #define HDMI_8x60_PHY_REG2_RCV_SENSE_EN                                0x00000080
 
-#define REG_HDMI_8x60_PHY_REG3                                 0x0000030c
+#define REG_HDMI_8x60_PHY_REG3                                 0x0000000c
 #define HDMI_8x60_PHY_REG3_PLL_ENABLE                          0x00000001
 
-#define REG_HDMI_8x60_PHY_REG4                                 0x00000310
+#define REG_HDMI_8x60_PHY_REG4                                 0x00000010
 
-#define REG_HDMI_8x60_PHY_REG5                                 0x00000314
+#define REG_HDMI_8x60_PHY_REG5                                 0x00000014
 
-#define REG_HDMI_8x60_PHY_REG6                                 0x00000318
+#define REG_HDMI_8x60_PHY_REG6                                 0x00000018
 
-#define REG_HDMI_8x60_PHY_REG7                                 0x0000031c
+#define REG_HDMI_8x60_PHY_REG7                                 0x0000001c
 
-#define REG_HDMI_8x60_PHY_REG8                                 0x00000320
+#define REG_HDMI_8x60_PHY_REG8                                 0x00000020
 
-#define REG_HDMI_8x60_PHY_REG9                                 0x00000324
+#define REG_HDMI_8x60_PHY_REG9                                 0x00000024
 
-#define REG_HDMI_8x60_PHY_REG10                                        0x00000328
+#define REG_HDMI_8x60_PHY_REG10                                        0x00000028
 
-#define REG_HDMI_8x60_PHY_REG11                                        0x0000032c
+#define REG_HDMI_8x60_PHY_REG11                                        0x0000002c
 
-#define REG_HDMI_8x60_PHY_REG12                                        0x00000330
+#define REG_HDMI_8x60_PHY_REG12                                        0x00000030
 #define HDMI_8x60_PHY_REG12_RETIMING_EN                                0x00000001
 #define HDMI_8x60_PHY_REG12_PLL_LOCK_DETECT_EN                 0x00000002
 #define HDMI_8x60_PHY_REG12_FORCE_LOCK                         0x00000010
 
-#define REG_HDMI_8960_PHY_REG0                                 0x00000400
+#define REG_HDMI_8960_PHY_REG0                                 0x00000000
 
-#define REG_HDMI_8960_PHY_REG1                                 0x00000404
+#define REG_HDMI_8960_PHY_REG1                                 0x00000004
 
-#define REG_HDMI_8960_PHY_REG2                                 0x00000408
+#define REG_HDMI_8960_PHY_REG2                                 0x00000008
 
-#define REG_HDMI_8960_PHY_REG3                                 0x0000040c
+#define REG_HDMI_8960_PHY_REG3                                 0x0000000c
 
-#define REG_HDMI_8960_PHY_REG4                                 0x00000410
+#define REG_HDMI_8960_PHY_REG4                                 0x00000010
 
-#define REG_HDMI_8960_PHY_REG5                                 0x00000414
+#define REG_HDMI_8960_PHY_REG5                                 0x00000014
 
-#define REG_HDMI_8960_PHY_REG6                                 0x00000418
+#define REG_HDMI_8960_PHY_REG6                                 0x00000018
 
-#define REG_HDMI_8960_PHY_REG7                                 0x0000041c
+#define REG_HDMI_8960_PHY_REG7                                 0x0000001c
 
-#define REG_HDMI_8960_PHY_REG8                                 0x00000420
+#define REG_HDMI_8960_PHY_REG8                                 0x00000020
 
-#define REG_HDMI_8960_PHY_REG9                                 0x00000424
+#define REG_HDMI_8960_PHY_REG9                                 0x00000024
 
-#define REG_HDMI_8960_PHY_REG10                                        0x00000428
+#define REG_HDMI_8960_PHY_REG10                                        0x00000028
 
-#define REG_HDMI_8960_PHY_REG11                                        0x0000042c
+#define REG_HDMI_8960_PHY_REG11                                        0x0000002c
 
-#define REG_HDMI_8960_PHY_REG12                                        0x00000430
+#define REG_HDMI_8960_PHY_REG12                                        0x00000030
 #define HDMI_8960_PHY_REG12_SW_RESET                           0x00000020
 #define HDMI_8960_PHY_REG12_PWRDN_B                            0x00000080
 
-#define REG_HDMI_8960_PHY_REG_BIST_CFG                         0x00000434
+#define REG_HDMI_8960_PHY_REG_BIST_CFG                         0x00000034
 
-#define REG_HDMI_8960_PHY_DEBUG_BUS_SEL                                0x00000438
+#define REG_HDMI_8960_PHY_DEBUG_BUS_SEL                                0x00000038
 
-#define REG_HDMI_8960_PHY_REG_MISC0                            0x0000043c
+#define REG_HDMI_8960_PHY_REG_MISC0                            0x0000003c
 
-#define REG_HDMI_8960_PHY_REG13                                        0x00000440
+#define REG_HDMI_8960_PHY_REG13                                        0x00000040
 
-#define REG_HDMI_8960_PHY_REG14                                        0x00000444
+#define REG_HDMI_8960_PHY_REG14                                        0x00000044
 
-#define REG_HDMI_8960_PHY_REG15                                        0x00000448
+#define REG_HDMI_8960_PHY_REG15                                        0x00000048
 
-#define REG_HDMI_8960_PHY_PLL_REFCLK_CFG                       0x00000500
+#define REG_HDMI_8960_PHY_PLL_REFCLK_CFG                       0x00000000
 
-#define REG_HDMI_8960_PHY_PLL_CHRG_PUMP_CFG                    0x00000504
+#define REG_HDMI_8960_PHY_PLL_CHRG_PUMP_CFG                    0x00000004
 
-#define REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0                    0x00000508
+#define REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0                    0x00000008
 
-#define REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1                    0x0000050c
+#define REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1                    0x0000000c
 
-#define REG_HDMI_8960_PHY_PLL_IDAC_ADJ_CFG                     0x00000510
+#define REG_HDMI_8960_PHY_PLL_IDAC_ADJ_CFG                     0x00000010
 
-#define REG_HDMI_8960_PHY_PLL_I_VI_KVCO_CFG                    0x00000514
+#define REG_HDMI_8960_PHY_PLL_I_VI_KVCO_CFG                    0x00000014
 
-#define REG_HDMI_8960_PHY_PLL_PWRDN_B                          0x00000518
+#define REG_HDMI_8960_PHY_PLL_PWRDN_B                          0x00000018
 #define HDMI_8960_PHY_PLL_PWRDN_B_PD_PLL                       0x00000002
 #define HDMI_8960_PHY_PLL_PWRDN_B_PLL_PWRDN_B                  0x00000008
 
-#define REG_HDMI_8960_PHY_PLL_SDM_CFG0                         0x0000051c
+#define REG_HDMI_8960_PHY_PLL_SDM_CFG0                         0x0000001c
 
-#define REG_HDMI_8960_PHY_PLL_SDM_CFG1                         0x00000520
+#define REG_HDMI_8960_PHY_PLL_SDM_CFG1                         0x00000020
 
-#define REG_HDMI_8960_PHY_PLL_SDM_CFG2                         0x00000524
+#define REG_HDMI_8960_PHY_PLL_SDM_CFG2                         0x00000024
 
-#define REG_HDMI_8960_PHY_PLL_SDM_CFG3                         0x00000528
+#define REG_HDMI_8960_PHY_PLL_SDM_CFG3                         0x00000028
 
-#define REG_HDMI_8960_PHY_PLL_SDM_CFG4                         0x0000052c
+#define REG_HDMI_8960_PHY_PLL_SDM_CFG4                         0x0000002c
 
-#define REG_HDMI_8960_PHY_PLL_SSC_CFG0                         0x00000530
+#define REG_HDMI_8960_PHY_PLL_SSC_CFG0                         0x00000030
 
-#define REG_HDMI_8960_PHY_PLL_SSC_CFG1                         0x00000534
+#define REG_HDMI_8960_PHY_PLL_SSC_CFG1                         0x00000034
 
-#define REG_HDMI_8960_PHY_PLL_SSC_CFG2                         0x00000538
+#define REG_HDMI_8960_PHY_PLL_SSC_CFG2                         0x00000038
 
-#define REG_HDMI_8960_PHY_PLL_SSC_CFG3                         0x0000053c
+#define REG_HDMI_8960_PHY_PLL_SSC_CFG3                         0x0000003c
 
-#define REG_HDMI_8960_PHY_PLL_LOCKDET_CFG0                     0x00000540
+#define REG_HDMI_8960_PHY_PLL_LOCKDET_CFG0                     0x00000040
 
-#define REG_HDMI_8960_PHY_PLL_LOCKDET_CFG1                     0x00000544
+#define REG_HDMI_8960_PHY_PLL_LOCKDET_CFG1                     0x00000044
 
-#define REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2                     0x00000548
+#define REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2                     0x00000048
 
-#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0                      0x0000054c
+#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0                      0x0000004c
 
-#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1                      0x00000550
+#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1                      0x00000050
 
-#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2                      0x00000554
+#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2                      0x00000054
 
-#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3                      0x00000558
+#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3                      0x00000058
 
-#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4                      0x0000055c
+#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4                      0x0000005c
 
-#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5                      0x00000560
+#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5                      0x00000060
 
-#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG6                      0x00000564
+#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG6                      0x00000064
 
-#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG7                      0x00000568
+#define REG_HDMI_8960_PHY_PLL_VCOCAL_CFG7                      0x00000068
 
-#define REG_HDMI_8960_PHY_PLL_DEBUG_SEL                                0x0000056c
+#define REG_HDMI_8960_PHY_PLL_DEBUG_SEL                                0x0000006c
 
-#define REG_HDMI_8960_PHY_PLL_MISC0                            0x00000570
+#define REG_HDMI_8960_PHY_PLL_MISC0                            0x00000070
 
-#define REG_HDMI_8960_PHY_PLL_MISC1                            0x00000574
+#define REG_HDMI_8960_PHY_PLL_MISC1                            0x00000074
 
-#define REG_HDMI_8960_PHY_PLL_MISC2                            0x00000578
+#define REG_HDMI_8960_PHY_PLL_MISC2                            0x00000078
 
-#define REG_HDMI_8960_PHY_PLL_MISC3                            0x0000057c
+#define REG_HDMI_8960_PHY_PLL_MISC3                            0x0000007c
 
-#define REG_HDMI_8960_PHY_PLL_MISC4                            0x00000580
+#define REG_HDMI_8960_PHY_PLL_MISC4                            0x00000080
 
-#define REG_HDMI_8960_PHY_PLL_MISC5                            0x00000584
+#define REG_HDMI_8960_PHY_PLL_MISC5                            0x00000084
 
-#define REG_HDMI_8960_PHY_PLL_MISC6                            0x00000588
+#define REG_HDMI_8960_PHY_PLL_MISC6                            0x00000088
 
-#define REG_HDMI_8960_PHY_PLL_DEBUG_BUS0                       0x0000058c
+#define REG_HDMI_8960_PHY_PLL_DEBUG_BUS0                       0x0000008c
 
-#define REG_HDMI_8960_PHY_PLL_DEBUG_BUS1                       0x00000590
+#define REG_HDMI_8960_PHY_PLL_DEBUG_BUS1                       0x00000090
 
-#define REG_HDMI_8960_PHY_PLL_DEBUG_BUS2                       0x00000594
+#define REG_HDMI_8960_PHY_PLL_DEBUG_BUS2                       0x00000094
 
-#define REG_HDMI_8960_PHY_PLL_STATUS0                          0x00000598
+#define REG_HDMI_8960_PHY_PLL_STATUS0                          0x00000098
 #define HDMI_8960_PHY_PLL_STATUS0_PLL_LOCK                     0x00000001
 
-#define REG_HDMI_8960_PHY_PLL_STATUS1                          0x0000059c
+#define REG_HDMI_8960_PHY_PLL_STATUS1                          0x0000009c
 
 #define REG_HDMI_8x74_ANA_CFG0                                 0x00000000
 
@@ -843,5 +844,501 @@ static inline uint32_t HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL(uint32_t val)
 
 #define REG_HDMI_28nm_PHY_PLL_DEBUG_BUS_SEL                    0x000000a0
 
+#define REG_HDMI_8996_PHY_CFG                                  0x00000000
+
+#define REG_HDMI_8996_PHY_PD_CTL                               0x00000004
+
+#define REG_HDMI_8996_PHY_MODE                                 0x00000008
+
+#define REG_HDMI_8996_PHY_MISR_CLEAR                           0x0000000c
+
+#define REG_HDMI_8996_PHY_TX0_TX1_BIST_CFG0                    0x00000010
+
+#define REG_HDMI_8996_PHY_TX0_TX1_BIST_CFG1                    0x00000014
+
+#define REG_HDMI_8996_PHY_TX0_TX1_PRBS_SEED_BYTE0              0x00000018
+
+#define REG_HDMI_8996_PHY_TX0_TX1_PRBS_SEED_BYTE1              0x0000001c
+
+#define REG_HDMI_8996_PHY_TX0_TX1_BIST_PATTERN0                        0x00000020
+
+#define REG_HDMI_8996_PHY_TX0_TX1_BIST_PATTERN1                        0x00000024
+
+#define REG_HDMI_8996_PHY_TX2_TX3_BIST_CFG0                    0x00000028
+
+#define REG_HDMI_8996_PHY_TX2_TX3_BIST_CFG1                    0x0000002c
+
+#define REG_HDMI_8996_PHY_TX2_TX3_PRBS_SEED_BYTE0              0x00000030
+
+#define REG_HDMI_8996_PHY_TX2_TX3_PRBS_SEED_BYTE1              0x00000034
+
+#define REG_HDMI_8996_PHY_TX2_TX3_BIST_PATTERN0                        0x00000038
+
+#define REG_HDMI_8996_PHY_TX2_TX3_BIST_PATTERN1                        0x0000003c
+
+#define REG_HDMI_8996_PHY_DEBUG_BUS_SEL                                0x00000040
+
+#define REG_HDMI_8996_PHY_TXCAL_CFG0                           0x00000044
+
+#define REG_HDMI_8996_PHY_TXCAL_CFG1                           0x00000048
+
+#define REG_HDMI_8996_PHY_TX0_TX1_LANE_CTL                     0x0000004c
+
+#define REG_HDMI_8996_PHY_TX2_TX3_LANE_CTL                     0x00000050
+
+#define REG_HDMI_8996_PHY_LANE_BIST_CONFIG                     0x00000054
+
+#define REG_HDMI_8996_PHY_CLOCK                                        0x00000058
+
+#define REG_HDMI_8996_PHY_MISC1                                        0x0000005c
+
+#define REG_HDMI_8996_PHY_MISC2                                        0x00000060
+
+#define REG_HDMI_8996_PHY_TX0_TX1_BIST_STATUS0                 0x00000064
+
+#define REG_HDMI_8996_PHY_TX0_TX1_BIST_STATUS1                 0x00000068
+
+#define REG_HDMI_8996_PHY_TX0_TX1_BIST_STATUS2                 0x0000006c
+
+#define REG_HDMI_8996_PHY_TX2_TX3_BIST_STATUS0                 0x00000070
+
+#define REG_HDMI_8996_PHY_TX2_TX3_BIST_STATUS1                 0x00000074
+
+#define REG_HDMI_8996_PHY_TX2_TX3_BIST_STATUS2                 0x00000078
+
+#define REG_HDMI_8996_PHY_PRE_MISR_STATUS0                     0x0000007c
+
+#define REG_HDMI_8996_PHY_PRE_MISR_STATUS1                     0x00000080
+
+#define REG_HDMI_8996_PHY_PRE_MISR_STATUS2                     0x00000084
+
+#define REG_HDMI_8996_PHY_PRE_MISR_STATUS3                     0x00000088
+
+#define REG_HDMI_8996_PHY_POST_MISR_STATUS0                    0x0000008c
+
+#define REG_HDMI_8996_PHY_POST_MISR_STATUS1                    0x00000090
+
+#define REG_HDMI_8996_PHY_POST_MISR_STATUS2                    0x00000094
+
+#define REG_HDMI_8996_PHY_POST_MISR_STATUS3                    0x00000098
+
+#define REG_HDMI_8996_PHY_STATUS                               0x0000009c
+
+#define REG_HDMI_8996_PHY_MISC3_STATUS                         0x000000a0
+
+#define REG_HDMI_8996_PHY_MISC4_STATUS                         0x000000a4
+
+#define REG_HDMI_8996_PHY_DEBUG_BUS0                           0x000000a8
+
+#define REG_HDMI_8996_PHY_DEBUG_BUS1                           0x000000ac
+
+#define REG_HDMI_8996_PHY_DEBUG_BUS2                           0x000000b0
+
+#define REG_HDMI_8996_PHY_DEBUG_BUS3                           0x000000b4
+
+#define REG_HDMI_8996_PHY_PHY_REVISION_ID0                     0x000000b8
+
+#define REG_HDMI_8996_PHY_PHY_REVISION_ID1                     0x000000bc
+
+#define REG_HDMI_8996_PHY_PHY_REVISION_ID2                     0x000000c0
+
+#define REG_HDMI_8996_PHY_PHY_REVISION_ID3                     0x000000c4
+
+#define REG_HDMI_PHY_QSERDES_COM_ATB_SEL1                      0x00000000
+
+#define REG_HDMI_PHY_QSERDES_COM_ATB_SEL2                      0x00000004
+
+#define REG_HDMI_PHY_QSERDES_COM_FREQ_UPDATE                   0x00000008
+
+#define REG_HDMI_PHY_QSERDES_COM_BG_TIMER                      0x0000000c
+
+#define REG_HDMI_PHY_QSERDES_COM_SSC_EN_CENTER                 0x00000010
+
+#define REG_HDMI_PHY_QSERDES_COM_SSC_ADJ_PER1                  0x00000014
+
+#define REG_HDMI_PHY_QSERDES_COM_SSC_ADJ_PER2                  0x00000018
+
+#define REG_HDMI_PHY_QSERDES_COM_SSC_PER1                      0x0000001c
+
+#define REG_HDMI_PHY_QSERDES_COM_SSC_PER2                      0x00000020
+
+#define REG_HDMI_PHY_QSERDES_COM_SSC_STEP_SIZE1                        0x00000024
+
+#define REG_HDMI_PHY_QSERDES_COM_SSC_STEP_SIZE2                        0x00000028
+
+#define REG_HDMI_PHY_QSERDES_COM_POST_DIV                      0x0000002c
+
+#define REG_HDMI_PHY_QSERDES_COM_POST_DIV_MUX                  0x00000030
+
+#define REG_HDMI_PHY_QSERDES_COM_BIAS_EN_CLKBUFLR_EN           0x00000034
+
+#define REG_HDMI_PHY_QSERDES_COM_CLK_ENABLE1                   0x00000038
+
+#define REG_HDMI_PHY_QSERDES_COM_SYS_CLK_CTRL                  0x0000003c
+
+#define REG_HDMI_PHY_QSERDES_COM_SYSCLK_BUF_ENABLE             0x00000040
+
+#define REG_HDMI_PHY_QSERDES_COM_PLL_EN                                0x00000044
+
+#define REG_HDMI_PHY_QSERDES_COM_PLL_IVCO                      0x00000048
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP1_MODE0               0x0000004c
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP2_MODE0               0x00000050
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP3_MODE0               0x00000054
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP1_MODE1               0x00000058
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP2_MODE1               0x0000005c
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP3_MODE1               0x00000060
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP1_MODE2               0x00000064
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_RSVD0                     0x00000064
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP2_MODE2               0x00000068
+
+#define REG_HDMI_PHY_QSERDES_COM_EP_CLOCK_DETECT_CTRL          0x00000068
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP3_MODE2               0x0000006c
+
+#define REG_HDMI_PHY_QSERDES_COM_SYSCLK_DET_COMP_STATUS                0x0000006c
+
+#define REG_HDMI_PHY_QSERDES_COM_BG_TRIM                       0x00000070
+
+#define REG_HDMI_PHY_QSERDES_COM_CLK_EP_DIV                    0x00000074
+
+#define REG_HDMI_PHY_QSERDES_COM_CP_CTRL_MODE0                 0x00000078
+
+#define REG_HDMI_PHY_QSERDES_COM_CP_CTRL_MODE1                 0x0000007c
+
+#define REG_HDMI_PHY_QSERDES_COM_CP_CTRL_MODE2                 0x00000080
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_RSVD1                     0x00000080
+
+#define REG_HDMI_PHY_QSERDES_COM_PLL_RCTRL_MODE0               0x00000084
+
+#define REG_HDMI_PHY_QSERDES_COM_PLL_RCTRL_MODE1               0x00000088
+
+#define REG_HDMI_PHY_QSERDES_COM_PLL_RCTRL_MODE2               0x0000008c
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_RSVD2                     0x0000008c
+
+#define REG_HDMI_PHY_QSERDES_COM_PLL_CCTRL_MODE0               0x00000090
+
+#define REG_HDMI_PHY_QSERDES_COM_PLL_CCTRL_MODE1               0x00000094
+
+#define REG_HDMI_PHY_QSERDES_COM_PLL_CCTRL_MODE2               0x00000098
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_RSVD3                     0x00000098
+
+#define REG_HDMI_PHY_QSERDES_COM_PLL_CNTRL                     0x0000009c
+
+#define REG_HDMI_PHY_QSERDES_COM_PHASE_SEL_CTRL                        0x000000a0
+
+#define REG_HDMI_PHY_QSERDES_COM_PHASE_SEL_DC                  0x000000a4
+
+#define REG_HDMI_PHY_QSERDES_COM_CORE_CLK_IN_SYNC_SEL          0x000000a8
+
+#define REG_HDMI_PHY_QSERDES_COM_BIAS_EN_CTRL_BY_PSM           0x000000a8
+
+#define REG_HDMI_PHY_QSERDES_COM_SYSCLK_EN_SEL                 0x000000ac
+
+#define REG_HDMI_PHY_QSERDES_COM_CML_SYSCLK_SEL                        0x000000b0
+
+#define REG_HDMI_PHY_QSERDES_COM_RESETSM_CNTRL                 0x000000b4
+
+#define REG_HDMI_PHY_QSERDES_COM_RESETSM_CNTRL2                        0x000000b8
+
+#define REG_HDMI_PHY_QSERDES_COM_RESTRIM_CTRL                  0x000000bc
+
+#define REG_HDMI_PHY_QSERDES_COM_RESTRIM_CTRL2                 0x000000c0
+
+#define REG_HDMI_PHY_QSERDES_COM_RESCODE_DIV_NUM               0x000000c4
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP_EN                   0x000000c8
+
+#define REG_HDMI_PHY_QSERDES_COM_LOCK_CMP_CFG                  0x000000cc
+
+#define REG_HDMI_PHY_QSERDES_COM_DEC_START_MODE0               0x000000d0
+
+#define REG_HDMI_PHY_QSERDES_COM_DEC_START_MODE1               0x000000d4
+
+#define REG_HDMI_PHY_QSERDES_COM_DEC_START_MODE2               0x000000d8
+
+#define REG_HDMI_PHY_QSERDES_COM_VCOCAL_DEADMAN_CTRL           0x000000d8
+
+#define REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START1_MODE0         0x000000dc
+
+#define REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START2_MODE0         0x000000e0
+
+#define REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START3_MODE0         0x000000e4
+
+#define REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START1_MODE1         0x000000e8
+
+#define REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START2_MODE1         0x000000ec
+
+#define REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START3_MODE1         0x000000f0
+
+#define REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START1_MODE2         0x000000f4
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_MINVAL1              0x000000f4
+
+#define REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START2_MODE2         0x000000f8
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_MINVAL2              0x000000f8
+
+#define REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START3_MODE2         0x000000fc
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_RSVD4                     0x000000fc
+
+#define REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_INITVAL             0x00000100
+
+#define REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_EN                  0x00000104
+
+#define REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_GAIN0_MODE0         0x00000108
+
+#define REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_GAIN1_MODE0         0x0000010c
+
+#define REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_GAIN0_MODE1         0x00000110
+
+#define REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_GAIN1_MODE1         0x00000114
+
+#define REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_GAIN0_MODE2         0x00000118
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_MAXVAL1              0x00000118
+
+#define REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_GAIN1_MODE2         0x0000011c
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_MAXVAL2              0x0000011c
+
+#define REG_HDMI_PHY_QSERDES_COM_RES_TRIM_CONTROL2             0x00000120
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_CTRL                 0x00000124
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_MAP                  0x00000128
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE1_MODE0               0x0000012c
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE2_MODE0               0x00000130
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE1_MODE1               0x00000134
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE2_MODE1               0x00000138
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE1_MODE2               0x0000013c
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_INITVAL1             0x0000013c
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE2_MODE2               0x00000140
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_INITVAL2             0x00000140
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_TIMER1               0x00000144
+
+#define REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_TIMER2               0x00000148
+
+#define REG_HDMI_PHY_QSERDES_COM_SAR                           0x0000014c
+
+#define REG_HDMI_PHY_QSERDES_COM_SAR_CLK                       0x00000150
+
+#define REG_HDMI_PHY_QSERDES_COM_SAR_CODE_OUT_STATUS           0x00000154
+
+#define REG_HDMI_PHY_QSERDES_COM_SAR_CODE_READY_STATUS         0x00000158
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_STATUS                    0x0000015c
+
+#define REG_HDMI_PHY_QSERDES_COM_RESET_SM_STATUS               0x00000160
+
+#define REG_HDMI_PHY_QSERDES_COM_RESTRIM_CODE_STATUS           0x00000164
+
+#define REG_HDMI_PHY_QSERDES_COM_PLLCAL_CODE1_STATUS           0x00000168
+
+#define REG_HDMI_PHY_QSERDES_COM_PLLCAL_CODE2_STATUS           0x0000016c
+
+#define REG_HDMI_PHY_QSERDES_COM_BG_CTRL                       0x00000170
+
+#define REG_HDMI_PHY_QSERDES_COM_CLK_SELECT                    0x00000174
+
+#define REG_HDMI_PHY_QSERDES_COM_HSCLK_SEL                     0x00000178
+
+#define REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_BINCODE_STATUS      0x0000017c
+
+#define REG_HDMI_PHY_QSERDES_COM_PLL_ANALOG                    0x00000180
+
+#define REG_HDMI_PHY_QSERDES_COM_CORECLK_DIV                   0x00000184
+
+#define REG_HDMI_PHY_QSERDES_COM_SW_RESET                      0x00000188
+
+#define REG_HDMI_PHY_QSERDES_COM_CORE_CLK_EN                   0x0000018c
+
+#define REG_HDMI_PHY_QSERDES_COM_C_READY_STATUS                        0x00000190
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_CONFIG                    0x00000194
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_RATE_OVERRIDE             0x00000198
+
+#define REG_HDMI_PHY_QSERDES_COM_SVS_MODE_CLK_SEL              0x0000019c
+
+#define REG_HDMI_PHY_QSERDES_COM_DEBUG_BUS0                    0x000001a0
+
+#define REG_HDMI_PHY_QSERDES_COM_DEBUG_BUS1                    0x000001a4
+
+#define REG_HDMI_PHY_QSERDES_COM_DEBUG_BUS2                    0x000001a8
+
+#define REG_HDMI_PHY_QSERDES_COM_DEBUG_BUS3                    0x000001ac
+
+#define REG_HDMI_PHY_QSERDES_COM_DEBUG_BUS_SEL                 0x000001b0
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_MISC1                     0x000001b4
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_MISC2                     0x000001b8
+
+#define REG_HDMI_PHY_QSERDES_COM_CORECLK_DIV_MODE1             0x000001bc
+
+#define REG_HDMI_PHY_QSERDES_COM_CORECLK_DIV_MODE2             0x000001c0
+
+#define REG_HDMI_PHY_QSERDES_COM_CMN_RSVD5                     0x000001c4
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_MODE_LANENO            0x00000000
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_INVERT                 0x00000004
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_CLKBUF_ENABLE               0x00000008
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_CMN_CONTROL_ONE             0x0000000c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_CMN_CONTROL_TWO             0x00000010
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_CMN_CONTROL_THREE           0x00000014
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_EMP_POST1_LVL            0x00000018
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_POST2_EMPH               0x0000001c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_BOOST_LVL_UP_DN          0x00000020
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_HP_PD_ENABLES               0x00000024
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_IDLE_LVL_LARGE_AMP       0x00000028
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_DRV_LVL                  0x0000002c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_DRV_LVL_OFFSET           0x00000030
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_RESET_TSYNC_EN              0x00000034
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PRE_STALL_LDO_BOOST_EN      0x00000038
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_BAND                     0x0000003c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_SLEW_CNTL                   0x00000040
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_INTERFACE_SELECT            0x00000044
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_LPB_EN                      0x00000048
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_RES_CODE_LANE_TX            0x0000004c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_RES_CODE_LANE_RX            0x00000050
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_RES_CODE_LANE_OFFSET                0x00000054
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PERL_LENGTH1                        0x00000058
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PERL_LENGTH2                        0x0000005c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_SERDES_BYP_EN_OUT           0x00000060
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_DEBUG_BUS_SEL               0x00000064
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN    0x00000068
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_POL_INV                  0x0000006c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PARRATE_REC_DETECT_IDLE_EN  0x00000070
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_PATTERN1               0x00000074
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_PATTERN2               0x00000078
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_PATTERN3               0x0000007c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_PATTERN4               0x00000080
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_PATTERN5               0x00000084
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_PATTERN6               0x00000088
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_PATTERN7               0x0000008c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_PATTERN8               0x00000090
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_LANE_MODE                   0x00000094
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_IDAC_CAL_LANE_MODE          0x00000098
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_IDAC_CAL_LANE_MODE_CONFIGURATION    0x0000009c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_ATB_SEL1                    0x000000a0
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_ATB_SEL2                    0x000000a4
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_RCV_DETECT_LVL              0x000000a8
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_RCV_DETECT_LVL_2            0x000000ac
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PRBS_SEED1                  0x000000b0
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PRBS_SEED2                  0x000000b4
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PRBS_SEED3                  0x000000b8
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PRBS_SEED4                  0x000000bc
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_RESET_GEN                   0x000000c0
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_RESET_GEN_MUXES             0x000000c4
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TRAN_DRVR_EMP_EN            0x000000c8
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_INTERFACE_MODE           0x000000cc
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PWM_CTRL                    0x000000d0
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PWM_ENCODED_OR_DATA         0x000000d4
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PWM_GEAR_1_DIVIDER_BAND2    0x000000d8
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PWM_GEAR_2_DIVIDER_BAND2    0x000000dc
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PWM_GEAR_3_DIVIDER_BAND2    0x000000e0
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PWM_GEAR_4_DIVIDER_BAND2    0x000000e4
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PWM_GEAR_1_DIVIDER_BAND0_1  0x000000e8
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PWM_GEAR_2_DIVIDER_BAND0_1  0x000000ec
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PWM_GEAR_3_DIVIDER_BAND0_1  0x000000f0
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_PWM_GEAR_4_DIVIDER_BAND0_1  0x000000f4
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_VMODE_CTRL1                 0x000000f8
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_VMODE_CTRL2                 0x000000fc
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_ALOG_INTF_OBSV_CNTL      0x00000100
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_STATUS                 0x00000104
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_ERROR_COUNT1           0x00000108
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_BIST_ERROR_COUNT2           0x0000010c
+
+#define REG_HDMI_PHY_QSERDES_TX_LX_TX_ALOG_INTF_OBSV           0x00000110
+
 
 #endif /* HDMI_XML */
index df232e2..a54d3bb 100644 (file)
@@ -89,7 +89,7 @@ static const struct hdmi_msm_audio_arcs *get_arcs(unsigned long int pixclock)
        return NULL;
 }
 
-int hdmi_audio_update(struct hdmi *hdmi)
+int msm_hdmi_audio_update(struct hdmi *hdmi)
 {
        struct hdmi_audio *audio = &hdmi->audio;
        struct hdmi_audio_infoframe *info = &audio->infoframe;
@@ -232,7 +232,7 @@ int hdmi_audio_update(struct hdmi *hdmi)
        return 0;
 }
 
-int hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled,
+int msm_hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled,
        uint32_t num_of_channels, uint32_t channel_allocation,
        uint32_t level_shift, bool down_mix)
 {
@@ -252,10 +252,10 @@ int hdmi_audio_info_setup(struct hdmi *hdmi, bool enabled,
        audio->infoframe.level_shift_value = level_shift;
        audio->infoframe.downmix_inhibit = down_mix;
 
-       return hdmi_audio_update(hdmi);
+       return msm_hdmi_audio_update(hdmi);
 }
 
-void hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate)
+void msm_hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate)
 {
        struct hdmi_audio *audio;
 
@@ -268,5 +268,5 @@ void hdmi_audio_set_sample_rate(struct hdmi *hdmi, int rate)
                return;
 
        audio->rate = rate;
-       hdmi_audio_update(hdmi);
+       msm_hdmi_audio_update(hdmi);
 }
index 92b69ae..bacbd5d 100644 (file)
@@ -23,11 +23,11 @@ struct hdmi_bridge {
 };
 #define to_hdmi_bridge(x) container_of(x, struct hdmi_bridge, base)
 
-void hdmi_bridge_destroy(struct drm_bridge *bridge)
+void msm_hdmi_bridge_destroy(struct drm_bridge *bridge)
 {
 }
 
-static void power_on(struct drm_bridge *bridge)
+static void msm_hdmi_power_on(struct drm_bridge *bridge)
 {
        struct drm_device *dev = bridge->dev;
        struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge);
@@ -86,7 +86,7 @@ static void power_off(struct drm_bridge *bridge)
        }
 }
 
-static void hdmi_bridge_pre_enable(struct drm_bridge *bridge)
+static void msm_hdmi_bridge_pre_enable(struct drm_bridge *bridge)
 {
        struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge);
        struct hdmi *hdmi = hdmi_bridge->hdmi;
@@ -95,51 +95,51 @@ static void hdmi_bridge_pre_enable(struct drm_bridge *bridge)
        DBG("power up");
 
        if (!hdmi->power_on) {
-               power_on(bridge);
+               msm_hdmi_phy_resource_enable(phy);
+               msm_hdmi_power_on(bridge);
                hdmi->power_on = true;
-               hdmi_audio_update(hdmi);
+               msm_hdmi_audio_update(hdmi);
        }
 
-       if (phy)
-               phy->funcs->powerup(phy, hdmi->pixclock);
+       msm_hdmi_phy_powerup(phy, hdmi->pixclock);
 
-       hdmi_set_mode(hdmi, true);
+       msm_hdmi_set_mode(hdmi, true);
 
        if (hdmi->hdcp_ctrl)
-               hdmi_hdcp_on(hdmi->hdcp_ctrl);
+               msm_hdmi_hdcp_on(hdmi->hdcp_ctrl);
 }
 
-static void hdmi_bridge_enable(struct drm_bridge *bridge)
+static void msm_hdmi_bridge_enable(struct drm_bridge *bridge)
 {
 }
 
-static void hdmi_bridge_disable(struct drm_bridge *bridge)
+static void msm_hdmi_bridge_disable(struct drm_bridge *bridge)
 {
 }
 
-static void hdmi_bridge_post_disable(struct drm_bridge *bridge)
+static void msm_hdmi_bridge_post_disable(struct drm_bridge *bridge)
 {
        struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge);
        struct hdmi *hdmi = hdmi_bridge->hdmi;
        struct hdmi_phy *phy = hdmi->phy;
 
        if (hdmi->hdcp_ctrl)
-               hdmi_hdcp_off(hdmi->hdcp_ctrl);
+               msm_hdmi_hdcp_off(hdmi->hdcp_ctrl);
 
        DBG("power down");
-       hdmi_set_mode(hdmi, false);
+       msm_hdmi_set_mode(hdmi, false);
 
-       if (phy)
-               phy->funcs->powerdown(phy);
+       msm_hdmi_phy_powerdown(phy);
 
        if (hdmi->power_on) {
                power_off(bridge);
                hdmi->power_on = false;
-               hdmi_audio_update(hdmi);
+               msm_hdmi_audio_update(hdmi);
+               msm_hdmi_phy_resource_disable(phy);
        }
 }
 
-static void hdmi_bridge_mode_set(struct drm_bridge *bridge,
+static void msm_hdmi_bridge_mode_set(struct drm_bridge *bridge,
                 struct drm_display_mode *mode,
                 struct drm_display_mode *adjusted_mode)
 {
@@ -196,20 +196,20 @@ static void hdmi_bridge_mode_set(struct drm_bridge *bridge,
        DBG("frame_ctrl=%08x", frame_ctrl);
        hdmi_write(hdmi, REG_HDMI_FRAME_CTRL, frame_ctrl);
 
-       hdmi_audio_update(hdmi);
+       msm_hdmi_audio_update(hdmi);
 }
 
-static const struct drm_bridge_funcs hdmi_bridge_funcs = {
-               .pre_enable = hdmi_bridge_pre_enable,
-               .enable = hdmi_bridge_enable,
-               .disable = hdmi_bridge_disable,
-               .post_disable = hdmi_bridge_post_disable,
-               .mode_set = hdmi_bridge_mode_set,
+static const struct drm_bridge_funcs msm_hdmi_bridge_funcs = {
+               .pre_enable = msm_hdmi_bridge_pre_enable,
+               .enable = msm_hdmi_bridge_enable,
+               .disable = msm_hdmi_bridge_disable,
+               .post_disable = msm_hdmi_bridge_post_disable,
+               .mode_set = msm_hdmi_bridge_mode_set,
 };
 
 
 /* initialize bridge */
-struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi)
+struct drm_bridge *msm_hdmi_bridge_init(struct hdmi *hdmi)
 {
        struct drm_bridge *bridge = NULL;
        struct hdmi_bridge *hdmi_bridge;
@@ -225,7 +225,7 @@ struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi)
        hdmi_bridge->hdmi = hdmi;
 
        bridge = &hdmi_bridge->base;
-       bridge->funcs = &hdmi_bridge_funcs;
+       bridge->funcs = &msm_hdmi_bridge_funcs;
 
        ret = drm_bridge_attach(hdmi->dev, bridge);
        if (ret)
@@ -235,7 +235,7 @@ struct drm_bridge *hdmi_bridge_init(struct hdmi *hdmi)
 
 fail:
        if (bridge)
-               hdmi_bridge_destroy(bridge);
+               msm_hdmi_bridge_destroy(bridge);
 
        return ERR_PTR(ret);
 }
index a3b05ae..26129bf 100644 (file)
@@ -28,7 +28,7 @@ struct hdmi_connector {
 };
 #define to_hdmi_connector(x) container_of(x, struct hdmi_connector, base)
 
-static void hdmi_phy_reset(struct hdmi *hdmi)
+static void msm_hdmi_phy_reset(struct hdmi *hdmi)
 {
        unsigned int val;
 
@@ -81,114 +81,54 @@ static int gpio_config(struct hdmi *hdmi, bool on)
 {
        struct device *dev = &hdmi->pdev->dev;
        const struct hdmi_platform_config *config = hdmi->config;
-       int ret;
+       int ret, i;
 
        if (on) {
-               if (config->ddc_clk_gpio != -1) {
-                       ret = gpio_request(config->ddc_clk_gpio, "HDMI_DDC_CLK");
-                       if (ret) {
-                               dev_err(dev, "'%s'(%d) gpio_request failed: %d\n",
-                                       "HDMI_DDC_CLK", config->ddc_clk_gpio, ret);
-                               goto error1;
-                       }
-                       gpio_set_value_cansleep(config->ddc_clk_gpio, 1);
-               }
-
-               if (config->ddc_data_gpio != -1) {
-                       ret = gpio_request(config->ddc_data_gpio, "HDMI_DDC_DATA");
-                       if (ret) {
-                               dev_err(dev, "'%s'(%d) gpio_request failed: %d\n",
-                                       "HDMI_DDC_DATA", config->ddc_data_gpio, ret);
-                               goto error2;
-                       }
-                       gpio_set_value_cansleep(config->ddc_data_gpio, 1);
-               }
-
-               ret = gpio_request(config->hpd_gpio, "HDMI_HPD");
-               if (ret) {
-                       dev_err(dev, "'%s'(%d) gpio_request failed: %d\n",
-                               "HDMI_HPD", config->hpd_gpio, ret);
-                       goto error3;
-               }
-               gpio_direction_input(config->hpd_gpio);
-               gpio_set_value_cansleep(config->hpd_gpio, 1);
-
-               if (config->mux_en_gpio != -1) {
-                       ret = gpio_request(config->mux_en_gpio, "HDMI_MUX_EN");
-                       if (ret) {
-                               dev_err(dev, "'%s'(%d) gpio_request failed: %d\n",
-                                       "HDMI_MUX_EN", config->mux_en_gpio, ret);
-                               goto error4;
-                       }
-                       gpio_set_value_cansleep(config->mux_en_gpio, 1);
-               }
-
-               if (config->mux_sel_gpio != -1) {
-                       ret = gpio_request(config->mux_sel_gpio, "HDMI_MUX_SEL");
-                       if (ret) {
-                               dev_err(dev, "'%s'(%d) gpio_request failed: %d\n",
-                                       "HDMI_MUX_SEL", config->mux_sel_gpio, ret);
-                               goto error5;
+               for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
+                       struct hdmi_gpio_data gpio = config->gpios[i];
+
+                       if (gpio.num != -1) {
+                               ret = gpio_request(gpio.num, gpio.label);
+                               if (ret) {
+                                       dev_err(dev,
+                                               "'%s'(%d) gpio_request failed: %d\n",
+                                               gpio.label, gpio.num, ret);
+                                       goto err;
+                               }
+
+                               if (gpio.output) {
+                                       gpio_direction_output(gpio.num,
+                                                             gpio.value);
+                               } else {
+                                       gpio_direction_input(gpio.num);
+                                       gpio_set_value_cansleep(gpio.num,
+                                                               gpio.value);
+                               }
                        }
-                       gpio_set_value_cansleep(config->mux_sel_gpio, 0);
                }
 
-               if (config->mux_lpm_gpio != -1) {
-                       ret = gpio_request(config->mux_lpm_gpio,
-                                       "HDMI_MUX_LPM");
-                       if (ret) {
-                               dev_err(dev,
-                                       "'%s'(%d) gpio_request failed: %d\n",
-                                       "HDMI_MUX_LPM",
-                                       config->mux_lpm_gpio, ret);
-                               goto error6;
-                       }
-                       gpio_set_value_cansleep(config->mux_lpm_gpio, 1);
-               }
                DBG("gpio on");
        } else {
-               if (config->ddc_clk_gpio != -1)
-                       gpio_free(config->ddc_clk_gpio);
-
-               if (config->ddc_data_gpio != -1)
-                       gpio_free(config->ddc_data_gpio);
+               for (i = 0; i < HDMI_MAX_NUM_GPIO; i++) {
+                       struct hdmi_gpio_data gpio = config->gpios[i];
 
-               gpio_free(config->hpd_gpio);
+                       if (gpio.output) {
+                               int value = gpio.value ? 0 : 1;
 
-               if (config->mux_en_gpio != -1) {
-                       gpio_set_value_cansleep(config->mux_en_gpio, 0);
-                       gpio_free(config->mux_en_gpio);
-               }
+                               gpio_set_value_cansleep(gpio.num, value);
+                       }
 
-               if (config->mux_sel_gpio != -1) {
-                       gpio_set_value_cansleep(config->mux_sel_gpio, 1);
-                       gpio_free(config->mux_sel_gpio);
-               }
+                       gpio_free(gpio.num);
+               };
 
-               if (config->mux_lpm_gpio != -1) {
-                       gpio_set_value_cansleep(config->mux_lpm_gpio, 0);
-                       gpio_free(config->mux_lpm_gpio);
-               }
                DBG("gpio off");
        }
 
        return 0;
+err:
+       while (i--)
+               gpio_free(config->gpios[i].num);
 
-error6:
-       if (config->mux_sel_gpio != -1)
-               gpio_free(config->mux_sel_gpio);
-error5:
-       if (config->mux_en_gpio != -1)
-               gpio_free(config->mux_en_gpio);
-error4:
-       gpio_free(config->hpd_gpio);
-error3:
-       if (config->ddc_data_gpio != -1)
-               gpio_free(config->ddc_data_gpio);
-error2:
-       if (config->ddc_clk_gpio != -1)
-               gpio_free(config->ddc_clk_gpio);
-error1:
        return ret;
 }
 
@@ -239,9 +179,9 @@ static int hpd_enable(struct hdmi_connector *hdmi_connector)
                }
        }
 
-       hdmi_set_mode(hdmi, false);
-       hdmi_phy_reset(hdmi);
-       hdmi_set_mode(hdmi, true);
+       msm_hdmi_set_mode(hdmi, false);
+       msm_hdmi_phy_reset(hdmi);
+       msm_hdmi_set_mode(hdmi, true);
 
        hdmi_write(hdmi, REG_HDMI_USEC_REFTIMER, 0x0001001b);
 
@@ -278,7 +218,7 @@ static void hdp_disable(struct hdmi_connector *hdmi_connector)
        /* Disable HPD interrupt */
        hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, 0);
 
-       hdmi_set_mode(hdmi, false);
+       msm_hdmi_set_mode(hdmi, false);
 
        for (i = 0; i < config->hpd_clk_cnt; i++)
                clk_disable_unprepare(hdmi->hpd_clks[i]);
@@ -300,7 +240,7 @@ static void hdp_disable(struct hdmi_connector *hdmi_connector)
 }
 
 static void
-hotplug_work(struct work_struct *work)
+msm_hdmi_hotplug_work(struct work_struct *work)
 {
        struct hdmi_connector *hdmi_connector =
                container_of(work, struct hdmi_connector, hpd_work);
@@ -308,7 +248,7 @@ hotplug_work(struct work_struct *work)
        drm_helper_hpd_irq_event(connector->dev);
 }
 
-void hdmi_connector_irq(struct drm_connector *connector)
+void msm_hdmi_connector_irq(struct drm_connector *connector)
 {
        struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
        struct hdmi *hdmi = hdmi_connector->hdmi;
@@ -345,10 +285,13 @@ static enum drm_connector_status detect_reg(struct hdmi *hdmi)
                        connector_status_connected : connector_status_disconnected;
 }
 
+#define HPD_GPIO_INDEX 2
 static enum drm_connector_status detect_gpio(struct hdmi *hdmi)
 {
        const struct hdmi_platform_config *config = hdmi->config;
-       return gpio_get_value(config->hpd_gpio) ?
+       struct hdmi_gpio_data hpd_gpio = config->gpios[HPD_GPIO_INDEX];
+
+       return gpio_get_value(hpd_gpio.num) ?
                        connector_status_connected :
                        connector_status_disconnected;
 }
@@ -358,9 +301,18 @@ static enum drm_connector_status hdmi_connector_detect(
 {
        struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
        struct hdmi *hdmi = hdmi_connector->hdmi;
+       const struct hdmi_platform_config *config = hdmi->config;
+       struct hdmi_gpio_data hpd_gpio = config->gpios[HPD_GPIO_INDEX];
        enum drm_connector_status stat_gpio, stat_reg;
        int retry = 20;
 
+       /*
+        * some platforms may not have hpd gpio. Rely only on the status
+        * provided by REG_HDMI_HPD_INT_STATUS in this case.
+        */
+       if (hpd_gpio.num == -1)
+               return detect_reg(hdmi);
+
        do {
                stat_gpio = detect_gpio(hdmi);
                stat_reg  = detect_reg(hdmi);
@@ -395,7 +347,7 @@ static void hdmi_connector_destroy(struct drm_connector *connector)
        kfree(hdmi_connector);
 }
 
-static int hdmi_connector_get_modes(struct drm_connector *connector)
+static int msm_hdmi_connector_get_modes(struct drm_connector *connector)
 {
        struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
        struct hdmi *hdmi = hdmi_connector->hdmi;
@@ -421,7 +373,7 @@ static int hdmi_connector_get_modes(struct drm_connector *connector)
        return ret;
 }
 
-static int hdmi_connector_mode_valid(struct drm_connector *connector,
+static int msm_hdmi_connector_mode_valid(struct drm_connector *connector,
                                 struct drm_display_mode *mode)
 {
        struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
@@ -451,7 +403,7 @@ static int hdmi_connector_mode_valid(struct drm_connector *connector,
 }
 
 static struct drm_encoder *
-hdmi_connector_best_encoder(struct drm_connector *connector)
+msm_hdmi_connector_best_encoder(struct drm_connector *connector)
 {
        struct hdmi_connector *hdmi_connector = to_hdmi_connector(connector);
        return hdmi_connector->hdmi->encoder;
@@ -467,14 +419,14 @@ static const struct drm_connector_funcs hdmi_connector_funcs = {
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static const struct drm_connector_helper_funcs hdmi_connector_helper_funcs = {
-       .get_modes = hdmi_connector_get_modes,
-       .mode_valid = hdmi_connector_mode_valid,
-       .best_encoder = hdmi_connector_best_encoder,
+static const struct drm_connector_helper_funcs msm_hdmi_connector_helper_funcs = {
+       .get_modes = msm_hdmi_connector_get_modes,
+       .mode_valid = msm_hdmi_connector_mode_valid,
+       .best_encoder = msm_hdmi_connector_best_encoder,
 };
 
 /* initialize connector */
-struct drm_connector *hdmi_connector_init(struct hdmi *hdmi)
+struct drm_connector *msm_hdmi_connector_init(struct hdmi *hdmi)
 {
        struct drm_connector *connector = NULL;
        struct hdmi_connector *hdmi_connector;
@@ -487,13 +439,13 @@ struct drm_connector *hdmi_connector_init(struct hdmi *hdmi)
        }
 
        hdmi_connector->hdmi = hdmi;
-       INIT_WORK(&hdmi_connector->hpd_work, hotplug_work);
+       INIT_WORK(&hdmi_connector->hpd_work, msm_hdmi_hotplug_work);
 
        connector = &hdmi_connector->base;
 
        drm_connector_init(hdmi->dev, connector, &hdmi_connector_funcs,
                        DRM_MODE_CONNECTOR_HDMIA);
-       drm_connector_helper_add(connector, &hdmi_connector_helper_funcs);
+       drm_connector_helper_add(connector, &msm_hdmi_connector_helper_funcs);
 
        connector->polled = DRM_CONNECTOR_POLL_CONNECT |
                        DRM_CONNECTOR_POLL_DISCONNECT;
index 1dc9c34..0baaaaa 100644 (file)
@@ -84,7 +84,7 @@ struct hdmi_hdcp_ctrl {
        bool max_dev_exceeded;
 };
 
-static int hdmi_ddc_read(struct hdmi *hdmi, u16 addr, u8 offset,
+static int msm_hdmi_ddc_read(struct hdmi *hdmi, u16 addr, u8 offset,
        u8 *data, u16 data_len)
 {
        int rc;
@@ -122,7 +122,7 @@ retry:
 
 #define HDCP_DDC_WRITE_MAX_BYTE_NUM 32
 
-static int hdmi_ddc_write(struct hdmi *hdmi, u16 addr, u8 offset,
+static int msm_hdmi_ddc_write(struct hdmi *hdmi, u16 addr, u8 offset,
        u8 *data, u16 data_len)
 {
        int rc;
@@ -162,7 +162,7 @@ retry:
        return rc;
 }
 
-static int hdmi_hdcp_scm_wr(struct hdmi_hdcp_ctrl *hdcp_ctrl, u32 *preg,
+static int msm_hdmi_hdcp_scm_wr(struct hdmi_hdcp_ctrl *hdcp_ctrl, u32 *preg,
        u32 *pdata, u32 count)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
@@ -202,7 +202,7 @@ static int hdmi_hdcp_scm_wr(struct hdmi_hdcp_ctrl *hdcp_ctrl, u32 *preg,
        return ret;
 }
 
-void hdmi_hdcp_irq(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+void msm_hdmi_hdcp_irq(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        u32 reg_val, hdcp_int_status;
@@ -247,7 +247,7 @@ void hdmi_hdcp_irq(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        }
 }
 
-static int hdmi_hdcp_msleep(struct hdmi_hdcp_ctrl *hdcp_ctrl, u32 ms, u32 ev)
+static int msm_hdmi_hdcp_msleep(struct hdmi_hdcp_ctrl *hdcp_ctrl, u32 ms, u32 ev)
 {
        int rc;
 
@@ -264,7 +264,7 @@ static int hdmi_hdcp_msleep(struct hdmi_hdcp_ctrl *hdcp_ctrl, u32 ms, u32 ev)
        return 0;
 }
 
-static int hdmi_hdcp_read_validate_aksv(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_read_validate_aksv(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
 
@@ -287,7 +287,7 @@ static int hdmi_hdcp_read_validate_aksv(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        return 0;
 }
 
-static int reset_hdcp_ddc_failures(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_reset_hdcp_ddc_failures(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        u32 reg_val, failure, nack0;
@@ -337,7 +337,7 @@ static int reset_hdcp_ddc_failures(struct hdmi_hdcp_ctrl *hdcp_ctrl)
                reg_val |= HDMI_DDC_CTRL_SW_STATUS_RESET;
                hdmi_write(hdmi, REG_HDMI_DDC_CTRL, reg_val);
 
-               rc = hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
+               rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
 
                reg_val = hdmi_read(hdmi, REG_HDMI_DDC_CTRL);
                reg_val &= ~HDMI_DDC_CTRL_SW_STATUS_RESET;
@@ -350,7 +350,7 @@ static int reset_hdcp_ddc_failures(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 
                /* If previous msleep is aborted, skip this msleep */
                if (!rc)
-                       rc = hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
+                       rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
 
                reg_val = hdmi_read(hdmi, REG_HDMI_DDC_CTRL);
                reg_val &= ~HDMI_DDC_CTRL_SOFT_RESET;
@@ -362,7 +362,7 @@ static int reset_hdcp_ddc_failures(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        return rc;
 }
 
-static int hdmi_hdcp_hw_ddc_clean(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_hw_ddc_clean(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int rc;
        u32 hdcp_ddc_status, ddc_hw_status;
@@ -394,7 +394,7 @@ static int hdmi_hdcp_hw_ddc_clean(struct hdmi_hdcp_ctrl *hdcp_ctrl)
                        return -ETIMEDOUT;
                }
 
-               rc = hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
+               rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
                if (rc)
                        return rc;
        } while (1);
@@ -402,7 +402,7 @@ static int hdmi_hdcp_hw_ddc_clean(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        return 0;
 }
 
-static void hdmi_hdcp_reauth_work(struct work_struct *work)
+static void msm_hdmi_hdcp_reauth_work(struct work_struct *work)
 {
        struct hdmi_hdcp_ctrl *hdcp_ctrl = container_of(work,
                struct hdmi_hdcp_ctrl, hdcp_reauth_work);
@@ -430,7 +430,7 @@ static void hdmi_hdcp_reauth_work(struct work_struct *work)
                HDMI_HDCP_RESET_LINK0_DEAUTHENTICATE);
 
        /* Wait to be clean on DDC HW engine */
-       if (hdmi_hdcp_hw_ddc_clean(hdcp_ctrl)) {
+       if (msm_hdmi_hdcp_hw_ddc_clean(hdcp_ctrl)) {
                pr_info("%s: reauth work aborted\n", __func__);
                return;
        }
@@ -461,7 +461,7 @@ static void hdmi_hdcp_reauth_work(struct work_struct *work)
        queue_work(hdmi->workq, &hdcp_ctrl->hdcp_auth_work);
 }
 
-static int hdmi_hdcp_auth_prepare(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_auth_prepare(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        u32 link0_status;
@@ -470,7 +470,7 @@ static int hdmi_hdcp_auth_prepare(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        int rc;
 
        if (!hdcp_ctrl->aksv_valid) {
-               rc = hdmi_hdcp_read_validate_aksv(hdcp_ctrl);
+               rc = msm_hdmi_hdcp_read_validate_aksv(hdcp_ctrl);
                if (rc) {
                        pr_err("%s: ASKV validation failed\n", __func__);
                        hdcp_ctrl->hdcp_state = HDCP_STATE_NO_AKSV;
@@ -538,12 +538,12 @@ static int hdmi_hdcp_auth_prepare(struct hdmi_hdcp_ctrl *hdcp_ctrl)
                DBG("An not ready after enabling HDCP");
 
        /* Clear any DDC failures from previous tries before enable HDCP*/
-       rc = reset_hdcp_ddc_failures(hdcp_ctrl);
+       rc = msm_reset_hdcp_ddc_failures(hdcp_ctrl);
 
        return rc;
 }
 
-static void hdmi_hdcp_auth_fail(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static void msm_hdmi_hdcp_auth_fail(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        u32 reg_val;
@@ -561,7 +561,7 @@ static void hdmi_hdcp_auth_fail(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        queue_work(hdmi->workq, &hdcp_ctrl->hdcp_reauth_work);
 }
 
-static void hdmi_hdcp_auth_done(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static void msm_hdmi_hdcp_auth_done(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        u32 reg_val;
@@ -596,7 +596,7 @@ static void hdmi_hdcp_auth_done(struct hdmi_hdcp_ctrl *hdcp_ctrl)
  * Write An and AKSV to sink
  * Read BKSV from sink and write into HDCP engine
  */
-static int hdmi_hdcp_wait_key_an_ready(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_wait_key_an_ready(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int rc;
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
@@ -621,7 +621,7 @@ static int hdmi_hdcp_wait_key_an_ready(struct hdmi_hdcp_ctrl *hdcp_ctrl)
                        return -ETIMEDOUT;
                }
 
-               rc = hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
+               rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
                if (rc)
                        return rc;
        } while (1);
@@ -643,7 +643,7 @@ static int hdmi_hdcp_wait_key_an_ready(struct hdmi_hdcp_ctrl *hdcp_ctrl)
                        return -ETIMEDOUT;
                }
 
-               rc = hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
+               rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
                if (rc)
                        return rc;
        } while (1);
@@ -651,7 +651,7 @@ static int hdmi_hdcp_wait_key_an_ready(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        return 0;
 }
 
-static int hdmi_hdcp_send_aksv_an(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_send_aksv_an(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int rc = 0;
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
@@ -676,7 +676,7 @@ static int hdmi_hdcp_send_aksv_an(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        aksv[4] =  link0_aksv_1        & 0xFF;
 
        /* Write An to offset 0x18 */
-       rc = hdmi_ddc_write(hdmi, HDCP_PORT_ADDR, 0x18, (u8 *)link0_an,
+       rc = msm_hdmi_ddc_write(hdmi, HDCP_PORT_ADDR, 0x18, (u8 *)link0_an,
                (u16)sizeof(link0_an));
        if (rc) {
                pr_err("%s:An write failed\n", __func__);
@@ -685,7 +685,7 @@ static int hdmi_hdcp_send_aksv_an(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        DBG("Link0-An=%08x%08x", link0_an[0], link0_an[1]);
 
        /* Write AKSV to offset 0x10 */
-       rc = hdmi_ddc_write(hdmi, HDCP_PORT_ADDR, 0x10, aksv, 5);
+       rc = msm_hdmi_ddc_write(hdmi, HDCP_PORT_ADDR, 0x10, aksv, 5);
        if (rc) {
                pr_err("%s:AKSV write failed\n", __func__);
                return rc;
@@ -695,7 +695,7 @@ static int hdmi_hdcp_send_aksv_an(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        return 0;
 }
 
-static int hdmi_hdcp_recv_bksv(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_recv_bksv(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int rc = 0;
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
@@ -703,7 +703,7 @@ static int hdmi_hdcp_recv_bksv(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        u32 reg[2], data[2];
 
        /* Read BKSV at offset 0x00 */
-       rc = hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x00, bksv, 5);
+       rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x00, bksv, 5);
        if (rc) {
                pr_err("%s:BKSV read failed\n", __func__);
                return rc;
@@ -728,19 +728,19 @@ static int hdmi_hdcp_recv_bksv(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        data[0] = hdcp_ctrl->bksv_lsb;
        reg[1] = REG_HDMI_HDCP_RCVPORT_DATA1;
        data[1] = hdcp_ctrl->bksv_msb;
-       rc = hdmi_hdcp_scm_wr(hdcp_ctrl, reg, data, 2);
+       rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, reg, data, 2);
 
        return rc;
 }
 
-static int hdmi_hdcp_recv_bcaps(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_recv_bcaps(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int rc = 0;
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        u32 reg, data;
        u8 bcaps;
 
-       rc = hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x40, &bcaps, 1);
+       rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x40, &bcaps, 1);
        if (rc) {
                pr_err("%s:BCAPS read failed\n", __func__);
                return rc;
@@ -753,26 +753,26 @@ static int hdmi_hdcp_recv_bcaps(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        /* Write BCAPS to the hardware */
        reg = REG_HDMI_HDCP_RCVPORT_DATA12;
        data = (u32)bcaps;
-       rc = hdmi_hdcp_scm_wr(hdcp_ctrl, &reg, &data, 1);
+       rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, &reg, &data, 1);
 
        return rc;
 }
 
-static int hdmi_hdcp_auth_part1_key_exchange(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_auth_part1_key_exchange(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        unsigned long flags;
        int rc;
 
        /* Wait for AKSV key and An ready */
-       rc = hdmi_hdcp_wait_key_an_ready(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_wait_key_an_ready(hdcp_ctrl);
        if (rc) {
                pr_err("%s: wait key and an ready failed\n", __func__);
                return rc;
        };
 
        /* Read BCAPS and send to HDCP engine */
-       rc = hdmi_hdcp_recv_bcaps(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_recv_bcaps(hdcp_ctrl);
        if (rc) {
                pr_err("%s: read bcaps error, abort\n", __func__);
                return rc;
@@ -785,14 +785,14 @@ static int hdmi_hdcp_auth_part1_key_exchange(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        hdmi_write(hdmi, REG_HDMI_HDCP_RCVPORT_DATA4, 0);
 
        /* Send AKSV and An to sink */
-       rc = hdmi_hdcp_send_aksv_an(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_send_aksv_an(hdcp_ctrl);
        if (rc) {
                pr_err("%s:An/Aksv write failed\n", __func__);
                return rc;
        }
 
        /* Read BKSV and send to HDCP engine*/
-       rc = hdmi_hdcp_recv_bksv(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_recv_bksv(hdcp_ctrl);
        if (rc) {
                pr_err("%s:BKSV Process failed\n", __func__);
                return rc;
@@ -812,7 +812,7 @@ static int hdmi_hdcp_auth_part1_key_exchange(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 }
 
 /* read R0' from sink and pass it to HDCP engine */
-static int hdmi_hdcp_auth_part1_recv_r0(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_auth_part1_recv_r0(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        int rc = 0;
@@ -822,12 +822,12 @@ static int hdmi_hdcp_auth_part1_recv_r0(struct hdmi_hdcp_ctrl *hdcp_ctrl)
         * HDCP Compliance Test case 1A-01:
         * Wait here at least 100ms before reading R0'
         */
-       rc = hdmi_hdcp_msleep(hdcp_ctrl, 125, AUTH_ABORT_EV);
+       rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 125, AUTH_ABORT_EV);
        if (rc)
                return rc;
 
        /* Read R0' at offset 0x08 */
-       rc = hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x08, buf, 2);
+       rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x08, buf, 2);
        if (rc) {
                pr_err("%s:R0' read failed\n", __func__);
                return rc;
@@ -842,14 +842,14 @@ static int hdmi_hdcp_auth_part1_recv_r0(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 }
 
 /* Wait for authenticating result: R0/R0' are matched or not */
-static int hdmi_hdcp_auth_part1_verify_r0(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_auth_part1_verify_r0(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        u32 link0_status;
        int rc;
 
        /* wait for hdcp irq, 10 sec should be long enough */
-       rc = hdmi_hdcp_msleep(hdcp_ctrl, 10000, AUTH_RESULT_RDY_EV);
+       rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 10000, AUTH_RESULT_RDY_EV);
        if (!rc) {
                pr_err("%s: Wait Auth IRQ timeout\n", __func__);
                return -ETIMEDOUT;
@@ -869,7 +869,7 @@ static int hdmi_hdcp_auth_part1_verify_r0(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        return 0;
 }
 
-static int hdmi_hdcp_recv_check_bstatus(struct hdmi_hdcp_ctrl *hdcp_ctrl,
+static int msm_hdmi_hdcp_recv_check_bstatus(struct hdmi_hdcp_ctrl *hdcp_ctrl,
        u16 *pbstatus)
 {
        int rc;
@@ -880,7 +880,7 @@ static int hdmi_hdcp_recv_check_bstatus(struct hdmi_hdcp_ctrl *hdcp_ctrl,
        u8 buf[2];
 
        /* Read BSTATUS at offset 0x41 */
-       rc = hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x41, buf, 2);
+       rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x41, buf, 2);
        if (rc) {
                pr_err("%s: BSTATUS read failed\n", __func__);
                goto error;
@@ -936,7 +936,7 @@ error:
        return rc;
 }
 
-static int hdmi_hdcp_auth_part2_wait_ksv_fifo_ready(
+static int msm_hdmi_hdcp_auth_part2_wait_ksv_fifo_ready(
        struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int rc;
@@ -953,7 +953,7 @@ static int hdmi_hdcp_auth_part2_wait_ksv_fifo_ready(
        timeout_count = 100;
        do {
                /* Read BCAPS at offset 0x40 */
-               rc = hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x40, &bcaps, 1);
+               rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x40, &bcaps, 1);
                if (rc) {
                        pr_err("%s: BCAPS read failed\n", __func__);
                        return rc;
@@ -968,12 +968,12 @@ static int hdmi_hdcp_auth_part2_wait_ksv_fifo_ready(
                        return -ETIMEDOUT;
                }
 
-               rc = hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
+               rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
                if (rc)
                        return rc;
        } while (1);
 
-       rc = hdmi_hdcp_recv_check_bstatus(hdcp_ctrl, &bstatus);
+       rc = msm_hdmi_hdcp_recv_check_bstatus(hdcp_ctrl, &bstatus);
        if (rc) {
                pr_err("%s: bstatus error\n", __func__);
                return rc;
@@ -982,7 +982,7 @@ static int hdmi_hdcp_auth_part2_wait_ksv_fifo_ready(
        /* Write BSTATUS and BCAPS to HDCP registers */
        reg = REG_HDMI_HDCP_RCVPORT_DATA12;
        data = bcaps | (bstatus << 8);
-       rc = hdmi_hdcp_scm_wr(hdcp_ctrl, &reg, &data, 1);
+       rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, &reg, &data, 1);
        if (rc) {
                pr_err("%s: BSTATUS write failed\n", __func__);
                return rc;
@@ -997,7 +997,7 @@ static int hdmi_hdcp_auth_part2_wait_ksv_fifo_ready(
  * transfer V' from sink to HDCP engine
  * reset SHA engine
  */
-static int hdmi_hdcp_transfer_v_h(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_transfer_v_h(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        int rc = 0;
@@ -1016,7 +1016,7 @@ static int hdmi_hdcp_transfer_v_h(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 
        for (i = 0; i < size; i++) {
                rd = &reg_data[i];
-               rc = hdmi_ddc_read(hdmi, HDCP_PORT_ADDR,
+               rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR,
                        rd->off, (u8 *)&data[i], (u16)sizeof(data[i]));
                if (rc) {
                        pr_err("%s: Read %s failed\n", __func__, rd->name);
@@ -1027,13 +1027,13 @@ static int hdmi_hdcp_transfer_v_h(struct hdmi_hdcp_ctrl *hdcp_ctrl)
                reg[i] = reg_data[i].reg_id;
        }
 
-       rc = hdmi_hdcp_scm_wr(hdcp_ctrl, reg, data, size);
+       rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, reg, data, size);
 
 error:
        return rc;
 }
 
-static int hdmi_hdcp_recv_ksv_fifo(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_recv_ksv_fifo(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int rc;
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
@@ -1041,7 +1041,7 @@ static int hdmi_hdcp_recv_ksv_fifo(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 
        ksv_bytes = 5 * hdcp_ctrl->dev_count;
 
-       rc = hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x43,
+       rc = msm_hdmi_ddc_read(hdmi, HDCP_PORT_ADDR, 0x43,
                hdcp_ctrl->ksv_list, ksv_bytes);
        if (rc)
                pr_err("%s: KSV FIFO read failed\n", __func__);
@@ -1049,7 +1049,7 @@ static int hdmi_hdcp_recv_ksv_fifo(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        return rc;
 }
 
-static int hdmi_hdcp_reset_sha_engine(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_reset_sha_engine(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        u32 reg[2], data[2];
        u32 rc  = 0;
@@ -1059,12 +1059,12 @@ static int hdmi_hdcp_reset_sha_engine(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        reg[1] = REG_HDMI_HDCP_SHA_CTRL;
        data[1] = HDCP_REG_DISABLE;
 
-       rc = hdmi_hdcp_scm_wr(hdcp_ctrl, reg, data, 2);
+       rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, reg, data, 2);
 
        return rc;
 }
 
-static int hdmi_hdcp_auth_part2_recv_ksv_fifo(
+static int msm_hdmi_hdcp_auth_part2_recv_ksv_fifo(
        struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int rc;
@@ -1081,7 +1081,7 @@ static int hdmi_hdcp_auth_part2_recv_ksv_fifo(
         */
        timeout_count = 100;
        do {
-               rc = hdmi_hdcp_recv_ksv_fifo(hdcp_ctrl);
+               rc = msm_hdmi_hdcp_recv_ksv_fifo(hdcp_ctrl);
                if (!rc)
                        break;
 
@@ -1091,19 +1091,19 @@ static int hdmi_hdcp_auth_part2_recv_ksv_fifo(
                        return -ETIMEDOUT;
                }
 
-               rc = hdmi_hdcp_msleep(hdcp_ctrl, 25, AUTH_ABORT_EV);
+               rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 25, AUTH_ABORT_EV);
                if (rc)
                        return rc;
        } while (1);
 
-       rc = hdmi_hdcp_transfer_v_h(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_transfer_v_h(hdcp_ctrl);
        if (rc) {
                pr_err("%s: transfer V failed\n", __func__);
                return rc;
        }
 
        /* reset SHA engine before write ksv fifo */
-       rc = hdmi_hdcp_reset_sha_engine(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_reset_sha_engine(hdcp_ctrl);
        if (rc) {
                pr_err("%s: fail to reset sha engine\n", __func__);
                return rc;
@@ -1120,7 +1120,7 @@ static int hdmi_hdcp_auth_part2_recv_ksv_fifo(
  * If the last byte is written, we need to poll for
  * HDCP_SHA_COMP_DONE to wait until HW finish
  */
-static int hdmi_hdcp_write_ksv_fifo(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_write_ksv_fifo(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int i;
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
@@ -1169,7 +1169,7 @@ static int hdmi_hdcp_write_ksv_fifo(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 
                reg = REG_HDMI_HDCP_SHA_DATA;
                data = reg_val;
-               rc = hdmi_hdcp_scm_wr(hdcp_ctrl, &reg, &data, 1);
+               rc = msm_hdmi_hdcp_scm_wr(hdcp_ctrl, &reg, &data, 1);
 
                if (rc)
                        return rc;
@@ -1184,7 +1184,7 @@ static int hdmi_hdcp_write_ksv_fifo(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 }
 
 /* write ksv fifo into HDCP engine */
-static int hdmi_hdcp_auth_part2_write_ksv_fifo(
+static int msm_hdmi_hdcp_auth_part2_write_ksv_fifo(
        struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int rc;
@@ -1193,7 +1193,7 @@ static int hdmi_hdcp_auth_part2_write_ksv_fifo(
        hdcp_ctrl->ksv_fifo_w_index = 0;
        timeout_count = 100;
        do {
-               rc = hdmi_hdcp_write_ksv_fifo(hdcp_ctrl);
+               rc = msm_hdmi_hdcp_write_ksv_fifo(hdcp_ctrl);
                if (!rc)
                        break;
 
@@ -1206,7 +1206,7 @@ static int hdmi_hdcp_auth_part2_write_ksv_fifo(
                        return -ETIMEDOUT;
                }
 
-               rc = hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
+               rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
                if (rc)
                        return rc;
        } while (1);
@@ -1214,7 +1214,7 @@ static int hdmi_hdcp_auth_part2_write_ksv_fifo(
        return 0;
 }
 
-static int hdmi_hdcp_auth_part2_check_v_match(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+static int msm_hdmi_hdcp_auth_part2_check_v_match(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        int rc = 0;
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
@@ -1232,7 +1232,7 @@ static int hdmi_hdcp_auth_part2_check_v_match(struct hdmi_hdcp_ctrl *hdcp_ctrl)
                                return -ETIMEDOUT;
                }
 
-               rc = hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
+               rc = msm_hdmi_hdcp_msleep(hdcp_ctrl, 20, AUTH_ABORT_EV);
                if (rc)
                        return rc;
        } while (1);
@@ -1240,32 +1240,32 @@ static int hdmi_hdcp_auth_part2_check_v_match(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        return 0;
 }
 
-static void hdmi_hdcp_auth_work(struct work_struct *work)
+static void msm_hdmi_hdcp_auth_work(struct work_struct *work)
 {
        struct hdmi_hdcp_ctrl *hdcp_ctrl = container_of(work,
                struct hdmi_hdcp_ctrl, hdcp_auth_work);
        int rc;
 
-       rc = hdmi_hdcp_auth_prepare(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_auth_prepare(hdcp_ctrl);
        if (rc) {
                pr_err("%s: auth prepare failed %d\n", __func__, rc);
                goto end;
        }
 
        /* HDCP PartI */
-       rc = hdmi_hdcp_auth_part1_key_exchange(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_auth_part1_key_exchange(hdcp_ctrl);
        if (rc) {
                pr_err("%s: key exchange failed %d\n", __func__, rc);
                goto end;
        }
 
-       rc = hdmi_hdcp_auth_part1_recv_r0(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_auth_part1_recv_r0(hdcp_ctrl);
        if (rc) {
                pr_err("%s: receive r0 failed %d\n", __func__, rc);
                goto end;
        }
 
-       rc = hdmi_hdcp_auth_part1_verify_r0(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_auth_part1_verify_r0(hdcp_ctrl);
        if (rc) {
                pr_err("%s: verify r0 failed %d\n", __func__, rc);
                goto end;
@@ -1275,25 +1275,25 @@ static void hdmi_hdcp_auth_work(struct work_struct *work)
                goto end;
 
        /* HDCP PartII */
-       rc = hdmi_hdcp_auth_part2_wait_ksv_fifo_ready(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_auth_part2_wait_ksv_fifo_ready(hdcp_ctrl);
        if (rc) {
                pr_err("%s: wait ksv fifo ready failed %d\n", __func__, rc);
                goto end;
        }
 
-       rc = hdmi_hdcp_auth_part2_recv_ksv_fifo(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_auth_part2_recv_ksv_fifo(hdcp_ctrl);
        if (rc) {
                pr_err("%s: recv ksv fifo failed %d\n", __func__, rc);
                goto end;
        }
 
-       rc = hdmi_hdcp_auth_part2_write_ksv_fifo(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_auth_part2_write_ksv_fifo(hdcp_ctrl);
        if (rc) {
                pr_err("%s: write ksv fifo failed %d\n", __func__, rc);
                goto end;
        }
 
-       rc = hdmi_hdcp_auth_part2_check_v_match(hdcp_ctrl);
+       rc = msm_hdmi_hdcp_auth_part2_check_v_match(hdcp_ctrl);
        if (rc)
                pr_err("%s: check v match failed %d\n", __func__, rc);
 
@@ -1304,13 +1304,13 @@ end:
                pr_info("%s: hdcp is not supported\n", __func__);
        } else if (rc) {
                pr_err("%s: hdcp authentication failed\n", __func__);
-               hdmi_hdcp_auth_fail(hdcp_ctrl);
+               msm_hdmi_hdcp_auth_fail(hdcp_ctrl);
        } else {
-               hdmi_hdcp_auth_done(hdcp_ctrl);
+               msm_hdmi_hdcp_auth_done(hdcp_ctrl);
        }
 }
 
-void hdmi_hdcp_on(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+void msm_hdmi_hdcp_on(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        u32 reg_val;
@@ -1335,7 +1335,7 @@ void hdmi_hdcp_on(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        queue_work(hdmi->workq, &hdcp_ctrl->hdcp_auth_work);
 }
 
-void hdmi_hdcp_off(struct hdmi_hdcp_ctrl *hdcp_ctrl)
+void msm_hdmi_hdcp_off(struct hdmi_hdcp_ctrl *hdcp_ctrl)
 {
        struct hdmi *hdmi = hdcp_ctrl->hdmi;
        unsigned long flags;
@@ -1399,7 +1399,7 @@ void hdmi_hdcp_off(struct hdmi_hdcp_ctrl *hdcp_ctrl)
        DBG("HDCP: Off");
 }
 
-struct hdmi_hdcp_ctrl *hdmi_hdcp_init(struct hdmi *hdmi)
+struct hdmi_hdcp_ctrl *msm_hdmi_hdcp_init(struct hdmi *hdmi)
 {
        struct hdmi_hdcp_ctrl *hdcp_ctrl = NULL;
 
@@ -1413,8 +1413,8 @@ struct hdmi_hdcp_ctrl *hdmi_hdcp_init(struct hdmi *hdmi)
        if (!hdcp_ctrl)
                return ERR_PTR(-ENOMEM);
 
-       INIT_WORK(&hdcp_ctrl->hdcp_auth_work, hdmi_hdcp_auth_work);
-       INIT_WORK(&hdcp_ctrl->hdcp_reauth_work, hdmi_hdcp_reauth_work);
+       INIT_WORK(&hdcp_ctrl->hdcp_auth_work, msm_hdmi_hdcp_auth_work);
+       INIT_WORK(&hdcp_ctrl->hdcp_reauth_work, msm_hdmi_hdcp_reauth_work);
        init_waitqueue_head(&hdcp_ctrl->auth_event_queue);
        hdcp_ctrl->hdmi = hdmi;
        hdcp_ctrl->hdcp_state = HDCP_STATE_INACTIVE;
@@ -1428,7 +1428,7 @@ struct hdmi_hdcp_ctrl *hdmi_hdcp_init(struct hdmi *hdmi)
        return hdcp_ctrl;
 }
 
-void hdmi_hdcp_destroy(struct hdmi *hdmi)
+void msm_hdmi_hdcp_destroy(struct hdmi *hdmi)
 {
        if (hdmi && hdmi->hdcp_ctrl) {
                kfree(hdmi->hdcp_ctrl);
index f4ab7f7..de9007e 100644 (file)
@@ -97,7 +97,7 @@ static bool sw_done(struct hdmi_i2c_adapter *hdmi_i2c)
        return hdmi_i2c->sw_done;
 }
 
-static int hdmi_i2c_xfer(struct i2c_adapter *i2c,
+static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,
                struct i2c_msg *msgs, int num)
 {
        struct hdmi_i2c_adapter *hdmi_i2c = to_hdmi_i2c_adapter(i2c);
@@ -216,17 +216,17 @@ static int hdmi_i2c_xfer(struct i2c_adapter *i2c,
        return i;
 }
 
-static u32 hdmi_i2c_func(struct i2c_adapter *adapter)
+static u32 msm_hdmi_i2c_func(struct i2c_adapter *adapter)
 {
        return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
-static const struct i2c_algorithm hdmi_i2c_algorithm = {
-       .master_xfer    = hdmi_i2c_xfer,
-       .functionality  = hdmi_i2c_func,
+static const struct i2c_algorithm msm_hdmi_i2c_algorithm = {
+       .master_xfer    = msm_hdmi_i2c_xfer,
+       .functionality  = msm_hdmi_i2c_func,
 };
 
-void hdmi_i2c_irq(struct i2c_adapter *i2c)
+void msm_hdmi_i2c_irq(struct i2c_adapter *i2c)
 {
        struct hdmi_i2c_adapter *hdmi_i2c = to_hdmi_i2c_adapter(i2c);
 
@@ -234,14 +234,14 @@ void hdmi_i2c_irq(struct i2c_adapter *i2c)
                wake_up_all(&hdmi_i2c->ddc_event);
 }
 
-void hdmi_i2c_destroy(struct i2c_adapter *i2c)
+void msm_hdmi_i2c_destroy(struct i2c_adapter *i2c)
 {
        struct hdmi_i2c_adapter *hdmi_i2c = to_hdmi_i2c_adapter(i2c);
        i2c_del_adapter(i2c);
        kfree(hdmi_i2c);
 }
 
-struct i2c_adapter *hdmi_i2c_init(struct hdmi *hdmi)
+struct i2c_adapter *msm_hdmi_i2c_init(struct hdmi *hdmi)
 {
        struct drm_device *dev = hdmi->dev;
        struct hdmi_i2c_adapter *hdmi_i2c;
@@ -264,7 +264,7 @@ struct i2c_adapter *hdmi_i2c_init(struct hdmi *hdmi)
        i2c->class = I2C_CLASS_DDC;
        snprintf(i2c->name, sizeof(i2c->name), "msm hdmi i2c");
        i2c->dev.parent = &hdmi->pdev->dev;
-       i2c->algo = &hdmi_i2c_algorithm;
+       i2c->algo = &msm_hdmi_i2c_algorithm;
 
        ret = i2c_add_adapter(i2c);
        if (ret) {
@@ -276,6 +276,6 @@ struct i2c_adapter *hdmi_i2c_init(struct hdmi *hdmi)
 
 fail:
        if (i2c)
-               hdmi_i2c_destroy(i2c);
+               msm_hdmi_i2c_destroy(i2c);
        return ERR_PTR(ret);
 }
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_phy.c b/drivers/gpu/drm/msm/hdmi/hdmi_phy.c
new file mode 100644 (file)
index 0000000..534ce5b
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/of_device.h>
+
+#include "hdmi.h"
+
+static int msm_hdmi_phy_resource_init(struct hdmi_phy *phy)
+{
+       struct hdmi_phy_cfg *cfg = phy->cfg;
+       struct device *dev = &phy->pdev->dev;
+       int i, ret;
+
+       phy->regs = devm_kzalloc(dev, sizeof(phy->regs[0]) * cfg->num_regs,
+                                GFP_KERNEL);
+       if (!phy->regs)
+               return -ENOMEM;
+
+       phy->clks = devm_kzalloc(dev, sizeof(phy->clks[0]) * cfg->num_clks,
+                                GFP_KERNEL);
+       if (!phy->clks)
+               return -ENOMEM;
+
+       for (i = 0; i < cfg->num_regs; i++) {
+               struct regulator *reg;
+
+               reg = devm_regulator_get(dev, cfg->reg_names[i]);
+               if (IS_ERR(reg)) {
+                       ret = PTR_ERR(reg);
+                       dev_err(dev, "failed to get phy regulator: %s (%d)\n",
+                               cfg->reg_names[i], ret);
+                       return ret;
+               }
+
+               phy->regs[i] = reg;
+       }
+
+       for (i = 0; i < cfg->num_clks; i++) {
+               struct clk *clk;
+
+               clk = devm_clk_get(dev, cfg->clk_names[i]);
+               if (IS_ERR(clk)) {
+                       ret = PTR_ERR(clk);
+                       dev_err(dev, "failed to get phy clock: %s (%d)\n",
+                               cfg->clk_names[i], ret);
+                       return ret;
+               }
+
+               phy->clks[i] = clk;
+       }
+
+       return 0;
+}
+
+int msm_hdmi_phy_resource_enable(struct hdmi_phy *phy)
+{
+       struct hdmi_phy_cfg *cfg = phy->cfg;
+       struct device *dev = &phy->pdev->dev;
+       int i, ret = 0;
+
+       pm_runtime_get_sync(dev);
+
+       for (i = 0; i < cfg->num_regs; i++) {
+               ret = regulator_enable(phy->regs[i]);
+               if (ret)
+                       dev_err(dev, "failed to enable regulator: %s (%d)\n",
+                               cfg->reg_names[i], ret);
+       }
+
+       for (i = 0; i < cfg->num_clks; i++) {
+               ret = clk_prepare_enable(phy->clks[i]);
+               if (ret)
+                       dev_err(dev, "failed to enable clock: %s (%d)\n",
+                               cfg->clk_names[i], ret);
+       }
+
+       return ret;
+}
+
+void msm_hdmi_phy_resource_disable(struct hdmi_phy *phy)
+{
+       struct hdmi_phy_cfg *cfg = phy->cfg;
+       struct device *dev = &phy->pdev->dev;
+       int i;
+
+       for (i = cfg->num_clks - 1; i >= 0; i--)
+               clk_disable_unprepare(phy->clks[i]);
+
+       for (i = cfg->num_regs - 1; i >= 0; i--)
+               regulator_disable(phy->regs[i]);
+
+       pm_runtime_put_sync(dev);
+}
+
+void msm_hdmi_phy_powerup(struct hdmi_phy *phy, unsigned long int pixclock)
+{
+       if (!phy || !phy->cfg->powerup)
+               return;
+
+       phy->cfg->powerup(phy, pixclock);
+}
+
+void msm_hdmi_phy_powerdown(struct hdmi_phy *phy)
+{
+       if (!phy || !phy->cfg->powerdown)
+               return;
+
+       phy->cfg->powerdown(phy);
+}
+
+static int msm_hdmi_phy_pll_init(struct platform_device *pdev,
+                            enum hdmi_phy_type type)
+{
+       int ret;
+
+       switch (type) {
+       case MSM_HDMI_PHY_8960:
+               ret = msm_hdmi_pll_8960_init(pdev);
+               break;
+       case MSM_HDMI_PHY_8996:
+               ret = msm_hdmi_pll_8996_init(pdev);
+               break;
+       /*
+        * we don't have PLL support for these, don't report an error for now
+        */
+       case MSM_HDMI_PHY_8x60:
+       case MSM_HDMI_PHY_8x74:
+       default:
+               ret = 0;
+               break;
+       }
+
+       return ret;
+}
+
+static int msm_hdmi_phy_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct hdmi_phy *phy;
+       int ret;
+
+       phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
+       if (!phy)
+               return -ENODEV;
+
+       phy->cfg = (struct hdmi_phy_cfg *)of_device_get_match_data(dev);
+       if (!phy->cfg)
+               return -ENODEV;
+
+       phy->mmio = msm_ioremap(pdev, "hdmi_phy", "HDMI_PHY");
+       if (IS_ERR(phy->mmio)) {
+               dev_err(dev, "%s: failed to map phy base\n", __func__);
+               return -ENOMEM;
+       }
+
+       phy->pdev = pdev;
+
+       ret = msm_hdmi_phy_resource_init(phy);
+       if (ret)
+               return ret;
+
+       pm_runtime_enable(&pdev->dev);
+
+       ret = msm_hdmi_phy_resource_enable(phy);
+       if (ret)
+               return ret;
+
+       ret = msm_hdmi_phy_pll_init(pdev, phy->cfg->type);
+       if (ret) {
+               dev_err(dev, "couldn't init PLL\n");
+               msm_hdmi_phy_resource_disable(phy);
+               return ret;
+       }
+
+       msm_hdmi_phy_resource_disable(phy);
+
+       platform_set_drvdata(pdev, phy);
+
+       return 0;
+}
+
+static int msm_hdmi_phy_remove(struct platform_device *pdev)
+{
+       pm_runtime_disable(&pdev->dev);
+
+       return 0;
+}
+
+static const struct of_device_id msm_hdmi_phy_dt_match[] = {
+       { .compatible = "qcom,hdmi-phy-8660",
+         .data = &msm_hdmi_phy_8x60_cfg },
+       { .compatible = "qcom,hdmi-phy-8960",
+         .data = &msm_hdmi_phy_8960_cfg },
+       { .compatible = "qcom,hdmi-phy-8974",
+         .data = &msm_hdmi_phy_8x74_cfg },
+       { .compatible = "qcom,hdmi-phy-8084",
+         .data = &msm_hdmi_phy_8x74_cfg },
+       { .compatible = "qcom,hdmi-phy-8996",
+         .data = &msm_hdmi_phy_8996_cfg },
+       {}
+};
+
+static struct platform_driver msm_hdmi_phy_platform_driver = {
+       .probe      = msm_hdmi_phy_probe,
+       .remove     = msm_hdmi_phy_remove,
+       .driver     = {
+               .name   = "msm_hdmi_phy",
+               .of_match_table = msm_hdmi_phy_dt_match,
+       },
+};
+
+void __init msm_hdmi_phy_driver_register(void)
+{
+       platform_driver_register(&msm_hdmi_phy_platform_driver);
+}
+
+void __exit msm_hdmi_phy_driver_unregister(void)
+{
+       platform_driver_unregister(&msm_hdmi_phy_platform_driver);
+}
index 3a01cb5..e6ee6b7 100644 (file)
  * this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifdef CONFIG_COMMON_CLK
-#include <linux/clk.h>
-#include <linux/clk-provider.h>
-#endif
-
 #include "hdmi.h"
 
-struct hdmi_phy_8960 {
-       struct hdmi_phy base;
-       struct hdmi *hdmi;
-#ifdef CONFIG_COMMON_CLK
-       struct clk_hw pll_hw;
-       struct clk *pll;
-       unsigned long pixclk;
-#endif
-};
-#define to_hdmi_phy_8960(x) container_of(x, struct hdmi_phy_8960, base)
-
-#ifdef CONFIG_COMMON_CLK
-#define clk_to_phy(x) container_of(x, struct hdmi_phy_8960, pll_hw)
-
-/*
- * HDMI PLL:
- *
- * To get the parent clock setup properly, we need to plug in hdmi pll
- * configuration into common-clock-framework.
- */
-
-struct pll_rate {
-       unsigned long rate;
-       struct {
-               uint32_t val;
-               uint32_t reg;
-       } conf[32];
-};
-
-/* NOTE: keep sorted highest freq to lowest: */
-static const struct pll_rate freqtbl[] = {
-       { 154000000, {
-               { 0x08, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
-               { 0x20, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
-               { 0xf9, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
-               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
-               { 0x03, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
-               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
-               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
-               { 0x0d, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
-               { 0x4d, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
-               { 0x5e, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
-               { 0x42, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
-               { 0, 0 } }
-       },
-       /* 1080p60/1080p50 case */
-       { 148500000, {
-               { 0x02, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
-               { 0x02, REG_HDMI_8960_PHY_PLL_CHRG_PUMP_CFG },
-               { 0x01, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
-               { 0x33, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
-               { 0x2c, REG_HDMI_8960_PHY_PLL_IDAC_ADJ_CFG  },
-               { 0x06, REG_HDMI_8960_PHY_PLL_I_VI_KVCO_CFG },
-               { 0x0a, REG_HDMI_8960_PHY_PLL_PWRDN_B       },
-               { 0x76, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
-               { 0x01, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
-               { 0x4c, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
-               { 0xc0, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
-               { 0x9a, REG_HDMI_8960_PHY_PLL_SSC_CFG0      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG1      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG2      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG3      },
-               { 0x10, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG0  },
-               { 0x1a, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG1  },
-               { 0x0d, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2  },
-               { 0xe6, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
-               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
-               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
-               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
-               { 0x33, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG6   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG7   },
-               { 0, 0 } }
-       },
-       { 108000000, {
-               { 0x08, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
-               { 0x21, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
-               { 0xf9, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
-               { 0x1c, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
-               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
-               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
-               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
-               { 0x49, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
-               { 0x49, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
-               { 0, 0 } }
-       },
-       /* 720p60/720p50/1080i60/1080i50/1080p24/1080p30/1080p25 */
-       { 74250000, {
-               { 0x0a, REG_HDMI_8960_PHY_PLL_PWRDN_B       },
-               { 0x12, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
-               { 0x01, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
-               { 0x33, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
-               { 0x76, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
-               { 0xe6, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
-               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
-               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
-               { 0, 0 } }
-       },
-       { 74176000, {
-               { 0x18, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
-               { 0x20, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
-               { 0xf9, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
-               { 0xe5, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
-               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
-               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
-               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
-               { 0x0c, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
-               { 0x4c, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
-               { 0x7d, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
-               { 0xbc, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
-               { 0, 0 } }
-       },
-       { 65000000, {
-               { 0x18, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
-               { 0x20, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
-               { 0xf9, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
-               { 0x8a, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
-               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
-               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
-               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
-               { 0x0b, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
-               { 0x4b, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
-               { 0x7b, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
-               { 0x09, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
-               { 0, 0 } }
-       },
-       /* 480p60/480i60 */
-       { 27030000, {
-               { 0x0a, REG_HDMI_8960_PHY_PLL_PWRDN_B       },
-               { 0x38, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
-               { 0x02, REG_HDMI_8960_PHY_PLL_CHRG_PUMP_CFG },
-               { 0x20, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
-               { 0xff, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
-               { 0x4e, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
-               { 0xd7, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
-               { 0x03, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
-               { 0x2a, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
-               { 0x03, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
-               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
-               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
-               { 0x33, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG6   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG7   },
-               { 0, 0 } }
-       },
-       /* 576p50/576i50 */
-       { 27000000, {
-               { 0x32, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
-               { 0x02, REG_HDMI_8960_PHY_PLL_CHRG_PUMP_CFG },
-               { 0x01, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
-               { 0x33, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
-               { 0x2c, REG_HDMI_8960_PHY_PLL_IDAC_ADJ_CFG  },
-               { 0x06, REG_HDMI_8960_PHY_PLL_I_VI_KVCO_CFG },
-               { 0x0a, REG_HDMI_8960_PHY_PLL_PWRDN_B       },
-               { 0x7b, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
-               { 0x01, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
-               { 0x4c, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
-               { 0xc0, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
-               { 0x9a, REG_HDMI_8960_PHY_PLL_SSC_CFG0      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG1      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG2      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG3      },
-               { 0x10, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG0  },
-               { 0x1a, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG1  },
-               { 0x0d, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2  },
-               { 0x2a, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
-               { 0x03, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
-               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
-               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
-               { 0x33, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG6   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG7   },
-               { 0, 0 } }
-       },
-       /* 640x480p60 */
-       { 25200000, {
-               { 0x32, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
-               { 0x02, REG_HDMI_8960_PHY_PLL_CHRG_PUMP_CFG },
-               { 0x01, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
-               { 0x33, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
-               { 0x2c, REG_HDMI_8960_PHY_PLL_IDAC_ADJ_CFG  },
-               { 0x06, REG_HDMI_8960_PHY_PLL_I_VI_KVCO_CFG },
-               { 0x0a, REG_HDMI_8960_PHY_PLL_PWRDN_B       },
-               { 0x77, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
-               { 0x4c, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
-               { 0xc0, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
-               { 0x9a, REG_HDMI_8960_PHY_PLL_SSC_CFG0      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG1      },
-               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG2      },
-               { 0x20, REG_HDMI_8960_PHY_PLL_SSC_CFG3      },
-               { 0x10, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG0  },
-               { 0x1a, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG1  },
-               { 0x0d, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2  },
-               { 0xf4, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
-               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
-               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
-               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
-               { 0x33, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG6   },
-               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG7   },
-               { 0, 0 } }
-       },
-};
-
-static int hdmi_pll_enable(struct clk_hw *hw)
-{
-       struct hdmi_phy_8960 *phy_8960 = clk_to_phy(hw);
-       struct hdmi *hdmi = phy_8960->hdmi;
-       int timeout_count, pll_lock_retry = 10;
-       unsigned int val;
-
-       DBG("");
-
-       /* Assert PLL S/W reset */
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2, 0x8d);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG0, 0x10);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG1, 0x1a);
-
-       /* Wait for a short time before de-asserting
-        * to allow the hardware to complete its job.
-        * This much of delay should be fine for hardware
-        * to assert and de-assert.
-        */
-       udelay(10);
-
-       /* De-assert PLL S/W reset */
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2, 0x0d);
-
-       val = hdmi_read(hdmi, REG_HDMI_8960_PHY_REG12);
-       val |= HDMI_8960_PHY_REG12_SW_RESET;
-       /* Assert PHY S/W reset */
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG12, val);
-       val &= ~HDMI_8960_PHY_REG12_SW_RESET;
-       /* Wait for a short time before de-asserting
-          to allow the hardware to complete its job.
-          This much of delay should be fine for hardware
-          to assert and de-assert. */
-       udelay(10);
-       /* De-assert PHY S/W reset */
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG12, val);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG2,  0x3f);
-
-       val = hdmi_read(hdmi, REG_HDMI_8960_PHY_REG12);
-       val |= HDMI_8960_PHY_REG12_PWRDN_B;
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG12, val);
-       /* Wait 10 us for enabling global power for PHY */
-       mb();
-       udelay(10);
-
-       val = hdmi_read(hdmi, REG_HDMI_8960_PHY_PLL_PWRDN_B);
-       val |= HDMI_8960_PHY_PLL_PWRDN_B_PLL_PWRDN_B;
-       val &= ~HDMI_8960_PHY_PLL_PWRDN_B_PD_PLL;
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_PLL_PWRDN_B, val);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG2, 0x80);
-
-       timeout_count = 1000;
-       while (--pll_lock_retry > 0) {
-
-               /* are we there yet? */
-               val = hdmi_read(hdmi, REG_HDMI_8960_PHY_PLL_STATUS0);
-               if (val & HDMI_8960_PHY_PLL_STATUS0_PLL_LOCK)
-                       break;
-
-               udelay(1);
-
-               if (--timeout_count > 0)
-                       continue;
-
-               /*
-                * PLL has still not locked.
-                * Do a software reset and try again
-                * Assert PLL S/W reset first
-                */
-               hdmi_write(hdmi, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2, 0x8d);
-               udelay(10);
-               hdmi_write(hdmi, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2, 0x0d);
-
-               /*
-                * Wait for a short duration for the PLL calibration
-                * before checking if the PLL gets locked
-                */
-               udelay(350);
-
-               timeout_count = 1000;
-       }
-
-       return 0;
-}
-
-static void hdmi_pll_disable(struct clk_hw *hw)
-{
-       struct hdmi_phy_8960 *phy_8960 = clk_to_phy(hw);
-       struct hdmi *hdmi = phy_8960->hdmi;
-       unsigned int val;
-
-       DBG("");
-
-       val = hdmi_read(hdmi, REG_HDMI_8960_PHY_REG12);
-       val &= ~HDMI_8960_PHY_REG12_PWRDN_B;
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG12, val);
-
-       val = hdmi_read(hdmi, REG_HDMI_8960_PHY_PLL_PWRDN_B);
-       val |= HDMI_8960_PHY_REG12_SW_RESET;
-       val &= ~HDMI_8960_PHY_REG12_PWRDN_B;
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_PLL_PWRDN_B, val);
-       /* Make sure HDMI PHY/PLL are powered down */
-       mb();
-}
-
-static const struct pll_rate *find_rate(unsigned long rate)
-{
-       int i;
-       for (i = 1; i < ARRAY_SIZE(freqtbl); i++)
-               if (rate > freqtbl[i].rate)
-                       return &freqtbl[i-1];
-       return &freqtbl[i-1];
-}
-
-static unsigned long hdmi_pll_recalc_rate(struct clk_hw *hw,
-                               unsigned long parent_rate)
-{
-       struct hdmi_phy_8960 *phy_8960 = clk_to_phy(hw);
-       return phy_8960->pixclk;
-}
-
-static long hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,
-               unsigned long *parent_rate)
-{
-       const struct pll_rate *pll_rate = find_rate(rate);
-       return pll_rate->rate;
-}
-
-static int hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,
-               unsigned long parent_rate)
-{
-       struct hdmi_phy_8960 *phy_8960 = clk_to_phy(hw);
-       struct hdmi *hdmi = phy_8960->hdmi;
-       const struct pll_rate *pll_rate = find_rate(rate);
-       int i;
-
-       DBG("rate=%lu", rate);
-
-       for (i = 0; pll_rate->conf[i].reg; i++)
-               hdmi_write(hdmi, pll_rate->conf[i].reg, pll_rate->conf[i].val);
-
-       phy_8960->pixclk = rate;
-
-       return 0;
-}
-
-
-static const struct clk_ops hdmi_pll_ops = {
-       .enable = hdmi_pll_enable,
-       .disable = hdmi_pll_disable,
-       .recalc_rate = hdmi_pll_recalc_rate,
-       .round_rate = hdmi_pll_round_rate,
-       .set_rate = hdmi_pll_set_rate,
-};
-
-static const char *hdmi_pll_parents[] = {
-       "pxo",
-};
-
-static struct clk_init_data pll_init = {
-       .name = "hdmi_pll",
-       .ops = &hdmi_pll_ops,
-       .parent_names = hdmi_pll_parents,
-       .num_parents = ARRAY_SIZE(hdmi_pll_parents),
-};
-#endif
-
-/*
- * HDMI Phy:
- */
-
-static void hdmi_phy_8960_destroy(struct hdmi_phy *phy)
-{
-       struct hdmi_phy_8960 *phy_8960 = to_hdmi_phy_8960(phy);
-       kfree(phy_8960);
-}
-
 static void hdmi_phy_8960_powerup(struct hdmi_phy *phy,
-               unsigned long int pixclock)
+                                 unsigned long int pixclock)
 {
-       struct hdmi_phy_8960 *phy_8960 = to_hdmi_phy_8960(phy);
-       struct hdmi *hdmi = phy_8960->hdmi;
-
        DBG("pixclock: %lu", pixclock);
 
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG2, 0x00);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG0, 0x1b);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG1, 0xf2);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG4, 0x00);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG5, 0x00);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG6, 0x00);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG7, 0x00);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG8, 0x00);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG9, 0x00);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG10, 0x00);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG11, 0x00);
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG3, 0x20);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG2, 0x00);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG0, 0x1b);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG1, 0xf2);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG4, 0x00);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG5, 0x00);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG6, 0x00);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG7, 0x00);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG8, 0x00);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG9, 0x00);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG10, 0x00);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG11, 0x00);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG3, 0x20);
 }
 
 static void hdmi_phy_8960_powerdown(struct hdmi_phy *phy)
 {
-       struct hdmi_phy_8960 *phy_8960 = to_hdmi_phy_8960(phy);
-       struct hdmi *hdmi = phy_8960->hdmi;
-
        DBG("");
 
-       hdmi_write(hdmi, REG_HDMI_8960_PHY_REG2, 0x7f);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG2, 0x7f);
 }
 
-static const struct hdmi_phy_funcs hdmi_phy_8960_funcs = {
-               .destroy = hdmi_phy_8960_destroy,
-               .powerup = hdmi_phy_8960_powerup,
-               .powerdown = hdmi_phy_8960_powerdown,
+static const char * const hdmi_phy_8960_reg_names[] = {
+       "core-vdda",
 };
 
-struct hdmi_phy *hdmi_phy_8960_init(struct hdmi *hdmi)
-{
-       struct hdmi_phy_8960 *phy_8960;
-       struct hdmi_phy *phy = NULL;
-       int ret;
-#ifdef CONFIG_COMMON_CLK
-       int i;
-
-       /* sanity check: */
-       for (i = 0; i < (ARRAY_SIZE(freqtbl) - 1); i++)
-               if (WARN_ON(freqtbl[i].rate < freqtbl[i+1].rate))
-                       return ERR_PTR(-EINVAL);
-#endif
-
-       phy_8960 = kzalloc(sizeof(*phy_8960), GFP_KERNEL);
-       if (!phy_8960) {
-               ret = -ENOMEM;
-               goto fail;
-       }
-
-       phy = &phy_8960->base;
-
-       phy->funcs = &hdmi_phy_8960_funcs;
-
-       phy_8960->hdmi = hdmi;
-
-#ifdef CONFIG_COMMON_CLK
-       phy_8960->pll_hw.init = &pll_init;
-       phy_8960->pll = devm_clk_register(&hdmi->pdev->dev, &phy_8960->pll_hw);
-       if (IS_ERR(phy_8960->pll)) {
-               ret = PTR_ERR(phy_8960->pll);
-               phy_8960->pll = NULL;
-               goto fail;
-       }
-#endif
-
-       return phy;
+static const char * const hdmi_phy_8960_clk_names[] = {
+       "slave_iface_clk",
+};
 
-fail:
-       if (phy)
-               hdmi_phy_8960_destroy(phy);
-       return ERR_PTR(ret);
-}
+const struct hdmi_phy_cfg msm_hdmi_phy_8960_cfg = {
+       .type = MSM_HDMI_PHY_8960,
+       .powerup = hdmi_phy_8960_powerup,
+       .powerdown = hdmi_phy_8960_powerdown,
+       .reg_names = hdmi_phy_8960_reg_names,
+       .num_regs = ARRAY_SIZE(hdmi_phy_8960_reg_names),
+       .clk_names = hdmi_phy_8960_clk_names,
+       .num_clks = ARRAY_SIZE(hdmi_phy_8960_clk_names),
+};
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_phy_8996.c b/drivers/gpu/drm/msm/hdmi/hdmi_phy_8996.c
new file mode 100644 (file)
index 0000000..aa94a55
--- /dev/null
@@ -0,0 +1,766 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only 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.
+ */
+
+#include <linux/clk-provider.h>
+
+#include "hdmi.h"
+
+#define HDMI_VCO_MAX_FREQ                      12000000000UL
+#define HDMI_VCO_MIN_FREQ                      8000000000UL
+
+#define HDMI_PCLK_MAX_FREQ                     600000000
+#define HDMI_PCLK_MIN_FREQ                     25000000
+
+#define HDMI_HIGH_FREQ_BIT_CLK_THRESHOLD       3400000000UL
+#define HDMI_DIG_FREQ_BIT_CLK_THRESHOLD                1500000000UL
+#define HDMI_MID_FREQ_BIT_CLK_THRESHOLD                750000000UL
+#define HDMI_CORECLK_DIV                       5
+#define HDMI_DEFAULT_REF_CLOCK                 19200000
+#define HDMI_PLL_CMP_CNT                       1024
+
+#define HDMI_PLL_POLL_MAX_READS                        100
+#define HDMI_PLL_POLL_TIMEOUT_US               150
+
+#define HDMI_NUM_TX_CHANNEL                    4
+
+struct hdmi_pll_8996 {
+       struct platform_device *pdev;
+       struct clk_hw clk_hw;
+
+       /* pll mmio base */
+       void __iomem *mmio_qserdes_com;
+       /* tx channel base */
+       void __iomem *mmio_qserdes_tx[HDMI_NUM_TX_CHANNEL];
+};
+
+#define hw_clk_to_pll(x) container_of(x, struct hdmi_pll_8996, clk_hw)
+
+struct hdmi_8996_phy_pll_reg_cfg {
+       u32 tx_lx_lane_mode[HDMI_NUM_TX_CHANNEL];
+       u32 tx_lx_tx_band[HDMI_NUM_TX_CHANNEL];
+       u32 com_svs_mode_clk_sel;
+       u32 com_hsclk_sel;
+       u32 com_pll_cctrl_mode0;
+       u32 com_pll_rctrl_mode0;
+       u32 com_cp_ctrl_mode0;
+       u32 com_dec_start_mode0;
+       u32 com_div_frac_start1_mode0;
+       u32 com_div_frac_start2_mode0;
+       u32 com_div_frac_start3_mode0;
+       u32 com_integloop_gain0_mode0;
+       u32 com_integloop_gain1_mode0;
+       u32 com_lock_cmp_en;
+       u32 com_lock_cmp1_mode0;
+       u32 com_lock_cmp2_mode0;
+       u32 com_lock_cmp3_mode0;
+       u32 com_core_clk_en;
+       u32 com_coreclk_div;
+       u32 com_vco_tune_ctrl;
+
+       u32 tx_lx_tx_drv_lvl[HDMI_NUM_TX_CHANNEL];
+       u32 tx_lx_tx_emp_post1_lvl[HDMI_NUM_TX_CHANNEL];
+       u32 tx_lx_vmode_ctrl1[HDMI_NUM_TX_CHANNEL];
+       u32 tx_lx_vmode_ctrl2[HDMI_NUM_TX_CHANNEL];
+       u32 tx_lx_res_code_lane_tx[HDMI_NUM_TX_CHANNEL];
+       u32 tx_lx_hp_pd_enables[HDMI_NUM_TX_CHANNEL];
+
+       u32 phy_mode;
+};
+
+struct hdmi_8996_post_divider {
+       u64 vco_freq;
+       int hsclk_divsel;
+       int vco_ratio;
+       int tx_band_sel;
+       int half_rate_mode;
+};
+
+static inline struct hdmi_phy *pll_get_phy(struct hdmi_pll_8996 *pll)
+{
+       return platform_get_drvdata(pll->pdev);
+}
+
+static inline void hdmi_pll_write(struct hdmi_pll_8996 *pll, int offset,
+                                 u32 data)
+{
+       msm_writel(data, pll->mmio_qserdes_com + offset);
+}
+
+static inline u32 hdmi_pll_read(struct hdmi_pll_8996 *pll, int offset)
+{
+       return msm_readl(pll->mmio_qserdes_com + offset);
+}
+
+static inline void hdmi_tx_chan_write(struct hdmi_pll_8996 *pll, int channel,
+                                     int offset, int data)
+{
+        msm_writel(data, pll->mmio_qserdes_tx[channel] + offset);
+}
+
+static inline u32 pll_get_cpctrl(u64 frac_start, unsigned long ref_clk,
+                                bool gen_ssc)
+{
+       if ((frac_start != 0) || gen_ssc)
+               return (11000000 / (ref_clk / 20));
+
+       return 0x23;
+}
+
+static inline u32 pll_get_rctrl(u64 frac_start, bool gen_ssc)
+{
+       if ((frac_start != 0) || gen_ssc)
+               return 0x16;
+
+       return 0x10;
+}
+
+static inline u32 pll_get_cctrl(u64 frac_start, bool gen_ssc)
+{
+       if ((frac_start != 0) || gen_ssc)
+               return 0x28;
+
+       return 0x1;
+}
+
+static inline u32 pll_get_integloop_gain(u64 frac_start, u64 bclk, u32 ref_clk,
+                                        bool gen_ssc)
+{
+       int digclk_divsel = bclk >= HDMI_DIG_FREQ_BIT_CLK_THRESHOLD ? 1 : 2;
+       u64 base;
+
+       if ((frac_start != 0) || gen_ssc)
+               base = (64 * ref_clk) / HDMI_DEFAULT_REF_CLOCK;
+       else
+               base = (1022 * ref_clk) / 100;
+
+       base <<= digclk_divsel;
+
+       return (base <= 2046 ? base : 2046);
+}
+
+static inline u32 pll_get_pll_cmp(u64 fdata, unsigned long ref_clk)
+{
+       u64 dividend = HDMI_PLL_CMP_CNT * fdata;
+       u32 divisor = ref_clk * 10;
+       u32 rem;
+
+       rem = do_div(dividend, divisor);
+       if (rem > (divisor >> 1))
+               dividend++;
+
+       return dividend - 1;
+}
+
+static inline u64 pll_cmp_to_fdata(u32 pll_cmp, unsigned long ref_clk)
+{
+       u64 fdata = ((u64)pll_cmp) * ref_clk * 10;
+
+       do_div(fdata, HDMI_PLL_CMP_CNT);
+
+       return fdata;
+}
+
+static int pll_get_post_div(struct hdmi_8996_post_divider *pd, u64 bclk)
+{
+       int ratio[] = { 2, 3, 4, 5, 6, 9, 10, 12, 14, 15, 20, 21, 25, 28, 35 };
+       int hs_divsel[] = { 0, 4, 8, 12, 1, 5, 2, 9, 3, 13, 10, 7, 14, 11, 15 };
+       int tx_band_sel[] = { 0, 1, 2, 3 };
+       u64 vco_freq[60];
+       u64 vco, vco_optimal;
+       int half_rate_mode = 0;
+       int vco_optimal_index, vco_freq_index;
+       int i, j;
+
+retry:
+       vco_optimal = HDMI_VCO_MAX_FREQ;
+       vco_optimal_index = -1;
+       vco_freq_index = 0;
+       for (i = 0; i < 15; i++) {
+               for (j = 0; j < 4; j++) {
+                       u32 ratio_mult = ratio[i] << tx_band_sel[j];
+
+                       vco = bclk >> half_rate_mode;
+                       vco *= ratio_mult;
+                       vco_freq[vco_freq_index++] = vco;
+               }
+       }
+
+       for (i = 0; i < 60; i++) {
+               u64 vco_tmp = vco_freq[i];
+
+               if ((vco_tmp >= HDMI_VCO_MIN_FREQ) &&
+                   (vco_tmp <= vco_optimal)) {
+                       vco_optimal = vco_tmp;
+                       vco_optimal_index = i;
+               }
+       }
+
+       if (vco_optimal_index == -1) {
+               if (!half_rate_mode) {
+                       half_rate_mode = 1;
+                       goto retry;
+               }
+       } else {
+               pd->vco_freq = vco_optimal;
+               pd->tx_band_sel = tx_band_sel[vco_optimal_index % 4];
+               pd->vco_ratio = ratio[vco_optimal_index / 4];
+               pd->hsclk_divsel = hs_divsel[vco_optimal_index / 4];
+
+               return 0;
+       }
+
+       return -EINVAL;
+}
+
+static int pll_calculate(unsigned long pix_clk, unsigned long ref_clk,
+                        struct hdmi_8996_phy_pll_reg_cfg *cfg)
+{
+       struct hdmi_8996_post_divider pd;
+       u64 bclk;
+       u64 tmds_clk;
+       u64 dec_start;
+       u64 frac_start;
+       u64 fdata;
+       u32 pll_divisor;
+       u32 rem;
+       u32 cpctrl;
+       u32 rctrl;
+       u32 cctrl;
+       u32 integloop_gain;
+       u32 pll_cmp;
+       int i, ret;
+
+       /* bit clk = 10 * pix_clk */
+       bclk = ((u64)pix_clk) * 10;
+
+       if (bclk > HDMI_HIGH_FREQ_BIT_CLK_THRESHOLD)
+               tmds_clk = pix_clk >> 2;
+       else
+               tmds_clk = pix_clk;
+
+       ret = pll_get_post_div(&pd, bclk);
+       if (ret)
+               return ret;
+
+       dec_start = pd.vco_freq;
+       pll_divisor = 4 * ref_clk;
+       do_div(dec_start, pll_divisor);
+
+       frac_start = pd.vco_freq * (1 << 20);
+
+       rem = do_div(frac_start, pll_divisor);
+       frac_start -= dec_start * (1 << 20);
+       if (rem > (pll_divisor >> 1))
+               frac_start++;
+
+       cpctrl = pll_get_cpctrl(frac_start, ref_clk, false);
+       rctrl = pll_get_rctrl(frac_start, false);
+       cctrl = pll_get_cctrl(frac_start, false);
+       integloop_gain = pll_get_integloop_gain(frac_start, bclk,
+                                               ref_clk, false);
+
+       fdata = pd.vco_freq;
+       do_div(fdata, pd.vco_ratio);
+
+       pll_cmp = pll_get_pll_cmp(fdata, ref_clk);
+
+       DBG("VCO freq: %llu", pd.vco_freq);
+       DBG("fdata: %llu", fdata);
+       DBG("pix_clk: %lu", pix_clk);
+       DBG("tmds clk: %llu", tmds_clk);
+       DBG("HSCLK_SEL: %d", pd.hsclk_divsel);
+       DBG("DEC_START: %llu", dec_start);
+       DBG("DIV_FRAC_START: %llu", frac_start);
+       DBG("PLL_CPCTRL: %u", cpctrl);
+       DBG("PLL_RCTRL: %u", rctrl);
+       DBG("PLL_CCTRL: %u", cctrl);
+       DBG("INTEGLOOP_GAIN: %u", integloop_gain);
+       DBG("TX_BAND: %d", pd.tx_band_sel);
+       DBG("PLL_CMP: %u", pll_cmp);
+
+       /* Convert these values to register specific values */
+       if (bclk > HDMI_DIG_FREQ_BIT_CLK_THRESHOLD)
+               cfg->com_svs_mode_clk_sel = 1;
+       else
+               cfg->com_svs_mode_clk_sel = 2;
+
+       cfg->com_hsclk_sel = (0x20 | pd.hsclk_divsel);
+       cfg->com_pll_cctrl_mode0 = cctrl;
+       cfg->com_pll_rctrl_mode0 = rctrl;
+       cfg->com_cp_ctrl_mode0 = cpctrl;
+       cfg->com_dec_start_mode0 = dec_start;
+       cfg->com_div_frac_start1_mode0 = (frac_start & 0xff);
+       cfg->com_div_frac_start2_mode0 = ((frac_start & 0xff00) >> 8);
+       cfg->com_div_frac_start3_mode0 = ((frac_start & 0xf0000) >> 16);
+       cfg->com_integloop_gain0_mode0 = (integloop_gain & 0xff);
+       cfg->com_integloop_gain1_mode0 = ((integloop_gain & 0xf00) >> 8);
+       cfg->com_lock_cmp1_mode0 = (pll_cmp & 0xff);
+       cfg->com_lock_cmp2_mode0 = ((pll_cmp & 0xff00) >> 8);
+       cfg->com_lock_cmp3_mode0 = ((pll_cmp & 0x30000) >> 16);
+       cfg->com_lock_cmp_en = 0x0;
+       cfg->com_core_clk_en = 0x2c;
+       cfg->com_coreclk_div = HDMI_CORECLK_DIV;
+       cfg->phy_mode = (bclk > HDMI_HIGH_FREQ_BIT_CLK_THRESHOLD) ? 0x10 : 0x0;
+       cfg->com_vco_tune_ctrl = 0x0;
+
+       cfg->tx_lx_lane_mode[0] =
+               cfg->tx_lx_lane_mode[2] = 0x43;
+
+       cfg->tx_lx_hp_pd_enables[0] =
+               cfg->tx_lx_hp_pd_enables[1] =
+               cfg->tx_lx_hp_pd_enables[2] = 0x0c;
+       cfg->tx_lx_hp_pd_enables[3] = 0x3;
+
+       for (i = 0; i < HDMI_NUM_TX_CHANNEL; i++)
+               cfg->tx_lx_tx_band[i] = pd.tx_band_sel + 4;
+
+       if (bclk > HDMI_HIGH_FREQ_BIT_CLK_THRESHOLD) {
+               cfg->tx_lx_tx_drv_lvl[0] =
+                       cfg->tx_lx_tx_drv_lvl[1] =
+                       cfg->tx_lx_tx_drv_lvl[2] = 0x25;
+               cfg->tx_lx_tx_drv_lvl[3] = 0x22;
+
+               cfg->tx_lx_tx_emp_post1_lvl[0] =
+                       cfg->tx_lx_tx_emp_post1_lvl[1] =
+                       cfg->tx_lx_tx_emp_post1_lvl[2] = 0x23;
+               cfg->tx_lx_tx_emp_post1_lvl[3] = 0x27;
+
+               cfg->tx_lx_vmode_ctrl1[0] =
+                       cfg->tx_lx_vmode_ctrl1[1] =
+                       cfg->tx_lx_vmode_ctrl1[2] =
+                       cfg->tx_lx_vmode_ctrl1[3] = 0x00;
+
+               cfg->tx_lx_vmode_ctrl2[0] =
+                       cfg->tx_lx_vmode_ctrl2[1] =
+                       cfg->tx_lx_vmode_ctrl2[2] = 0x0D;
+
+               cfg->tx_lx_vmode_ctrl2[3] = 0x00;
+       } else if (bclk > HDMI_MID_FREQ_BIT_CLK_THRESHOLD) {
+               for (i = 0; i < HDMI_NUM_TX_CHANNEL; i++) {
+                       cfg->tx_lx_tx_drv_lvl[i] = 0x25;
+                       cfg->tx_lx_tx_emp_post1_lvl[i] = 0x23;
+                       cfg->tx_lx_vmode_ctrl1[i] = 0x00;
+               }
+
+               cfg->tx_lx_vmode_ctrl2[0] =
+                       cfg->tx_lx_vmode_ctrl2[1] =
+                       cfg->tx_lx_vmode_ctrl2[2] = 0x0D;
+               cfg->tx_lx_vmode_ctrl2[3] = 0x00;
+       } else {
+               for (i = 0; i < HDMI_NUM_TX_CHANNEL; i++) {
+                       cfg->tx_lx_tx_drv_lvl[i] = 0x20;
+                       cfg->tx_lx_tx_emp_post1_lvl[i] = 0x20;
+                       cfg->tx_lx_vmode_ctrl1[i] = 0x00;
+                       cfg->tx_lx_vmode_ctrl2[i] = 0x0E;
+               }
+       }
+
+       DBG("com_svs_mode_clk_sel = 0x%x", cfg->com_svs_mode_clk_sel);
+       DBG("com_hsclk_sel = 0x%x", cfg->com_hsclk_sel);
+       DBG("com_lock_cmp_en = 0x%x", cfg->com_lock_cmp_en);
+       DBG("com_pll_cctrl_mode0 = 0x%x", cfg->com_pll_cctrl_mode0);
+       DBG("com_pll_rctrl_mode0 = 0x%x", cfg->com_pll_rctrl_mode0);
+       DBG("com_cp_ctrl_mode0 = 0x%x", cfg->com_cp_ctrl_mode0);
+       DBG("com_dec_start_mode0 = 0x%x", cfg->com_dec_start_mode0);
+       DBG("com_div_frac_start1_mode0 = 0x%x", cfg->com_div_frac_start1_mode0);
+       DBG("com_div_frac_start2_mode0 = 0x%x", cfg->com_div_frac_start2_mode0);
+       DBG("com_div_frac_start3_mode0 = 0x%x", cfg->com_div_frac_start3_mode0);
+       DBG("com_integloop_gain0_mode0 = 0x%x", cfg->com_integloop_gain0_mode0);
+       DBG("com_integloop_gain1_mode0 = 0x%x", cfg->com_integloop_gain1_mode0);
+       DBG("com_lock_cmp1_mode0 = 0x%x", cfg->com_lock_cmp1_mode0);
+       DBG("com_lock_cmp2_mode0 = 0x%x", cfg->com_lock_cmp2_mode0);
+       DBG("com_lock_cmp3_mode0 = 0x%x", cfg->com_lock_cmp3_mode0);
+       DBG("com_core_clk_en = 0x%x", cfg->com_core_clk_en);
+       DBG("com_coreclk_div = 0x%x", cfg->com_coreclk_div);
+       DBG("phy_mode = 0x%x", cfg->phy_mode);
+
+       DBG("tx_l0_lane_mode = 0x%x", cfg->tx_lx_lane_mode[0]);
+       DBG("tx_l2_lane_mode = 0x%x", cfg->tx_lx_lane_mode[2]);
+
+       for (i = 0; i < HDMI_NUM_TX_CHANNEL; i++) {
+               DBG("tx_l%d_tx_band = 0x%x", i, cfg->tx_lx_tx_band[i]);
+               DBG("tx_l%d_tx_drv_lvl = 0x%x", i, cfg->tx_lx_tx_drv_lvl[i]);
+               DBG("tx_l%d_tx_emp_post1_lvl = 0x%x", i,
+                   cfg->tx_lx_tx_emp_post1_lvl[i]);
+               DBG("tx_l%d_vmode_ctrl1 = 0x%x", i, cfg->tx_lx_vmode_ctrl1[i]);
+               DBG("tx_l%d_vmode_ctrl2 = 0x%x", i, cfg->tx_lx_vmode_ctrl2[i]);
+       }
+
+       return 0;
+}
+
+static int hdmi_8996_pll_set_clk_rate(struct clk_hw *hw, unsigned long rate,
+                                     unsigned long parent_rate)
+{
+       struct hdmi_pll_8996 *pll = hw_clk_to_pll(hw);
+       struct hdmi_phy *phy = pll_get_phy(pll);
+       struct hdmi_8996_phy_pll_reg_cfg cfg;
+       int i, ret;
+
+       memset(&cfg, 0x00, sizeof(cfg));
+
+       ret = pll_calculate(rate, parent_rate, &cfg);
+       if (ret) {
+               DRM_ERROR("PLL calculation failed\n");
+               return ret;
+       }
+
+       /* Initially shut down PHY */
+       DBG("Disabling PHY");
+       hdmi_phy_write(phy, REG_HDMI_8996_PHY_PD_CTL, 0x0);
+       udelay(500);
+
+       /* Power up sequence */
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_BG_CTRL, 0x04);
+
+       hdmi_phy_write(phy, REG_HDMI_8996_PHY_PD_CTL, 0x1);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_RESETSM_CNTRL, 0x20);
+       hdmi_phy_write(phy, REG_HDMI_8996_PHY_TX0_TX1_LANE_CTL, 0x0F);
+       hdmi_phy_write(phy, REG_HDMI_8996_PHY_TX2_TX3_LANE_CTL, 0x0F);
+
+       for (i = 0; i < HDMI_NUM_TX_CHANNEL; i++) {
+               hdmi_tx_chan_write(pll, i,
+                                  REG_HDMI_PHY_QSERDES_TX_LX_CLKBUF_ENABLE,
+                                  0x03);
+               hdmi_tx_chan_write(pll, i,
+                                  REG_HDMI_PHY_QSERDES_TX_LX_TX_BAND,
+                                  cfg.tx_lx_tx_band[i]);
+               hdmi_tx_chan_write(pll, i,
+                                  REG_HDMI_PHY_QSERDES_TX_LX_RESET_TSYNC_EN,
+                                  0x03);
+       }
+
+       hdmi_tx_chan_write(pll, 0, REG_HDMI_PHY_QSERDES_TX_LX_LANE_MODE,
+                          cfg.tx_lx_lane_mode[0]);
+       hdmi_tx_chan_write(pll, 2, REG_HDMI_PHY_QSERDES_TX_LX_LANE_MODE,
+                          cfg.tx_lx_lane_mode[2]);
+
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_SYSCLK_BUF_ENABLE, 0x1E);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x07);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_SYSCLK_EN_SEL, 0x37);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_SYS_CLK_CTRL, 0x02);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_CLK_ENABLE1, 0x0E);
+
+       /* Bypass VCO calibration */
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_SVS_MODE_CLK_SEL,
+                      cfg.com_svs_mode_clk_sel);
+
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_BG_TRIM, 0x0F);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_PLL_IVCO, 0x0F);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_CTRL,
+                      cfg.com_vco_tune_ctrl);
+
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_BG_CTRL, 0x06);
+
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_CLK_SELECT, 0x30);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_HSCLK_SEL,
+                      cfg.com_hsclk_sel);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_LOCK_CMP_EN,
+                      cfg.com_lock_cmp_en);
+
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_PLL_CCTRL_MODE0,
+                      cfg.com_pll_cctrl_mode0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_PLL_RCTRL_MODE0,
+                      cfg.com_pll_rctrl_mode0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_CP_CTRL_MODE0,
+                      cfg.com_cp_ctrl_mode0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_DEC_START_MODE0,
+                      cfg.com_dec_start_mode0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START1_MODE0,
+                      cfg.com_div_frac_start1_mode0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START2_MODE0,
+                      cfg.com_div_frac_start2_mode0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_DIV_FRAC_START3_MODE0,
+                      cfg.com_div_frac_start3_mode0);
+
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_GAIN0_MODE0,
+                      cfg.com_integloop_gain0_mode0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_INTEGLOOP_GAIN1_MODE0,
+                      cfg.com_integloop_gain1_mode0);
+
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_LOCK_CMP1_MODE0,
+                      cfg.com_lock_cmp1_mode0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_LOCK_CMP2_MODE0,
+                      cfg.com_lock_cmp2_mode0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_LOCK_CMP3_MODE0,
+                      cfg.com_lock_cmp3_mode0);
+
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_VCO_TUNE_MAP, 0x00);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_CORE_CLK_EN,
+                      cfg.com_core_clk_en);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_CORECLK_DIV,
+                      cfg.com_coreclk_div);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_CMN_CONFIG, 0x02);
+
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_RESCODE_DIV_NUM, 0x15);
+
+       /* TX lanes setup (TX 0/1/2/3) */
+       for (i = 0; i < HDMI_NUM_TX_CHANNEL; i++) {
+               hdmi_tx_chan_write(pll, i,
+                                  REG_HDMI_PHY_QSERDES_TX_LX_TX_DRV_LVL,
+                                  cfg.tx_lx_tx_drv_lvl[i]);
+               hdmi_tx_chan_write(pll, i,
+                                  REG_HDMI_PHY_QSERDES_TX_LX_TX_EMP_POST1_LVL,
+                                  cfg.tx_lx_tx_emp_post1_lvl[i]);
+               hdmi_tx_chan_write(pll, i,
+                                  REG_HDMI_PHY_QSERDES_TX_LX_VMODE_CTRL1,
+                                  cfg.tx_lx_vmode_ctrl1[i]);
+               hdmi_tx_chan_write(pll, i,
+                                  REG_HDMI_PHY_QSERDES_TX_LX_VMODE_CTRL2,
+                                  cfg.tx_lx_vmode_ctrl2[i]);
+               hdmi_tx_chan_write(pll, i,
+                                  REG_HDMI_PHY_QSERDES_TX_LX_TX_DRV_LVL_OFFSET,
+                                  0x00);
+               hdmi_tx_chan_write(pll, i,
+                       REG_HDMI_PHY_QSERDES_TX_LX_RES_CODE_LANE_OFFSET,
+                       0x00);
+               hdmi_tx_chan_write(pll, i,
+                       REG_HDMI_PHY_QSERDES_TX_LX_TRAN_DRVR_EMP_EN,
+                       0x03);
+               hdmi_tx_chan_write(pll, i,
+                       REG_HDMI_PHY_QSERDES_TX_LX_PARRATE_REC_DETECT_IDLE_EN,
+                       0x40);
+               hdmi_tx_chan_write(pll, i,
+                                  REG_HDMI_PHY_QSERDES_TX_LX_HP_PD_ENABLES,
+                                  cfg.tx_lx_hp_pd_enables[i]);
+       }
+
+       hdmi_phy_write(phy, REG_HDMI_8996_PHY_MODE, cfg.phy_mode);
+       hdmi_phy_write(phy, REG_HDMI_8996_PHY_PD_CTL, 0x1F);
+
+       /*
+        * Ensure that vco configuration gets flushed to hardware before
+        * enabling the PLL
+        */
+       wmb();
+
+       return 0;
+}
+
+static int hdmi_8996_phy_ready_status(struct hdmi_phy *phy)
+{
+       u32 nb_tries = HDMI_PLL_POLL_MAX_READS;
+       unsigned long timeout = HDMI_PLL_POLL_TIMEOUT_US;
+       u32 status;
+       int phy_ready = 0;
+
+       DBG("Waiting for PHY ready");
+
+       while (nb_tries--) {
+               status = hdmi_phy_read(phy, REG_HDMI_8996_PHY_STATUS);
+               phy_ready = status & BIT(0);
+
+               if (phy_ready)
+                       break;
+
+               udelay(timeout);
+       }
+
+       DBG("PHY is %sready", phy_ready ? "" : "*not* ");
+
+       return phy_ready;
+}
+
+static int hdmi_8996_pll_lock_status(struct hdmi_pll_8996 *pll)
+{
+       u32 status;
+       int nb_tries = HDMI_PLL_POLL_MAX_READS;
+       unsigned long timeout = HDMI_PLL_POLL_TIMEOUT_US;
+       int pll_locked = 0;
+
+       DBG("Waiting for PLL lock");
+
+       while (nb_tries--) {
+               status = hdmi_pll_read(pll,
+                                      REG_HDMI_PHY_QSERDES_COM_C_READY_STATUS);
+               pll_locked = status & BIT(0);
+
+               if (pll_locked)
+                       break;
+
+               udelay(timeout);
+       }
+
+       DBG("HDMI PLL is %slocked", pll_locked ? "" : "*not* ");
+
+       return pll_locked;
+}
+
+static int hdmi_8996_pll_prepare(struct clk_hw *hw)
+{
+       struct hdmi_pll_8996 *pll = hw_clk_to_pll(hw);
+       struct hdmi_phy *phy = pll_get_phy(pll);
+       int i, ret = 0;
+
+       hdmi_phy_write(phy, REG_HDMI_8996_PHY_CFG, 0x1);
+       udelay(100);
+
+       hdmi_phy_write(phy, REG_HDMI_8996_PHY_CFG, 0x19);
+       udelay(100);
+
+       ret = hdmi_8996_pll_lock_status(pll);
+       if (!ret)
+               return ret;
+
+       for (i = 0; i < HDMI_NUM_TX_CHANNEL; i++)
+               hdmi_tx_chan_write(pll, i,
+                       REG_HDMI_PHY_QSERDES_TX_LX_HIGHZ_TRANSCEIVEREN_BIAS_DRVR_EN,
+                       0x6F);
+
+       /* Disable SSC */
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_SSC_PER1, 0x0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_SSC_PER2, 0x0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_SSC_STEP_SIZE1, 0x0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_SSC_STEP_SIZE2, 0x0);
+       hdmi_pll_write(pll, REG_HDMI_PHY_QSERDES_COM_SSC_EN_CENTER, 0x2);
+
+       ret = hdmi_8996_phy_ready_status(phy);
+       if (!ret)
+               return ret;
+
+       /* Restart the retiming buffer */
+       hdmi_phy_write(phy, REG_HDMI_8996_PHY_CFG, 0x18);
+       udelay(1);
+       hdmi_phy_write(phy, REG_HDMI_8996_PHY_CFG, 0x19);
+
+       return 0;
+}
+
+static long hdmi_8996_pll_round_rate(struct clk_hw *hw,
+                                    unsigned long rate,
+                                    unsigned long *parent_rate)
+{
+       if (rate < HDMI_PCLK_MIN_FREQ)
+               return HDMI_PCLK_MIN_FREQ;
+       else if (rate > HDMI_PCLK_MAX_FREQ)
+               return HDMI_PCLK_MAX_FREQ;
+       else
+               return rate;
+}
+
+static unsigned long hdmi_8996_pll_recalc_rate(struct clk_hw *hw,
+                                              unsigned long parent_rate)
+{
+       struct hdmi_pll_8996 *pll = hw_clk_to_pll(hw);
+       u64 fdata;
+       u32 cmp1, cmp2, cmp3, pll_cmp;
+
+       cmp1 = hdmi_pll_read(pll, REG_HDMI_PHY_QSERDES_COM_LOCK_CMP1_MODE0);
+       cmp2 = hdmi_pll_read(pll, REG_HDMI_PHY_QSERDES_COM_LOCK_CMP2_MODE0);
+       cmp3 = hdmi_pll_read(pll, REG_HDMI_PHY_QSERDES_COM_LOCK_CMP3_MODE0);
+
+       pll_cmp = cmp1 | (cmp2 << 8) | (cmp3 << 16);
+
+       fdata = pll_cmp_to_fdata(pll_cmp + 1, parent_rate);
+
+       do_div(fdata, 10);
+
+       return fdata;
+}
+
+static void hdmi_8996_pll_unprepare(struct clk_hw *hw)
+{
+}
+
+static int hdmi_8996_pll_is_enabled(struct clk_hw *hw)
+{
+       struct hdmi_pll_8996 *pll = hw_clk_to_pll(hw);
+       u32 status;
+       int pll_locked;
+
+       status = hdmi_pll_read(pll, REG_HDMI_PHY_QSERDES_COM_C_READY_STATUS);
+       pll_locked = status & BIT(0);
+
+       return pll_locked;
+}
+
+static struct clk_ops hdmi_8996_pll_ops = {
+       .set_rate = hdmi_8996_pll_set_clk_rate,
+       .round_rate = hdmi_8996_pll_round_rate,
+       .recalc_rate = hdmi_8996_pll_recalc_rate,
+       .prepare = hdmi_8996_pll_prepare,
+       .unprepare = hdmi_8996_pll_unprepare,
+       .is_enabled = hdmi_8996_pll_is_enabled,
+};
+
+static const char * const hdmi_pll_parents[] = {
+       "xo",
+};
+
+static struct clk_init_data pll_init = {
+       .name = "hdmipll",
+       .ops = &hdmi_8996_pll_ops,
+       .parent_names = hdmi_pll_parents,
+       .num_parents = ARRAY_SIZE(hdmi_pll_parents),
+};
+
+int msm_hdmi_pll_8996_init(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct hdmi_pll_8996 *pll;
+       struct clk *clk;
+       int i;
+
+       pll = devm_kzalloc(dev, sizeof(*pll), GFP_KERNEL);
+       if (!pll)
+               return -ENOMEM;
+
+       pll->pdev = pdev;
+
+       pll->mmio_qserdes_com = msm_ioremap(pdev, "hdmi_pll", "HDMI_PLL");
+       if (IS_ERR(pll->mmio_qserdes_com)) {
+               dev_err(dev, "failed to map pll base\n");
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < HDMI_NUM_TX_CHANNEL; i++) {
+               char name[32], label[32];
+
+               snprintf(name, sizeof(name), "hdmi_tx_l%d", i);
+               snprintf(label, sizeof(label), "HDMI_TX_L%d", i);
+
+               pll->mmio_qserdes_tx[i] = msm_ioremap(pdev, name, label);
+               if (IS_ERR(pll->mmio_qserdes_tx[i])) {
+                       dev_err(dev, "failed to map pll base\n");
+                       return -ENOMEM;
+               }
+       }
+       pll->clk_hw.init = &pll_init;
+
+       clk = devm_clk_register(dev, &pll->clk_hw);
+       if (IS_ERR(clk)) {
+               dev_err(dev, "failed to register pll clock\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static const char * const hdmi_phy_8996_reg_names[] = {
+       "vddio",
+       "vcca",
+};
+
+static const char * const hdmi_phy_8996_clk_names[] = {
+       "mmagic_iface_clk",
+       "iface_clk",
+       "ref_clk",
+};
+
+const struct hdmi_phy_cfg msm_hdmi_phy_8996_cfg = {
+       .type = MSM_HDMI_PHY_8996,
+       .reg_names = hdmi_phy_8996_reg_names,
+       .num_regs = ARRAY_SIZE(hdmi_phy_8996_reg_names),
+       .clk_names = hdmi_phy_8996_clk_names,
+       .num_clks = ARRAY_SIZE(hdmi_phy_8996_clk_names),
+};
index cb01421..a68eea4 100644 (file)
 
 #include "hdmi.h"
 
-struct hdmi_phy_8x60 {
-       struct hdmi_phy base;
-       struct hdmi *hdmi;
-};
-#define to_hdmi_phy_8x60(x) container_of(x, struct hdmi_phy_8x60, base)
-
-static void hdmi_phy_8x60_destroy(struct hdmi_phy *phy)
-{
-       struct hdmi_phy_8x60 *phy_8x60 = to_hdmi_phy_8x60(phy);
-       kfree(phy_8x60);
-}
-
 static void hdmi_phy_8x60_powerup(struct hdmi_phy *phy,
                unsigned long int pixclock)
 {
-       struct hdmi_phy_8x60 *phy_8x60 = to_hdmi_phy_8x60(phy);
-       struct hdmi *hdmi = phy_8x60->hdmi;
-
        /* De-serializer delay D/C for non-lbk mode: */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG0,
-                       HDMI_8x60_PHY_REG0_DESER_DEL_CTRL(3));
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG0,
+                      HDMI_8x60_PHY_REG0_DESER_DEL_CTRL(3));
 
        if (pixclock == 27000000) {
                /* video_format == HDMI_VFRMT_720x480p60_16_9 */
-               hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG1,
-                               HDMI_8x60_PHY_REG1_DTEST_MUX_SEL(5) |
-                               HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL(3));
+               hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG1,
+                              HDMI_8x60_PHY_REG1_DTEST_MUX_SEL(5) |
+                              HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL(3));
        } else {
-               hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG1,
-                               HDMI_8x60_PHY_REG1_DTEST_MUX_SEL(5) |
-                               HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL(4));
+               hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG1,
+                              HDMI_8x60_PHY_REG1_DTEST_MUX_SEL(5) |
+                              HDMI_8x60_PHY_REG1_OUTVOL_SWING_CTRL(4));
        }
 
        /* No matter what, start from the power down mode: */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG2,
-                       HDMI_8x60_PHY_REG2_PD_PWRGEN |
-                       HDMI_8x60_PHY_REG2_PD_PLL |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
-                       HDMI_8x60_PHY_REG2_PD_DESER);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
+                      HDMI_8x60_PHY_REG2_PD_PWRGEN |
+                      HDMI_8x60_PHY_REG2_PD_PLL |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
+                      HDMI_8x60_PHY_REG2_PD_DESER);
 
        /* Turn PowerGen on: */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG2,
-                       HDMI_8x60_PHY_REG2_PD_PLL |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
-                       HDMI_8x60_PHY_REG2_PD_DESER);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
+                      HDMI_8x60_PHY_REG2_PD_PLL |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
+                      HDMI_8x60_PHY_REG2_PD_DESER);
 
        /* Turn PLL power on: */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG2,
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
-                       HDMI_8x60_PHY_REG2_PD_DESER);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
+                      HDMI_8x60_PHY_REG2_PD_DESER);
 
        /* Write to HIGH after PLL power down de-assert: */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG3,
-                       HDMI_8x60_PHY_REG3_PLL_ENABLE);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG3,
+                      HDMI_8x60_PHY_REG3_PLL_ENABLE);
 
        /* ASIC power on; PHY REG9 = 0 */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG9, 0);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG9, 0);
 
        /* Enable PLL lock detect, PLL lock det will go high after lock
         * Enable the re-time logic
         */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG12,
-                       HDMI_8x60_PHY_REG12_RETIMING_EN |
-                       HDMI_8x60_PHY_REG12_PLL_LOCK_DETECT_EN);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG12,
+                      HDMI_8x60_PHY_REG12_RETIMING_EN |
+                      HDMI_8x60_PHY_REG12_PLL_LOCK_DETECT_EN);
 
        /* Drivers are on: */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG2,
-                       HDMI_8x60_PHY_REG2_PD_DESER);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
+                      HDMI_8x60_PHY_REG2_PD_DESER);
 
        /* If the RX detector is needed: */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG2,
-                       HDMI_8x60_PHY_REG2_RCV_SENSE_EN |
-                       HDMI_8x60_PHY_REG2_PD_DESER);
-
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG4, 0);
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG5, 0);
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG6, 0);
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG7, 0);
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG8, 0);
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG9, 0);
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG10, 0);
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG11, 0);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
+                      HDMI_8x60_PHY_REG2_RCV_SENSE_EN |
+                      HDMI_8x60_PHY_REG2_PD_DESER);
+
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG4, 0);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG5, 0);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG6, 0);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG7, 0);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG8, 0);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG9, 0);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG10, 0);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG11, 0);
 
        /* If we want to use lock enable based on counting: */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG12,
-                       HDMI_8x60_PHY_REG12_RETIMING_EN |
-                       HDMI_8x60_PHY_REG12_PLL_LOCK_DETECT_EN |
-                       HDMI_8x60_PHY_REG12_FORCE_LOCK);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG12,
+                      HDMI_8x60_PHY_REG12_RETIMING_EN |
+                      HDMI_8x60_PHY_REG12_PLL_LOCK_DETECT_EN |
+                      HDMI_8x60_PHY_REG12_FORCE_LOCK);
 }
 
 static void hdmi_phy_8x60_powerdown(struct hdmi_phy *phy)
 {
-       struct hdmi_phy_8x60 *phy_8x60 = to_hdmi_phy_8x60(phy);
-       struct hdmi *hdmi = phy_8x60->hdmi;
-
        /* Assert RESET PHY from controller */
-       hdmi_write(hdmi, REG_HDMI_PHY_CTRL,
-                       HDMI_PHY_CTRL_SW_RESET);
+       hdmi_phy_write(phy, REG_HDMI_PHY_CTRL,
+                      HDMI_PHY_CTRL_SW_RESET);
        udelay(10);
        /* De-assert RESET PHY from controller */
-       hdmi_write(hdmi, REG_HDMI_PHY_CTRL, 0);
+       hdmi_phy_write(phy, REG_HDMI_PHY_CTRL, 0);
        /* Turn off Driver */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG2,
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
-                       HDMI_8x60_PHY_REG2_PD_DESER);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
+                      HDMI_8x60_PHY_REG2_PD_DESER);
        udelay(10);
        /* Disable PLL */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG3, 0);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG3, 0);
        /* Power down PHY, but keep RX-sense: */
-       hdmi_write(hdmi, REG_HDMI_8x60_PHY_REG2,
-                       HDMI_8x60_PHY_REG2_RCV_SENSE_EN |
-                       HDMI_8x60_PHY_REG2_PD_PWRGEN |
-                       HDMI_8x60_PHY_REG2_PD_PLL |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
-                       HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
-                       HDMI_8x60_PHY_REG2_PD_DESER);
+       hdmi_phy_write(phy, REG_HDMI_8x60_PHY_REG2,
+                      HDMI_8x60_PHY_REG2_RCV_SENSE_EN |
+                      HDMI_8x60_PHY_REG2_PD_PWRGEN |
+                      HDMI_8x60_PHY_REG2_PD_PLL |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_4 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_3 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_2 |
+                      HDMI_8x60_PHY_REG2_PD_DRIVE_1 |
+                      HDMI_8x60_PHY_REG2_PD_DESER);
 }
 
-static const struct hdmi_phy_funcs hdmi_phy_8x60_funcs = {
-               .destroy = hdmi_phy_8x60_destroy,
-               .powerup = hdmi_phy_8x60_powerup,
-               .powerdown = hdmi_phy_8x60_powerdown,
+const struct hdmi_phy_cfg msm_hdmi_phy_8x60_cfg = {
+       .type = MSM_HDMI_PHY_8x60,
+       .powerup = hdmi_phy_8x60_powerup,
+       .powerdown = hdmi_phy_8x60_powerdown,
 };
-
-struct hdmi_phy *hdmi_phy_8x60_init(struct hdmi *hdmi)
-{
-       struct hdmi_phy_8x60 *phy_8x60;
-       struct hdmi_phy *phy = NULL;
-       int ret;
-
-       phy_8x60 = kzalloc(sizeof(*phy_8x60), GFP_KERNEL);
-       if (!phy_8x60) {
-               ret = -ENOMEM;
-               goto fail;
-       }
-
-       phy = &phy_8x60->base;
-
-       phy->funcs = &hdmi_phy_8x60_funcs;
-
-       phy_8x60->hdmi = hdmi;
-
-       return phy;
-
-fail:
-       if (phy)
-               hdmi_phy_8x60_destroy(phy);
-       return ERR_PTR(ret);
-}
index 56ab891..c4a61e5 100644 (file)
 
 #include "hdmi.h"
 
-struct hdmi_phy_8x74 {
-       struct hdmi_phy base;
-       void __iomem *mmio;
-};
-#define to_hdmi_phy_8x74(x) container_of(x, struct hdmi_phy_8x74, base)
-
-
-static void phy_write(struct hdmi_phy_8x74 *phy, u32 reg, u32 data)
-{
-       msm_writel(data, phy->mmio + reg);
-}
-
-//static u32 phy_read(struct hdmi_phy_8x74 *phy, u32 reg)
-//{
-//     return msm_readl(phy->mmio + reg);
-//}
-
-static void hdmi_phy_8x74_destroy(struct hdmi_phy *phy)
-{
-       struct hdmi_phy_8x74 *phy_8x74 = to_hdmi_phy_8x74(phy);
-       kfree(phy_8x74);
-}
-
 static void hdmi_phy_8x74_powerup(struct hdmi_phy *phy,
                unsigned long int pixclock)
 {
-       struct hdmi_phy_8x74 *phy_8x74 = to_hdmi_phy_8x74(phy);
-
-       phy_write(phy_8x74, REG_HDMI_8x74_ANA_CFG0,   0x1b);
-       phy_write(phy_8x74, REG_HDMI_8x74_ANA_CFG1,   0xf2);
-       phy_write(phy_8x74, REG_HDMI_8x74_BIST_CFG0,  0x0);
-       phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN0, 0x0);
-       phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN1, 0x0);
-       phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN2, 0x0);
-       phy_write(phy_8x74, REG_HDMI_8x74_BIST_PATN3, 0x0);
-       phy_write(phy_8x74, REG_HDMI_8x74_PD_CTRL1,   0x20);
+       hdmi_phy_write(phy, REG_HDMI_8x74_ANA_CFG0,   0x1b);
+       hdmi_phy_write(phy, REG_HDMI_8x74_ANA_CFG1,   0xf2);
+       hdmi_phy_write(phy, REG_HDMI_8x74_BIST_CFG0,  0x0);
+       hdmi_phy_write(phy, REG_HDMI_8x74_BIST_PATN0, 0x0);
+       hdmi_phy_write(phy, REG_HDMI_8x74_BIST_PATN1, 0x0);
+       hdmi_phy_write(phy, REG_HDMI_8x74_BIST_PATN2, 0x0);
+       hdmi_phy_write(phy, REG_HDMI_8x74_BIST_PATN3, 0x0);
+       hdmi_phy_write(phy, REG_HDMI_8x74_PD_CTRL1,   0x20);
 }
 
 static void hdmi_phy_8x74_powerdown(struct hdmi_phy *phy)
 {
-       struct hdmi_phy_8x74 *phy_8x74 = to_hdmi_phy_8x74(phy);
-       phy_write(phy_8x74, REG_HDMI_8x74_PD_CTRL0, 0x7f);
+       hdmi_phy_write(phy, REG_HDMI_8x74_PD_CTRL0, 0x7f);
 }
 
-static const struct hdmi_phy_funcs hdmi_phy_8x74_funcs = {
-               .destroy = hdmi_phy_8x74_destroy,
-               .powerup = hdmi_phy_8x74_powerup,
-               .powerdown = hdmi_phy_8x74_powerdown,
+static const char * const hdmi_phy_8x74_reg_names[] = {
+       "core-vdda",
+       "vddio",
 };
 
-struct hdmi_phy *hdmi_phy_8x74_init(struct hdmi *hdmi)
-{
-       struct hdmi_phy_8x74 *phy_8x74;
-       struct hdmi_phy *phy = NULL;
-       int ret;
-
-       phy_8x74 = kzalloc(sizeof(*phy_8x74), GFP_KERNEL);
-       if (!phy_8x74) {
-               ret = -ENOMEM;
-               goto fail;
-       }
-
-       phy = &phy_8x74->base;
-
-       phy->funcs = &hdmi_phy_8x74_funcs;
-
-       /* for 8x74, the phy mmio is mapped separately: */
-       phy_8x74->mmio = msm_ioremap(hdmi->pdev,
-                       "phy_physical", "HDMI_8x74");
-       if (IS_ERR(phy_8x74->mmio)) {
-               ret = PTR_ERR(phy_8x74->mmio);
-               goto fail;
-       }
-
-       return phy;
+static const char * const hdmi_phy_8x74_clk_names[] = {
+       "iface_clk",
+       "alt_iface_clk"
+};
 
-fail:
-       if (phy)
-               hdmi_phy_8x74_destroy(phy);
-       return ERR_PTR(ret);
-}
+const struct hdmi_phy_cfg msm_hdmi_phy_8x74_cfg = {
+       .type = MSM_HDMI_PHY_8x74,
+       .powerup = hdmi_phy_8x74_powerup,
+       .powerdown = hdmi_phy_8x74_powerdown,
+       .reg_names = hdmi_phy_8x74_reg_names,
+       .num_regs = ARRAY_SIZE(hdmi_phy_8x74_reg_names),
+       .clk_names = hdmi_phy_8x74_clk_names,
+       .num_clks = ARRAY_SIZE(hdmi_phy_8x74_clk_names),
+};
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_pll_8960.c b/drivers/gpu/drm/msm/hdmi/hdmi_pll_8960.c
new file mode 100644 (file)
index 0000000..92da69a
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (C) 2013 Red Hat
+ * Author: Rob Clark <robdclark@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/clk-provider.h>
+#include "hdmi.h"
+
+struct hdmi_pll_8960 {
+       struct platform_device *pdev;
+       struct clk_hw clk_hw;
+       void __iomem *mmio;
+
+       unsigned long pixclk;
+};
+
+#define hw_clk_to_pll(x) container_of(x, struct hdmi_pll_8960, clk_hw)
+
+/*
+ * HDMI PLL:
+ *
+ * To get the parent clock setup properly, we need to plug in hdmi pll
+ * configuration into common-clock-framework.
+ */
+
+struct pll_rate {
+       unsigned long rate;
+       int num_reg;
+       struct {
+               u32 val;
+               u32 reg;
+       } conf[32];
+};
+
+/* NOTE: keep sorted highest freq to lowest: */
+static const struct pll_rate freqtbl[] = {
+       { 154000000, 14, {
+               { 0x08, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
+               { 0x20, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
+               { 0xf9, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
+               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
+               { 0x03, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
+               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
+               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
+               { 0x0d, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
+               { 0x4d, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
+               { 0x5e, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
+               { 0x42, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
+                       }
+       },
+       /* 1080p60/1080p50 case */
+       { 148500000, 27, {
+               { 0x02, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
+               { 0x02, REG_HDMI_8960_PHY_PLL_CHRG_PUMP_CFG },
+               { 0x01, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
+               { 0x33, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
+               { 0x2c, REG_HDMI_8960_PHY_PLL_IDAC_ADJ_CFG  },
+               { 0x06, REG_HDMI_8960_PHY_PLL_I_VI_KVCO_CFG },
+               { 0x0a, REG_HDMI_8960_PHY_PLL_PWRDN_B       },
+               { 0x76, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
+               { 0x01, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
+               { 0x4c, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
+               { 0xc0, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
+               { 0x9a, REG_HDMI_8960_PHY_PLL_SSC_CFG0      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG1      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG2      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG3      },
+               { 0x10, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG0  },
+               { 0x1a, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG1  },
+               { 0x0d, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2  },
+               { 0xe6, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
+               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
+               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
+               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
+               { 0x33, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG6   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG7   },
+                       }
+       },
+       { 108000000, 13, {
+               { 0x08, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
+               { 0x21, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
+               { 0xf9, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
+               { 0x1c, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
+               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
+               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
+               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
+               { 0x49, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
+               { 0x49, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
+                       }
+       },
+       /* 720p60/720p50/1080i60/1080i50/1080p24/1080p30/1080p25 */
+       { 74250000, 8, {
+               { 0x0a, REG_HDMI_8960_PHY_PLL_PWRDN_B       },
+               { 0x12, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
+               { 0x01, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
+               { 0x33, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
+               { 0x76, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
+               { 0xe6, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
+               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
+               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
+                       }
+       },
+       { 74176000, 14, {
+               { 0x18, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
+               { 0x20, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
+               { 0xf9, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
+               { 0xe5, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
+               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
+               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
+               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
+               { 0x0c, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
+               { 0x4c, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
+               { 0x7d, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
+               { 0xbc, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
+                       }
+       },
+       { 65000000, 14, {
+               { 0x18, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
+               { 0x20, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
+               { 0xf9, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
+               { 0x8a, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
+               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
+               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
+               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
+               { 0x0b, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
+               { 0x4b, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
+               { 0x7b, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
+               { 0x09, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
+                       }
+       },
+       /* 480p60/480i60 */
+       { 27030000, 18, {
+               { 0x0a, REG_HDMI_8960_PHY_PLL_PWRDN_B       },
+               { 0x38, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
+               { 0x02, REG_HDMI_8960_PHY_PLL_CHRG_PUMP_CFG },
+               { 0x20, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
+               { 0xff, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
+               { 0x4e, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
+               { 0xd7, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
+               { 0x03, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
+               { 0x2a, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
+               { 0x03, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
+               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
+               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
+               { 0x33, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG6   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG7   },
+                       }
+       },
+       /* 576p50/576i50 */
+       { 27000000, 27, {
+               { 0x32, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
+               { 0x02, REG_HDMI_8960_PHY_PLL_CHRG_PUMP_CFG },
+               { 0x01, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
+               { 0x33, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
+               { 0x2c, REG_HDMI_8960_PHY_PLL_IDAC_ADJ_CFG  },
+               { 0x06, REG_HDMI_8960_PHY_PLL_I_VI_KVCO_CFG },
+               { 0x0a, REG_HDMI_8960_PHY_PLL_PWRDN_B       },
+               { 0x7b, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
+               { 0x01, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
+               { 0x4c, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
+               { 0xc0, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
+               { 0x9a, REG_HDMI_8960_PHY_PLL_SSC_CFG0      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG1      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG2      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG3      },
+               { 0x10, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG0  },
+               { 0x1a, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG1  },
+               { 0x0d, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2  },
+               { 0x2a, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
+               { 0x03, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
+               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
+               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
+               { 0x33, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG6   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG7   },
+                       }
+       },
+       /* 640x480p60 */
+       { 25200000, 27, {
+               { 0x32, REG_HDMI_8960_PHY_PLL_REFCLK_CFG    },
+               { 0x02, REG_HDMI_8960_PHY_PLL_CHRG_PUMP_CFG },
+               { 0x01, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG0 },
+               { 0x33, REG_HDMI_8960_PHY_PLL_LOOP_FLT_CFG1 },
+               { 0x2c, REG_HDMI_8960_PHY_PLL_IDAC_ADJ_CFG  },
+               { 0x06, REG_HDMI_8960_PHY_PLL_I_VI_KVCO_CFG },
+               { 0x0a, REG_HDMI_8960_PHY_PLL_PWRDN_B       },
+               { 0x77, REG_HDMI_8960_PHY_PLL_SDM_CFG0      },
+               { 0x4c, REG_HDMI_8960_PHY_PLL_SDM_CFG1      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG2      },
+               { 0xc0, REG_HDMI_8960_PHY_PLL_SDM_CFG3      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SDM_CFG4      },
+               { 0x9a, REG_HDMI_8960_PHY_PLL_SSC_CFG0      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG1      },
+               { 0x00, REG_HDMI_8960_PHY_PLL_SSC_CFG2      },
+               { 0x20, REG_HDMI_8960_PHY_PLL_SSC_CFG3      },
+               { 0x10, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG0  },
+               { 0x1a, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG1  },
+               { 0x0d, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2  },
+               { 0xf4, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG0   },
+               { 0x02, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG1   },
+               { 0x3b, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG2   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG3   },
+               { 0x86, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG4   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG5   },
+               { 0x33, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG6   },
+               { 0x00, REG_HDMI_8960_PHY_PLL_VCOCAL_CFG7   },
+                       }
+       },
+};
+
+static inline void pll_write(struct hdmi_pll_8960 *pll, u32 reg, u32 data)
+{
+       msm_writel(data, pll->mmio + reg);
+}
+
+static inline u32 pll_read(struct hdmi_pll_8960 *pll, u32 reg)
+{
+       return msm_readl(pll->mmio + reg);
+}
+
+static inline struct hdmi_phy *pll_get_phy(struct hdmi_pll_8960 *pll)
+{
+       return platform_get_drvdata(pll->pdev);
+}
+
+static int hdmi_pll_enable(struct clk_hw *hw)
+{
+       struct hdmi_pll_8960 *pll = hw_clk_to_pll(hw);
+       struct hdmi_phy *phy = pll_get_phy(pll);
+       int timeout_count, pll_lock_retry = 10;
+       unsigned int val;
+
+       DBG("");
+
+       /* Assert PLL S/W reset */
+       pll_write(pll, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2, 0x8d);
+       pll_write(pll, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG0, 0x10);
+       pll_write(pll, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG1, 0x1a);
+
+       /* Wait for a short time before de-asserting
+        * to allow the hardware to complete its job.
+        * This much of delay should be fine for hardware
+        * to assert and de-assert.
+        */
+       udelay(10);
+
+       /* De-assert PLL S/W reset */
+       pll_write(pll, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2, 0x0d);
+
+       val = hdmi_phy_read(phy, REG_HDMI_8960_PHY_REG12);
+       val |= HDMI_8960_PHY_REG12_SW_RESET;
+       /* Assert PHY S/W reset */
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG12, val);
+       val &= ~HDMI_8960_PHY_REG12_SW_RESET;
+       /*
+        * Wait for a short time before de-asserting to allow the hardware to
+        * complete its job. This much of delay should be fine for hardware to
+        * assert and de-assert.
+        */
+       udelay(10);
+       /* De-assert PHY S/W reset */
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG12, val);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG2,  0x3f);
+
+       val = hdmi_phy_read(phy, REG_HDMI_8960_PHY_REG12);
+       val |= HDMI_8960_PHY_REG12_PWRDN_B;
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG12, val);
+       /* Wait 10 us for enabling global power for PHY */
+       mb();
+       udelay(10);
+
+       val = pll_read(pll, REG_HDMI_8960_PHY_PLL_PWRDN_B);
+       val |= HDMI_8960_PHY_PLL_PWRDN_B_PLL_PWRDN_B;
+       val &= ~HDMI_8960_PHY_PLL_PWRDN_B_PD_PLL;
+       pll_write(pll, REG_HDMI_8960_PHY_PLL_PWRDN_B, val);
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG2, 0x80);
+
+       timeout_count = 1000;
+       while (--pll_lock_retry > 0) {
+               /* are we there yet? */
+               val = pll_read(pll, REG_HDMI_8960_PHY_PLL_STATUS0);
+               if (val & HDMI_8960_PHY_PLL_STATUS0_PLL_LOCK)
+                       break;
+
+               udelay(1);
+
+               if (--timeout_count > 0)
+                       continue;
+
+               /*
+                * PLL has still not locked.
+                * Do a software reset and try again
+                * Assert PLL S/W reset first
+                */
+               pll_write(pll, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2, 0x8d);
+               udelay(10);
+               pll_write(pll, REG_HDMI_8960_PHY_PLL_LOCKDET_CFG2, 0x0d);
+
+               /*
+                * Wait for a short duration for the PLL calibration
+                * before checking if the PLL gets locked
+                */
+               udelay(350);
+
+               timeout_count = 1000;
+       }
+
+       return 0;
+}
+
+static void hdmi_pll_disable(struct clk_hw *hw)
+{
+       struct hdmi_pll_8960 *pll = hw_clk_to_pll(hw);
+       struct hdmi_phy *phy = pll_get_phy(pll);
+       unsigned int val;
+
+       DBG("");
+
+       val = hdmi_phy_read(phy, REG_HDMI_8960_PHY_REG12);
+       val &= ~HDMI_8960_PHY_REG12_PWRDN_B;
+       hdmi_phy_write(phy, REG_HDMI_8960_PHY_REG12, val);
+
+       val = pll_read(pll, REG_HDMI_8960_PHY_PLL_PWRDN_B);
+       val |= HDMI_8960_PHY_REG12_SW_RESET;
+       val &= ~HDMI_8960_PHY_REG12_PWRDN_B;
+       pll_write(pll, REG_HDMI_8960_PHY_PLL_PWRDN_B, val);
+       /* Make sure HDMI PHY/PLL are powered down */
+       mb();
+}
+
+static const struct pll_rate *find_rate(unsigned long rate)
+{
+       int i;
+
+       for (i = 1; i < ARRAY_SIZE(freqtbl); i++)
+               if (rate > freqtbl[i].rate)
+                       return &freqtbl[i - 1];
+
+       return &freqtbl[i - 1];
+}
+
+static unsigned long hdmi_pll_recalc_rate(struct clk_hw *hw,
+                                         unsigned long parent_rate)
+{
+       struct hdmi_pll_8960 *pll = hw_clk_to_pll(hw);
+
+       return pll->pixclk;
+}
+
+static long hdmi_pll_round_rate(struct clk_hw *hw, unsigned long rate,
+                               unsigned long *parent_rate)
+{
+       const struct pll_rate *pll_rate = find_rate(rate);
+
+       return pll_rate->rate;
+}
+
+static int hdmi_pll_set_rate(struct clk_hw *hw, unsigned long rate,
+                            unsigned long parent_rate)
+{
+       struct hdmi_pll_8960 *pll = hw_clk_to_pll(hw);
+       const struct pll_rate *pll_rate = find_rate(rate);
+       int i;
+
+       DBG("rate=%lu", rate);
+
+       for (i = 0; i < pll_rate->num_reg; i++)
+               pll_write(pll, pll_rate->conf[i].reg, pll_rate->conf[i].val);
+
+       pll->pixclk = rate;
+
+       return 0;
+}
+
+static const struct clk_ops hdmi_pll_ops = {
+       .enable = hdmi_pll_enable,
+       .disable = hdmi_pll_disable,
+       .recalc_rate = hdmi_pll_recalc_rate,
+       .round_rate = hdmi_pll_round_rate,
+       .set_rate = hdmi_pll_set_rate,
+};
+
+static const char * const hdmi_pll_parents[] = {
+       "pxo",
+};
+
+static struct clk_init_data pll_init = {
+       .name = "hdmi_pll",
+       .ops = &hdmi_pll_ops,
+       .parent_names = hdmi_pll_parents,
+       .num_parents = ARRAY_SIZE(hdmi_pll_parents),
+};
+
+int msm_hdmi_pll_8960_init(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct hdmi_pll_8960 *pll;
+       struct clk *clk;
+       int i;
+
+       /* sanity check: */
+       for (i = 0; i < (ARRAY_SIZE(freqtbl) - 1); i++)
+               if (WARN_ON(freqtbl[i].rate < freqtbl[i + 1].rate))
+                       return -EINVAL;
+
+       pll = devm_kzalloc(dev, sizeof(*pll), GFP_KERNEL);
+       if (!pll)
+               return -ENOMEM;
+
+       pll->mmio = msm_ioremap(pdev, "hdmi_pll", "HDMI_PLL");
+       if (IS_ERR(pll->mmio)) {
+               dev_err(dev, "failed to map pll base\n");
+               return -ENOMEM;
+       }
+
+       pll->pdev = pdev;
+       pll->clk_hw.init = &pll_init;
+
+       clk = devm_clk_register(dev, &pll->clk_hw);
+       if (IS_ERR(clk)) {
+               dev_err(dev, "failed to register pll clock\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
index dbd9cc4..6eab7d0 100644 (file)
@@ -9,7 +9,7 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/msm.xml                 (    676 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp4.xml            (  20915 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp_common.xml      (   2849 bytes, from 2015-09-18 12:07:28)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp5.xml            (  37194 bytes, from 2015-09-18 12:07:28)
@@ -17,11 +17,12 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/sfpb.xml            (    602 bytes, from 2015-10-22 16:35:02)
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/mmss_cc.xml         (   1686 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/hdmi/qfprom.xml         (    600 bytes, from 2015-05-20 20:03:07)
-- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  29154 bytes, from 2015-08-10 21:25:43)
+- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  41472 bytes, from 2016-01-22 18:18:18)
 - /home/robclark/src/freedreno/envytools/rnndb/edp/edp.xml             (  10416 bytes, from 2015-05-20 20:03:14)
 
 Copyright (C) 2013-2015 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
index d5d9457..6688e79 100644 (file)
@@ -9,7 +9,7 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/msm.xml                 (    676 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp4.xml            (  20915 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp_common.xml      (   2849 bytes, from 2015-09-18 12:07:28)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp5.xml            (  37194 bytes, from 2015-09-18 12:07:28)
@@ -17,11 +17,12 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/sfpb.xml            (    602 bytes, from 2015-10-22 16:35:02)
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/mmss_cc.xml         (   1686 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/hdmi/qfprom.xml         (    600 bytes, from 2015-05-20 20:03:07)
-- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  29154 bytes, from 2015-08-10 21:25:43)
+- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  41472 bytes, from 2016-01-22 18:18:18)
 - /home/robclark/src/freedreno/envytools/rnndb/edp/edp.xml             (  10416 bytes, from 2015-05-20 20:03:14)
 
 Copyright (C) 2013-2015 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
index 909d742..e233acf 100644 (file)
@@ -147,13 +147,6 @@ static void mdp4_crtc_destroy(struct drm_crtc *crtc)
        kfree(mdp4_crtc);
 }
 
-static bool mdp4_crtc_mode_fixup(struct drm_crtc *crtc,
-               const struct drm_display_mode *mode,
-               struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 /* statically (for now) map planes to mixer stage (z-order): */
 static const int idxs[] = {
                [VG1]  = 1,
@@ -361,13 +354,6 @@ static void mdp4_crtc_atomic_flush(struct drm_crtc *crtc,
        request_pending(crtc, PENDING_FLIP);
 }
 
-static int mdp4_crtc_set_property(struct drm_crtc *crtc,
-               struct drm_property *property, uint64_t val)
-{
-       // XXX
-       return -EINVAL;
-}
-
 #define CURSOR_WIDTH 64
 #define CURSOR_HEIGHT 64
 
@@ -499,7 +485,7 @@ static const struct drm_crtc_funcs mdp4_crtc_funcs = {
        .set_config = drm_atomic_helper_set_config,
        .destroy = mdp4_crtc_destroy,
        .page_flip = drm_atomic_helper_page_flip,
-       .set_property = mdp4_crtc_set_property,
+       .set_property = drm_atomic_helper_crtc_set_property,
        .cursor_set = mdp4_crtc_cursor_set,
        .cursor_move = mdp4_crtc_cursor_move,
        .reset = drm_atomic_helper_crtc_reset,
@@ -508,7 +494,6 @@ static const struct drm_crtc_funcs mdp4_crtc_funcs = {
 };
 
 static const struct drm_crtc_helper_funcs mdp4_crtc_helper_funcs = {
-       .mode_fixup = mdp4_crtc_mode_fixup,
        .mode_set_nofb = mdp4_crtc_mode_set_nofb,
        .disable = mdp4_crtc_disable,
        .enable = mdp4_crtc_enable,
index 1c8e330..76e1dfb 100644 (file)
@@ -179,9 +179,20 @@ static long mdp4_round_pixclk(struct msm_kms *kms, unsigned long rate,
        }
 }
 
+static const char * const iommu_ports[] = {
+       "mdp_port0_cb0", "mdp_port1_cb0",
+};
+
 static void mdp4_destroy(struct msm_kms *kms)
 {
        struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
+       struct msm_mmu *mmu = mdp4_kms->mmu;
+
+       if (mmu) {
+               mmu->funcs->detach(mmu, iommu_ports, ARRAY_SIZE(iommu_ports));
+               mmu->funcs->destroy(mmu);
+       }
+
        if (mdp4_kms->blank_cursor_iova)
                msm_gem_put_iova(mdp4_kms->blank_cursor_bo, mdp4_kms->id);
        if (mdp4_kms->blank_cursor_bo)
@@ -315,7 +326,7 @@ static int mdp4_modeset_init_intf(struct mdp4_kms *mdp4_kms,
 
                if (priv->hdmi) {
                        /* Construct bridge/connector for HDMI: */
-                       ret = hdmi_modeset_init(priv->hdmi, dev, encoder);
+                       ret = msm_hdmi_modeset_init(priv->hdmi, dev, encoder);
                        if (ret) {
                                dev_err(dev->dev, "failed to initialize HDMI: %d\n", ret);
                                return ret;
@@ -446,10 +457,6 @@ fail:
        return ret;
 }
 
-static const char *iommu_ports[] = {
-               "mdp_port0_cb0", "mdp_port1_cb0",
-};
-
 struct msm_kms *mdp4_kms_init(struct drm_device *dev)
 {
        struct platform_device *pdev = dev->platformdev;
@@ -554,6 +561,8 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev)
                                ARRAY_SIZE(iommu_ports));
                if (ret)
                        goto fail;
+
+               mdp4_kms->mmu = mmu;
        } else {
                dev_info(dev->dev, "no iommu, fallback to phys "
                                "contig buffers for scanout\n");
index 9ec53b4..b282871 100644 (file)
@@ -45,6 +45,7 @@ struct mdp4_kms {
        struct clk *pclk;
        struct clk *lut_clk;
        struct clk *axi_clk;
+       struct msm_mmu *mmu;
 
        struct mdp_irq error_handler;
 
index c37da9c..b275ce1 100644 (file)
@@ -9,7 +9,7 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/msm.xml                 (    676 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp4.xml            (  20915 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp_common.xml      (   2849 bytes, from 2015-09-18 12:07:28)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp5.xml            (  37194 bytes, from 2015-09-18 12:07:28)
@@ -17,11 +17,12 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/sfpb.xml            (    602 bytes, from 2015-10-22 16:35:02)
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/mmss_cc.xml         (   1686 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/hdmi/qfprom.xml         (    600 bytes, from 2015-05-20 20:03:07)
-- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  29154 bytes, from 2015-08-10 21:25:43)
+- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  41472 bytes, from 2016-01-22 18:18:18)
 - /home/robclark/src/freedreno/envytools/rnndb/edp/edp.xml             (  10416 bytes, from 2015-05-20 20:03:14)
 
 Copyright (C) 2013-2015 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
index 46682aa..9673b95 100644 (file)
@@ -185,13 +185,6 @@ static void mdp5_crtc_destroy(struct drm_crtc *crtc)
        kfree(mdp5_crtc);
 }
 
-static bool mdp5_crtc_mode_fixup(struct drm_crtc *crtc,
-               const struct drm_display_mode *mode,
-               struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 /*
  * blend_setup() - blend all the planes of a CRTC
  *
@@ -468,13 +461,6 @@ static void mdp5_crtc_atomic_flush(struct drm_crtc *crtc,
        request_pending(crtc, PENDING_FLIP);
 }
 
-static int mdp5_crtc_set_property(struct drm_crtc *crtc,
-               struct drm_property *property, uint64_t val)
-{
-       // XXX
-       return -EINVAL;
-}
-
 static void get_roi(struct drm_crtc *crtc, uint32_t *roi_w, uint32_t *roi_h)
 {
        struct mdp5_crtc *mdp5_crtc = to_mdp5_crtc(crtc);
@@ -625,7 +611,7 @@ static const struct drm_crtc_funcs mdp5_crtc_funcs = {
        .set_config = drm_atomic_helper_set_config,
        .destroy = mdp5_crtc_destroy,
        .page_flip = drm_atomic_helper_page_flip,
-       .set_property = mdp5_crtc_set_property,
+       .set_property = drm_atomic_helper_crtc_set_property,
        .reset = drm_atomic_helper_crtc_reset,
        .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
@@ -634,7 +620,6 @@ static const struct drm_crtc_funcs mdp5_crtc_funcs = {
 };
 
 static const struct drm_crtc_helper_funcs mdp5_crtc_helper_funcs = {
-       .mode_fixup = mdp5_crtc_mode_fixup,
        .mode_set_nofb = mdp5_crtc_mode_set_nofb,
        .disable = mdp5_crtc_disable,
        .enable = mdp5_crtc_enable,
index 5e4d16b..484b4d1 100644 (file)
@@ -284,7 +284,7 @@ static int modeset_init_intf(struct mdp5_kms *mdp5_kms, int intf_num)
                        break;
                }
 
-               ret = hdmi_modeset_init(priv->hdmi, dev, encoder);
+               ret = msm_hdmi_modeset_init(priv->hdmi, dev, encoder);
                break;
        case INTF_DSI:
        {
index 0aec1ac..452e351 100644 (file)
@@ -9,7 +9,7 @@ git clone https://github.com/freedreno/envytools.git
 
 The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/msm.xml                 (    676 bytes, from 2015-05-20 20:03:14)
-- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1453 bytes, from 2015-05-20 20:03:07)
+- /home/robclark/src/freedreno/envytools/rnndb/freedreno_copyright.xml (   1572 bytes, from 2016-02-10 17:07:21)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp4.xml            (  20915 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp_common.xml      (   2849 bytes, from 2015-09-18 12:07:28)
 - /home/robclark/src/freedreno/envytools/rnndb/mdp/mdp5.xml            (  37194 bytes, from 2015-09-18 12:07:28)
@@ -17,11 +17,12 @@ The rules-ng-ng source files this header was generated from are:
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/sfpb.xml            (    602 bytes, from 2015-10-22 16:35:02)
 - /home/robclark/src/freedreno/envytools/rnndb/dsi/mmss_cc.xml         (   1686 bytes, from 2015-05-20 20:03:14)
 - /home/robclark/src/freedreno/envytools/rnndb/hdmi/qfprom.xml         (    600 bytes, from 2015-05-20 20:03:07)
-- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  29154 bytes, from 2015-08-10 21:25:43)
+- /home/robclark/src/freedreno/envytools/rnndb/hdmi/hdmi.xml           (  41472 bytes, from 2016-01-22 18:18:18)
 - /home/robclark/src/freedreno/envytools/rnndb/edp/edp.xml             (  10416 bytes, from 2015-05-20 20:03:14)
 
 Copyright (C) 2013-2015 by the following authors:
 - Rob Clark <robdclark@gmail.com> (robclark)
+- Ilia Mirkin <imirkin@alum.mit.edu> (imirkin)
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
index 9a30807..d52910e 100644 (file)
@@ -61,7 +61,7 @@ module_param(fbdev, bool, 0600);
 #endif
 
 static char *vram = "16m";
-MODULE_PARM_DESC(vram, "Configure VRAM size (for devices without IOMMU/GPUMMU");
+MODULE_PARM_DESC(vram, "Configure VRAM size (for devices without IOMMU/GPUMMU)");
 module_param(vram, charp, 0);
 
 /*
@@ -196,6 +196,11 @@ static int msm_unload(struct drm_device *dev)
        }
 
        drm_kms_helper_poll_fini(dev);
+
+#ifdef CONFIG_DRM_FBDEV_EMULATION
+       if (fbdev && priv->fbdev)
+               msm_fbdev_free(dev);
+#endif
        drm_mode_config_cleanup(dev);
        drm_vblank_cleanup(dev);
 
@@ -1116,7 +1121,7 @@ static int __init msm_drm_register(void)
        DBG("init");
        msm_dsi_register();
        msm_edp_register();
-       hdmi_register();
+       msm_hdmi_register();
        adreno_register();
        return platform_driver_register(&msm_platform_driver);
 }
@@ -1125,7 +1130,7 @@ static void __exit msm_drm_unregister(void)
 {
        DBG("fini");
        platform_driver_unregister(&msm_platform_driver);
-       hdmi_unregister();
+       msm_hdmi_unregister();
        adreno_unregister();
        msm_edp_unregister();
        msm_dsi_unregister();
index c1e7bba..870dbe5 100644 (file)
@@ -240,12 +240,13 @@ struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev,
                struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd);
 
 struct drm_fb_helper *msm_fbdev_init(struct drm_device *dev);
+void msm_fbdev_free(struct drm_device *dev);
 
 struct hdmi;
-int hdmi_modeset_init(struct hdmi *hdmi, struct drm_device *dev,
+int msm_hdmi_modeset_init(struct hdmi *hdmi, struct drm_device *dev,
                struct drm_encoder *encoder);
-void __init hdmi_register(void);
-void __exit hdmi_unregister(void);
+void __init msm_hdmi_register(void);
+void __exit msm_hdmi_unregister(void);
 
 struct msm_edp;
 void __init msm_edp_register(void);
index 6d7cd3f..43d2181 100644 (file)
@@ -323,28 +323,27 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
        struct drm_msm_gem_submit *args = data;
        struct msm_file_private *ctx = file->driver_priv;
        struct msm_gem_submit *submit;
-       struct msm_gpu *gpu;
+       struct msm_gpu *gpu = priv->gpu;
        unsigned i;
        int ret;
 
+       if (!gpu)
+               return -ENXIO;
+
        /* for now, we just have 3d pipe.. eventually this would need to
         * be more clever to dispatch to appropriate gpu module:
         */
        if (args->pipe != MSM_PIPE_3D0)
                return -EINVAL;
 
-       gpu = priv->gpu;
-
        if (args->nr_cmds > MAX_CMDS)
                return -EINVAL;
 
-       mutex_lock(&dev->struct_mutex);
-
        submit = submit_create(dev, gpu, args->nr_bos);
-       if (!submit) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (!submit)
+               return -ENOMEM;
+
+       mutex_lock(&dev->struct_mutex);
 
        ret = submit_lookup_objects(submit, args, file);
        if (ret)
@@ -419,8 +418,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
        args->fence = submit->fence;
 
 out:
-       if (submit)
-               submit_cleanup(submit, !!ret);
+       submit_cleanup(submit, !!ret);
        mutex_unlock(&dev->struct_mutex);
        return ret;
 }
index 7ac2f19..a7a0b6d 100644 (file)
@@ -31,13 +31,15 @@ static int msm_fault_handler(struct iommu_domain *iommu, struct device *dev,
        return 0;
 }
 
-static int msm_iommu_attach(struct msm_mmu *mmu, const char **names, int cnt)
+static int msm_iommu_attach(struct msm_mmu *mmu, const char * const *names,
+                           int cnt)
 {
        struct msm_iommu *iommu = to_msm_iommu(mmu);
        return iommu_attach_device(iommu->domain, mmu->dev);
 }
 
-static void msm_iommu_detach(struct msm_mmu *mmu, const char **names, int cnt)
+static void msm_iommu_detach(struct msm_mmu *mmu, const char * const *names,
+                            int cnt)
 {
        struct msm_iommu *iommu = to_msm_iommu(mmu);
        iommu_detach_device(iommu->domain, mmu->dev);
index 7cd88d9..b8ca9a0 100644 (file)
@@ -21,8 +21,8 @@
 #include <linux/iommu.h>
 
 struct msm_mmu_funcs {
-       int (*attach)(struct msm_mmu *mmu, const char **names, int cnt);
-       void (*detach)(struct msm_mmu *mmu, const char **names, int cnt);
+       int (*attach)(struct msm_mmu *mmu, const char * const *names, int cnt);
+       void (*detach)(struct msm_mmu *mmu, const char * const *names, int cnt);
        int (*map)(struct msm_mmu *mmu, uint32_t iova, struct sg_table *sgt,
                        unsigned len, int prot);
        int (*unmap)(struct msm_mmu *mmu, uint32_t iova, struct sg_table *sgt,
index 6f04397..55ccbf0 100644 (file)
@@ -227,13 +227,6 @@ nv_crtc_dpms(struct drm_crtc *crtc, int mode)
        NVWriteVgaCrtc(dev, nv_crtc->index, NV_CIO_CRE_RPC1_INDEX, crtc1A);
 }
 
-static bool
-nv_crtc_mode_fixup(struct drm_crtc *crtc, const struct drm_display_mode *mode,
-                  struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 static void
 nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode)
 {
@@ -1093,7 +1086,6 @@ static const struct drm_crtc_helper_funcs nv04_crtc_helper_funcs = {
        .dpms = nv_crtc_dpms,
        .prepare = nv_crtc_prepare,
        .commit = nv_crtc_commit,
-       .mode_fixup = nv_crtc_mode_fixup,
        .mode_set = nv_crtc_mode_set,
        .mode_set_base = nv04_crtc_mode_set_base,
        .mode_set_base_atomic = nv04_crtc_mode_set_base_atomic,
index 85b7827..46301ec 100644 (file)
@@ -3,19 +3,27 @@
 
 struct kepler_channel_gpfifo_a_v0 {
        __u8  version;
-#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_GR                               0x01
-#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_MSPDEC                           0x02
-#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_MSPPP                            0x04
-#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_MSVLD                            0x08
-#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE0                              0x10
-#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE1                              0x20
-#define KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_ENC                              0x40
-       __u8  engine;
+       __u8  pad01[5];
        __u16 chid;
+#define NVA06F_V0_ENGINE_SW                                          0x00000001
+#define NVA06F_V0_ENGINE_GR                                          0x00000002
+#define NVA06F_V0_ENGINE_SEC                                         0x00000004
+#define NVA06F_V0_ENGINE_MSVLD                                       0x00000010
+#define NVA06F_V0_ENGINE_MSPDEC                                      0x00000020
+#define NVA06F_V0_ENGINE_MSPPP                                       0x00000040
+#define NVA06F_V0_ENGINE_MSENC                                       0x00000080
+#define NVA06F_V0_ENGINE_VIC                                         0x00000100
+#define NVA06F_V0_ENGINE_NVDEC                                       0x00000200
+#define NVA06F_V0_ENGINE_NVENC0                                      0x00000400
+#define NVA06F_V0_ENGINE_NVENC1                                      0x00000800
+#define NVA06F_V0_ENGINE_CE0                                         0x00010000
+#define NVA06F_V0_ENGINE_CE1                                         0x00020000
+#define NVA06F_V0_ENGINE_CE2                                         0x00040000
+       __u32 engines;
        __u32 ilength;
        __u64 ioffset;
        __u64 vm;
 };
 
-#define KEPLER_CHANNEL_GPFIFO_A_V0_NTFY_UEVENT                             0x00
+#define NVA06F_V0_NTFY_UEVENT                                              0x00
 #endif
index 4179cd6..982aad8 100644 (file)
@@ -37,6 +37,7 @@
 #define G82_CHANNEL_GPFIFO                            /* cl826f.h */ 0x0000826f
 #define FERMI_CHANNEL_GPFIFO                          /* cl906f.h */ 0x0000906f
 #define KEPLER_CHANNEL_GPFIFO_A                       /* cla06f.h */ 0x0000a06f
+#define KEPLER_CHANNEL_GPFIFO_B                       /* cla06f.h */ 0x0000a16f
 #define MAXWELL_CHANNEL_GPFIFO_A                      /* cla06f.h */ 0x0000b06f
 
 #define NV50_DISP                                     /* cl5070.h */ 0x00005070
@@ -48,7 +49,7 @@
 #define GK104_DISP                                    /* cl5070.h */ 0x00009170
 #define GK110_DISP                                    /* cl5070.h */ 0x00009270
 #define GM107_DISP                                    /* cl5070.h */ 0x00009470
-#define GM204_DISP                                    /* cl5070.h */ 0x00009570
+#define GM200_DISP                                    /* cl5070.h */ 0x00009570
 
 #define NV31_MPEG                                                    0x00003174
 #define G82_MPEG                                                     0x00008274
@@ -84,7 +85,7 @@
 #define GK104_DISP_CORE_CHANNEL_DMA                   /* cl507d.h */ 0x0000917d
 #define GK110_DISP_CORE_CHANNEL_DMA                   /* cl507d.h */ 0x0000927d
 #define GM107_DISP_CORE_CHANNEL_DMA                   /* cl507d.h */ 0x0000947d
-#define GM204_DISP_CORE_CHANNEL_DMA                   /* cl507d.h */ 0x0000957d
+#define GM200_DISP_CORE_CHANNEL_DMA                   /* cl507d.h */ 0x0000957d
 
 #define NV50_DISP_OVERLAY_CHANNEL_DMA                 /* cl507e.h */ 0x0000507e
 #define G82_DISP_OVERLAY_CHANNEL_DMA                  /* cl507e.h */ 0x0000827e
index e0ed2f4..bcb9817 100644 (file)
@@ -62,6 +62,7 @@ u64  nvif_device_time(struct nvif_device *);
 #define nvxx_gpio(a) nvxx_device(a)->gpio
 #define nvxx_clk(a) nvxx_device(a)->clk
 #define nvxx_i2c(a) nvxx_device(a)->i2c
+#define nvxx_iccsense(a) nvxx_device(a)->iccsense
 #define nvxx_therm(a) nvxx_device(a)->therm
 #define nvxx_volt(a) nvxx_device(a)->volt
 
index 913192c..4993a86 100644 (file)
@@ -22,30 +22,41 @@ enum nvkm_devidx {
        NVKM_SUBDEV_BAR,
        NVKM_SUBDEV_PMU,
        NVKM_SUBDEV_VOLT,
+       NVKM_SUBDEV_ICCSENSE,
        NVKM_SUBDEV_THERM,
        NVKM_SUBDEV_CLK,
+       NVKM_SUBDEV_SECBOOT,
 
-       NVKM_ENGINE_DMAOBJ,
-       NVKM_ENGINE_IFB,
-       NVKM_ENGINE_FIFO,
-       NVKM_ENGINE_SW,
-       NVKM_ENGINE_GR,
-       NVKM_ENGINE_MPEG,
-       NVKM_ENGINE_ME,
-       NVKM_ENGINE_VP,
-       NVKM_ENGINE_CIPHER,
        NVKM_ENGINE_BSP,
-       NVKM_ENGINE_MSPPP,
+
        NVKM_ENGINE_CE0,
        NVKM_ENGINE_CE1,
        NVKM_ENGINE_CE2,
-       NVKM_ENGINE_VIC,
-       NVKM_ENGINE_MSENC,
+       NVKM_ENGINE_CE_LAST = NVKM_ENGINE_CE2,
+
+       NVKM_ENGINE_CIPHER,
        NVKM_ENGINE_DISP,
-       NVKM_ENGINE_PM,
+       NVKM_ENGINE_DMAOBJ,
+       NVKM_ENGINE_FIFO,
+       NVKM_ENGINE_GR,
+       NVKM_ENGINE_IFB,
+       NVKM_ENGINE_ME,
+       NVKM_ENGINE_MPEG,
+       NVKM_ENGINE_MSENC,
+       NVKM_ENGINE_MSPDEC,
+       NVKM_ENGINE_MSPPP,
        NVKM_ENGINE_MSVLD,
+
+       NVKM_ENGINE_NVENC0,
+       NVKM_ENGINE_NVENC1,
+       NVKM_ENGINE_NVENC_LAST = NVKM_ENGINE_NVENC1,
+
+       NVKM_ENGINE_NVDEC,
+       NVKM_ENGINE_PM,
        NVKM_ENGINE_SEC,
-       NVKM_ENGINE_MSPDEC,
+       NVKM_ENGINE_SW,
+       NVKM_ENGINE_VIC,
+       NVKM_ENGINE_VP,
 
        NVKM_SUBDEV_NR
 };
@@ -109,6 +120,7 @@ struct nvkm_device {
        struct nvkm_gpio *gpio;
        struct nvkm_i2c *i2c;
        struct nvkm_subdev *ibus;
+       struct nvkm_iccsense *iccsense;
        struct nvkm_instmem *imem;
        struct nvkm_ltc *ltc;
        struct nvkm_mc *mc;
@@ -116,6 +128,7 @@ struct nvkm_device {
        struct nvkm_subdev *mxm;
        struct nvkm_pci *pci;
        struct nvkm_pmu *pmu;
+       struct nvkm_secboot *secboot;
        struct nvkm_therm *therm;
        struct nvkm_timer *timer;
        struct nvkm_volt *volt;
@@ -134,6 +147,8 @@ struct nvkm_device {
        struct nvkm_engine *mspdec;
        struct nvkm_engine *msppp;
        struct nvkm_engine *msvld;
+       struct nvkm_engine *nvenc[2];
+       struct nvkm_engine *nvdec;
        struct nvkm_pm *pm;
        struct nvkm_engine *sec;
        struct nvkm_sw *sw;
@@ -164,46 +179,50 @@ struct nvkm_device_quirk {
 struct nvkm_device_chip {
        const char *name;
 
-       int (*bar    )(struct nvkm_device *, int idx, struct nvkm_bar **);
-       int (*bios   )(struct nvkm_device *, int idx, struct nvkm_bios **);
-       int (*bus    )(struct nvkm_device *, int idx, struct nvkm_bus **);
-       int (*clk    )(struct nvkm_device *, int idx, struct nvkm_clk **);
-       int (*devinit)(struct nvkm_device *, int idx, struct nvkm_devinit **);
-       int (*fb     )(struct nvkm_device *, int idx, struct nvkm_fb **);
-       int (*fuse   )(struct nvkm_device *, int idx, struct nvkm_fuse **);
-       int (*gpio   )(struct nvkm_device *, int idx, struct nvkm_gpio **);
-       int (*i2c    )(struct nvkm_device *, int idx, struct nvkm_i2c **);
-       int (*ibus   )(struct nvkm_device *, int idx, struct nvkm_subdev **);
-       int (*imem   )(struct nvkm_device *, int idx, struct nvkm_instmem **);
-       int (*ltc    )(struct nvkm_device *, int idx, struct nvkm_ltc **);
-       int (*mc     )(struct nvkm_device *, int idx, struct nvkm_mc **);
-       int (*mmu    )(struct nvkm_device *, int idx, struct nvkm_mmu **);
-       int (*mxm    )(struct nvkm_device *, int idx, struct nvkm_subdev **);
-       int (*pci    )(struct nvkm_device *, int idx, struct nvkm_pci **);
-       int (*pmu    )(struct nvkm_device *, int idx, struct nvkm_pmu **);
-       int (*therm  )(struct nvkm_device *, int idx, struct nvkm_therm **);
-       int (*timer  )(struct nvkm_device *, int idx, struct nvkm_timer **);
-       int (*volt   )(struct nvkm_device *, int idx, struct nvkm_volt **);
-
-       int (*bsp    )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*ce[3]  )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*cipher )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*disp   )(struct nvkm_device *, int idx, struct nvkm_disp **);
-       int (*dma    )(struct nvkm_device *, int idx, struct nvkm_dma **);
-       int (*fifo   )(struct nvkm_device *, int idx, struct nvkm_fifo **);
-       int (*gr     )(struct nvkm_device *, int idx, struct nvkm_gr **);
-       int (*ifb    )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*me     )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*mpeg   )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*msenc  )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*mspdec )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*msppp  )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*msvld  )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*pm     )(struct nvkm_device *, int idx, struct nvkm_pm **);
-       int (*sec    )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*sw     )(struct nvkm_device *, int idx, struct nvkm_sw **);
-       int (*vic    )(struct nvkm_device *, int idx, struct nvkm_engine **);
-       int (*vp     )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*bar     )(struct nvkm_device *, int idx, struct nvkm_bar **);
+       int (*bios    )(struct nvkm_device *, int idx, struct nvkm_bios **);
+       int (*bus     )(struct nvkm_device *, int idx, struct nvkm_bus **);
+       int (*clk     )(struct nvkm_device *, int idx, struct nvkm_clk **);
+       int (*devinit )(struct nvkm_device *, int idx, struct nvkm_devinit **);
+       int (*fb      )(struct nvkm_device *, int idx, struct nvkm_fb **);
+       int (*fuse    )(struct nvkm_device *, int idx, struct nvkm_fuse **);
+       int (*gpio    )(struct nvkm_device *, int idx, struct nvkm_gpio **);
+       int (*i2c     )(struct nvkm_device *, int idx, struct nvkm_i2c **);
+       int (*ibus    )(struct nvkm_device *, int idx, struct nvkm_subdev **);
+       int (*iccsense)(struct nvkm_device *, int idx, struct nvkm_iccsense **);
+       int (*imem    )(struct nvkm_device *, int idx, struct nvkm_instmem **);
+       int (*ltc     )(struct nvkm_device *, int idx, struct nvkm_ltc **);
+       int (*mc      )(struct nvkm_device *, int idx, struct nvkm_mc **);
+       int (*mmu     )(struct nvkm_device *, int idx, struct nvkm_mmu **);
+       int (*mxm     )(struct nvkm_device *, int idx, struct nvkm_subdev **);
+       int (*pci     )(struct nvkm_device *, int idx, struct nvkm_pci **);
+       int (*pmu     )(struct nvkm_device *, int idx, struct nvkm_pmu **);
+       int (*secboot )(struct nvkm_device *, int idx, struct nvkm_secboot **);
+       int (*therm   )(struct nvkm_device *, int idx, struct nvkm_therm **);
+       int (*timer   )(struct nvkm_device *, int idx, struct nvkm_timer **);
+       int (*volt    )(struct nvkm_device *, int idx, struct nvkm_volt **);
+
+       int (*bsp     )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*ce[3]   )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*cipher  )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*disp    )(struct nvkm_device *, int idx, struct nvkm_disp **);
+       int (*dma     )(struct nvkm_device *, int idx, struct nvkm_dma **);
+       int (*fifo    )(struct nvkm_device *, int idx, struct nvkm_fifo **);
+       int (*gr      )(struct nvkm_device *, int idx, struct nvkm_gr **);
+       int (*ifb     )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*me      )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*mpeg    )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*msenc   )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*mspdec  )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*msppp   )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*msvld   )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*nvenc[2])(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*nvdec   )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*pm      )(struct nvkm_device *, int idx, struct nvkm_pm **);
+       int (*sec     )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*sw      )(struct nvkm_device *, int idx, struct nvkm_sw **);
+       int (*vic     )(struct nvkm_device *, int idx, struct nvkm_engine **);
+       int (*vp      )(struct nvkm_device *, int idx, struct nvkm_engine **);
 };
 
 struct nvkm_device *nvkm_device_find(u64 name);
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/firmware.h b/drivers/gpu/drm/nouveau/include/nvkm/core/firmware.h
new file mode 100644 (file)
index 0000000..a626ce3
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef __NVKM_FIRMWARE_H__
+#define __NVKM_FIRMWARE_H__
+
+#include <core/device.h>
+
+int nvkm_firmware_get(struct nvkm_device *device, const char *fwname,
+                     const struct firmware **fw);
+
+void nvkm_firmware_put(const struct firmware *fw);
+
+#endif
index d4f56ea..c23da4f 100644 (file)
@@ -37,4 +37,8 @@ int nvkm_gpuobj_wrap(struct nvkm_memory *, struct nvkm_gpuobj **);
 int nvkm_gpuobj_map(struct nvkm_gpuobj *, struct nvkm_vm *, u32 access,
                    struct nvkm_vma *);
 void nvkm_gpuobj_unmap(struct nvkm_vma *);
+void nvkm_gpuobj_memcpy_to(struct nvkm_gpuobj *dst, u32 dstoffset, void *src,
+                          u32 length);
+void nvkm_gpuobj_memcpy_from(void *dst, struct nvkm_gpuobj *src, u32 srcoffset,
+                            u32 length);
 #endif
index e2e22cd..594d719 100644 (file)
@@ -5,5 +5,6 @@
 int gt215_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
 int gf100_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
 int gk104_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
-int gm204_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
+int gm107_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
+int gm200_ce_new(struct nvkm_device *, int, struct nvkm_engine **);
 #endif
index efc74d0..d4fdce2 100644 (file)
@@ -31,5 +31,5 @@ int gf119_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
 int gk104_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
 int gk110_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
 int gm107_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
-int gm204_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
+int gm200_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
 #endif
index 9e66449..15ddfcf 100644 (file)
@@ -60,8 +60,10 @@ int nv50_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
 int g84_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
 int gf100_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
 int gk104_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
+int gk110_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
 int gk208_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
 int gk20a_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
-int gm204_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
+int gm107_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
+int gm200_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
 int gm20b_fifo_new(struct nvkm_device *, int, struct nvkm_fifo **);
 #endif
index f126e54..6515f58 100644 (file)
@@ -40,7 +40,6 @@ int gk110b_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
 int gk208_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
 int gk20a_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
 int gm107_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
-int gm204_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
-int gm206_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
+int gm200_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
 int gm20b_gr_new(struct nvkm_device *, int, struct nvkm_gr **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/msenc.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/msenc.h
new file mode 100644 (file)
index 0000000..748ea9b
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef __NVKM_MSENC_H__
+#define __NVKM_MSENC_H__
+#include <core/engine.h>
+#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/nvdec.h
new file mode 100644 (file)
index 0000000..30b76d1
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef __NVKM_NVDEC_H__
+#define __NVKM_NVDEC_H__
+#include <core/engine.h>
+#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/nvenc.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/nvenc.h
new file mode 100644 (file)
index 0000000..8a81932
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef __NVKM_NVENC_H__
+#define __NVKM_NVENC_H__
+#include <core/engine.h>
+#endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/engine/vic.h b/drivers/gpu/drm/nouveau/include/nvkm/engine/vic.h
new file mode 100644 (file)
index 0000000..2b0dc4c
--- /dev/null
@@ -0,0 +1,4 @@
+#ifndef __NVKM_VIC_H__
+#define __NVKM_VIC_H__
+#include <core/engine.h>
+#endif
index 6d3bedc..bb49bd5 100644 (file)
@@ -5,6 +5,9 @@ enum nvbios_extdev_type {
        NVBIOS_EXTDEV_VT1103M           = 0x40,
        NVBIOS_EXTDEV_PX3540            = 0x41,
        NVBIOS_EXTDEV_VT1105M           = 0x42, /* or close enough... */
+       NVBIOS_EXTDEV_INA219            = 0x4c,
+       NVBIOS_EXTDEV_INA209            = 0x4d,
+       NVBIOS_EXTDEV_INA3221           = 0x4e,
        NVBIOS_EXTDEV_ADT7473           = 0x70, /* can also be a LM64 */
        NVBIOS_EXTDEV_HDCP_EEPROM       = 0x90,
        NVBIOS_EXTDEV_NONE              = 0xff,
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/iccsense.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/iccsense.h
new file mode 100644 (file)
index 0000000..9cb9747
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __NVBIOS_ICCSENSE_H__
+#define __NVBIOS_ICCSENSE_H__
+struct pwr_rail_t {
+       u8 mode;
+       u8 extdev_id;
+       u8 resistor_mohm;
+       u8 rail;
+};
+
+struct nvbios_iccsense {
+       int nr_entry;
+       struct pwr_rail_t *rail;
+};
+
+int nvbios_iccsense_parse(struct nvkm_bios *, struct nvbios_iccsense *);
+#endif
index 6b33bc0..fb54417 100644 (file)
@@ -121,4 +121,5 @@ int gt215_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
 int gf100_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
 int gk104_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
 int gk20a_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
+int gm20b_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
 #endif
index 6c1407f..193626c 100644 (file)
@@ -27,5 +27,5 @@ int gt215_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
 int mcp89_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
 int gf100_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
 int gm107_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
-int gm204_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
+int gm200_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
 #endif
index 6b6224d..a63c5ac 100644 (file)
@@ -89,7 +89,7 @@ int g94_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
 int gf117_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
 int gf119_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
 int gk104_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
-int gm204_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
+int gm200_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
 
 static inline int
 nvkm_rdi2cr(struct i2c_adapter *adap, u8 addr, u8 reg)
@@ -108,6 +108,22 @@ nvkm_rdi2cr(struct i2c_adapter *adap, u8 addr, u8 reg)
 }
 
 static inline int
+nv_rd16i2cr(struct i2c_adapter *adap, u8 addr, u8 reg)
+{
+       u8 val[2];
+       struct i2c_msg msgs[] = {
+               { .addr = addr, .flags = 0, .len = 1, .buf = &reg },
+               { .addr = addr, .flags = I2C_M_RD, .len = 2, .buf = val },
+       };
+
+       int ret = i2c_transfer(adap, msgs, ARRAY_SIZE(msgs));
+       if (ret != 2)
+               return -EIO;
+
+       return val[0] << 8 | val[1];
+}
+
+static inline int
 nvkm_wri2cr(struct i2c_adapter *adap, u8 addr, u8 reg, u8 val)
 {
        u8 buf[2] = { reg, val };
@@ -122,6 +138,21 @@ nvkm_wri2cr(struct i2c_adapter *adap, u8 addr, u8 reg, u8 val)
        return 0;
 }
 
+static inline int
+nv_wr16i2cr(struct i2c_adapter *adap, u8 addr, u8 reg, u16 val)
+{
+       u8 buf[3] = { reg, val >> 8, val & 0xff};
+       struct i2c_msg msgs[] = {
+               { .addr = addr, .flags = 0, .len = 3, .buf = buf },
+       };
+
+       int ret = i2c_transfer(adap, msgs, ARRAY_SIZE(msgs));
+       if (ret != 1)
+               return -EIO;
+
+       return 0;
+}
+
 static inline bool
 nvkm_probe_i2c(struct i2c_adapter *adap, u8 addr)
 {
index ea23e24..c4ecf25 100644 (file)
@@ -6,5 +6,5 @@ int gf100_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
 int gf117_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
 int gk104_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
 int gk20a_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
-int gm204_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
+int gm200_ibus_new(struct nvkm_device *, int, struct nvkm_subdev **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/iccsense.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/iccsense.h
new file mode 100644 (file)
index 0000000..530c621
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef __NVKM_ICCSENSE_H__
+#define __NVKM_ICCSENSE_H__
+
+#include <core/subdev.h>
+
+struct nkvm_iccsense_rail;
+struct nvkm_iccsense {
+       struct nvkm_subdev subdev;
+       u8 rail_count;
+       bool data_valid;
+       struct nvkm_iccsense_rail *rails;
+};
+
+int gf100_iccsense_new(struct nvkm_device *, int index, struct nvkm_iccsense **);
+int nvkm_iccsense_read(struct nvkm_iccsense *iccsense, u8 idx);
+int nvkm_iccsense_read_all(struct nvkm_iccsense *iccsense);
+#endif
index 0ffa2ec..c6b90b6 100644 (file)
@@ -37,5 +37,5 @@ int gf100_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
 int gk104_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
 int gk20a_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
 int gm107_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
-int gm204_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
+int gm200_ltc_new(struct nvkm_device *, int, struct nvkm_ltc **);
 #endif
diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/secboot.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/secboot.h
new file mode 100644 (file)
index 0000000..c6edd95
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __NVKM_SECURE_BOOT_H__
+#define __NVKM_SECURE_BOOT_H__
+
+#include <core/subdev.h>
+
+enum nvkm_secboot_falcon {
+       NVKM_SECBOOT_FALCON_PMU = 0,
+       NVKM_SECBOOT_FALCON_RESERVED = 1,
+       NVKM_SECBOOT_FALCON_FECS = 2,
+       NVKM_SECBOOT_FALCON_GPCCS = 3,
+       NVKM_SECBOOT_FALCON_END = 4,
+       NVKM_SECBOOT_FALCON_INVALID = 0xffffffff,
+};
+
+/**
+ * @base:              base IO address of the falcon performing secure boot
+ * @irq_mask:          IRQ mask of the falcon performing secure boot
+ * @enable_mask:       enable mask of the falcon performing secure boot
+*/
+struct nvkm_secboot {
+       const struct nvkm_secboot_func *func;
+       struct nvkm_subdev subdev;
+
+       u32 base;
+       u32 irq_mask;
+       u32 enable_mask;
+};
+#define nvkm_secboot(p) container_of((p), struct nvkm_secboot, subdev)
+
+bool nvkm_secboot_is_managed(struct nvkm_secboot *, enum nvkm_secboot_falcon);
+int nvkm_secboot_reset(struct nvkm_secboot *, u32 falcon);
+int nvkm_secboot_start(struct nvkm_secboot *, u32 falcon);
+
+int gm200_secboot_new(struct nvkm_device *, int, struct nvkm_secboot **);
+int gm20b_secboot_new(struct nvkm_device *, int, struct nvkm_secboot **);
+
+#endif
index b458d04..feff55c 100644 (file)
@@ -20,4 +20,5 @@ int nvkm_volt_set_id(struct nvkm_volt *, u8 id, int condition);
 int nv40_volt_new(struct nvkm_device *, int, struct nvkm_volt **);
 int gk104_volt_new(struct nvkm_device *, int, struct nvkm_volt **);
 int gk20a_volt_new(struct nvkm_device *, int, struct nvkm_volt **);
+int gm20b_volt_new(struct nvkm_device *, int, struct nvkm_volt **);
 #endif
index 50f52ff..a59e524 100644 (file)
@@ -263,13 +263,23 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
        /* hack to allow channel engine type specification on kepler */
        if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
                if (init->fb_ctxdma_handle != ~0)
-                       init->fb_ctxdma_handle = KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_GR;
-               else
-                       init->fb_ctxdma_handle = init->tt_ctxdma_handle;
+                       init->fb_ctxdma_handle = NVA06F_V0_ENGINE_GR;
+               else {
+                       init->fb_ctxdma_handle = 0;
+#define _(A,B) if (init->tt_ctxdma_handle & (A)) init->fb_ctxdma_handle |= (B)
+                       _(0x01, NVA06F_V0_ENGINE_GR);
+                       _(0x02, NVA06F_V0_ENGINE_MSPDEC);
+                       _(0x04, NVA06F_V0_ENGINE_MSPPP);
+                       _(0x08, NVA06F_V0_ENGINE_MSVLD);
+                       _(0x10, NVA06F_V0_ENGINE_CE0);
+                       _(0x20, NVA06F_V0_ENGINE_CE1);
+                       _(0x40, NVA06F_V0_ENGINE_MSENC);
+#undef _
+               }
 
                /* allow flips to be executed if this is a graphics channel */
                init->tt_ctxdma_handle = 0;
-               if (init->fb_ctxdma_handle == KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_GR)
+               if (init->fb_ctxdma_handle == NVA06F_V0_ENGINE_GR)
                        init->tt_ctxdma_handle = 1;
        }
 
index 78f520d..2cdaea5 100644 (file)
@@ -1502,7 +1502,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
        }
 #endif
 
-#ifdef CONFIG_SWIOTLB
+#if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86)
        if (swiotlb_nr_tbl()) {
                return ttm_dma_populate((void *)ttm, dev->dev);
        }
@@ -1520,7 +1520,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
                                    DMA_BIDIRECTIONAL);
 
                if (dma_mapping_error(pdev, addr)) {
-                       while (--i) {
+                       while (i--) {
                                dma_unmap_page(pdev, ttm_dma->dma_address[i],
                                               PAGE_SIZE, DMA_BIDIRECTIONAL);
                                ttm_dma->dma_address[i] = 0;
@@ -1570,7 +1570,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)
        }
 #endif
 
-#ifdef CONFIG_SWIOTLB
+#if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86)
        if (swiotlb_nr_tbl()) {
                ttm_dma_unpopulate((void *)ttm, dev->dev);
                return;
index 3f804a8..879655c 100644 (file)
@@ -192,6 +192,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
                    u32 engine, struct nouveau_channel **pchan)
 {
        static const u16 oclasses[] = { MAXWELL_CHANNEL_GPFIFO_A,
+                                       KEPLER_CHANNEL_GPFIFO_B,
                                        KEPLER_CHANNEL_GPFIFO_A,
                                        FERMI_CHANNEL_GPFIFO,
                                        G82_CHANNEL_GPFIFO,
@@ -217,7 +218,7 @@ nouveau_channel_ind(struct nouveau_drm *drm, struct nvif_device *device,
        do {
                if (oclass[0] >= KEPLER_CHANNEL_GPFIFO_A) {
                        args.kepler.version = 0;
-                       args.kepler.engine  = engine;
+                       args.kepler.engines = engine;
                        args.kepler.ilength = 0x02000;
                        args.kepler.ioffset = 0x10000 + chan->push.vma.offset;
                        args.kepler.vm = 0;
index 24be27d..7ce7fa5 100644 (file)
@@ -495,7 +495,7 @@ nouveau_display_create(struct drm_device *dev)
 
        if (nouveau_modeset != 2 && drm->vbios.dcb.entries) {
                static const u16 oclass[] = {
-                       GM204_DISP,
+                       GM200_DISP,
                        GM107_DISP,
                        GK110_DISP,
                        GK104_DISP,
@@ -635,10 +635,6 @@ nouveau_display_resume(struct drm_device *dev, bool runtime)
                nv_crtc->lut.depth = 0;
        }
 
-       /* Make sure that drm and hw vblank irqs get resumed if needed. */
-       for (head = 0; head < dev->mode_config.num_crtc; head++)
-               drm_vblank_on(dev, head);
-
        /* This should ensure we don't hit a locking problem when someone
         * wakes us up via a connector.  We should never go into suspend
         * while the display is on anyways.
@@ -648,6 +644,10 @@ nouveau_display_resume(struct drm_device *dev, bool runtime)
 
        drm_helper_resume_force_mode(dev);
 
+       /* Make sure that drm and hw vblank irqs get resumed if needed. */
+       for (head = 0; head < dev->mode_config.num_crtc; head++)
+               drm_vblank_on(dev, head);
+
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
                struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
 
index bb8498c..d06877d 100644 (file)
@@ -198,6 +198,7 @@ nouveau_accel_init(struct nouveau_drm *drm)
                        break;
                case FERMI_CHANNEL_GPFIFO:
                case KEPLER_CHANNEL_GPFIFO_A:
+               case KEPLER_CHANNEL_GPFIFO_B:
                case MAXWELL_CHANNEL_GPFIFO_A:
                        ret = nvc0_fence_create(drm);
                        break;
@@ -215,13 +216,13 @@ nouveau_accel_init(struct nouveau_drm *drm)
 
        if (device->info.family >= NV_DEVICE_INFO_V0_KEPLER) {
                ret = nouveau_channel_new(drm, &drm->device,
-                                         KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE0|
-                                         KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_CE1,
+                                         NVA06F_V0_ENGINE_CE0 |
+                                         NVA06F_V0_ENGINE_CE1,
                                          0, &drm->cechan);
                if (ret)
                        NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
 
-               arg0 = KEPLER_CHANNEL_GPFIFO_A_V0_ENGINE_GR;
+               arg0 = NVA06F_V0_ENGINE_GR;
                arg1 = 1;
        } else
        if (device->info.chipset >= 0xa3 &&
@@ -375,7 +376,7 @@ nouveau_get_hdmi_dev(struct nouveau_drm *drm)
        struct pci_dev *pdev = drm->dev->pdev;
 
        if (!pdev) {
-               DRM_INFO("not a PCI device; no HDMI\n");
+               NV_DEBUG(drm, "not a PCI device; no HDMI\n");
                drm->hdmi_device = NULL;
                return;
        }
index 8e13467..67edd2f 100644 (file)
@@ -34,6 +34,7 @@
 #include "nouveau_drm.h"
 #include "nouveau_hwmon.h"
 
+#include <nvkm/subdev/iccsense.h>
 #include <nvkm/subdev/volt.h>
 
 #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
@@ -543,6 +544,24 @@ nouveau_hwmon_get_in0_label(struct device *d,
 static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO,
                          nouveau_hwmon_get_in0_label, NULL, 0);
 
+static ssize_t
+nouveau_hwmon_get_power1_input(struct device *d, struct device_attribute *a,
+                              char *buf)
+{
+       struct drm_device *dev = dev_get_drvdata(d);
+       struct nouveau_drm *drm = nouveau_drm(dev);
+       struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->device);
+       int result = nvkm_iccsense_read_all(iccsense);
+
+       if (result < 0)
+               return result;
+
+       return sprintf(buf, "%i\n", result);
+}
+
+static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO,
+                         nouveau_hwmon_get_power1_input, NULL, 0);
+
 static struct attribute *hwmon_default_attributes[] = {
        &sensor_dev_attr_name.dev_attr.attr,
        &sensor_dev_attr_update_rate.dev_attr.attr,
@@ -579,6 +598,11 @@ static struct attribute *hwmon_in0_attributes[] = {
        NULL
 };
 
+static struct attribute *hwmon_power_attributes[] = {
+       &sensor_dev_attr_power1_input.dev_attr.attr,
+       NULL
+};
+
 static const struct attribute_group hwmon_default_attrgroup = {
        .attrs = hwmon_default_attributes,
 };
@@ -594,6 +618,9 @@ static const struct attribute_group hwmon_pwm_fan_attrgroup = {
 static const struct attribute_group hwmon_in0_attrgroup = {
        .attrs = hwmon_in0_attributes,
 };
+static const struct attribute_group hwmon_power_attrgroup = {
+       .attrs = hwmon_power_attributes,
+};
 #endif
 
 int
@@ -603,6 +630,7 @@ nouveau_hwmon_init(struct drm_device *dev)
        struct nouveau_drm *drm = nouveau_drm(dev);
        struct nvkm_therm *therm = nvxx_therm(&drm->device);
        struct nvkm_volt *volt = nvxx_volt(&drm->device);
+       struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->device);
        struct nouveau_hwmon *hwmon;
        struct device *hwmon_dev;
        int ret = 0;
@@ -612,10 +640,7 @@ nouveau_hwmon_init(struct drm_device *dev)
                return -ENOMEM;
        hwmon->dev = dev;
 
-       if (!therm || !therm->attr_get || !therm->attr_set)
-               return -ENODEV;
-
-       hwmon_dev = hwmon_device_register(&dev->pdev->dev);
+       hwmon_dev = hwmon_device_register(dev->dev);
        if (IS_ERR(hwmon_dev)) {
                ret = PTR_ERR(hwmon_dev);
                NV_ERROR(drm, "Unable to register hwmon device: %d\n", ret);
@@ -628,26 +653,28 @@ nouveau_hwmon_init(struct drm_device *dev)
        if (ret)
                goto error;
 
-       /* if the card has a working thermal sensor */
-       if (nvkm_therm_temp_get(therm) >= 0) {
-               ret = sysfs_create_group(&hwmon_dev->kobj, &hwmon_temp_attrgroup);
-               if (ret)
-                       goto error;
-       }
-
-       /* if the card has a pwm fan */
-       /*XXX: incorrect, need better detection for this, some boards have
-        *     the gpio entries for pwm fan control even when there's no
-        *     actual fan connected to it... therm table? */
-       if (therm->fan_get && therm->fan_get(therm) >= 0) {
-               ret = sysfs_create_group(&hwmon_dev->kobj,
-                                        &hwmon_pwm_fan_attrgroup);
-               if (ret)
-                       goto error;
+       if (therm && therm->attr_get && therm->attr_set) {
+               /* if the card has a working thermal sensor */
+               if (nvkm_therm_temp_get(therm) >= 0) {
+                       ret = sysfs_create_group(&hwmon_dev->kobj, &hwmon_temp_attrgroup);
+                       if (ret)
+                               goto error;
+               }
+
+               /* if the card has a pwm fan */
+               /*XXX: incorrect, need better detection for this, some boards have
+                *     the gpio entries for pwm fan control even when there's no
+                *     actual fan connected to it... therm table? */
+               if (therm->fan_get && therm->fan_get(therm) >= 0) {
+                       ret = sysfs_create_group(&hwmon_dev->kobj,
+                                                &hwmon_pwm_fan_attrgroup);
+                       if (ret)
+                               goto error;
+               }
        }
 
        /* if the card can read the fan rpm */
-       if (nvkm_therm_fan_sense(therm) >= 0) {
+       if (therm && nvkm_therm_fan_sense(therm) >= 0) {
                ret = sysfs_create_group(&hwmon_dev->kobj,
                                         &hwmon_fan_rpm_attrgroup);
                if (ret)
@@ -662,6 +689,13 @@ nouveau_hwmon_init(struct drm_device *dev)
                        goto error;
        }
 
+       if (iccsense && iccsense->data_valid && iccsense->rail_count) {
+               ret = sysfs_create_group(&hwmon_dev->kobj,
+                                        &hwmon_power_attrgroup);
+               if (ret)
+                       goto error;
+       }
+
        hwmon->hwmon = hwmon_dev;
 
        return 0;
@@ -688,6 +722,7 @@ nouveau_hwmon_fini(struct drm_device *dev)
                sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_pwm_fan_attrgroup);
                sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_fan_rpm_attrgroup);
                sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_in0_attrgroup);
+               sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_power_attrgroup);
 
                hwmon_device_unregister(hwmon->hwmon);
        }
index 8a70cec..2dfe58a 100644 (file)
@@ -24,7 +24,7 @@
 static int nouveau_platform_probe(struct platform_device *pdev)
 {
        const struct nvkm_device_tegra_func *func;
-       struct nvkm_device *device;
+       struct nvkm_device *device = NULL;
        struct drm_device *drm;
        int ret;
 
index ea39216..a43445c 100644 (file)
@@ -297,7 +297,7 @@ nv50_core_create(struct nvif_device *device, struct nvif_object *disp,
                .pushbuf = 0xb0007d00,
        };
        static const s32 oclass[] = {
-               GM204_DISP_CORE_CHANNEL_DMA,
+               GM200_DISP_CORE_CHANNEL_DMA,
                GM107_DISP_CORE_CHANNEL_DMA,
                GK110_DISP_CORE_CHANNEL_DMA,
                GK104_DISP_CORE_CHANNEL_DMA,
index 7f66963..86a31a8 100644 (file)
@@ -2,6 +2,7 @@ nvkm-y := nvkm/core/client.o
 nvkm-y += nvkm/core/engine.o
 nvkm-y += nvkm/core/enum.o
 nvkm-y += nvkm/core/event.o
+nvkm-y += nvkm/core/firmware.o
 nvkm-y += nvkm/core/gpuobj.o
 nvkm-y += nvkm/core/ioctl.o
 nvkm-y += nvkm/core/memory.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
new file mode 100644 (file)
index 0000000..34ecd4a
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include <core/device.h>
+
+/**
+ * nvkm_firmware_get - load firmware from the official nvidia/chip/ directory
+ * @device     device that will use that firmware
+ * @fwname     name of firmware file to load
+ * @fw         firmware structure to load to
+ *
+ * Use this function to load firmware files in the form nvidia/chip/fwname.bin.
+ * Firmware files released by NVIDIA will always follow this format.
+ */
+int
+nvkm_firmware_get(struct nvkm_device *device, const char *fwname,
+                 const struct firmware **fw)
+{
+       char f[64];
+       char cname[16];
+       int i;
+
+       /* Convert device name to lowercase */
+       strncpy(cname, device->chip->name, sizeof(cname));
+       cname[sizeof(cname) - 1] = '\0';
+       i = strlen(cname);
+       while (i) {
+               --i;
+               cname[i] = tolower(cname[i]);
+       }
+
+       snprintf(f, sizeof(f), "nvidia/%s/%s.bin", cname, fwname);
+       return request_firmware(fw, f, device->dev);
+}
+
+/**
+ * nvkm_firmware_put - release firmware loaded with nvkm_firmware_get
+ */
+void
+nvkm_firmware_put(const struct firmware *fw)
+{
+       release_firmware(fw);
+}
index c3a790e..a7bd227 100644 (file)
@@ -253,3 +253,23 @@ nvkm_gpuobj_wrap(struct nvkm_memory *memory, struct nvkm_gpuobj **pgpuobj)
        (*pgpuobj)->size = nvkm_memory_size(memory);
        return 0;
 }
+
+void
+nvkm_gpuobj_memcpy_to(struct nvkm_gpuobj *dst, u32 dstoffset, void *src,
+                     u32 length)
+{
+       int i;
+
+       for (i = 0; i < length; i += 4)
+               nvkm_wo32(dst, dstoffset + i, *(u32 *)(src + i));
+}
+
+void
+nvkm_gpuobj_memcpy_from(void *dst, struct nvkm_gpuobj *src, u32 srcoffset,
+                       u32 length)
+{
+       int i;
+
+       for (i = 0; i < length; i += 4)
+               ((u32 *)src)[i / 4] = nvkm_ro32(src, srcoffset + i);
+}
index 3216e15..89da472 100644 (file)
@@ -131,7 +131,7 @@ nvkm_ramht_del(struct nvkm_ramht **pramht)
        struct nvkm_ramht *ramht = *pramht;
        if (ramht) {
                nvkm_gpuobj_del(&ramht->gpuobj);
-               kfree(*pramht);
+               vfree(*pramht);
                *pramht = NULL;
        }
 }
@@ -143,8 +143,8 @@ nvkm_ramht_new(struct nvkm_device *device, u32 size, u32 align,
        struct nvkm_ramht *ramht;
        int ret, i;
 
-       if (!(ramht = *pramht = kzalloc(sizeof(*ramht) + (size >> 3) *
-                                       sizeof(*ramht->data), GFP_KERNEL)))
+       if (!(ramht = *pramht = vzalloc(sizeof(*ramht) +
+                                       (size >> 3) * sizeof(*ramht->data))))
                return -ENOMEM;
 
        ramht->device = device;
index 7de9847..3bf08cb 100644 (file)
@@ -29,47 +29,52 @@ static struct lock_class_key nvkm_subdev_lock_class[NVKM_SUBDEV_NR];
 
 const char *
 nvkm_subdev_name[NVKM_SUBDEV_NR] = {
-       [NVKM_SUBDEV_BAR    ] = "bar",
-       [NVKM_SUBDEV_VBIOS  ] = "bios",
-       [NVKM_SUBDEV_BUS    ] = "bus",
-       [NVKM_SUBDEV_CLK    ] = "clk",
-       [NVKM_SUBDEV_DEVINIT] = "devinit",
-       [NVKM_SUBDEV_FB     ] = "fb",
-       [NVKM_SUBDEV_FUSE   ] = "fuse",
-       [NVKM_SUBDEV_GPIO   ] = "gpio",
-       [NVKM_SUBDEV_I2C    ] = "i2c",
-       [NVKM_SUBDEV_IBUS   ] = "priv",
-       [NVKM_SUBDEV_INSTMEM] = "imem",
-       [NVKM_SUBDEV_LTC    ] = "ltc",
-       [NVKM_SUBDEV_MC     ] = "mc",
-       [NVKM_SUBDEV_MMU    ] = "mmu",
-       [NVKM_SUBDEV_MXM    ] = "mxm",
-       [NVKM_SUBDEV_PCI    ] = "pci",
-       [NVKM_SUBDEV_PMU    ] = "pmu",
-       [NVKM_SUBDEV_THERM  ] = "therm",
-       [NVKM_SUBDEV_TIMER  ] = "tmr",
-       [NVKM_SUBDEV_VOLT   ] = "volt",
-       [NVKM_ENGINE_BSP    ] = "bsp",
-       [NVKM_ENGINE_CE0    ] = "ce0",
-       [NVKM_ENGINE_CE1    ] = "ce1",
-       [NVKM_ENGINE_CE2    ] = "ce2",
-       [NVKM_ENGINE_CIPHER ] = "cipher",
-       [NVKM_ENGINE_DISP   ] = "disp",
-       [NVKM_ENGINE_DMAOBJ ] = "dma",
-       [NVKM_ENGINE_FIFO   ] = "fifo",
-       [NVKM_ENGINE_GR     ] = "gr",
-       [NVKM_ENGINE_IFB    ] = "ifb",
-       [NVKM_ENGINE_ME     ] = "me",
-       [NVKM_ENGINE_MPEG   ] = "mpeg",
-       [NVKM_ENGINE_MSENC  ] = "msenc",
-       [NVKM_ENGINE_MSPDEC ] = "mspdec",
-       [NVKM_ENGINE_MSPPP  ] = "msppp",
-       [NVKM_ENGINE_MSVLD  ] = "msvld",
-       [NVKM_ENGINE_PM     ] = "pm",
-       [NVKM_ENGINE_SEC    ] = "sec",
-       [NVKM_ENGINE_SW     ] = "sw",
-       [NVKM_ENGINE_VIC    ] = "vic",
-       [NVKM_ENGINE_VP     ] = "vp",
+       [NVKM_SUBDEV_BAR     ] = "bar",
+       [NVKM_SUBDEV_VBIOS   ] = "bios",
+       [NVKM_SUBDEV_BUS     ] = "bus",
+       [NVKM_SUBDEV_CLK     ] = "clk",
+       [NVKM_SUBDEV_DEVINIT ] = "devinit",
+       [NVKM_SUBDEV_FB      ] = "fb",
+       [NVKM_SUBDEV_FUSE    ] = "fuse",
+       [NVKM_SUBDEV_GPIO    ] = "gpio",
+       [NVKM_SUBDEV_I2C     ] = "i2c",
+       [NVKM_SUBDEV_IBUS    ] = "priv",
+       [NVKM_SUBDEV_ICCSENSE] = "iccsense",
+       [NVKM_SUBDEV_INSTMEM ] = "imem",
+       [NVKM_SUBDEV_LTC     ] = "ltc",
+       [NVKM_SUBDEV_MC      ] = "mc",
+       [NVKM_SUBDEV_MMU     ] = "mmu",
+       [NVKM_SUBDEV_MXM     ] = "mxm",
+       [NVKM_SUBDEV_PCI     ] = "pci",
+       [NVKM_SUBDEV_PMU     ] = "pmu",
+       [NVKM_SUBDEV_SECBOOT ] = "secboot",
+       [NVKM_SUBDEV_THERM   ] = "therm",
+       [NVKM_SUBDEV_TIMER   ] = "tmr",
+       [NVKM_SUBDEV_VOLT    ] = "volt",
+       [NVKM_ENGINE_BSP     ] = "bsp",
+       [NVKM_ENGINE_CE0     ] = "ce0",
+       [NVKM_ENGINE_CE1     ] = "ce1",
+       [NVKM_ENGINE_CE2     ] = "ce2",
+       [NVKM_ENGINE_CIPHER  ] = "cipher",
+       [NVKM_ENGINE_DISP    ] = "disp",
+       [NVKM_ENGINE_DMAOBJ  ] = "dma",
+       [NVKM_ENGINE_FIFO    ] = "fifo",
+       [NVKM_ENGINE_GR      ] = "gr",
+       [NVKM_ENGINE_IFB     ] = "ifb",
+       [NVKM_ENGINE_ME      ] = "me",
+       [NVKM_ENGINE_MPEG    ] = "mpeg",
+       [NVKM_ENGINE_MSENC   ] = "msenc",
+       [NVKM_ENGINE_MSPDEC  ] = "mspdec",
+       [NVKM_ENGINE_MSPPP   ] = "msppp",
+       [NVKM_ENGINE_MSVLD   ] = "msvld",
+       [NVKM_ENGINE_NVENC0  ] = "nvenc0",
+       [NVKM_ENGINE_NVENC1  ] = "nvenc1",
+       [NVKM_ENGINE_NVDEC   ] = "nvdec",
+       [NVKM_ENGINE_PM      ] = "pm",
+       [NVKM_ENGINE_SEC     ] = "sec",
+       [NVKM_ENGINE_SW      ] = "sw",
+       [NVKM_ENGINE_VIC     ] = "vic",
+       [NVKM_ENGINE_VP      ] = "vp",
 };
 
 void
index 36f7247..c2c8d2a 100644 (file)
@@ -10,10 +10,14 @@ include $(src)/nvkm/engine/dma/Kbuild
 include $(src)/nvkm/engine/fifo/Kbuild
 include $(src)/nvkm/engine/gr/Kbuild
 include $(src)/nvkm/engine/mpeg/Kbuild
+include $(src)/nvkm/engine/msenc/Kbuild
 include $(src)/nvkm/engine/mspdec/Kbuild
 include $(src)/nvkm/engine/msppp/Kbuild
 include $(src)/nvkm/engine/msvld/Kbuild
+include $(src)/nvkm/engine/nvenc/Kbuild
+include $(src)/nvkm/engine/nvdec/Kbuild
 include $(src)/nvkm/engine/pm/Kbuild
 include $(src)/nvkm/engine/sec/Kbuild
 include $(src)/nvkm/engine/sw/Kbuild
+include $(src)/nvkm/engine/vic/Kbuild
 include $(src)/nvkm/engine/vp/Kbuild
index fa8cda7..9c19d59 100644 (file)
@@ -1,4 +1,5 @@
 nvkm-y += nvkm/engine/ce/gt215.o
 nvkm-y += nvkm/engine/ce/gf100.o
 nvkm-y += nvkm/engine/ce/gk104.o
-nvkm-y += nvkm/engine/ce/gm204.o
+nvkm-y += nvkm/engine/ce/gm107.o
+nvkm-y += nvkm/engine/ce/gm200.o
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Red Hat Inc.
+ * Copyright 2016 Red Hat Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  *
- * Authors: Ben Skeggs <bskeggs@redhat.com>
+ * Authors: Ben Skeggs
  */
-#include "gf100.h"
-#include "ctxgf100.h"
+#include "priv.h"
 
 #include <nvif/class.h>
 
-static const struct gf100_gr_func
-gm206_gr = {
-       .init = gm204_gr_init,
-       .mmio = gm204_gr_pack_mmio,
-       .ppc_nr = 2,
-       .grctx = &gm206_grctx,
+static const struct nvkm_engine_func
+gm107_ce = {
+       .intr = gk104_ce_intr,
        .sclass = {
-               { -1, -1, FERMI_TWOD_A },
-               { -1, -1, KEPLER_INLINE_TO_MEMORY_B },
-               { -1, -1, MAXWELL_B, &gf100_fermi },
-               { -1, -1, MAXWELL_COMPUTE_B },
+               { -1, -1, KEPLER_DMA_COPY_A },
+               { -1, -1, MAXWELL_DMA_COPY_A },
                {}
        }
 };
 
 int
-gm206_gr_new(struct nvkm_device *device, int index, struct nvkm_gr **pgr)
+gm107_ce_new(struct nvkm_device *device, int index,
+            struct nvkm_engine **pengine)
 {
-       return gf100_gr_new_(&gm206_gr, device, index, pgr);
+       if (index == NVKM_ENGINE_CE0) {
+               return nvkm_engine_new_(&gm107_ce, device, index,
+                                       0x00000040, true, pengine);
+       } else
+       if (index == NVKM_ENGINE_CE1) {
+               return nvkm_engine_new_(&gm107_ce, device, index,
+                                       0x00000080, true, pengine);
+       } else
+       if (index == NVKM_ENGINE_CE2) {
+               return nvkm_engine_new_(&gm107_ce, device, index,
+                                       0x00200000, true, pengine);
+       }
+       return -ENODEV;
 }
@@ -26,7 +26,7 @@
 #include <nvif/class.h>
 
 static const struct nvkm_engine_func
-gm204_ce = {
+gm200_ce = {
        .intr = gk104_ce_intr,
        .sclass = {
                { -1, -1, MAXWELL_DMA_COPY_A },
@@ -35,19 +35,19 @@ gm204_ce = {
 };
 
 int
-gm204_ce_new(struct nvkm_device *device, int index,
+gm200_ce_new(struct nvkm_device *device, int index,
             struct nvkm_engine **pengine)
 {
        if (index == NVKM_ENGINE_CE0) {
-               return nvkm_engine_new_(&gm204_ce, device, index,
+               return nvkm_engine_new_(&gm200_ce, device, index,
                                        0x00000040, true, pengine);
        } else
        if (index == NVKM_ENGINE_CE1) {
-               return nvkm_engine_new_(&gm204_ce, device, index,
+               return nvkm_engine_new_(&gm200_ce, device, index,
                                        0x00000080, true, pengine);
        } else
        if (index == NVKM_ENGINE_CE2) {
-               return nvkm_engine_new_(&gm204_ce, device, index,
+               return nvkm_engine_new_(&gm200_ce, device, index,
                                        0x00200000, true, pengine);
        }
        return -ENODEV;
index b1ba1c7..9f32c87 100644 (file)
@@ -1347,6 +1347,7 @@ nvc0_chipset = {
        .gpio = g94_gpio_new,
        .i2c = g94_i2c_new,
        .ibus = gf100_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gf100_ltc_new,
        .mc = gf100_mc_new,
@@ -1383,6 +1384,7 @@ nvc1_chipset = {
        .gpio = g94_gpio_new,
        .i2c = g94_i2c_new,
        .ibus = gf100_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gf100_ltc_new,
        .mc = gf100_mc_new,
@@ -1418,6 +1420,7 @@ nvc3_chipset = {
        .gpio = g94_gpio_new,
        .i2c = g94_i2c_new,
        .ibus = gf100_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gf100_ltc_new,
        .mc = gf100_mc_new,
@@ -1453,6 +1456,7 @@ nvc4_chipset = {
        .gpio = g94_gpio_new,
        .i2c = g94_i2c_new,
        .ibus = gf100_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gf100_ltc_new,
        .mc = gf100_mc_new,
@@ -1489,6 +1493,7 @@ nvc8_chipset = {
        .gpio = g94_gpio_new,
        .i2c = g94_i2c_new,
        .ibus = gf100_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gf100_ltc_new,
        .mc = gf100_mc_new,
@@ -1525,6 +1530,7 @@ nvce_chipset = {
        .gpio = g94_gpio_new,
        .i2c = g94_i2c_new,
        .ibus = gf100_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gf100_ltc_new,
        .mc = gf100_mc_new,
@@ -1561,6 +1567,7 @@ nvcf_chipset = {
        .gpio = g94_gpio_new,
        .i2c = g94_i2c_new,
        .ibus = gf100_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gf100_ltc_new,
        .mc = gf100_mc_new,
@@ -1596,6 +1603,7 @@ nvd7_chipset = {
        .gpio = gf119_gpio_new,
        .i2c = gf117_i2c_new,
        .ibus = gf117_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gf100_ltc_new,
        .mc = gf100_mc_new,
@@ -1629,6 +1637,7 @@ nvd9_chipset = {
        .gpio = gf119_gpio_new,
        .i2c = gf119_i2c_new,
        .ibus = gf117_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gf100_ltc_new,
        .mc = gf100_mc_new,
@@ -1664,6 +1673,7 @@ nve4_chipset = {
        .gpio = gk104_gpio_new,
        .i2c = gk104_i2c_new,
        .ibus = gk104_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gk104_ltc_new,
        .mc = gf100_mc_new,
@@ -1701,6 +1711,7 @@ nve6_chipset = {
        .gpio = gk104_gpio_new,
        .i2c = gk104_i2c_new,
        .ibus = gk104_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gk104_ltc_new,
        .mc = gf100_mc_new,
@@ -1738,6 +1749,7 @@ nve7_chipset = {
        .gpio = gk104_gpio_new,
        .i2c = gk104_i2c_new,
        .ibus = gk104_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gk104_ltc_new,
        .mc = gf100_mc_new,
@@ -1799,6 +1811,7 @@ nvf0_chipset = {
        .gpio = gk104_gpio_new,
        .i2c = gk104_i2c_new,
        .ibus = gk104_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gk104_ltc_new,
        .mc = gf100_mc_new,
@@ -1814,7 +1827,7 @@ nvf0_chipset = {
        .ce[2] = gk104_ce_new,
        .disp = gk110_disp_new,
        .dma = gf119_dma_new,
-       .fifo = gk104_fifo_new,
+       .fifo = gk110_fifo_new,
        .gr = gk110_gr_new,
        .mspdec = gk104_mspdec_new,
        .msppp = gf100_msppp_new,
@@ -1835,6 +1848,7 @@ nvf1_chipset = {
        .gpio = gk104_gpio_new,
        .i2c = gf119_i2c_new,
        .ibus = gk104_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gk104_ltc_new,
        .mc = gf100_mc_new,
@@ -1850,7 +1864,7 @@ nvf1_chipset = {
        .ce[2] = gk104_ce_new,
        .disp = gk110_disp_new,
        .dma = gf119_dma_new,
-       .fifo = gk104_fifo_new,
+       .fifo = gk110_fifo_new,
        .gr = gk110b_gr_new,
        .mspdec = gk104_mspdec_new,
        .msppp = gf100_msppp_new,
@@ -1871,6 +1885,7 @@ nv106_chipset = {
        .gpio = gk104_gpio_new,
        .i2c = gk104_i2c_new,
        .ibus = gk104_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gk104_ltc_new,
        .mc = gk20a_mc_new,
@@ -1907,6 +1922,7 @@ nv108_chipset = {
        .gpio = gk104_gpio_new,
        .i2c = gk104_i2c_new,
        .ibus = gk104_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gk104_ltc_new,
        .mc = gk20a_mc_new,
@@ -1943,6 +1959,7 @@ nv117_chipset = {
        .gpio = gk104_gpio_new,
        .i2c = gf119_i2c_new,
        .ibus = gk104_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
        .ltc = gm107_ltc_new,
        .mc = gk20a_mc_new,
@@ -1953,43 +1970,78 @@ nv117_chipset = {
        .therm = gm107_therm_new,
        .timer = gk20a_timer_new,
        .volt = gk104_volt_new,
-       .ce[0] = gk104_ce_new,
-       .ce[2] = gk104_ce_new,
+       .ce[0] = gm107_ce_new,
+       .ce[2] = gm107_ce_new,
        .disp = gm107_disp_new,
        .dma = gf119_dma_new,
-       .fifo = gk208_fifo_new,
+       .fifo = gm107_fifo_new,
        .gr = gm107_gr_new,
        .sw = gf100_sw_new,
 };
 
 static const struct nvkm_device_chip
+nv120_chipset = {
+       .name = "GM200",
+       .bar = gf100_bar_new,
+       .bios = nvkm_bios_new,
+       .bus = gf100_bus_new,
+       .devinit = gm200_devinit_new,
+       .fb = gm107_fb_new,
+       .fuse = gm107_fuse_new,
+       .gpio = gk104_gpio_new,
+       .i2c = gm200_i2c_new,
+       .ibus = gm200_ibus_new,
+       .iccsense = gf100_iccsense_new,
+       .imem = nv50_instmem_new,
+       .ltc = gm200_ltc_new,
+       .mc = gk20a_mc_new,
+       .mmu = gf100_mmu_new,
+       .mxm = nv50_mxm_new,
+       .pci = gk104_pci_new,
+       .pmu = gm107_pmu_new,
+       .secboot = gm200_secboot_new,
+       .timer = gk20a_timer_new,
+       .volt = gk104_volt_new,
+       .ce[0] = gm200_ce_new,
+       .ce[1] = gm200_ce_new,
+       .ce[2] = gm200_ce_new,
+       .disp = gm200_disp_new,
+       .dma = gf119_dma_new,
+       .fifo = gm200_fifo_new,
+       .gr = gm200_gr_new,
+       .sw = gf100_sw_new,
+};
+
+static const struct nvkm_device_chip
 nv124_chipset = {
        .name = "GM204",
        .bar = gf100_bar_new,
        .bios = nvkm_bios_new,
        .bus = gf100_bus_new,
-       .devinit = gm204_devinit_new,
+       .devinit = gm200_devinit_new,
        .fb = gm107_fb_new,
        .fuse = gm107_fuse_new,
        .gpio = gk104_gpio_new,
-       .i2c = gm204_i2c_new,
-       .ibus = gm204_ibus_new,
+       .i2c = gm200_i2c_new,
+       .ibus = gm200_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
-       .ltc = gm204_ltc_new,
+       .ltc = gm200_ltc_new,
        .mc = gk20a_mc_new,
        .mmu = gf100_mmu_new,
        .mxm = nv50_mxm_new,
        .pci = gk104_pci_new,
        .pmu = gm107_pmu_new,
+       .secboot = gm200_secboot_new,
        .timer = gk20a_timer_new,
        .volt = gk104_volt_new,
-       .ce[0] = gm204_ce_new,
-       .ce[1] = gm204_ce_new,
-       .ce[2] = gm204_ce_new,
-       .disp = gm204_disp_new,
+       .ce[0] = gm200_ce_new,
+       .ce[1] = gm200_ce_new,
+       .ce[2] = gm200_ce_new,
+       .disp = gm200_disp_new,
        .dma = gf119_dma_new,
-       .fifo = gm204_fifo_new,
-       .gr = gm204_gr_new,
+       .fifo = gm200_fifo_new,
+       .gr = gm200_gr_new,
        .sw = gf100_sw_new,
 };
 
@@ -1999,28 +2051,30 @@ nv126_chipset = {
        .bar = gf100_bar_new,
        .bios = nvkm_bios_new,
        .bus = gf100_bus_new,
-       .devinit = gm204_devinit_new,
+       .devinit = gm200_devinit_new,
        .fb = gm107_fb_new,
        .fuse = gm107_fuse_new,
        .gpio = gk104_gpio_new,
-       .i2c = gm204_i2c_new,
-       .ibus = gm204_ibus_new,
+       .i2c = gm200_i2c_new,
+       .ibus = gm200_ibus_new,
+       .iccsense = gf100_iccsense_new,
        .imem = nv50_instmem_new,
-       .ltc = gm204_ltc_new,
+       .ltc = gm200_ltc_new,
        .mc = gk20a_mc_new,
        .mmu = gf100_mmu_new,
        .mxm = nv50_mxm_new,
        .pci = gk104_pci_new,
        .pmu = gm107_pmu_new,
+       .secboot = gm200_secboot_new,
        .timer = gk20a_timer_new,
        .volt = gk104_volt_new,
-       .ce[0] = gm204_ce_new,
-       .ce[1] = gm204_ce_new,
-       .ce[2] = gm204_ce_new,
-       .disp = gm204_disp_new,
+       .ce[0] = gm200_ce_new,
+       .ce[1] = gm200_ce_new,
+       .ce[2] = gm200_ce_new,
+       .disp = gm200_disp_new,
        .dma = gf119_dma_new,
-       .fifo = gm204_fifo_new,
-       .gr = gm206_gr_new,
+       .fifo = gm200_fifo_new,
+       .gr = gm200_gr_new,
        .sw = gf100_sw_new,
 };
 
@@ -2029,15 +2083,18 @@ nv12b_chipset = {
        .name = "GM20B",
        .bar = gk20a_bar_new,
        .bus = gf100_bus_new,
+       .clk = gm20b_clk_new,
        .fb = gk20a_fb_new,
        .fuse = gm107_fuse_new,
        .ibus = gk20a_ibus_new,
        .imem = gk20a_instmem_new,
-       .ltc = gm204_ltc_new,
+       .ltc = gm200_ltc_new,
        .mc = gk20a_mc_new,
        .mmu = gf100_mmu_new,
+       .secboot = gm20b_secboot_new,
        .timer = gk20a_timer_new,
-       .ce[2] = gm204_ce_new,
+       .ce[2] = gm200_ce_new,
+       .volt = gm20b_volt_new,
        .dma = gf119_dma_new,
        .fifo = gm20b_fifo_new,
        .gr = gm20b_gr_new,
@@ -2072,26 +2129,28 @@ nvkm_device_subdev(struct nvkm_device *device, int index)
 
        switch (index) {
 #define _(n,p,m) case NVKM_SUBDEV_##n: if (p) return (m); break
-       _(BAR    , device->bar    , &device->bar->subdev);
-       _(VBIOS  , device->bios   , &device->bios->subdev);
-       _(BUS    , device->bus    , &device->bus->subdev);
-       _(CLK    , device->clk    , &device->clk->subdev);
-       _(DEVINIT, device->devinit, &device->devinit->subdev);
-       _(FB     , device->fb     , &device->fb->subdev);
-       _(FUSE   , device->fuse   , &device->fuse->subdev);
-       _(GPIO   , device->gpio   , &device->gpio->subdev);
-       _(I2C    , device->i2c    , &device->i2c->subdev);
-       _(IBUS   , device->ibus   ,  device->ibus);
-       _(INSTMEM, device->imem   , &device->imem->subdev);
-       _(LTC    , device->ltc    , &device->ltc->subdev);
-       _(MC     , device->mc     , &device->mc->subdev);
-       _(MMU    , device->mmu    , &device->mmu->subdev);
-       _(MXM    , device->mxm    ,  device->mxm);
-       _(PCI    , device->pci    , &device->pci->subdev);
-       _(PMU    , device->pmu    , &device->pmu->subdev);
-       _(THERM  , device->therm  , &device->therm->subdev);
-       _(TIMER  , device->timer  , &device->timer->subdev);
-       _(VOLT   , device->volt   , &device->volt->subdev);
+       _(BAR     , device->bar     , &device->bar->subdev);
+       _(VBIOS   , device->bios    , &device->bios->subdev);
+       _(BUS     , device->bus     , &device->bus->subdev);
+       _(CLK     , device->clk     , &device->clk->subdev);
+       _(DEVINIT , device->devinit , &device->devinit->subdev);
+       _(FB      , device->fb      , &device->fb->subdev);
+       _(FUSE    , device->fuse    , &device->fuse->subdev);
+       _(GPIO    , device->gpio    , &device->gpio->subdev);
+       _(I2C     , device->i2c     , &device->i2c->subdev);
+       _(IBUS    , device->ibus    ,  device->ibus);
+       _(ICCSENSE, device->iccsense, &device->iccsense->subdev);
+       _(INSTMEM , device->imem    , &device->imem->subdev);
+       _(LTC     , device->ltc     , &device->ltc->subdev);
+       _(MC      , device->mc      , &device->mc->subdev);
+       _(MMU     , device->mmu     , &device->mmu->subdev);
+       _(MXM     , device->mxm     ,  device->mxm);
+       _(PCI     , device->pci     , &device->pci->subdev);
+       _(PMU     , device->pmu     , &device->pmu->subdev);
+       _(SECBOOT , device->secboot , &device->secboot->subdev);
+       _(THERM   , device->therm   , &device->therm->subdev);
+       _(TIMER   , device->timer   , &device->timer->subdev);
+       _(VOLT    , device->volt    , &device->volt->subdev);
 #undef _
        default:
                engine = nvkm_device_engine(device, index);
@@ -2110,27 +2169,30 @@ nvkm_device_engine(struct nvkm_device *device, int index)
 
        switch (index) {
 #define _(n,p,m) case NVKM_ENGINE_##n: if (p) return (m); break
-       _(BSP    , device->bsp    ,  device->bsp);
-       _(CE0    , device->ce[0]  ,  device->ce[0]);
-       _(CE1    , device->ce[1]  ,  device->ce[1]);
-       _(CE2    , device->ce[2]  ,  device->ce[2]);
-       _(CIPHER , device->cipher ,  device->cipher);
-       _(DISP   , device->disp   , &device->disp->engine);
-       _(DMAOBJ , device->dma    , &device->dma->engine);
-       _(FIFO   , device->fifo   , &device->fifo->engine);
-       _(GR     , device->gr     , &device->gr->engine);
-       _(IFB    , device->ifb    ,  device->ifb);
-       _(ME     , device->me     ,  device->me);
-       _(MPEG   , device->mpeg   ,  device->mpeg);
-       _(MSENC  , device->msenc  ,  device->msenc);
-       _(MSPDEC , device->mspdec ,  device->mspdec);
-       _(MSPPP  , device->msppp  ,  device->msppp);
-       _(MSVLD  , device->msvld  ,  device->msvld);
-       _(PM     , device->pm     , &device->pm->engine);
-       _(SEC    , device->sec    ,  device->sec);
-       _(SW     , device->sw     , &device->sw->engine);
-       _(VIC    , device->vic    ,  device->vic);
-       _(VP     , device->vp     ,  device->vp);
+       _(BSP    , device->bsp     ,  device->bsp);
+       _(CE0    , device->ce[0]   ,  device->ce[0]);
+       _(CE1    , device->ce[1]   ,  device->ce[1]);
+       _(CE2    , device->ce[2]   ,  device->ce[2]);
+       _(CIPHER , device->cipher  ,  device->cipher);
+       _(DISP   , device->disp    , &device->disp->engine);
+       _(DMAOBJ , device->dma     , &device->dma->engine);
+       _(FIFO   , device->fifo    , &device->fifo->engine);
+       _(GR     , device->gr      , &device->gr->engine);
+       _(IFB    , device->ifb     ,  device->ifb);
+       _(ME     , device->me      ,  device->me);
+       _(MPEG   , device->mpeg    ,  device->mpeg);
+       _(MSENC  , device->msenc   ,  device->msenc);
+       _(MSPDEC , device->mspdec  ,  device->mspdec);
+       _(MSPPP  , device->msppp   ,  device->msppp);
+       _(MSVLD  , device->msvld   ,  device->msvld);
+       _(NVENC0 , device->nvenc[0],  device->nvenc[0]);
+       _(NVENC1 , device->nvenc[1],  device->nvenc[1]);
+       _(NVDEC  , device->nvdec   ,  device->nvdec);
+       _(PM     , device->pm      , &device->pm->engine);
+       _(SEC    , device->sec     ,  device->sec);
+       _(SW     , device->sw      , &device->sw->engine);
+       _(VIC    , device->vic     ,  device->vic);
+       _(VP     , device->vp      ,  device->vp);
 #undef _
        default:
                WARN_ON(1);
@@ -2261,6 +2323,8 @@ fail_subdev:
        } while (--i >= 0);
 
 fail:
+       nvkm_device_fini(device, false);
+
        nvdev_error(device, "init failed with %d\n", ret);
        return ret;
 }
@@ -2459,6 +2523,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
                case 0x106: device->chip = &nv106_chipset; break;
                case 0x108: device->chip = &nv108_chipset; break;
                case 0x117: device->chip = &nv117_chipset; break;
+               case 0x120: device->chip = &nv120_chipset; break;
                case 0x124: device->chip = &nv124_chipset; break;
                case 0x126: device->chip = &nv126_chipset; break;
                case 0x12b: device->chip = &nv12b_chipset; break;
@@ -2518,47 +2583,52 @@ nvkm_device_ctor(const struct nvkm_device_func *func,
        }                                                                      \
        break
                switch (i) {
-               _(NVKM_SUBDEV_BAR    ,     bar);
-               _(NVKM_SUBDEV_VBIOS  ,    bios);
-               _(NVKM_SUBDEV_BUS    ,     bus);
-               _(NVKM_SUBDEV_CLK    ,     clk);
-               _(NVKM_SUBDEV_DEVINIT, devinit);
-               _(NVKM_SUBDEV_FB     ,      fb);
-               _(NVKM_SUBDEV_FUSE   ,    fuse);
-               _(NVKM_SUBDEV_GPIO   ,    gpio);
-               _(NVKM_SUBDEV_I2C    ,     i2c);
-               _(NVKM_SUBDEV_IBUS   ,    ibus);
-               _(NVKM_SUBDEV_INSTMEM,    imem);
-               _(NVKM_SUBDEV_LTC    ,     ltc);
-               _(NVKM_SUBDEV_MC     ,      mc);
-               _(NVKM_SUBDEV_MMU    ,     mmu);
-               _(NVKM_SUBDEV_MXM    ,     mxm);
-               _(NVKM_SUBDEV_PCI    ,     pci);
-               _(NVKM_SUBDEV_PMU    ,     pmu);
-               _(NVKM_SUBDEV_THERM  ,   therm);
-               _(NVKM_SUBDEV_TIMER  ,   timer);
-               _(NVKM_SUBDEV_VOLT   ,    volt);
-               _(NVKM_ENGINE_BSP    ,     bsp);
-               _(NVKM_ENGINE_CE0    ,   ce[0]);
-               _(NVKM_ENGINE_CE1    ,   ce[1]);
-               _(NVKM_ENGINE_CE2    ,   ce[2]);
-               _(NVKM_ENGINE_CIPHER ,  cipher);
-               _(NVKM_ENGINE_DISP   ,    disp);
-               _(NVKM_ENGINE_DMAOBJ ,     dma);
-               _(NVKM_ENGINE_FIFO   ,    fifo);
-               _(NVKM_ENGINE_GR     ,      gr);
-               _(NVKM_ENGINE_IFB    ,     ifb);
-               _(NVKM_ENGINE_ME     ,      me);
-               _(NVKM_ENGINE_MPEG   ,    mpeg);
-               _(NVKM_ENGINE_MSENC  ,   msenc);
-               _(NVKM_ENGINE_MSPDEC ,  mspdec);
-               _(NVKM_ENGINE_MSPPP  ,   msppp);
-               _(NVKM_ENGINE_MSVLD  ,   msvld);
-               _(NVKM_ENGINE_PM     ,      pm);
-               _(NVKM_ENGINE_SEC    ,     sec);
-               _(NVKM_ENGINE_SW     ,      sw);
-               _(NVKM_ENGINE_VIC    ,     vic);
-               _(NVKM_ENGINE_VP     ,      vp);
+               _(NVKM_SUBDEV_BAR     ,      bar);
+               _(NVKM_SUBDEV_VBIOS   ,     bios);
+               _(NVKM_SUBDEV_BUS     ,      bus);
+               _(NVKM_SUBDEV_CLK     ,      clk);
+               _(NVKM_SUBDEV_DEVINIT ,  devinit);
+               _(NVKM_SUBDEV_FB      ,       fb);
+               _(NVKM_SUBDEV_FUSE    ,     fuse);
+               _(NVKM_SUBDEV_GPIO    ,     gpio);
+               _(NVKM_SUBDEV_I2C     ,      i2c);
+               _(NVKM_SUBDEV_IBUS    ,     ibus);
+               _(NVKM_SUBDEV_ICCSENSE, iccsense);
+               _(NVKM_SUBDEV_INSTMEM ,     imem);
+               _(NVKM_SUBDEV_LTC     ,      ltc);
+               _(NVKM_SUBDEV_MC      ,       mc);
+               _(NVKM_SUBDEV_MMU     ,      mmu);
+               _(NVKM_SUBDEV_MXM     ,      mxm);
+               _(NVKM_SUBDEV_PCI     ,      pci);
+               _(NVKM_SUBDEV_PMU     ,      pmu);
+               _(NVKM_SUBDEV_SECBOOT ,  secboot);
+               _(NVKM_SUBDEV_THERM   ,    therm);
+               _(NVKM_SUBDEV_TIMER   ,    timer);
+               _(NVKM_SUBDEV_VOLT    ,     volt);
+               _(NVKM_ENGINE_BSP     ,      bsp);
+               _(NVKM_ENGINE_CE0     ,    ce[0]);
+               _(NVKM_ENGINE_CE1     ,    ce[1]);
+               _(NVKM_ENGINE_CE2     ,    ce[2]);
+               _(NVKM_ENGINE_CIPHER  ,   cipher);
+               _(NVKM_ENGINE_DISP    ,     disp);
+               _(NVKM_ENGINE_DMAOBJ  ,      dma);
+               _(NVKM_ENGINE_FIFO    ,     fifo);
+               _(NVKM_ENGINE_GR      ,       gr);
+               _(NVKM_ENGINE_IFB     ,      ifb);
+               _(NVKM_ENGINE_ME      ,       me);
+               _(NVKM_ENGINE_MPEG    ,     mpeg);
+               _(NVKM_ENGINE_MSENC   ,    msenc);
+               _(NVKM_ENGINE_MSPDEC  ,   mspdec);
+               _(NVKM_ENGINE_MSPPP   ,    msppp);
+               _(NVKM_ENGINE_MSVLD   ,    msvld);
+               _(NVKM_ENGINE_NVENC0  , nvenc[0]);
+               _(NVKM_ENGINE_NVENC1  , nvenc[1]);
+               _(NVKM_ENGINE_NVDEC   ,    nvdec);
+               _(NVKM_ENGINE_PM      ,       pm);
+               _(NVKM_ENGINE_SEC     ,      sec);
+               _(NVKM_ENGINE_SW      ,       sw);
+               _(NVKM_ENGINE_VIC     ,      vic);
+               _(NVKM_ENGINE_VP      ,       vp);
                default:
                        WARN_ON(1);
                        continue;
index 62ad030..18fab39 100644 (file)
@@ -1614,7 +1614,7 @@ nvkm_device_pci_func = {
        .fini = nvkm_device_pci_fini,
        .resource_addr = nvkm_device_pci_resource_addr,
        .resource_size = nvkm_device_pci_resource_size,
-       .cpu_coherent = !IS_ENABLED(CONFIG_ARM),
+       .cpu_coherent = !IS_ENABLED(CONFIG_ARM) && !IS_ENABLED(CONFIG_ARM64),
 };
 
 int
index ed3ad2c..e80f6ab 100644 (file)
@@ -12,6 +12,7 @@
 #include <subdev/gpio.h>
 #include <subdev/i2c.h>
 #include <subdev/ibus.h>
+#include <subdev/iccsense.h>
 #include <subdev/instmem.h>
 #include <subdev/ltc.h>
 #include <subdev/mc.h>
@@ -22,6 +23,7 @@
 #include <subdev/therm.h>
 #include <subdev/timer.h>
 #include <subdev/volt.h>
+#include <subdev/secboot.h>
 
 #include <engine/bsp.h>
 #include <engine/ce.h>
 #include <engine/mspdec.h>
 #include <engine/msppp.h>
 #include <engine/msvld.h>
+#include <engine/nvenc.h>
+#include <engine/nvdec.h>
 #include <engine/pm.h>
 #include <engine/sec.h>
 #include <engine/sw.h>
+#include <engine/vic.h>
 #include <engine/vp.h>
 
 int  nvkm_device_ctor(const struct nvkm_device_func *,
index 7f8a427..9afa5f3 100644 (file)
@@ -252,32 +252,48 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func,
 
        if (!(tdev = kzalloc(sizeof(*tdev), GFP_KERNEL)))
                return -ENOMEM;
-       *pdevice = &tdev->device;
+
        tdev->func = func;
        tdev->pdev = pdev;
-       tdev->irq = -1;
 
        tdev->vdd = devm_regulator_get(&pdev->dev, "vdd");
-       if (IS_ERR(tdev->vdd))
-               return PTR_ERR(tdev->vdd);
+       if (IS_ERR(tdev->vdd)) {
+               ret = PTR_ERR(tdev->vdd);
+               goto free;
+       }
 
        tdev->rst = devm_reset_control_get(&pdev->dev, "gpu");
-       if (IS_ERR(tdev->rst))
-               return PTR_ERR(tdev->rst);
+       if (IS_ERR(tdev->rst)) {
+               ret = PTR_ERR(tdev->rst);
+               goto free;
+       }
 
        tdev->clk = devm_clk_get(&pdev->dev, "gpu");
-       if (IS_ERR(tdev->clk))
-               return PTR_ERR(tdev->clk);
+       if (IS_ERR(tdev->clk)) {
+               ret = PTR_ERR(tdev->clk);
+               goto free;
+       }
 
        tdev->clk_pwr = devm_clk_get(&pdev->dev, "pwr");
-       if (IS_ERR(tdev->clk_pwr))
-               return PTR_ERR(tdev->clk_pwr);
+       if (IS_ERR(tdev->clk_pwr)) {
+               ret = PTR_ERR(tdev->clk_pwr);
+               goto free;
+       }
+
+       /**
+        * The IOMMU bit defines the upper limit of the GPU-addressable space.
+        * This will be refined in nouveau_ttm_init but we need to do it early
+        * for instmem to behave properly
+        */
+       ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(tdev->func->iommu_bit));
+       if (ret)
+               goto free;
 
        nvkm_device_tegra_probe_iommu(tdev);
 
        ret = nvkm_device_tegra_power_up(tdev);
        if (ret)
-               return ret;
+               goto remove;
 
        tdev->gpu_speedo = tegra_sku_info.gpu_speedo_value;
        ret = nvkm_device_ctor(&nvkm_device_tegra_func, NULL, &pdev->dev,
@@ -285,9 +301,19 @@ nvkm_device_tegra_new(const struct nvkm_device_tegra_func *func,
                               cfg, dbg, detect, mmio, subdev_mask,
                               &tdev->device);
        if (ret)
-               return ret;
+               goto powerdown;
+
+       *pdevice = &tdev->device;
 
        return 0;
+
+powerdown:
+       nvkm_device_tegra_power_down(tdev);
+remove:
+       nvkm_device_tegra_remove_iommu(tdev);
+free:
+       kfree(tdev);
+       return ret;
 }
 #else
 int
index 04f6045..a74c5dd 100644 (file)
@@ -9,7 +9,7 @@ nvkm-y += nvkm/engine/disp/gf119.o
 nvkm-y += nvkm/engine/disp/gk104.o
 nvkm-y += nvkm/engine/disp/gk110.o
 nvkm-y += nvkm/engine/disp/gm107.o
-nvkm-y += nvkm/engine/disp/gm204.o
+nvkm-y += nvkm/engine/disp/gm200.o
 
 nvkm-y += nvkm/engine/disp/outp.o
 nvkm-y += nvkm/engine/disp/outpdp.o
@@ -18,7 +18,7 @@ nvkm-y += nvkm/engine/disp/piornv50.o
 nvkm-y += nvkm/engine/disp/sornv50.o
 nvkm-y += nvkm/engine/disp/sorg94.o
 nvkm-y += nvkm/engine/disp/sorgf119.o
-nvkm-y += nvkm/engine/disp/sorgm204.o
+nvkm-y += nvkm/engine/disp/sorgm200.o
 nvkm-y += nvkm/engine/disp/dport.o
 
 nvkm-y += nvkm/engine/disp/conn.o
@@ -43,7 +43,7 @@ nvkm-y += nvkm/engine/disp/rootgf119.o
 nvkm-y += nvkm/engine/disp/rootgk104.o
 nvkm-y += nvkm/engine/disp/rootgk110.o
 nvkm-y += nvkm/engine/disp/rootgm107.o
-nvkm-y += nvkm/engine/disp/rootgm204.o
+nvkm-y += nvkm/engine/disp/rootgm200.o
 
 nvkm-y += nvkm/engine/disp/channv50.o
 nvkm-y += nvkm/engine/disp/changf119.o
@@ -68,7 +68,7 @@ nvkm-y += nvkm/engine/disp/coregf119.o
 nvkm-y += nvkm/engine/disp/coregk104.o
 nvkm-y += nvkm/engine/disp/coregk110.o
 nvkm-y += nvkm/engine/disp/coregm107.o
-nvkm-y += nvkm/engine/disp/coregm204.o
+nvkm-y += nvkm/engine/disp/coregm200.o
 
 nvkm-y += nvkm/engine/disp/ovlynv50.o
 nvkm-y += nvkm/engine/disp/ovlyg84.o
@@ -27,8 +27,8 @@
 #include <nvif/class.h>
 
 const struct nv50_disp_dmac_oclass
-gm204_disp_core_oclass = {
-       .base.oclass = GM204_DISP_CORE_CHANNEL_DMA,
+gm200_disp_core_oclass = {
+       .base.oclass = GM200_DISP_CORE_CHANNEL_DMA,
        .base.minver = 0,
        .base.maxver = 0,
        .ctor = nv50_disp_core_new,
index c748ca2..fc84eb8 100644 (file)
@@ -87,5 +87,5 @@ extern const struct nv50_disp_dmac_oclass gk110_disp_base_oclass;
 
 extern const struct nv50_disp_dmac_oclass gm107_disp_core_oclass;
 
-extern const struct nv50_disp_dmac_oclass gm204_disp_core_oclass;
+extern const struct nv50_disp_dmac_oclass gm200_disp_core_oclass;
 #endif
index 74e2f7c..9688970 100644 (file)
@@ -328,6 +328,7 @@ nvkm_dp_train(struct work_struct *w)
                .outp = outp,
        }, *dp = &_dp;
        u32 datarate = 0;
+       u8  pwr;
        int ret;
 
        if (!outp->base.info.location && disp->func->sor.magic)
@@ -355,6 +356,15 @@ nvkm_dp_train(struct work_struct *w)
        /* disable link interrupt handling during link training */
        nvkm_notify_put(&outp->irq);
 
+       /* ensure sink is not in a low-power state */
+       if (!nvkm_rdaux(outp->aux, DPCD_SC00, &pwr, 1)) {
+               if ((pwr & DPCD_SC00_SET_POWER) != DPCD_SC00_SET_POWER_D0) {
+                       pwr &= ~DPCD_SC00_SET_POWER;
+                       pwr |=  DPCD_SC00_SET_POWER_D0;
+                       nvkm_wraux(outp->aux, DPCD_SC00, &pwr, 1);
+               }
+       }
+
        /* enable down-spreading and execute pre-train script from vbios */
        dp_link_train_init(dp, outp->dpcd[3] & 0x01);
 
index 9596290..6e10c5e 100644 (file)
 #define DPCD_LS0C_LANE1_POST_CURSOR2                                       0x0c
 #define DPCD_LS0C_LANE0_POST_CURSOR2                                       0x03
 
+/* DPCD Sink Control */
+#define DPCD_SC00                                                       0x00600
+#define DPCD_SC00_SET_POWER                                                0x03
+#define DPCD_SC00_SET_POWER_D0                                             0x01
+#define DPCD_SC00_SET_POWER_D3                                             0x03
+
 void nvkm_dp_train(struct work_struct *);
 #endif
 #include "rootnv50.h"
 
 static const struct nv50_disp_func
-gm204_disp = {
+gm200_disp = {
        .intr = gf119_disp_intr,
        .uevent = &gf119_disp_chan_uevent,
        .super = gf119_disp_intr_supervisor,
-       .root = &gm204_disp_root_oclass,
+       .root = &gm200_disp_root_oclass,
        .head.vblank_init = gf119_disp_vblank_init,
        .head.vblank_fini = gf119_disp_vblank_fini,
        .head.scanoutpos = gf119_disp_root_scanoutpos,
        .outp.internal.crt = nv50_dac_output_new,
        .outp.internal.tmds = nv50_sor_output_new,
        .outp.internal.lvds = nv50_sor_output_new,
-       .outp.internal.dp = gm204_sor_dp_new,
+       .outp.internal.dp = gm200_sor_dp_new,
        .dac.nr = 3,
        .dac.power = nv50_dac_power,
        .dac.sense = nv50_dac_sense,
@@ -44,11 +44,11 @@ gm204_disp = {
        .sor.power = nv50_sor_power,
        .sor.hda_eld = gf119_hda_eld,
        .sor.hdmi = gk104_hdmi_ctrl,
-       .sor.magic = gm204_sor_magic,
+       .sor.magic = gm200_sor_magic,
 };
 
 int
-gm204_disp_new(struct nvkm_device *device, int index, struct nvkm_disp **pdisp)
+gm200_disp_new(struct nvkm_device *device, int index, struct nvkm_disp **pdisp)
 {
-       return gf119_disp_new_(&gm204_disp, device, index, pdisp);
+       return gf119_disp_new_(&gm200_disp, device, index, pdisp);
 }
index 2590fec..0772719 100644 (file)
@@ -42,7 +42,7 @@ int nv50_pior_output_new(struct nvkm_disp *, int, struct dcb_output *,
 
 u32 g94_sor_dp_lane_map(struct nvkm_device *, u8 lane);
 
-void gm204_sor_magic(struct nvkm_output *outp);
+void gm200_sor_magic(struct nvkm_output *outp);
 
 #define OUTP_MSG(o,l,f,a...) do {                                              \
        struct nvkm_output *_outp = (o);                                       \
index 731136d..e9067ba 100644 (file)
@@ -63,6 +63,6 @@ int gf119_sor_dp_new(struct nvkm_disp *, int, struct dcb_output *,
                     struct nvkm_output **);
 int gf119_sor_dp_lnk_ctl(struct nvkm_output_dp *, int, int, bool);
 
-int  gm204_sor_dp_new(struct nvkm_disp *, int, struct dcb_output *,
+int  gm200_sor_dp_new(struct nvkm_disp *, int, struct dcb_output *,
                      struct nvkm_output **);
 #endif
 #include <nvif/class.h>
 
 static const struct nv50_disp_root_func
-gm204_disp_root = {
+gm200_disp_root = {
        .init = gf119_disp_root_init,
        .fini = gf119_disp_root_fini,
        .dmac = {
-               &gm204_disp_core_oclass,
+               &gm200_disp_core_oclass,
                &gk110_disp_base_oclass,
                &gk104_disp_ovly_oclass,
        },
@@ -42,17 +42,17 @@ gm204_disp_root = {
 };
 
 static int
-gm204_disp_root_new(struct nvkm_disp *disp, const struct nvkm_oclass *oclass,
+gm200_disp_root_new(struct nvkm_disp *disp, const struct nvkm_oclass *oclass,
                    void *data, u32 size, struct nvkm_object **pobject)
 {
-       return nv50_disp_root_new_(&gm204_disp_root, disp, oclass,
+       return nv50_disp_root_new_(&gm200_disp_root, disp, oclass,
                                   data, size, pobject);
 }
 
 const struct nvkm_disp_oclass
-gm204_disp_root_oclass = {
-       .base.oclass = GM204_DISP,
+gm200_disp_root_oclass = {
+       .base.oclass = GM200_DISP,
        .base.minver = -1,
        .base.maxver = -1,
-       .ctor = gm204_disp_root_new,
+       .ctor = gm200_disp_root_new,
 };
index 5b2c903..cb449ed 100644 (file)
@@ -39,5 +39,5 @@ extern const struct nvkm_disp_oclass gf119_disp_root_oclass;
 extern const struct nvkm_disp_oclass gk104_disp_root_oclass;
 extern const struct nvkm_disp_oclass gk110_disp_root_oclass;
 extern const struct nvkm_disp_oclass gm107_disp_root_oclass;
-extern const struct nvkm_disp_oclass gm204_disp_root_oclass;
+extern const struct nvkm_disp_oclass gm200_disp_root_oclass;
 #endif
 #include <subdev/timer.h>
 
 static inline u32
-gm204_sor_soff(struct nvkm_output_dp *outp)
+gm200_sor_soff(struct nvkm_output_dp *outp)
 {
        return (ffs(outp->base.info.or) - 1) * 0x800;
 }
 
 static inline u32
-gm204_sor_loff(struct nvkm_output_dp *outp)
+gm200_sor_loff(struct nvkm_output_dp *outp)
 {
-       return gm204_sor_soff(outp) + !(outp->base.info.sorconf.link & 1) * 0x80;
+       return gm200_sor_soff(outp) + !(outp->base.info.sorconf.link & 1) * 0x80;
 }
 
 void
-gm204_sor_magic(struct nvkm_output *outp)
+gm200_sor_magic(struct nvkm_output *outp)
 {
        struct nvkm_device *device = outp->disp->engine.subdev.device;
        const u32 soff = outp->or * 0x100;
@@ -51,16 +51,16 @@ gm204_sor_magic(struct nvkm_output *outp)
 }
 
 static inline u32
-gm204_sor_dp_lane_map(struct nvkm_device *device, u8 lane)
+gm200_sor_dp_lane_map(struct nvkm_device *device, u8 lane)
 {
        return lane * 0x08;
 }
 
 static int
-gm204_sor_dp_pattern(struct nvkm_output_dp *outp, int pattern)
+gm200_sor_dp_pattern(struct nvkm_output_dp *outp, int pattern)
 {
        struct nvkm_device *device = outp->base.disp->engine.subdev.device;
-       const u32 soff = gm204_sor_soff(outp);
+       const u32 soff = gm200_sor_soff(outp);
        const u32 data = 0x01010101 * pattern;
        if (outp->base.info.sorconf.link & 1)
                nvkm_mask(device, 0x61c110 + soff, 0x0f0f0f0f, data);
@@ -70,15 +70,15 @@ gm204_sor_dp_pattern(struct nvkm_output_dp *outp, int pattern)
 }
 
 static int
-gm204_sor_dp_lnk_pwr(struct nvkm_output_dp *outp, int nr)
+gm200_sor_dp_lnk_pwr(struct nvkm_output_dp *outp, int nr)
 {
        struct nvkm_device *device = outp->base.disp->engine.subdev.device;
-       const u32 soff = gm204_sor_soff(outp);
-       const u32 loff = gm204_sor_loff(outp);
+       const u32 soff = gm200_sor_soff(outp);
+       const u32 loff = gm200_sor_loff(outp);
        u32 mask = 0, i;
 
        for (i = 0; i < nr; i++)
-               mask |= 1 << (gm204_sor_dp_lane_map(device, i) >> 3);
+               mask |= 1 << (gm200_sor_dp_lane_map(device, i) >> 3);
 
        nvkm_mask(device, 0x61c130 + loff, 0x0000000f, mask);
        nvkm_mask(device, 0x61c034 + soff, 0x80000000, 0x80000000);
@@ -90,13 +90,13 @@ gm204_sor_dp_lnk_pwr(struct nvkm_output_dp *outp, int nr)
 }
 
 static int
-gm204_sor_dp_drv_ctl(struct nvkm_output_dp *outp,
+gm200_sor_dp_drv_ctl(struct nvkm_output_dp *outp,
                     int ln, int vs, int pe, int pc)
 {
        struct nvkm_device *device = outp->base.disp->engine.subdev.device;
        struct nvkm_bios *bios = device->bios;
-       const u32 shift = gm204_sor_dp_lane_map(device, ln);
-       const u32 loff = gm204_sor_loff(outp);
+       const u32 shift = gm200_sor_dp_lane_map(device, ln);
+       const u32 loff = gm200_sor_loff(outp);
        u32 addr, data[4];
        u8  ver, hdr, cnt, len;
        struct nvbios_dpout info;
@@ -128,16 +128,16 @@ gm204_sor_dp_drv_ctl(struct nvkm_output_dp *outp,
 }
 
 static const struct nvkm_output_dp_func
-gm204_sor_dp_func = {
-       .pattern = gm204_sor_dp_pattern,
-       .lnk_pwr = gm204_sor_dp_lnk_pwr,
+gm200_sor_dp_func = {
+       .pattern = gm200_sor_dp_pattern,
+       .lnk_pwr = gm200_sor_dp_lnk_pwr,
        .lnk_ctl = gf119_sor_dp_lnk_ctl,
-       .drv_ctl = gm204_sor_dp_drv_ctl,
+       .drv_ctl = gm200_sor_dp_drv_ctl,
 };
 
 int
-gm204_sor_dp_new(struct nvkm_disp *disp, int index, struct dcb_output *dcbE,
+gm200_sor_dp_new(struct nvkm_disp *disp, int index, struct dcb_output *dcbE,
                 struct nvkm_output **poutp)
 {
-       return nvkm_output_dp_new_(&gm204_sor_dp_func, disp, index, dcbE, poutp);
+       return nvkm_output_dp_new_(&gm200_sor_dp_func, disp, index, dcbE, poutp);
 }
index 74993c1..65e5d29 100644 (file)
@@ -7,9 +7,11 @@ nvkm-y += nvkm/engine/fifo/nv50.o
 nvkm-y += nvkm/engine/fifo/g84.o
 nvkm-y += nvkm/engine/fifo/gf100.o
 nvkm-y += nvkm/engine/fifo/gk104.o
+nvkm-y += nvkm/engine/fifo/gk110.o
 nvkm-y += nvkm/engine/fifo/gk208.o
 nvkm-y += nvkm/engine/fifo/gk20a.o
-nvkm-y += nvkm/engine/fifo/gm204.o
+nvkm-y += nvkm/engine/fifo/gm107.o
+nvkm-y += nvkm/engine/fifo/gm200.o
 nvkm-y += nvkm/engine/fifo/gm20b.o
 
 nvkm-y += nvkm/engine/fifo/chan.o
@@ -27,4 +29,5 @@ nvkm-y += nvkm/engine/fifo/gpfifonv50.o
 nvkm-y += nvkm/engine/fifo/gpfifog84.o
 nvkm-y += nvkm/engine/fifo/gpfifogf100.o
 nvkm-y += nvkm/engine/fifo/gpfifogk104.o
-nvkm-y += nvkm/engine/fifo/gpfifogm204.o
+nvkm-y += nvkm/engine/fifo/gpfifogk110.o
+nvkm-y += nvkm/engine/fifo/gpfifogm200.o
index 97bdddb..e06f4d4 100644 (file)
@@ -7,7 +7,7 @@
 struct gk104_fifo_chan {
        struct nvkm_fifo_chan base;
        struct gk104_fifo *fifo;
-       int engine;
+       int runl;
 
        struct list_head head;
        bool killed;
@@ -25,5 +25,6 @@ int gk104_fifo_gpfifo_new(struct nvkm_fifo *, const struct nvkm_oclass *,
                          void *data, u32 size, struct nvkm_object **);
 
 extern const struct nvkm_fifo_chan_oclass gk104_fifo_gpfifo_oclass;
-extern const struct nvkm_fifo_chan_oclass gm204_fifo_gpfifo_oclass;
+extern const struct nvkm_fifo_chan_oclass gk110_fifo_gpfifo_oclass;
+extern const struct nvkm_fifo_chan_oclass gm200_fifo_gpfifo_oclass;
 #endif
index 36a39c7..352a0ba 100644 (file)
@@ -54,6 +54,7 @@ gf100_fifo_runlist_commit(struct gf100_fifo *fifo)
        struct nvkm_device *device = subdev->device;
        struct nvkm_memory *cur;
        int nr = 0;
+       int target;
 
        mutex_lock(&subdev->mutex);
        cur = fifo->runlist.mem[fifo->runlist.active];
@@ -67,7 +68,10 @@ gf100_fifo_runlist_commit(struct gf100_fifo *fifo)
        }
        nvkm_done(cur);
 
-       nvkm_wr32(device, 0x002270, nvkm_memory_addr(cur) >> 12);
+       target = (nvkm_memory_target(cur) == NVKM_MEM_TARGET_HOST) ? 0x3 : 0x0;
+
+       nvkm_wr32(device, 0x002270, (nvkm_memory_addr(cur) >> 12) |
+                                   (target << 28));
        nvkm_wr32(device, 0x002274, 0x01f00000 | nr);
 
        if (wait_event_timeout(fifo->runlist.wait,
@@ -130,9 +134,9 @@ gf100_fifo_engine(struct gf100_fifo *fifo, u32 engn)
 }
 
 static void
-gf100_fifo_recover_work(struct work_struct *work)
+gf100_fifo_recover_work(struct work_struct *w)
 {
-       struct gf100_fifo *fifo = container_of(work, typeof(*fifo), fault);
+       struct gf100_fifo *fifo = container_of(w, typeof(*fifo), recover.work);
        struct nvkm_device *device = fifo->base.engine.subdev.device;
        struct nvkm_engine *engine;
        unsigned long flags;
@@ -140,15 +144,15 @@ gf100_fifo_recover_work(struct work_struct *work)
        u64 mask, todo;
 
        spin_lock_irqsave(&fifo->base.lock, flags);
-       mask = fifo->mask;
-       fifo->mask = 0ULL;
+       mask = fifo->recover.mask;
+       fifo->recover.mask = 0ULL;
        spin_unlock_irqrestore(&fifo->base.lock, flags);
 
-       for (todo = mask; engn = __ffs64(todo), todo; todo &= ~(1 << engn))
+       for (todo = mask; engn = __ffs64(todo), todo; todo &= ~BIT_ULL(engn))
                engm |= 1 << gf100_fifo_engidx(fifo, engn);
        nvkm_mask(device, 0x002630, engm, engm);
 
-       for (todo = mask; engn = __ffs64(todo), todo; todo &= ~(1 << engn)) {
+       for (todo = mask; engn = __ffs64(todo), todo; todo &= ~BIT_ULL(engn)) {
                if ((engine = nvkm_device_engine(device, engn))) {
                        nvkm_subdev_fini(&engine->subdev, false);
                        WARN_ON(nvkm_subdev_init(&engine->subdev));
@@ -176,8 +180,8 @@ gf100_fifo_recover(struct gf100_fifo *fifo, struct nvkm_engine *engine,
        list_del_init(&chan->head);
        chan->killed = true;
 
-       fifo->mask |= 1ULL << engine->subdev.index;
-       schedule_work(&fifo->fault);
+       fifo->recover.mask |= 1ULL << engine->subdev.index;
+       schedule_work(&fifo->recover.work);
 }
 
 static const struct nvkm_enum
@@ -330,7 +334,7 @@ gf100_fifo_intr_fault(struct gf100_fifo *fifo, int unit)
                snprintf(gpcid, sizeof(gpcid), "GPC%d/", gpc);
        }
 
-       if (eu) {
+       if (eu && eu->data2) {
                switch (eu->data2) {
                case NVKM_SUBDEV_BAR:
                        nvkm_mask(device, 0x001704, 0x00000000, 0x00000000);
@@ -544,9 +548,16 @@ static int
 gf100_fifo_oneinit(struct nvkm_fifo *base)
 {
        struct gf100_fifo *fifo = gf100_fifo(base);
-       struct nvkm_device *device = fifo->base.engine.subdev.device;
+       struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
+       struct nvkm_device *device = subdev->device;
        int ret;
 
+       /* Determine number of PBDMAs by checking valid enable bits. */
+       nvkm_wr32(device, 0x002204, 0xffffffff);
+       fifo->pbdma_nr = hweight32(nvkm_rd32(device, 0x002204));
+       nvkm_debug(subdev, "%d PBDMA(s)\n", fifo->pbdma_nr);
+
+
        ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, 0x1000, 0x1000,
                              false, &fifo->runlist.mem[0]);
        if (ret)
@@ -576,25 +587,22 @@ static void
 gf100_fifo_fini(struct nvkm_fifo *base)
 {
        struct gf100_fifo *fifo = gf100_fifo(base);
-       flush_work(&fifo->fault);
+       flush_work(&fifo->recover.work);
 }
 
 static void
 gf100_fifo_init(struct nvkm_fifo *base)
 {
        struct gf100_fifo *fifo = gf100_fifo(base);
-       struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
-       struct nvkm_device *device = subdev->device;
+       struct nvkm_device *device = fifo->base.engine.subdev.device;
        int i;
 
-       nvkm_wr32(device, 0x000204, 0xffffffff);
-       nvkm_wr32(device, 0x002204, 0xffffffff);
-
-       fifo->spoon_nr = hweight32(nvkm_rd32(device, 0x002204));
-       nvkm_debug(subdev, "%d PBDMA unit(s)\n", fifo->spoon_nr);
+       /* Enable PBDMAs. */
+       nvkm_wr32(device, 0x000204, (1 << fifo->pbdma_nr) - 1);
+       nvkm_wr32(device, 0x002204, (1 << fifo->pbdma_nr) - 1);
 
-       /* assign engines to PBDMAs */
-       if (fifo->spoon_nr >= 3) {
+       /* Assign engines to PBDMAs. */
+       if (fifo->pbdma_nr >= 3) {
                nvkm_wr32(device, 0x002208, ~(1 << 0)); /* PGRAPH */
                nvkm_wr32(device, 0x00220c, ~(1 << 1)); /* PVP */
                nvkm_wr32(device, 0x002210, ~(1 << 1)); /* PMSPP */
@@ -604,7 +612,7 @@ gf100_fifo_init(struct nvkm_fifo *base)
        }
 
        /* PBDMA[n] */
-       for (i = 0; i < fifo->spoon_nr; i++) {
+       for (i = 0; i < fifo->pbdma_nr; i++) {
                nvkm_mask(device, 0x04013c + (i * 0x2000), 0x10000100, 0x00000000);
                nvkm_wr32(device, 0x040108 + (i * 0x2000), 0xffffffff); /* INTR */
                nvkm_wr32(device, 0x04010c + (i * 0x2000), 0xfffffeff); /* INTREN */
@@ -652,7 +660,7 @@ gf100_fifo_new(struct nvkm_device *device, int index, struct nvkm_fifo **pfifo)
        if (!(fifo = kzalloc(sizeof(*fifo), GFP_KERNEL)))
                return -ENOMEM;
        INIT_LIST_HEAD(&fifo->chan);
-       INIT_WORK(&fifo->fault, gf100_fifo_recover_work);
+       INIT_WORK(&fifo->recover.work, gf100_fifo_recover_work);
        *pfifo = &fifo->base;
 
        return nvkm_fifo_ctor(&gf100_fifo, device, index, 128, &fifo->base);
index 08c33c3..70db58e 100644 (file)
@@ -11,8 +11,12 @@ struct gf100_fifo {
 
        struct list_head chan;
 
-       struct work_struct fault;
-       u64 mask;
+       struct {
+               struct work_struct work;
+               u64 mask;
+       } recover;
+
+       int pbdma_nr;
 
        struct {
                struct nvkm_memory *mem[2];
@@ -24,7 +28,6 @@ struct gf100_fifo {
                struct nvkm_memory *mem;
                struct nvkm_vma bar;
        } user;
-       int spoon_nr;
 };
 
 void gf100_fifo_intr_engine(struct gf100_fifo *);
index 4fcd147..68acb36 100644 (file)
@@ -47,34 +47,41 @@ gk104_fifo_uevent_init(struct nvkm_fifo *fifo)
 }
 
 void
-gk104_fifo_runlist_commit(struct gk104_fifo *fifo, u32 engine)
+gk104_fifo_runlist_commit(struct gk104_fifo *fifo, int runl)
 {
-       struct gk104_fifo_engn *engn = &fifo->engine[engine];
        struct gk104_fifo_chan *chan;
        struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
        struct nvkm_device *device = subdev->device;
-       struct nvkm_memory *cur;
+       struct nvkm_memory *mem;
        int nr = 0;
+       int target;
 
        mutex_lock(&subdev->mutex);
-       cur = engn->runlist[engn->cur_runlist];
-       engn->cur_runlist = !engn->cur_runlist;
+       mem = fifo->runlist[runl].mem[fifo->runlist[runl].next];
+       fifo->runlist[runl].next = !fifo->runlist[runl].next;
 
-       nvkm_kmap(cur);
-       list_for_each_entry(chan, &engn->chan, head) {
-               nvkm_wo32(cur, (nr * 8) + 0, chan->base.chid);
-               nvkm_wo32(cur, (nr * 8) + 4, 0x00000000);
+       nvkm_kmap(mem);
+       list_for_each_entry(chan, &fifo->runlist[runl].chan, head) {
+               nvkm_wo32(mem, (nr * 8) + 0, chan->base.chid);
+               nvkm_wo32(mem, (nr * 8) + 4, 0x00000000);
                nr++;
        }
-       nvkm_done(cur);
-
-       nvkm_wr32(device, 0x002270, nvkm_memory_addr(cur) >> 12);
-       nvkm_wr32(device, 0x002274, (engine << 20) | nr);
-
-       if (wait_event_timeout(engn->wait, !(nvkm_rd32(device, 0x002284 +
-                              (engine * 0x08)) & 0x00100000),
-                               msecs_to_jiffies(2000)) == 0)
-               nvkm_error(subdev, "runlist %d update timeout\n", engine);
+       nvkm_done(mem);
+
+       if (nvkm_memory_target(mem) == NVKM_MEM_TARGET_VRAM)
+               target = 0;
+       else
+               target = 3;
+
+       nvkm_wr32(device, 0x002270, (nvkm_memory_addr(mem) >> 12) |
+                                   (target << 28));
+       nvkm_wr32(device, 0x002274, (runl << 20) | nr);
+
+       if (wait_event_timeout(fifo->runlist[runl].wait,
+                              !(nvkm_rd32(device, 0x002284 + (runl * 0x08))
+                                      & 0x00100000),
+                              msecs_to_jiffies(2000)) == 0)
+               nvkm_error(subdev, "runlist %d update timeout\n", runl);
        mutex_unlock(&subdev->mutex);
 }
 
@@ -90,58 +97,51 @@ void
 gk104_fifo_runlist_insert(struct gk104_fifo *fifo, struct gk104_fifo_chan *chan)
 {
        mutex_lock(&fifo->base.engine.subdev.mutex);
-       list_add_tail(&chan->head, &fifo->engine[chan->engine].chan);
+       list_add_tail(&chan->head, &fifo->runlist[chan->runl].chan);
        mutex_unlock(&fifo->base.engine.subdev.mutex);
 }
 
-static inline struct nvkm_engine *
-gk104_fifo_engine(struct gk104_fifo *fifo, u32 engn)
-{
-       struct nvkm_device *device = fifo->base.engine.subdev.device;
-       u64 subdevs = gk104_fifo_engine_subdev(engn);
-       if (subdevs)
-               return nvkm_device_engine(device, __ffs(subdevs));
-       return NULL;
-}
-
 static void
-gk104_fifo_recover_work(struct work_struct *work)
+gk104_fifo_recover_work(struct work_struct *w)
 {
-       struct gk104_fifo *fifo = container_of(work, typeof(*fifo), fault);
+       struct gk104_fifo *fifo = container_of(w, typeof(*fifo), recover.work);
        struct nvkm_device *device = fifo->base.engine.subdev.device;
        struct nvkm_engine *engine;
        unsigned long flags;
-       u32 engn, engm = 0;
-       u64 mask, todo;
+       u32 engm, runm, todo;
+       int engn, runl;
 
        spin_lock_irqsave(&fifo->base.lock, flags);
-       mask = fifo->mask;
-       fifo->mask = 0ULL;
+       runm = fifo->recover.runm;
+       engm = fifo->recover.engm;
+       fifo->recover.engm = 0;
+       fifo->recover.runm = 0;
        spin_unlock_irqrestore(&fifo->base.lock, flags);
 
-       for (todo = mask; engn = __ffs64(todo), todo; todo &= ~(1 << engn))
-               engm |= 1 << gk104_fifo_subdev_engine(engn);
-       nvkm_mask(device, 0x002630, engm, engm);
+       nvkm_mask(device, 0x002630, runm, runm);
 
-       for (todo = mask; engn = __ffs64(todo), todo; todo &= ~(1 << engn)) {
-               if ((engine = nvkm_device_engine(device, engn))) {
+       for (todo = engm; engn = __ffs(todo), todo; todo &= ~BIT(engn)) {
+               if ((engine = fifo->engine[engn].engine)) {
                        nvkm_subdev_fini(&engine->subdev, false);
                        WARN_ON(nvkm_subdev_init(&engine->subdev));
                }
-               gk104_fifo_runlist_commit(fifo, gk104_fifo_subdev_engine(engn));
        }
 
-       nvkm_wr32(device, 0x00262c, engm);
-       nvkm_mask(device, 0x002630, engm, 0x00000000);
+       for (todo = runm; runl = __ffs(todo), todo; todo &= ~BIT(runl))
+               gk104_fifo_runlist_commit(fifo, runl);
+
+       nvkm_wr32(device, 0x00262c, runm);
+       nvkm_mask(device, 0x002630, runm, 0x00000000);
 }
 
 static void
 gk104_fifo_recover(struct gk104_fifo *fifo, struct nvkm_engine *engine,
-                 struct gk104_fifo_chan *chan)
+                  struct gk104_fifo_chan *chan)
 {
        struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
        struct nvkm_device *device = subdev->device;
        u32 chid = chan->base.chid;
+       int engn;
 
        nvkm_error(subdev, "%s engine fault on channel %d, recovering...\n",
                   nvkm_subdev_name[engine->subdev.index], chid);
@@ -151,8 +151,15 @@ gk104_fifo_recover(struct gk104_fifo *fifo, struct nvkm_engine *engine,
        list_del_init(&chan->head);
        chan->killed = true;
 
-       fifo->mask |= 1ULL << engine->subdev.index;
-       schedule_work(&fifo->fault);
+       for (engn = 0; engn < fifo->engine_nr; engn++) {
+               if (fifo->engine[engn].engine == engine) {
+                       fifo->recover.engm |= BIT(engn);
+                       break;
+               }
+       }
+
+       fifo->recover.runm |= BIT(chan->runl);
+       schedule_work(&fifo->recover.work);
 }
 
 static const struct nvkm_enum
@@ -189,32 +196,31 @@ static void
 gk104_fifo_intr_sched_ctxsw(struct gk104_fifo *fifo)
 {
        struct nvkm_device *device = fifo->base.engine.subdev.device;
-       struct nvkm_engine *engine;
        struct gk104_fifo_chan *chan;
        unsigned long flags;
        u32 engn;
 
        spin_lock_irqsave(&fifo->base.lock, flags);
-       for (engn = 0; engn < ARRAY_SIZE(fifo->engine); engn++) {
+       for (engn = 0; engn < fifo->engine_nr; engn++) {
+               struct nvkm_engine *engine = fifo->engine[engn].engine;
+               int runl = fifo->engine[engn].runl;
                u32 stat = nvkm_rd32(device, 0x002640 + (engn * 0x08));
                u32 busy = (stat & 0x80000000);
-               u32 next = (stat & 0x07ff0000) >> 16;
+               u32 next = (stat & 0x0fff0000) >> 16;
                u32 chsw = (stat & 0x00008000);
                u32 save = (stat & 0x00004000);
                u32 load = (stat & 0x00002000);
-               u32 prev = (stat & 0x000007ff);
+               u32 prev = (stat & 0x00000fff);
                u32 chid = load ? next : prev;
                (void)save;
 
-               if (busy && chsw) {
-                       list_for_each_entry(chan, &fifo->engine[engn].chan, head) {
-                               if (chan->base.chid == chid) {
-                                       engine = gk104_fifo_engine(fifo, engn);
-                                       if (!engine)
-                                               break;
-                                       gk104_fifo_recover(fifo, engine, chan);
-                                       break;
-                               }
+               if (!busy || !chsw)
+                       continue;
+
+               list_for_each_entry(chan, &fifo->runlist[runl].chan, head) {
+                       if (chan->base.chid == chid && engine) {
+                               gk104_fifo_recover(fifo, engine, chan);
+                               break;
                        }
                }
        }
@@ -395,7 +401,7 @@ gk104_fifo_intr_fault(struct gk104_fifo *fifo, int unit)
                snprintf(gpcid, sizeof(gpcid), "GPC%d/", gpc);
        }
 
-       if (eu) {
+       if (eu && eu->data2) {
                switch (eu->data2) {
                case NVKM_SUBDEV_BAR:
                        nvkm_mask(device, 0x001704, 0x00000000, 0x00000000);
@@ -484,9 +490,10 @@ gk104_fifo_intr_pbdma_0(struct gk104_fifo *fifo, int unit)
                        if (nvkm_sw_mthd(device->sw, chid, subc, mthd, data))
                                show &= ~0x00800000;
                }
-               nvkm_wr32(device, 0x0400c0 + (unit * 0x2000), 0x80600008);
        }
 
+       nvkm_wr32(device, 0x0400c0 + (unit * 0x2000), 0x80600008);
+
        if (show) {
                nvkm_snprintbf(msg, sizeof(msg), gk104_fifo_pbdma_intr_0, show);
                chan = nvkm_fifo_chan_chid(&fifo->base, chid, &flags);
@@ -537,10 +544,10 @@ gk104_fifo_intr_runlist(struct gk104_fifo *fifo)
        struct nvkm_device *device = fifo->base.engine.subdev.device;
        u32 mask = nvkm_rd32(device, 0x002a00);
        while (mask) {
-               u32 engn = __ffs(mask);
-               wake_up(&fifo->engine[engn].wait);
-               nvkm_wr32(device, 0x002a00, 1 << engn);
-               mask &= ~(1 << engn);
+               int runl = __ffs(mask);
+               wake_up(&fifo->runlist[runl].wait);
+               nvkm_wr32(device, 0x002a00, 1 << runl);
+               mask &= ~(1 << runl);
        }
 }
 
@@ -647,7 +654,7 @@ gk104_fifo_fini(struct nvkm_fifo *base)
 {
        struct gk104_fifo *fifo = gk104_fifo(base);
        struct nvkm_device *device = fifo->base.engine.subdev.device;
-       flush_work(&fifo->fault);
+       flush_work(&fifo->recover.work);
        /* allow mmu fault interrupts, even when we're not using fifo */
        nvkm_mask(device, 0x002140, 0x10000000, 0x10000000);
 }
@@ -656,24 +663,122 @@ int
 gk104_fifo_oneinit(struct nvkm_fifo *base)
 {
        struct gk104_fifo *fifo = gk104_fifo(base);
-       struct nvkm_device *device = fifo->base.engine.subdev.device;
+       struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
+       struct nvkm_device *device = subdev->device;
        int ret, i;
+       u32 *map;
+
+       /* Determine number of PBDMAs by checking valid enable bits. */
+       nvkm_wr32(device, 0x000204, 0xffffffff);
+       fifo->pbdma_nr = hweight32(nvkm_rd32(device, 0x000204));
+       nvkm_debug(subdev, "%d PBDMA(s)\n", fifo->pbdma_nr);
+
+       /* Read PBDMA->runlist(s) mapping from HW. */
+       if (!(map = kzalloc(sizeof(*map) * fifo->pbdma_nr, GFP_KERNEL)))
+               return -ENOMEM;
+
+       for (i = 0; i < fifo->pbdma_nr; i++)
+               map[i] = nvkm_rd32(device, 0x002390 + (i * 0x04));
+
+       /* Read device topology from HW. */
+       for (i = 0; i < 64; i++) {
+               int type = -1, pbid = -1, engidx = -1;
+               int engn = -1, runl = -1, intr = -1, mcen = -1;
+               int fault = -1, j;
+               u32 data, addr = 0;
+
+               do {
+                       data = nvkm_rd32(device, 0x022700 + (i * 0x04));
+                       nvkm_trace(subdev, "%02x: %08x\n", i, data);
+                       switch (data & 0x00000003) {
+                       case 0x00000000: /* NOT_VALID */
+                               continue;
+                       case 0x00000001: /* DATA */
+                               addr  = (data & 0x00fff000);
+                               fault = (data & 0x000000f8) >> 3;
+                               break;
+                       case 0x00000002: /* ENUM */
+                               if (data & 0x00000020)
+                                       engn = (data & 0x3c000000) >> 26;
+                               if (data & 0x00000010)
+                                       runl = (data & 0x01e00000) >> 21;
+                               if (data & 0x00000008)
+                                       intr = (data & 0x000f8000) >> 15;
+                               if (data & 0x00000004)
+                                       mcen = (data & 0x00003e00) >> 9;
+                               break;
+                       case 0x00000003: /* ENGINE_TYPE */
+                               type = (data & 0x7ffffffc) >> 2;
+                               break;
+                       }
+               } while ((data & 0x80000000) && ++i < 64);
+
+               if (!data)
+                       continue;
+
+               /* Determine which PBDMA handles requests for this engine. */
+               for (j = 0; runl >= 0 && j < fifo->pbdma_nr; j++) {
+                       if (map[j] & (1 << runl)) {
+                               pbid = j;
+                               break;
+                       }
+               }
+
+               /* Translate engine type to NVKM engine identifier. */
+               switch (type) {
+               case 0x00000000: engidx = NVKM_ENGINE_GR; break;
+               case 0x00000001: engidx = NVKM_ENGINE_CE0; break;
+               case 0x00000002: engidx = NVKM_ENGINE_CE1; break;
+               case 0x00000003: engidx = NVKM_ENGINE_CE2; break;
+               case 0x00000008: engidx = NVKM_ENGINE_MSPDEC; break;
+               case 0x00000009: engidx = NVKM_ENGINE_MSPPP; break;
+               case 0x0000000a: engidx = NVKM_ENGINE_MSVLD; break;
+               case 0x0000000b: engidx = NVKM_ENGINE_MSENC; break;
+               case 0x0000000c: engidx = NVKM_ENGINE_VIC; break;
+               case 0x0000000d: engidx = NVKM_ENGINE_SEC; break;
+               case 0x0000000e: engidx = NVKM_ENGINE_NVENC0; break;
+               case 0x0000000f: engidx = NVKM_ENGINE_NVENC1; break;
+               case 0x00000010: engidx = NVKM_ENGINE_NVDEC; break;
+                       break;
+               default:
+                       break;
+               }
+
+               nvkm_debug(subdev, "%02x (%8s): engine %2d runlist %2d "
+                                  "pbdma %2d intr %2d reset %2d "
+                                  "fault %2d addr %06x\n", type,
+                          engidx < 0 ? NULL : nvkm_subdev_name[engidx],
+                          engn, runl, pbid, intr, mcen, fault, addr);
+
+               /* Mark the engine as supported if everything checks out. */
+               if (engn >= 0 && runl >= 0) {
+                       fifo->engine[engn].engine = engidx < 0 ? NULL :
+                               nvkm_device_engine(device, engidx);
+                       fifo->engine[engn].runl = runl;
+                       fifo->engine[engn].pbid = pbid;
+                       fifo->engine_nr = max(fifo->engine_nr, engn + 1);
+                       fifo->runlist[runl].engm |= 1 << engn;
+                       fifo->runlist_nr = max(fifo->runlist_nr, runl + 1);
+               }
+       }
 
-       for (i = 0; i < ARRAY_SIZE(fifo->engine); i++) {
+       kfree(map);
+
+       for (i = 0; i < fifo->runlist_nr; i++) {
                ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST,
                                      0x8000, 0x1000, false,
-                                     &fifo->engine[i].runlist[0]);
+                                     &fifo->runlist[i].mem[0]);
                if (ret)
                        return ret;
 
                ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST,
                                      0x8000, 0x1000, false,
-                                     &fifo->engine[i].runlist[1]);
+                                     &fifo->runlist[i].mem[1]);
                if (ret)
                        return ret;
 
-               init_waitqueue_head(&fifo->engine[i].wait);
-               INIT_LIST_HEAD(&fifo->engine[i].chan);
+               init_waitqueue_head(&fifo->runlist[i].wait);
+               INIT_LIST_HEAD(&fifo->runlist[i].chan);
        }
 
        ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST,
@@ -695,24 +800,21 @@ void
 gk104_fifo_init(struct nvkm_fifo *base)
 {
        struct gk104_fifo *fifo = gk104_fifo(base);
-       struct nvkm_subdev *subdev = &fifo->base.engine.subdev;
-       struct nvkm_device *device = subdev->device;
+       struct nvkm_device *device = fifo->base.engine.subdev.device;
        int i;
 
-       /* enable all available PBDMA units */
-       nvkm_wr32(device, 0x000204, 0xffffffff);
-       fifo->spoon_nr = hweight32(nvkm_rd32(device, 0x000204));
-       nvkm_debug(subdev, "%d PBDMA unit(s)\n", fifo->spoon_nr);
+       /* Enable PBDMAs. */
+       nvkm_wr32(device, 0x000204, (1 << fifo->pbdma_nr) - 1);
 
        /* PBDMA[n] */
-       for (i = 0; i < fifo->spoon_nr; i++) {
+       for (i = 0; i < fifo->pbdma_nr; i++) {
                nvkm_mask(device, 0x04013c + (i * 0x2000), 0x10000100, 0x00000000);
                nvkm_wr32(device, 0x040108 + (i * 0x2000), 0xffffffff); /* INTR */
                nvkm_wr32(device, 0x04010c + (i * 0x2000), 0xfffffeff); /* INTREN */
        }
 
        /* PBDMA[n].HCE */
-       for (i = 0; i < fifo->spoon_nr; i++) {
+       for (i = 0; i < fifo->pbdma_nr; i++) {
                nvkm_wr32(device, 0x040148 + (i * 0x2000), 0xffffffff); /* INTR */
                nvkm_wr32(device, 0x04014c + (i * 0x2000), 0xffffffff); /* INTREN */
        }
@@ -732,9 +834,9 @@ gk104_fifo_dtor(struct nvkm_fifo *base)
        nvkm_vm_put(&fifo->user.bar);
        nvkm_memory_del(&fifo->user.mem);
 
-       for (i = 0; i < ARRAY_SIZE(fifo->engine); i++) {
-               nvkm_memory_del(&fifo->engine[i].runlist[1]);
-               nvkm_memory_del(&fifo->engine[i].runlist[0]);
+       for (i = 0; i < fifo->runlist_nr; i++) {
+               nvkm_memory_del(&fifo->runlist[i].mem[1]);
+               nvkm_memory_del(&fifo->runlist[i].mem[0]);
        }
 
        return fifo;
@@ -748,7 +850,7 @@ gk104_fifo_new_(const struct nvkm_fifo_func *func, struct nvkm_device *device,
 
        if (!(fifo = kzalloc(sizeof(*fifo), GFP_KERNEL)))
                return -ENOMEM;
-       INIT_WORK(&fifo->fault, gk104_fifo_recover_work);
+       INIT_WORK(&fifo->recover.work, gk104_fifo_recover_work);
        *pfifo = &fifo->base;
 
        return nvkm_fifo_ctor(func, device, index, nr, &fifo->base);
index bec519d..9e5d00b 100644 (file)
@@ -6,25 +6,37 @@
 #include <subdev/mmu.h>
 
 struct gk104_fifo_chan;
-struct gk104_fifo_engn {
-       struct nvkm_memory *runlist[2];
-       int cur_runlist;
-       wait_queue_head_t wait;
-       struct list_head chan;
-};
-
 struct gk104_fifo {
        struct nvkm_fifo base;
 
-       struct work_struct fault;
-       u64 mask;
+       struct {
+               struct work_struct work;
+               u32 engm;
+               u32 runm;
+       } recover;
+
+       int pbdma_nr;
+
+       struct {
+               struct nvkm_engine *engine;
+               int runl;
+               int pbid;
+       } engine[16];
+       int engine_nr;
+
+       struct {
+               struct nvkm_memory *mem[2];
+               int next;
+               wait_queue_head_t wait;
+               struct list_head chan;
+               u32 engm;
+       } runlist[16];
+       int runlist_nr;
 
-       struct gk104_fifo_engn engine[7];
        struct {
                struct nvkm_memory *mem;
                struct nvkm_vma bar;
        } user;
-       int spoon_nr;
 };
 
 int gk104_fifo_new_(const struct nvkm_fifo_func *, struct nvkm_device *,
@@ -38,7 +50,7 @@ void gk104_fifo_uevent_init(struct nvkm_fifo *);
 void gk104_fifo_uevent_fini(struct nvkm_fifo *);
 void gk104_fifo_runlist_insert(struct gk104_fifo *, struct gk104_fifo_chan *);
 void gk104_fifo_runlist_remove(struct gk104_fifo *, struct gk104_fifo_chan *);
-void gk104_fifo_runlist_commit(struct gk104_fifo *, u32 engine);
+void gk104_fifo_runlist_commit(struct gk104_fifo *, int runl);
 
 static inline u64
 gk104_fifo_engine_subdev(int engine)
@@ -58,23 +70,4 @@ gk104_fifo_engine_subdev(int engine)
                return 0;
        }
 }
-
-static inline int
-gk104_fifo_subdev_engine(int subdev)
-{
-       switch (subdev) {
-       case NVKM_ENGINE_GR:
-       case NVKM_ENGINE_SW:
-       case NVKM_ENGINE_CE2   : return 0;
-       case NVKM_ENGINE_MSPDEC: return 1;
-       case NVKM_ENGINE_MSPPP : return 2;
-       case NVKM_ENGINE_MSVLD : return 3;
-       case NVKM_ENGINE_CE0   : return 4;
-       case NVKM_ENGINE_CE1   : return 5;
-       case NVKM_ENGINE_MSENC : return 6;
-       default:
-               WARN_ON(1);
-               return 0;
-       }
-}
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk110.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk110.c
new file mode 100644 (file)
index 0000000..41307fc
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2016 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Ben Skeggs
+ */
+#include "gk104.h"
+#include "changk104.h"
+
+static const struct nvkm_fifo_func
+gk110_fifo = {
+       .dtor = gk104_fifo_dtor,
+       .oneinit = gk104_fifo_oneinit,
+       .init = gk104_fifo_init,
+       .fini = gk104_fifo_fini,
+       .intr = gk104_fifo_intr,
+       .uevent_init = gk104_fifo_uevent_init,
+       .uevent_fini = gk104_fifo_uevent_fini,
+       .chan = {
+               &gk110_fifo_gpfifo_oclass,
+               NULL
+       },
+};
+
+int
+gk110_fifo_new(struct nvkm_device *device, int index, struct nvkm_fifo **pfifo)
+{
+       return gk104_fifo_new_(&gk110_fifo, device, index, 4096, pfifo);
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm107.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gm107.c
new file mode 100644 (file)
index 0000000..6d59d65
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2016 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Ben Skeggs
+ */
+#include "gk104.h"
+#include "changk104.h"
+
+static const struct nvkm_fifo_func
+gm107_fifo = {
+       .dtor = gk104_fifo_dtor,
+       .oneinit = gk104_fifo_oneinit,
+       .init = gk104_fifo_init,
+       .fini = gk104_fifo_fini,
+       .intr = gk104_fifo_intr,
+       .uevent_init = gk104_fifo_uevent_init,
+       .uevent_fini = gk104_fifo_uevent_fini,
+       .chan = {
+               &gk110_fifo_gpfifo_oclass,
+               NULL
+       },
+};
+
+int
+gm107_fifo_new(struct nvkm_device *device, int index, struct nvkm_fifo **pfifo)
+{
+       return gk104_fifo_new_(&gm107_fifo, device, index, 2048, pfifo);
+}
@@ -25,7 +25,7 @@
 #include "changk104.h"
 
 static const struct nvkm_fifo_func
-gm204_fifo = {
+gm200_fifo = {
        .dtor = gk104_fifo_dtor,
        .oneinit = gk104_fifo_oneinit,
        .init = gk104_fifo_init,
@@ -34,13 +34,13 @@ gm204_fifo = {
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .chan = {
-               &gm204_fifo_gpfifo_oclass,
+               &gm200_fifo_gpfifo_oclass,
                NULL
        },
 };
 
 int
-gm204_fifo_new(struct nvkm_device *device, int index, struct nvkm_fifo **pfifo)
+gm200_fifo_new(struct nvkm_device *device, int index, struct nvkm_fifo **pfifo)
 {
-       return gk104_fifo_new_(&gm204_fifo, device, index, 4096, pfifo);
+       return gk104_fifo_new_(&gm200_fifo, device, index, 4096, pfifo);
 }
index ae6375d..4c91d4a 100644 (file)
@@ -32,7 +32,7 @@ gm20b_fifo = {
        .uevent_init = gk104_fifo_uevent_init,
        .uevent_fini = gk104_fifo_uevent_fini,
        .chan = {
-               &gm204_fifo_gpfifo_oclass,
+               &gm200_fifo_gpfifo_oclass,
                NULL
        },
 };
index 2e1df01..ed43510 100644 (file)
@@ -63,9 +63,15 @@ gk104_fifo_gpfifo_engine_addr(struct nvkm_engine *engine)
        case NVKM_ENGINE_CE1   :
        case NVKM_ENGINE_CE2   : return 0x0000;
        case NVKM_ENGINE_GR    : return 0x0210;
+       case NVKM_ENGINE_SEC   : return 0x0220;
        case NVKM_ENGINE_MSPDEC: return 0x0250;
        case NVKM_ENGINE_MSPPP : return 0x0260;
        case NVKM_ENGINE_MSVLD : return 0x0270;
+       case NVKM_ENGINE_VIC   : return 0x0280;
+       case NVKM_ENGINE_MSENC : return 0x0290;
+       case NVKM_ENGINE_NVDEC : return 0x02100270;
+       case NVKM_ENGINE_NVENC0: return 0x02100290;
+       case NVKM_ENGINE_NVENC1: return 0x0210;
        default:
                WARN_ON(1);
                return 0;
@@ -76,9 +82,9 @@ static int
 gk104_fifo_gpfifo_engine_fini(struct nvkm_fifo_chan *base,
                              struct nvkm_engine *engine, bool suspend)
 {
-       const u32 offset = gk104_fifo_gpfifo_engine_addr(engine);
        struct gk104_fifo_chan *chan = gk104_fifo_chan(base);
        struct nvkm_gpuobj *inst = chan->base.inst;
+       u32 offset = gk104_fifo_gpfifo_engine_addr(engine);
        int ret;
 
        ret = gk104_fifo_gpfifo_kick(chan);
@@ -87,8 +93,12 @@ gk104_fifo_gpfifo_engine_fini(struct nvkm_fifo_chan *base,
 
        if (offset) {
                nvkm_kmap(inst);
-               nvkm_wo32(inst, offset + 0x00, 0x00000000);
-               nvkm_wo32(inst, offset + 0x04, 0x00000000);
+               nvkm_wo32(inst, (offset & 0xffff) + 0x00, 0x00000000);
+               nvkm_wo32(inst, (offset & 0xffff) + 0x04, 0x00000000);
+               if ((offset >>= 16)) {
+                       nvkm_wo32(inst, offset + 0x00, 0x00000000);
+                       nvkm_wo32(inst, offset + 0x04, 0x00000000);
+               }
                nvkm_done(inst);
        }
 
@@ -99,15 +109,21 @@ static int
 gk104_fifo_gpfifo_engine_init(struct nvkm_fifo_chan *base,
                              struct nvkm_engine *engine)
 {
-       const u32 offset = gk104_fifo_gpfifo_engine_addr(engine);
        struct gk104_fifo_chan *chan = gk104_fifo_chan(base);
        struct nvkm_gpuobj *inst = chan->base.inst;
+       u32 offset = gk104_fifo_gpfifo_engine_addr(engine);
 
        if (offset) {
-               u64 addr = chan->engn[engine->subdev.index].vma.offset;
+               u64   addr = chan->engn[engine->subdev.index].vma.offset;
+               u32 datalo = lower_32_bits(addr) | 0x00000004;
+               u32 datahi = upper_32_bits(addr);
                nvkm_kmap(inst);
-               nvkm_wo32(inst, offset + 0x00, lower_32_bits(addr) | 4);
-               nvkm_wo32(inst, offset + 0x04, upper_32_bits(addr));
+               nvkm_wo32(inst, (offset & 0xffff) + 0x00, datalo);
+               nvkm_wo32(inst, (offset & 0xffff) + 0x04, datahi);
+               if ((offset >>= 16)) {
+                       nvkm_wo32(inst, offset + 0x00, datalo);
+                       nvkm_wo32(inst, offset + 0x04, datahi);
+               }
                nvkm_done(inst);
        }
 
@@ -154,7 +170,8 @@ gk104_fifo_gpfifo_fini(struct nvkm_fifo_chan *base)
        if (!list_empty(&chan->head)) {
                gk104_fifo_runlist_remove(fifo, chan);
                nvkm_mask(device, 0x800004 + coff, 0x00000800, 0x00000800);
-               gk104_fifo_runlist_commit(fifo, chan->engine);
+               gk104_fifo_gpfifo_kick(chan);
+               gk104_fifo_runlist_commit(fifo, chan->runl);
        }
 
        nvkm_wr32(device, 0x800000 + coff, 0x00000000);
@@ -169,13 +186,13 @@ gk104_fifo_gpfifo_init(struct nvkm_fifo_chan *base)
        u32 addr = chan->base.inst->addr >> 12;
        u32 coff = chan->base.chid * 8;
 
-       nvkm_mask(device, 0x800004 + coff, 0x000f0000, chan->engine << 16);
+       nvkm_mask(device, 0x800004 + coff, 0x000f0000, chan->runl << 16);
        nvkm_wr32(device, 0x800000 + coff, 0x80000000 | addr);
 
        if (list_empty(&chan->head) && !chan->killed) {
                gk104_fifo_runlist_insert(fifo, chan);
                nvkm_mask(device, 0x800004 + coff, 0x00000400, 0x00000400);
-               gk104_fifo_runlist_commit(fifo, chan->engine);
+               gk104_fifo_runlist_commit(fifo, chan->runl);
                nvkm_mask(device, 0x800004 + coff, 0x00000400, 0x00000400);
        }
 }
@@ -201,73 +218,79 @@ gk104_fifo_gpfifo_func = {
        .engine_fini = gk104_fifo_gpfifo_engine_fini,
 };
 
-int
-gk104_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
-                     void *data, u32 size, struct nvkm_object **pobject)
+struct gk104_fifo_chan_func {
+       u32 engine;
+       u64 subdev;
+};
+
+static int
+gk104_fifo_gpfifo_new_(const struct gk104_fifo_chan_func *func,
+                      struct gk104_fifo *fifo, u32 *engmask, u16 *chid,
+                      u64 vm, u64 ioffset, u64 ilength,
+                      const struct nvkm_oclass *oclass,
+                      struct nvkm_object **pobject)
 {
-       union {
-               struct kepler_channel_gpfifo_a_v0 v0;
-       } *args = data;
-       struct gk104_fifo *fifo = gk104_fifo(base);
        struct nvkm_device *device = fifo->base.engine.subdev.device;
-       struct nvkm_object *parent = oclass->parent;
        struct gk104_fifo_chan *chan;
-       u64 usermem, ioffset, ilength;
-       u32 engines;
-       int ret = -ENOSYS, i;
-
-       nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
-       if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
-               nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
-                                  "ioffset %016llx ilength %08x engine %08x\n",
-                          args->v0.version, args->v0.vm, args->v0.ioffset,
-                          args->v0.ilength, args->v0.engine);
-       } else
-               return ret;
-
-       /* determine which downstream engines are present */
-       for (i = 0, engines = 0; i < ARRAY_SIZE(fifo->engine); i++) {
-               u64 subdevs = gk104_fifo_engine_subdev(i);
-               if (!nvkm_device_engine(device, __ffs64(subdevs)))
-                       continue;
-               engines |= (1 << i);
+       int runlist = -1, ret = -ENOSYS, i, j;
+       u32 engines = 0, present = 0;
+       u64 subdevs = 0;
+       u64 usermem;
+
+       /* Determine which downstream engines are present */
+       for (i = 0; i < fifo->engine_nr; i++) {
+               struct nvkm_engine *engine = fifo->engine[i].engine;
+               if (engine) {
+                       u64 submask = BIT_ULL(engine->subdev.index);
+                       for (j = 0; func[j].subdev; j++) {
+                               if (func[j].subdev & submask) {
+                                       present |= func[j].engine;
+                                       break;
+                               }
+                       }
+
+                       if (!func[j].subdev)
+                               continue;
+
+                       if (runlist < 0 && (*engmask & present))
+                               runlist = fifo->engine[i].runl;
+                       if (runlist == fifo->engine[i].runl) {
+                               engines |= func[j].engine;
+                               subdevs |= func[j].subdev;
+                       }
+               }
        }
 
-       /* if this is an engine mask query, we're done */
-       if (!args->v0.engine) {
-               args->v0.engine = engines;
+       /* Just an engine mask query?  All done here! */
+       if (!*engmask) {
+               *engmask = present;
                return nvkm_object_new(oclass, NULL, 0, pobject);
        }
 
-       /* check that we support a requested engine - note that the user
-        * argument is a mask in order to allow the user to request (for
-        * example) *any* copy engine, but doesn't matter which.
-        */
-       args->v0.engine &= engines;
-       if (!args->v0.engine) {
-               nvif_ioctl(parent, "no supported engine\n");
+       /* No runlist?  No supported engines. */
+       *engmask = present;
+       if (runlist < 0)
                return -ENODEV;
-       }
+       *engmask = engines;
 
-       /* allocate the channel */
+       /* Allocate the channel. */
        if (!(chan = kzalloc(sizeof(*chan), GFP_KERNEL)))
                return -ENOMEM;
        *pobject = &chan->base.object;
        chan->fifo = fifo;
-       chan->engine = __ffs(args->v0.engine);
+       chan->runl = runlist;
        INIT_LIST_HEAD(&chan->head);
 
        ret = nvkm_fifo_chan_ctor(&gk104_fifo_gpfifo_func, &fifo->base,
-                                 0x1000, 0x1000, true, args->v0.vm, 0,
-                                 gk104_fifo_engine_subdev(chan->engine),
+                                 0x1000, 0x1000, true, vm, 0, subdevs,
                                  1, fifo->user.bar.offset, 0x200,
                                  oclass, &chan->base);
        if (ret)
                return ret;
 
-       args->v0.chid = chan->base.chid;
+       *chid = chan->base.chid;
 
-       /* page directory */
+       /* Page directory. */
        ret = nvkm_gpuobj_new(device, 0x10000, 0x1000, false, NULL, &chan->pgd);
        if (ret)
                return ret;
@@ -283,10 +306,9 @@ gk104_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
        if (ret)
                return ret;
 
-       /* clear channel control registers */
+       /* Clear channel control registers. */
        usermem = chan->base.chid * 0x200;
-       ioffset = args->v0.ioffset;
-       ilength = order_base_2(args->v0.ilength / 8);
+       ilength = order_base_2(ilength / 8);
 
        nvkm_kmap(fifo->user.mem);
        for (i = 0; i < 0x200; i += 4)
@@ -315,6 +337,56 @@ gk104_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
        return 0;
 }
 
+static const struct gk104_fifo_chan_func
+gk104_fifo_gpfifo[] = {
+       { NVA06F_V0_ENGINE_SW | NVA06F_V0_ENGINE_GR,
+               BIT_ULL(NVKM_ENGINE_SW) | BIT_ULL(NVKM_ENGINE_GR)
+       },
+       { NVA06F_V0_ENGINE_SEC   , BIT_ULL(NVKM_ENGINE_SEC   ) },
+       { NVA06F_V0_ENGINE_MSVLD , BIT_ULL(NVKM_ENGINE_MSVLD ) },
+       { NVA06F_V0_ENGINE_MSPDEC, BIT_ULL(NVKM_ENGINE_MSPDEC) },
+       { NVA06F_V0_ENGINE_MSPPP , BIT_ULL(NVKM_ENGINE_MSPPP ) },
+       { NVA06F_V0_ENGINE_MSENC , BIT_ULL(NVKM_ENGINE_MSENC ) },
+       { NVA06F_V0_ENGINE_VIC   , BIT_ULL(NVKM_ENGINE_VIC   ) },
+       { NVA06F_V0_ENGINE_NVDEC , BIT_ULL(NVKM_ENGINE_NVDEC ) },
+       { NVA06F_V0_ENGINE_NVENC0, BIT_ULL(NVKM_ENGINE_NVENC0) },
+       { NVA06F_V0_ENGINE_NVENC1, BIT_ULL(NVKM_ENGINE_NVENC1) },
+       { NVA06F_V0_ENGINE_CE0   , BIT_ULL(NVKM_ENGINE_CE0   ) },
+       { NVA06F_V0_ENGINE_CE1   , BIT_ULL(NVKM_ENGINE_CE1   ) },
+       { NVA06F_V0_ENGINE_CE2   , BIT_ULL(NVKM_ENGINE_CE2   ) },
+       {}
+};
+
+int
+gk104_fifo_gpfifo_new(struct nvkm_fifo *base, const struct nvkm_oclass *oclass,
+                     void *data, u32 size, struct nvkm_object **pobject)
+{
+       struct nvkm_object *parent = oclass->parent;
+       union {
+               struct kepler_channel_gpfifo_a_v0 v0;
+       } *args = data;
+       struct gk104_fifo *fifo = gk104_fifo(base);
+       int ret = -ENOSYS;
+
+       nvif_ioctl(parent, "create channel gpfifo size %d\n", size);
+       if (!(ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false))) {
+               nvif_ioctl(parent, "create channel gpfifo vers %d vm %llx "
+                                  "ioffset %016llx ilength %08x engine %08x\n",
+                          args->v0.version, args->v0.vm, args->v0.ioffset,
+                          args->v0.ilength, args->v0.engines);
+               return gk104_fifo_gpfifo_new_(gk104_fifo_gpfifo, fifo,
+                                             &args->v0.engines,
+                                             &args->v0.chid,
+                                              args->v0.vm,
+                                              args->v0.ioffset,
+                                              args->v0.ilength,
+                                             oclass, pobject);
+
+       }
+
+       return ret;
+}
+
 const struct nvkm_fifo_chan_oclass
 gk104_fifo_gpfifo_oclass = {
        .base.oclass = KEPLER_CHANNEL_GPFIFO_A,
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk110.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gpfifogk110.c
new file mode 100644 (file)
index 0000000..a9aa69c
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2016 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Ben Skeggs
+ */
+#include "changk104.h"
+
+#include <nvif/class.h>
+
+const struct nvkm_fifo_chan_oclass
+gk110_fifo_gpfifo_oclass = {
+       .base.oclass = KEPLER_CHANNEL_GPFIFO_B,
+       .base.minver = 0,
+       .base.maxver = 0,
+       .ctor = gk104_fifo_gpfifo_new,
+};
@@ -26,7 +26,7 @@
 #include <nvif/class.h>
 
 const struct nvkm_fifo_chan_oclass
-gm204_fifo_gpfifo_oclass = {
+gm200_fifo_gpfifo_oclass = {
        .base.oclass = MAXWELL_CHANNEL_GPFIFO_A,
        .base.minver = 0,
        .base.maxver = 0,
index 9ad0d0e..290ed0d 100644 (file)
@@ -29,8 +29,7 @@ nvkm-y += nvkm/engine/gr/gk110b.o
 nvkm-y += nvkm/engine/gr/gk208.o
 nvkm-y += nvkm/engine/gr/gk20a.o
 nvkm-y += nvkm/engine/gr/gm107.o
-nvkm-y += nvkm/engine/gr/gm204.o
-nvkm-y += nvkm/engine/gr/gm206.o
+nvkm-y += nvkm/engine/gr/gm200.o
 nvkm-y += nvkm/engine/gr/gm20b.o
 
 nvkm-y += nvkm/engine/gr/ctxnv40.o
@@ -47,6 +46,5 @@ nvkm-y += nvkm/engine/gr/ctxgk110b.o
 nvkm-y += nvkm/engine/gr/ctxgk208.o
 nvkm-y += nvkm/engine/gr/ctxgk20a.o
 nvkm-y += nvkm/engine/gr/ctxgm107.o
-nvkm-y += nvkm/engine/gr/ctxgm204.o
-nvkm-y += nvkm/engine/gr/ctxgm206.o
+nvkm-y += nvkm/engine/gr/ctxgm200.o
 nvkm-y += nvkm/engine/gr/ctxgm20b.o
index 3c64040..3c86739 100644 (file)
@@ -97,12 +97,11 @@ void gm107_grctx_generate_bundle(struct gf100_grctx *);
 void gm107_grctx_generate_pagepool(struct gf100_grctx *);
 void gm107_grctx_generate_attrib(struct gf100_grctx *);
 
-extern const struct gf100_grctx_func gm204_grctx;
-void gm204_grctx_generate_main(struct gf100_gr *, struct gf100_grctx *);
-void gm204_grctx_generate_tpcid(struct gf100_gr *);
-void gm204_grctx_generate_405b60(struct gf100_gr *);
+extern const struct gf100_grctx_func gm200_grctx;
+void gm200_grctx_generate_main(struct gf100_gr *, struct gf100_grctx *);
+void gm200_grctx_generate_tpcid(struct gf100_gr *);
+void gm200_grctx_generate_405b60(struct gf100_gr *);
 
-extern const struct gf100_grctx_func gm206_grctx;
 extern const struct gf100_grctx_func gm20b_grctx;
 
 /* context init value lists */
@@ -210,19 +209,4 @@ extern const struct gf100_gr_init gk208_grctx_init_crstr_0[];
 
 extern const struct gf100_gr_init gm107_grctx_init_gpc_unk_0[];
 extern const struct gf100_gr_init gm107_grctx_init_wwdx_0[];
-
-extern const struct gf100_gr_pack gm204_grctx_pack_icmd[];
-
-extern const struct gf100_gr_pack gm204_grctx_pack_mthd[];
-
-extern const struct gf100_gr_pack gm204_grctx_pack_hub[];
-
-extern const struct gf100_gr_init gm204_grctx_init_prop_0[];
-extern const struct gf100_gr_init gm204_grctx_init_setup_0[];
-extern const struct gf100_gr_init gm204_grctx_init_gpm_0[];
-extern const struct gf100_gr_init gm204_grctx_init_gpc_unk_2[];
-
-extern const struct gf100_gr_pack gm204_grctx_pack_tpc[];
-
-extern const struct gf100_gr_pack gm204_grctx_pack_ppc[];
 #endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm200.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm200.c
new file mode 100644 (file)
index 0000000..e586699
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2015 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Ben Skeggs <bskeggs@redhat.com>
+ */
+#include "ctxgf100.h"
+
+/*******************************************************************************
+ * PGRAPH context implementation
+ ******************************************************************************/
+
+void
+gm200_grctx_generate_tpcid(struct gf100_gr *gr)
+{
+       struct nvkm_device *device = gr->base.engine.subdev.device;
+       int gpc, tpc, id;
+
+       for (tpc = 0, id = 0; tpc < 4; tpc++) {
+               for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
+                       if (tpc < gr->tpc_nr[gpc]) {
+                               nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x698), id);
+                               nvkm_wr32(device, GPC_UNIT(gpc, 0x0c10 + tpc * 4), id);
+                               nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x088), id);
+                               id++;
+                       }
+               }
+       }
+}
+
+static void
+gm200_grctx_generate_rop_active_fbps(struct gf100_gr *gr)
+{
+       struct nvkm_device *device = gr->base.engine.subdev.device;
+       const u32 fbp_count = nvkm_rd32(device, 0x12006c);
+       nvkm_mask(device, 0x408850, 0x0000000f, fbp_count); /* zrop */
+       nvkm_mask(device, 0x408958, 0x0000000f, fbp_count); /* crop */
+}
+
+void
+gm200_grctx_generate_405b60(struct gf100_gr *gr)
+{
+       struct nvkm_device *device = gr->base.engine.subdev.device;
+       const u32 dist_nr = DIV_ROUND_UP(gr->tpc_total, 4);
+       u32 dist[TPC_MAX / 4] = {};
+       u32 gpcs[GPC_MAX] = {};
+       u8  tpcnr[GPC_MAX];
+       int tpc, gpc, i;
+
+       memcpy(tpcnr, gr->tpc_nr, sizeof(gr->tpc_nr));
+
+       /* won't result in the same distribution as the binary driver where
+        * some of the gpcs have more tpcs than others, but this shall do
+        * for the moment.  the code for earlier gpus has this issue too.
+        */
+       for (gpc = -1, i = 0; i < gr->tpc_total; i++) {
+               do {
+                       gpc = (gpc + 1) % gr->gpc_nr;
+               } while(!tpcnr[gpc]);
+               tpc = gr->tpc_nr[gpc] - tpcnr[gpc]--;
+
+               dist[i / 4] |= ((gpc << 4) | tpc) << ((i % 4) * 8);
+               gpcs[gpc] |= i << (tpc * 8);
+       }
+
+       for (i = 0; i < dist_nr; i++)
+               nvkm_wr32(device, 0x405b60 + (i * 4), dist[i]);
+       for (i = 0; i < gr->gpc_nr; i++)
+               nvkm_wr32(device, 0x405ba0 + (i * 4), gpcs[i]);
+}
+
+void
+gm200_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info)
+{
+       struct nvkm_device *device = gr->base.engine.subdev.device;
+       const struct gf100_grctx_func *grctx = gr->func->grctx;
+       u32 tmp;
+       int i;
+
+       gf100_gr_mmio(gr, gr->fuc_sw_ctx);
+
+       nvkm_wr32(device, 0x404154, 0x00000000);
+
+       grctx->bundle(info);
+       grctx->pagepool(info);
+       grctx->attrib(info);
+       grctx->unkn(gr);
+
+       gm200_grctx_generate_tpcid(gr);
+       gf100_grctx_generate_r406028(gr);
+       gk104_grctx_generate_r418bb8(gr);
+
+       for (i = 0; i < 8; i++)
+               nvkm_wr32(device, 0x4064d0 + (i * 0x04), 0x00000000);
+       nvkm_wr32(device, 0x406500, 0x00000000);
+
+       nvkm_wr32(device, 0x405b00, (gr->tpc_total << 8) | gr->gpc_nr);
+
+       gm200_grctx_generate_rop_active_fbps(gr);
+
+       for (tmp = 0, i = 0; i < gr->gpc_nr; i++)
+               tmp |= ((1 << gr->tpc_nr[i]) - 1) << (i * 4);
+       nvkm_wr32(device, 0x4041c4, tmp);
+
+       gm200_grctx_generate_405b60(gr);
+
+       gf100_gr_icmd(gr, gr->fuc_bundle);
+       nvkm_wr32(device, 0x404154, 0x00000800);
+       gf100_gr_mthd(gr, gr->fuc_method);
+
+       nvkm_mask(device, 0x418e94, 0xffffffff, 0xc4230000);
+       nvkm_mask(device, 0x418e4c, 0xffffffff, 0x70000000);
+}
+
+const struct gf100_grctx_func
+gm200_grctx = {
+       .main  = gm200_grctx_generate_main,
+       .unkn  = gk104_grctx_generate_unkn,
+       .bundle = gm107_grctx_generate_bundle,
+       .bundle_size = 0x3000,
+       .bundle_min_gpm_fifo_depth = 0x180,
+       .bundle_token_limit = 0x780,
+       .pagepool = gm107_grctx_generate_pagepool,
+       .pagepool_size = 0x20000,
+       .attrib = gm107_grctx_generate_attrib,
+       .attrib_nr_max = 0x600,
+       .attrib_nr = 0x400,
+       .alpha_nr_max = 0x1800,
+       .alpha_nr = 0x1000,
+};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm204.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm204.c
deleted file mode 100644 (file)
index 170cbfd..0000000
+++ /dev/null
@@ -1,1049 +0,0 @@
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs <bskeggs@redhat.com>
- */
-#include "ctxgf100.h"
-
-/*******************************************************************************
- * PGRAPH context register lists
- ******************************************************************************/
-
-static const struct gf100_gr_init
-gm204_grctx_init_icmd_0[] = {
-       { 0x001000,   1, 0x01, 0x00000002 },
-       { 0x0006aa,   1, 0x01, 0x00000001 },
-       { 0x0006ad,   2, 0x01, 0x00000100 },
-       { 0x0006b1,   1, 0x01, 0x00000011 },
-       { 0x00078c,   1, 0x01, 0x00000008 },
-       { 0x000792,   1, 0x01, 0x00000001 },
-       { 0x000794,   3, 0x01, 0x00000001 },
-       { 0x000797,   1, 0x01, 0x000000cf },
-       { 0x00079a,   1, 0x01, 0x00000002 },
-       { 0x0007a1,   1, 0x01, 0x00000001 },
-       { 0x0007a3,   3, 0x01, 0x00000001 },
-       { 0x000831,   1, 0x01, 0x00000004 },
-       { 0x01e100,   1, 0x01, 0x00000001 },
-       { 0x001000,   1, 0x01, 0x00000008 },
-       { 0x000039,   3, 0x01, 0x00000000 },
-       { 0x000380,   1, 0x01, 0x00000001 },
-       { 0x000366,   2, 0x01, 0x00000000 },
-       { 0x000368,   1, 0x01, 0x00000fff },
-       { 0x000370,   2, 0x01, 0x00000000 },
-       { 0x000372,   1, 0x01, 0x000fffff },
-       { 0x000374,   1, 0x01, 0x00000100 },
-       { 0x000818,   8, 0x01, 0x00000000 },
-       { 0x000848,  16, 0x01, 0x00000000 },
-       { 0x000738,   1, 0x01, 0x00000000 },
-       { 0x000b07,   1, 0x01, 0x00000002 },
-       { 0x000b08,   2, 0x01, 0x00000100 },
-       { 0x000b0a,   1, 0x01, 0x00000001 },
-       { 0x000a04,   1, 0x01, 0x000000ff },
-       { 0x000a0b,   1, 0x01, 0x00000040 },
-       { 0x00097f,   1, 0x01, 0x00000100 },
-       { 0x000a02,   1, 0x01, 0x00000001 },
-       { 0x000809,   1, 0x01, 0x00000007 },
-       { 0x00c221,   1, 0x01, 0x00000040 },
-       { 0x00c401,   1, 0x01, 0x00000001 },
-       { 0x00c402,   1, 0x01, 0x00010001 },
-       { 0x00c403,   2, 0x01, 0x00000001 },
-       { 0x00c40e,   1, 0x01, 0x00000020 },
-       { 0x01e100,   1, 0x01, 0x00000001 },
-       { 0x001000,   1, 0x01, 0x00000001 },
-       { 0x000b07,   1, 0x01, 0x00000002 },
-       { 0x000b08,   2, 0x01, 0x00000100 },
-       { 0x000b0a,   1, 0x01, 0x00000001 },
-       { 0x01e100,   1, 0x01, 0x00000001 },
-       { 0x001000,   1, 0x01, 0x00000004 },
-       { 0x000039,   3, 0x01, 0x00000000 },
-       { 0x0000a9,   1, 0x01, 0x0000ffff },
-       { 0x000038,   1, 0x01, 0x0fac6881 },
-       { 0x00003d,   1, 0x01, 0x00000001 },
-       { 0x0000e8,   8, 0x01, 0x00000400 },
-       { 0x000078,   8, 0x01, 0x00000300 },
-       { 0x000050,   1, 0x01, 0x00000011 },
-       { 0x000058,   8, 0x01, 0x00000008 },
-       { 0x000208,   8, 0x01, 0x00000001 },
-       { 0x000081,   1, 0x01, 0x00000001 },
-       { 0x000085,   1, 0x01, 0x00000004 },
-       { 0x000088,   1, 0x01, 0x00000400 },
-       { 0x000090,   1, 0x01, 0x00000300 },
-       { 0x000098,   1, 0x01, 0x00001001 },
-       { 0x0000e3,   1, 0x01, 0x00000001 },
-       { 0x0000da,   1, 0x01, 0x00000001 },
-       { 0x0000b4,   4, 0x01, 0x88888888 },
-       { 0x0000f8,   1, 0x01, 0x00000003 },
-       { 0x0000fa,   1, 0x01, 0x00000001 },
-       { 0x0000b1,   2, 0x01, 0x00000001 },
-       { 0x00009f,   4, 0x01, 0x0000ffff },
-       { 0x0000a8,   1, 0x01, 0x0000ffff },
-       { 0x0000ad,   1, 0x01, 0x0000013e },
-       { 0x0000e1,   1, 0x01, 0x00000010 },
-       { 0x000290,  16, 0x01, 0x00000000 },
-       { 0x0003b0,  16, 0x01, 0x00000000 },
-       { 0x0002a0,  16, 0x01, 0x00000000 },
-       { 0x000420,  16, 0x01, 0x00000000 },
-       { 0x0002b0,  16, 0x01, 0x00000000 },
-       { 0x000430,  16, 0x01, 0x00000000 },
-       { 0x0002c0,  16, 0x01, 0x00000000 },
-       { 0x0004d0,  16, 0x01, 0x00000000 },
-       { 0x000720,  16, 0x01, 0x00000000 },
-       { 0x0008c0,  16, 0x01, 0x00000000 },
-       { 0x000890,  16, 0x01, 0x00000000 },
-       { 0x0008e0,  16, 0x01, 0x00000000 },
-       { 0x0008a0,  16, 0x01, 0x00000000 },
-       { 0x0008f0,  16, 0x01, 0x00000000 },
-       { 0x00094c,   1, 0x01, 0x000000ff },
-       { 0x00094d,   1, 0x01, 0xffffffff },
-       { 0x00094e,   1, 0x01, 0x00000002 },
-       { 0x0002f2,   2, 0x01, 0x00000001 },
-       { 0x0002f5,   1, 0x01, 0x00000001 },
-       { 0x0002f7,   1, 0x01, 0x00000001 },
-       { 0x000303,   1, 0x01, 0x00000001 },
-       { 0x0002e6,   1, 0x01, 0x00000001 },
-       { 0x000466,   1, 0x01, 0x00000052 },
-       { 0x000301,   1, 0x01, 0x3f800000 },
-       { 0x000304,   1, 0x01, 0x30201000 },
-       { 0x000305,   1, 0x01, 0x70605040 },
-       { 0x000306,   1, 0x01, 0xb8a89888 },
-       { 0x000307,   1, 0x01, 0xf8e8d8c8 },
-       { 0x00030a,   1, 0x01, 0x00ffff00 },
-       { 0x00030b,   1, 0x01, 0x0000001a },
-       { 0x00030c,   1, 0x01, 0x00000001 },
-       { 0x000318,   1, 0x01, 0x00000001 },
-       { 0x000340,   1, 0x01, 0x00000000 },
-       { 0x00037d,   1, 0x01, 0x00000006 },
-       { 0x0003a0,   1, 0x01, 0x00000002 },
-       { 0x0003aa,   1, 0x01, 0x00000001 },
-       { 0x0003a9,   1, 0x01, 0x00000001 },
-       { 0x000380,   1, 0x01, 0x00000001 },
-       { 0x000383,   1, 0x01, 0x00000011 },
-       { 0x000360,   1, 0x01, 0x00000040 },
-       { 0x000366,   2, 0x01, 0x00000000 },
-       { 0x000368,   1, 0x01, 0x00000fff },
-       { 0x000370,   2, 0x01, 0x00000000 },
-       { 0x000372,   1, 0x01, 0x000fffff },
-       { 0x000374,   1, 0x01, 0x00000100 },
-       { 0x00037a,   1, 0x01, 0x00000012 },
-       { 0x000619,   1, 0x01, 0x00000003 },
-       { 0x000811,   1, 0x01, 0x00000003 },
-       { 0x000812,   1, 0x01, 0x00000004 },
-       { 0x000813,   1, 0x01, 0x00000006 },
-       { 0x000814,   1, 0x01, 0x00000008 },
-       { 0x000815,   1, 0x01, 0x0000000b },
-       { 0x000800,   6, 0x01, 0x00000001 },
-       { 0x000632,   1, 0x01, 0x00000001 },
-       { 0x000633,   1, 0x01, 0x00000002 },
-       { 0x000634,   1, 0x01, 0x00000003 },
-       { 0x000635,   1, 0x01, 0x00000004 },
-       { 0x000654,   1, 0x01, 0x3f800000 },
-       { 0x000657,   1, 0x01, 0x3f800000 },
-       { 0x000655,   2, 0x01, 0x3f800000 },
-       { 0x0006cd,   1, 0x01, 0x3f800000 },
-       { 0x0007f5,   1, 0x01, 0x3f800000 },
-       { 0x0007dc,   1, 0x01, 0x39291909 },
-       { 0x0007dd,   1, 0x01, 0x79695949 },
-       { 0x0007de,   1, 0x01, 0xb9a99989 },
-       { 0x0007df,   1, 0x01, 0xf9e9d9c9 },
-       { 0x0007e8,   1, 0x01, 0x00003210 },
-       { 0x0007e9,   1, 0x01, 0x00007654 },
-       { 0x0007ea,   1, 0x01, 0x00000098 },
-       { 0x0007ec,   1, 0x01, 0x39291909 },
-       { 0x0007ed,   1, 0x01, 0x79695949 },
-       { 0x0007ee,   1, 0x01, 0xb9a99989 },
-       { 0x0007ef,   1, 0x01, 0xf9e9d9c9 },
-       { 0x0007f0,   1, 0x01, 0x00003210 },
-       { 0x0007f1,   1, 0x01, 0x00007654 },
-       { 0x0007f2,   1, 0x01, 0x00000098 },
-       { 0x0005a5,   1, 0x01, 0x00000001 },
-       { 0x0005aa,   1, 0x01, 0x00000002 },
-       { 0x0005cb,   1, 0x01, 0x00000004 },
-       { 0x0005d0,   1, 0x01, 0x20181008 },
-       { 0x0005d1,   1, 0x01, 0x40383028 },
-       { 0x0005d2,   1, 0x01, 0x60585048 },
-       { 0x0005d3,   1, 0x01, 0x80787068 },
-       { 0x000980, 128, 0x01, 0x00000000 },
-       { 0x000468,   1, 0x01, 0x00000004 },
-       { 0x00046c,   1, 0x01, 0x00000001 },
-       { 0x000470,  96, 0x01, 0x00000000 },
-       { 0x0005e0,  16, 0x01, 0x00000d10 },
-       { 0x000510,  16, 0x01, 0x3f800000 },
-       { 0x000520,   1, 0x01, 0x000002b6 },
-       { 0x000529,   1, 0x01, 0x00000001 },
-       { 0x000530,  16, 0x01, 0xffff0000 },
-       { 0x000550,  32, 0x01, 0xffff0000 },
-       { 0x000585,   1, 0x01, 0x0000003f },
-       { 0x000576,   1, 0x01, 0x00000003 },
-       { 0x00057b,   1, 0x01, 0x00000059 },
-       { 0x000586,   1, 0x01, 0x00000040 },
-       { 0x000582,   2, 0x01, 0x00000080 },
-       { 0x000595,   1, 0x01, 0x00400040 },
-       { 0x000596,   1, 0x01, 0x00000492 },
-       { 0x000597,   1, 0x01, 0x08080203 },
-       { 0x0005ad,   1, 0x01, 0x00000008 },
-       { 0x000598,   1, 0x01, 0x00020001 },
-       { 0x0005d4,   1, 0x01, 0x00000001 },
-       { 0x0005c2,   1, 0x01, 0x00000001 },
-       { 0x000638,   2, 0x01, 0x00000001 },
-       { 0x00063a,   1, 0x01, 0x00000002 },
-       { 0x00063b,   2, 0x01, 0x00000001 },
-       { 0x00063d,   1, 0x01, 0x00000002 },
-       { 0x00063e,   1, 0x01, 0x00000001 },
-       { 0x0008b8,   8, 0x01, 0x00000001 },
-       { 0x000900,   8, 0x01, 0x00000001 },
-       { 0x000908,   8, 0x01, 0x00000002 },
-       { 0x000910,  16, 0x01, 0x00000001 },
-       { 0x000920,   8, 0x01, 0x00000002 },
-       { 0x000928,   8, 0x01, 0x00000001 },
-       { 0x000662,   1, 0x01, 0x00000001 },
-       { 0x000648,   9, 0x01, 0x00000001 },
-       { 0x000674,   1, 0x01, 0x00000001 },
-       { 0x000658,   1, 0x01, 0x0000000f },
-       { 0x0007ff,   1, 0x01, 0x0000000a },
-       { 0x00066a,   1, 0x01, 0x40000000 },
-       { 0x00066b,   1, 0x01, 0x10000000 },
-       { 0x00066c,   2, 0x01, 0xffff0000 },
-       { 0x0007af,   2, 0x01, 0x00000008 },
-       { 0x0007f6,   1, 0x01, 0x00000001 },
-       { 0x0006b2,   1, 0x01, 0x00000055 },
-       { 0x0007ad,   1, 0x01, 0x00000003 },
-       { 0x000971,   1, 0x01, 0x00000008 },
-       { 0x000972,   1, 0x01, 0x00000040 },
-       { 0x000973,   1, 0x01, 0x0000012c },
-       { 0x00097c,   1, 0x01, 0x00000040 },
-       { 0x000975,   1, 0x01, 0x00000020 },
-       { 0x000976,   1, 0x01, 0x00000001 },
-       { 0x000977,   1, 0x01, 0x00000020 },
-       { 0x000978,   1, 0x01, 0x00000001 },
-       { 0x000957,   1, 0x01, 0x00000003 },
-       { 0x00095e,   1, 0x01, 0x20164010 },
-       { 0x00095f,   1, 0x01, 0x00000020 },
-       { 0x000a0d,   1, 0x01, 0x00000006 },
-       { 0x00097d,   1, 0x01, 0x0000000c },
-       { 0x000683,   1, 0x01, 0x00000006 },
-       { 0x000687,   1, 0x01, 0x003fffff },
-       { 0x0006a0,   1, 0x01, 0x00000005 },
-       { 0x000840,   1, 0x01, 0x00400008 },
-       { 0x000841,   1, 0x01, 0x08000080 },
-       { 0x000842,   1, 0x01, 0x00400008 },
-       { 0x000843,   1, 0x01, 0x08000080 },
-       { 0x000818,   8, 0x01, 0x00000000 },
-       { 0x000848,  16, 0x01, 0x00000000 },
-       { 0x000738,   1, 0x01, 0x00000000 },
-       { 0x0006aa,   1, 0x01, 0x00000001 },
-       { 0x0006ab,   1, 0x01, 0x00000002 },
-       { 0x0006ac,   1, 0x01, 0x00000080 },
-       { 0x0006ad,   2, 0x01, 0x00000100 },
-       { 0x0006b1,   1, 0x01, 0x00000011 },
-       { 0x0006bb,   1, 0x01, 0x000000cf },
-       { 0x0006ce,   1, 0x01, 0x2a712488 },
-       { 0x000739,   1, 0x01, 0x4085c000 },
-       { 0x00073a,   1, 0x01, 0x00000080 },
-       { 0x000786,   1, 0x01, 0x80000100 },
-       { 0x00073c,   1, 0x01, 0x00010100 },
-       { 0x00073d,   1, 0x01, 0x02800000 },
-       { 0x000787,   1, 0x01, 0x000000cf },
-       { 0x00078c,   1, 0x01, 0x00000008 },
-       { 0x000792,   1, 0x01, 0x00000001 },
-       { 0x000794,   3, 0x01, 0x00000001 },
-       { 0x000797,   1, 0x01, 0x000000cf },
-       { 0x000836,   1, 0x01, 0x00000001 },
-       { 0x00079a,   1, 0x01, 0x00000002 },
-       { 0x000833,   1, 0x01, 0x04444480 },
-       { 0x0007a1,   1, 0x01, 0x00000001 },
-       { 0x0007a3,   3, 0x01, 0x00000001 },
-       { 0x000831,   1, 0x01, 0x00000004 },
-       { 0x000b07,   1, 0x01, 0x00000002 },
-       { 0x000b08,   2, 0x01, 0x00000100 },
-       { 0x000b0a,   1, 0x01, 0x00000001 },
-       { 0x000a04,   1, 0x01, 0x000000ff },
-       { 0x000a0b,   1, 0x01, 0x00000040 },
-       { 0x00097f,   1, 0x01, 0x00000100 },
-       { 0x000a02,   1, 0x01, 0x00000001 },
-       { 0x000809,   1, 0x01, 0x00000007 },
-       { 0x00c221,   1, 0x01, 0x00000040 },
-       { 0x00c1b0,   8, 0x01, 0x0000000f },
-       { 0x00c1b8,   1, 0x01, 0x0fac6881 },
-       { 0x00c1b9,   1, 0x01, 0x00fac688 },
-       { 0x00c401,   1, 0x01, 0x00000001 },
-       { 0x00c402,   1, 0x01, 0x00010001 },
-       { 0x00c403,   2, 0x01, 0x00000001 },
-       { 0x00c40e,   1, 0x01, 0x00000020 },
-       { 0x00c413,   4, 0x01, 0x88888888 },
-       { 0x00c423,   1, 0x01, 0x0000ff00 },
-       { 0x00c420,   1, 0x01, 0x00880101 },
-       { 0x01e100,   1, 0x01, 0x00000001 },
-       {}
-};
-
-const struct gf100_gr_pack
-gm204_grctx_pack_icmd[] = {
-       { gm204_grctx_init_icmd_0 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_b197_0[] = {
-       { 0x000800,   8, 0x40, 0x00000000 },
-       { 0x000804,   8, 0x40, 0x00000000 },
-       { 0x000808,   8, 0x40, 0x00000400 },
-       { 0x00080c,   8, 0x40, 0x00000300 },
-       { 0x000810,   1, 0x04, 0x000000cf },
-       { 0x000850,   7, 0x40, 0x00000000 },
-       { 0x000814,   8, 0x40, 0x00000040 },
-       { 0x000818,   8, 0x40, 0x00000001 },
-       { 0x00081c,   8, 0x40, 0x00000000 },
-       { 0x000820,   8, 0x40, 0x00000000 },
-       { 0x001c00,  16, 0x10, 0x00000000 },
-       { 0x001c04,  16, 0x10, 0x00000000 },
-       { 0x001c08,  16, 0x10, 0x00000000 },
-       { 0x001c0c,  16, 0x10, 0x00000000 },
-       { 0x001d00,  16, 0x10, 0x00000000 },
-       { 0x001d04,  16, 0x10, 0x00000000 },
-       { 0x001d08,  16, 0x10, 0x00000000 },
-       { 0x001d0c,  16, 0x10, 0x00000000 },
-       { 0x001f00,  16, 0x08, 0x00000000 },
-       { 0x001f04,  16, 0x08, 0x00000000 },
-       { 0x001f80,  16, 0x08, 0x00000000 },
-       { 0x001f84,  16, 0x08, 0x00000000 },
-       { 0x002000,   1, 0x04, 0x00000000 },
-       { 0x002040,   1, 0x04, 0x00000011 },
-       { 0x002080,   1, 0x04, 0x00000020 },
-       { 0x0020c0,   1, 0x04, 0x00000030 },
-       { 0x002100,   1, 0x04, 0x00000040 },
-       { 0x002140,   1, 0x04, 0x00000051 },
-       { 0x00200c,   6, 0x40, 0x00000001 },
-       { 0x002010,   1, 0x04, 0x00000000 },
-       { 0x002050,   1, 0x04, 0x00000000 },
-       { 0x002090,   1, 0x04, 0x00000001 },
-       { 0x0020d0,   1, 0x04, 0x00000002 },
-       { 0x002110,   1, 0x04, 0x00000003 },
-       { 0x002150,   1, 0x04, 0x00000004 },
-       { 0x000380,   4, 0x20, 0x00000000 },
-       { 0x000384,   4, 0x20, 0x00000000 },
-       { 0x000388,   4, 0x20, 0x00000000 },
-       { 0x00038c,   4, 0x20, 0x00000000 },
-       { 0x000700,   4, 0x10, 0x00000000 },
-       { 0x000704,   4, 0x10, 0x00000000 },
-       { 0x000708,   4, 0x10, 0x00000000 },
-       { 0x002800, 128, 0x04, 0x00000000 },
-       { 0x000a00,  16, 0x20, 0x00000000 },
-       { 0x000a04,  16, 0x20, 0x00000000 },
-       { 0x000a08,  16, 0x20, 0x00000000 },
-       { 0x000a0c,  16, 0x20, 0x00000000 },
-       { 0x000a10,  16, 0x20, 0x00000000 },
-       { 0x000a14,  16, 0x20, 0x00000000 },
-       { 0x000a18,  16, 0x20, 0x00006420 },
-       { 0x000a1c,  16, 0x20, 0x00000000 },
-       { 0x000c00,  16, 0x10, 0x00000000 },
-       { 0x000c04,  16, 0x10, 0x00000000 },
-       { 0x000c08,  16, 0x10, 0x00000000 },
-       { 0x000c0c,  16, 0x10, 0x3f800000 },
-       { 0x000d00,   8, 0x08, 0xffff0000 },
-       { 0x000d04,   8, 0x08, 0xffff0000 },
-       { 0x000e00,  16, 0x10, 0x00000000 },
-       { 0x000e04,  16, 0x10, 0xffff0000 },
-       { 0x000e08,  16, 0x10, 0xffff0000 },
-       { 0x000d40,   4, 0x08, 0x00000000 },
-       { 0x000d44,   4, 0x08, 0x00000000 },
-       { 0x001e00,   8, 0x20, 0x00000001 },
-       { 0x001e04,   8, 0x20, 0x00000001 },
-       { 0x001e08,   8, 0x20, 0x00000002 },
-       { 0x001e0c,   8, 0x20, 0x00000001 },
-       { 0x001e10,   8, 0x20, 0x00000001 },
-       { 0x001e14,   8, 0x20, 0x00000002 },
-       { 0x001e18,   8, 0x20, 0x00000001 },
-       { 0x001480,   8, 0x10, 0x00000000 },
-       { 0x001484,   8, 0x10, 0x00000000 },
-       { 0x001488,   8, 0x10, 0x00000000 },
-       { 0x003400, 128, 0x04, 0x00000000 },
-       { 0x00030c,   1, 0x04, 0x00000001 },
-       { 0x001944,   1, 0x04, 0x00000000 },
-       { 0x001514,   1, 0x04, 0x00000000 },
-       { 0x000d68,   1, 0x04, 0x0000ffff },
-       { 0x00121c,   1, 0x04, 0x0fac6881 },
-       { 0x000fac,   1, 0x04, 0x00000001 },
-       { 0x001538,   1, 0x04, 0x00000001 },
-       { 0x000fe0,   2, 0x04, 0x00000000 },
-       { 0x000fe8,   1, 0x04, 0x00000014 },
-       { 0x000fec,   1, 0x04, 0x00000040 },
-       { 0x000ff0,   1, 0x04, 0x00000000 },
-       { 0x00179c,   1, 0x04, 0x00000000 },
-       { 0x001228,   1, 0x04, 0x00000400 },
-       { 0x00122c,   1, 0x04, 0x00000300 },
-       { 0x001230,   1, 0x04, 0x00010001 },
-       { 0x0007f8,   1, 0x04, 0x00000000 },
-       { 0x001208,   1, 0x04, 0x00000000 },
-       { 0x0015b4,   1, 0x04, 0x00000001 },
-       { 0x0015cc,   1, 0x04, 0x00000000 },
-       { 0x001534,   1, 0x04, 0x00000000 },
-       { 0x000754,   1, 0x04, 0x00000001 },
-       { 0x000fb0,   1, 0x04, 0x00000000 },
-       { 0x0015d0,   1, 0x04, 0x00000000 },
-       { 0x0011e0,   4, 0x04, 0x88888888 },
-       { 0x00153c,   1, 0x04, 0x00000000 },
-       { 0x0016b4,   1, 0x04, 0x00000003 },
-       { 0x000fa4,   1, 0x04, 0x00000001 },
-       { 0x000fbc,   4, 0x04, 0x0000ffff },
-       { 0x000fa8,   1, 0x04, 0x0000ffff },
-       { 0x000df8,   2, 0x04, 0x00000000 },
-       { 0x001948,   1, 0x04, 0x00000000 },
-       { 0x001970,   1, 0x04, 0x00000001 },
-       { 0x00161c,   1, 0x04, 0x000009f0 },
-       { 0x000dcc,   1, 0x04, 0x00000010 },
-       { 0x0015e4,   1, 0x04, 0x00000000 },
-       { 0x001160,  32, 0x04, 0x25e00040 },
-       { 0x001880,  32, 0x04, 0x00000000 },
-       { 0x000f84,   2, 0x04, 0x00000000 },
-       { 0x0017c8,   2, 0x04, 0x00000000 },
-       { 0x0017d0,   1, 0x04, 0x000000ff },
-       { 0x0017d4,   1, 0x04, 0xffffffff },
-       { 0x0017d8,   1, 0x04, 0x00000002 },
-       { 0x0017dc,   1, 0x04, 0x00000000 },
-       { 0x0015f4,   2, 0x04, 0x00000000 },
-       { 0x001434,   2, 0x04, 0x00000000 },
-       { 0x000d74,   1, 0x04, 0x00000000 },
-       { 0x0013a4,   1, 0x04, 0x00000000 },
-       { 0x001318,   1, 0x04, 0x00000001 },
-       { 0x001080,   2, 0x04, 0x00000000 },
-       { 0x001088,   2, 0x04, 0x00000001 },
-       { 0x001090,   1, 0x04, 0x00000000 },
-       { 0x001094,   1, 0x04, 0x00000001 },
-       { 0x001098,   1, 0x04, 0x00000000 },
-       { 0x00109c,   1, 0x04, 0x00000001 },
-       { 0x0010a0,   2, 0x04, 0x00000000 },
-       { 0x001644,   1, 0x04, 0x00000000 },
-       { 0x000748,   1, 0x04, 0x00000000 },
-       { 0x000de8,   1, 0x04, 0x00000000 },
-       { 0x001648,   1, 0x04, 0x00000000 },
-       { 0x0012a4,   1, 0x04, 0x00000000 },
-       { 0x001120,   4, 0x04, 0x00000000 },
-       { 0x001118,   1, 0x04, 0x00000000 },
-       { 0x00164c,   1, 0x04, 0x00000000 },
-       { 0x001658,   1, 0x04, 0x00000000 },
-       { 0x001910,   1, 0x04, 0x00000290 },
-       { 0x001518,   1, 0x04, 0x00000000 },
-       { 0x00165c,   1, 0x04, 0x00000001 },
-       { 0x001520,   1, 0x04, 0x00000000 },
-       { 0x001604,   1, 0x04, 0x00000000 },
-       { 0x001570,   1, 0x04, 0x00000000 },
-       { 0x0013b0,   2, 0x04, 0x3f800000 },
-       { 0x00020c,   1, 0x04, 0x00000000 },
-       { 0x001670,   1, 0x04, 0x30201000 },
-       { 0x001674,   1, 0x04, 0x70605040 },
-       { 0x001678,   1, 0x04, 0xb8a89888 },
-       { 0x00167c,   1, 0x04, 0xf8e8d8c8 },
-       { 0x00166c,   1, 0x04, 0x00000000 },
-       { 0x001680,   1, 0x04, 0x00ffff00 },
-       { 0x0012d0,   1, 0x04, 0x00000003 },
-       { 0x00113c,   1, 0x04, 0x00000000 },
-       { 0x0012d4,   1, 0x04, 0x00000002 },
-       { 0x001684,   2, 0x04, 0x00000000 },
-       { 0x000dac,   2, 0x04, 0x00001b02 },
-       { 0x000db4,   1, 0x04, 0x00000000 },
-       { 0x00168c,   1, 0x04, 0x00000000 },
-       { 0x0015bc,   1, 0x04, 0x00000000 },
-       { 0x00156c,   1, 0x04, 0x00000000 },
-       { 0x00187c,   1, 0x04, 0x00000000 },
-       { 0x001110,   1, 0x04, 0x00000001 },
-       { 0x000dc0,   3, 0x04, 0x00000000 },
-       { 0x000f40,   5, 0x04, 0x00000000 },
-       { 0x001234,   1, 0x04, 0x00000000 },
-       { 0x001690,   1, 0x04, 0x00000000 },
-       { 0x000790,   5, 0x04, 0x00000000 },
-       { 0x00077c,   1, 0x04, 0x00000000 },
-       { 0x001000,   1, 0x04, 0x00000010 },
-       { 0x0010fc,   1, 0x04, 0x00000000 },
-       { 0x001290,   1, 0x04, 0x00000000 },
-       { 0x000218,   1, 0x04, 0x00000010 },
-       { 0x0012d8,   1, 0x04, 0x00000000 },
-       { 0x0012dc,   1, 0x04, 0x00000010 },
-       { 0x000d94,   1, 0x04, 0x00000001 },
-       { 0x00155c,   2, 0x04, 0x00000000 },
-       { 0x001564,   1, 0x04, 0x00000fff },
-       { 0x001574,   2, 0x04, 0x00000000 },
-       { 0x00157c,   1, 0x04, 0x000fffff },
-       { 0x001354,   1, 0x04, 0x00000000 },
-       { 0x001610,   1, 0x04, 0x00000012 },
-       { 0x001608,   2, 0x04, 0x00000000 },
-       { 0x00260c,   1, 0x04, 0x00000000 },
-       { 0x0007ac,   1, 0x04, 0x00000000 },
-       { 0x00162c,   1, 0x04, 0x00000003 },
-       { 0x000210,   1, 0x04, 0x00000000 },
-       { 0x000320,   1, 0x04, 0x00000000 },
-       { 0x000324,   6, 0x04, 0x3f800000 },
-       { 0x000750,   1, 0x04, 0x00000000 },
-       { 0x000760,   1, 0x04, 0x39291909 },
-       { 0x000764,   1, 0x04, 0x79695949 },
-       { 0x000768,   1, 0x04, 0xb9a99989 },
-       { 0x00076c,   1, 0x04, 0xf9e9d9c9 },
-       { 0x000770,   1, 0x04, 0x30201000 },
-       { 0x000774,   1, 0x04, 0x70605040 },
-       { 0x000778,   1, 0x04, 0x00009080 },
-       { 0x000780,   1, 0x04, 0x39291909 },
-       { 0x000784,   1, 0x04, 0x79695949 },
-       { 0x000788,   1, 0x04, 0xb9a99989 },
-       { 0x00078c,   1, 0x04, 0xf9e9d9c9 },
-       { 0x0007d0,   1, 0x04, 0x30201000 },
-       { 0x0007d4,   1, 0x04, 0x70605040 },
-       { 0x0007d8,   1, 0x04, 0x00009080 },
-       { 0x001004,   1, 0x04, 0x00000000 },
-       { 0x001240,   8, 0x04, 0x00000000 },
-       { 0x00037c,   1, 0x04, 0x00000001 },
-       { 0x000740,   1, 0x04, 0x00000000 },
-       { 0x001148,   1, 0x04, 0x00000000 },
-       { 0x000fb4,   1, 0x04, 0x00000000 },
-       { 0x000fb8,   1, 0x04, 0x00000002 },
-       { 0x001130,   1, 0x04, 0x00000002 },
-       { 0x000fd4,   2, 0x04, 0x00000000 },
-       { 0x001030,   1, 0x04, 0x20181008 },
-       { 0x001034,   1, 0x04, 0x40383028 },
-       { 0x001038,   1, 0x04, 0x60585048 },
-       { 0x00103c,   1, 0x04, 0x80787068 },
-       { 0x000744,   1, 0x04, 0x00000000 },
-       { 0x002600,   1, 0x04, 0x00000000 },
-       { 0x001918,   1, 0x04, 0x00000000 },
-       { 0x00191c,   1, 0x04, 0x00000900 },
-       { 0x001920,   1, 0x04, 0x00000405 },
-       { 0x001308,   1, 0x04, 0x00000001 },
-       { 0x001924,   1, 0x04, 0x00000000 },
-       { 0x0013ac,   1, 0x04, 0x00000000 },
-       { 0x00192c,   1, 0x04, 0x00000001 },
-       { 0x00193c,   1, 0x04, 0x00002c1c },
-       { 0x000d7c,   1, 0x04, 0x00000000 },
-       { 0x000f8c,   1, 0x04, 0x00000000 },
-       { 0x0002c0,   1, 0x04, 0x00000001 },
-       { 0x001510,   1, 0x04, 0x00000000 },
-       { 0x001940,   1, 0x04, 0x00000000 },
-       { 0x000ff4,   2, 0x04, 0x00000000 },
-       { 0x00194c,   2, 0x04, 0x00000000 },
-       { 0x001968,   1, 0x04, 0x00000000 },
-       { 0x001590,   1, 0x04, 0x0000003f },
-       { 0x0007e8,   4, 0x04, 0x00000000 },
-       { 0x00196c,   1, 0x04, 0x00000011 },
-       { 0x0002e4,   1, 0x04, 0x0000b001 },
-       { 0x00036c,   2, 0x04, 0x00000000 },
-       { 0x00197c,   1, 0x04, 0x00000000 },
-       { 0x000fcc,   2, 0x04, 0x00000000 },
-       { 0x0002d8,   1, 0x04, 0x00000040 },
-       { 0x001980,   1, 0x04, 0x00000080 },
-       { 0x001504,   1, 0x04, 0x00000080 },
-       { 0x001984,   1, 0x04, 0x00000000 },
-       { 0x000f60,   1, 0x04, 0x00000000 },
-       { 0x000f64,   1, 0x04, 0x00400040 },
-       { 0x000f68,   1, 0x04, 0x00002212 },
-       { 0x000f6c,   1, 0x04, 0x08080203 },
-       { 0x001108,   1, 0x04, 0x00000008 },
-       { 0x000f70,   1, 0x04, 0x00080001 },
-       { 0x000ffc,   1, 0x04, 0x00000000 },
-       { 0x001134,   1, 0x04, 0x00000000 },
-       { 0x000f1c,   1, 0x04, 0x00000000 },
-       { 0x0011f8,   1, 0x04, 0x00000000 },
-       { 0x001138,   1, 0x04, 0x00000001 },
-       { 0x000300,   1, 0x04, 0x00000001 },
-       { 0x0013a8,   1, 0x04, 0x00000000 },
-       { 0x001224,   1, 0x04, 0x00000000 },
-       { 0x0012ec,   1, 0x04, 0x00000000 },
-       { 0x001310,   1, 0x04, 0x00000000 },
-       { 0x001314,   1, 0x04, 0x00000001 },
-       { 0x001380,   1, 0x04, 0x00000000 },
-       { 0x001384,   4, 0x04, 0x00000001 },
-       { 0x001394,   1, 0x04, 0x00000000 },
-       { 0x00139c,   1, 0x04, 0x00000000 },
-       { 0x001398,   1, 0x04, 0x00000000 },
-       { 0x001594,   1, 0x04, 0x00000000 },
-       { 0x001598,   4, 0x04, 0x00000001 },
-       { 0x000f54,   3, 0x04, 0x00000000 },
-       { 0x0019bc,   1, 0x04, 0x00000000 },
-       { 0x000f9c,   2, 0x04, 0x00000000 },
-       { 0x0012cc,   1, 0x04, 0x00000000 },
-       { 0x0012e8,   1, 0x04, 0x00000000 },
-       { 0x00130c,   1, 0x04, 0x00000001 },
-       { 0x001360,   8, 0x04, 0x00000000 },
-       { 0x00133c,   2, 0x04, 0x00000001 },
-       { 0x001344,   1, 0x04, 0x00000002 },
-       { 0x001348,   2, 0x04, 0x00000001 },
-       { 0x001350,   1, 0x04, 0x00000002 },
-       { 0x001358,   1, 0x04, 0x00000001 },
-       { 0x0012e4,   1, 0x04, 0x00000000 },
-       { 0x00131c,   4, 0x04, 0x00000000 },
-       { 0x0019c0,   1, 0x04, 0x00000000 },
-       { 0x001140,   1, 0x04, 0x00000000 },
-       { 0x000dd0,   1, 0x04, 0x00000000 },
-       { 0x000dd4,   1, 0x04, 0x00000001 },
-       { 0x0002f4,   1, 0x04, 0x00000000 },
-       { 0x0019c4,   1, 0x04, 0x00000000 },
-       { 0x0019c8,   1, 0x04, 0x00001500 },
-       { 0x00135c,   1, 0x04, 0x00000000 },
-       { 0x000f90,   1, 0x04, 0x00000000 },
-       { 0x0019e0,   8, 0x04, 0x00000001 },
-       { 0x0019cc,   1, 0x04, 0x00000001 },
-       { 0x00111c,   1, 0x04, 0x00000001 },
-       { 0x0015b8,   1, 0x04, 0x00000000 },
-       { 0x001a00,   1, 0x04, 0x00001111 },
-       { 0x001a04,   7, 0x04, 0x00000000 },
-       { 0x000d6c,   2, 0x04, 0xffff0000 },
-       { 0x0010f8,   1, 0x04, 0x00001010 },
-       { 0x000d80,   5, 0x04, 0x00000000 },
-       { 0x000da0,   1, 0x04, 0x00000000 },
-       { 0x0007a4,   2, 0x04, 0x00000000 },
-       { 0x001508,   1, 0x04, 0x80000000 },
-       { 0x00150c,   1, 0x04, 0x40000000 },
-       { 0x001668,   1, 0x04, 0x00000000 },
-       { 0x000318,   2, 0x04, 0x00000008 },
-       { 0x000d9c,   1, 0x04, 0x00000001 },
-       { 0x000f14,   1, 0x04, 0x00000000 },
-       { 0x000374,   1, 0x04, 0x00000000 },
-       { 0x000378,   1, 0x04, 0x0000000c },
-       { 0x0007dc,   1, 0x04, 0x00000000 },
-       { 0x00074c,   1, 0x04, 0x00000055 },
-       { 0x001420,   1, 0x04, 0x00000003 },
-       { 0x001008,   1, 0x04, 0x00000008 },
-       { 0x00100c,   1, 0x04, 0x00000040 },
-       { 0x001010,   1, 0x04, 0x0000012c },
-       { 0x000d60,   1, 0x04, 0x00000040 },
-       { 0x001018,   1, 0x04, 0x00000020 },
-       { 0x00101c,   1, 0x04, 0x00000001 },
-       { 0x001020,   1, 0x04, 0x00000020 },
-       { 0x001024,   1, 0x04, 0x00000001 },
-       { 0x001444,   3, 0x04, 0x00000000 },
-       { 0x000360,   1, 0x04, 0x20164010 },
-       { 0x000364,   1, 0x04, 0x00000020 },
-       { 0x000368,   1, 0x04, 0x00000000 },
-       { 0x000da8,   1, 0x04, 0x00000030 },
-       { 0x000de4,   1, 0x04, 0x00000000 },
-       { 0x000204,   1, 0x04, 0x00000006 },
-       { 0x0002d0,   1, 0x04, 0x003fffff },
-       { 0x001220,   1, 0x04, 0x00000005 },
-       { 0x000fdc,   1, 0x04, 0x00000000 },
-       { 0x000f98,   1, 0x04, 0x00400008 },
-       { 0x001284,   1, 0x04, 0x08000080 },
-       { 0x001450,   1, 0x04, 0x00400008 },
-       { 0x001454,   1, 0x04, 0x08000080 },
-       { 0x000214,   1, 0x04, 0x00000000 },
-       {}
-};
-
-const struct gf100_gr_pack
-gm204_grctx_pack_mthd[] = {
-       { gm204_grctx_init_b197_0, 0xb197 },
-       { gf100_grctx_init_902d_0, 0x902d },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_fe_0[] = {
-       { 0x404004,   8, 0x04, 0x00000000 },
-       { 0x404024,   1, 0x04, 0x0000e000 },
-       { 0x404028,   8, 0x04, 0x00000000 },
-       { 0x4040a8,   8, 0x04, 0x00000000 },
-       { 0x4040c8,   1, 0x04, 0xf801008f },
-       { 0x4040d0,   6, 0x04, 0x00000000 },
-       { 0x4040f8,   1, 0x04, 0x00000000 },
-       { 0x404100,  10, 0x04, 0x00000000 },
-       { 0x404130,   2, 0x04, 0x00000000 },
-       { 0x404150,   1, 0x04, 0x0000002e },
-       { 0x404154,   2, 0x04, 0x00000800 },
-       { 0x404164,   1, 0x04, 0x00000045 },
-       { 0x40417c,   2, 0x04, 0x00000000 },
-       { 0x404194,   1, 0x04, 0x33000700 },
-       { 0x4041a0,   4, 0x04, 0x00000000 },
-       { 0x4041c4,   2, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_ds_0[] = {
-       { 0x405800,   1, 0x04, 0x8f8001bf },
-       { 0x405830,   1, 0x04, 0x04001000 },
-       { 0x405834,   1, 0x04, 0x08000000 },
-       { 0x405838,   1, 0x04, 0x00010000 },
-       { 0x405854,   1, 0x04, 0x00000000 },
-       { 0x405870,   4, 0x04, 0x00000001 },
-       { 0x405a00,   2, 0x04, 0x00000000 },
-       { 0x405a18,   1, 0x04, 0x00000000 },
-       { 0x405a1c,   1, 0x04, 0x000000ff },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_cwd_0[] = {
-       { 0x405b00,   1, 0x04, 0x00000000 },
-       { 0x405b10,   1, 0x04, 0x00001000 },
-       { 0x405b20,   1, 0x04, 0x04000000 },
-       { 0x405b60,   6, 0x04, 0x00000000 },
-       { 0x405ba0,   6, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_pd_0[] = {
-       { 0x406020,   1, 0x04, 0x17410001 },
-       { 0x406028,   4, 0x04, 0x00000001 },
-       { 0x4064a8,   1, 0x04, 0x00000000 },
-       { 0x4064ac,   1, 0x04, 0x00003fff },
-       { 0x4064b0,   3, 0x04, 0x00000000 },
-       { 0x4064c0,   1, 0x04, 0x80400280 },
-       { 0x4064c4,   1, 0x04, 0x0400ffff },
-       { 0x4064c8,   1, 0x04, 0x01800780 },
-       { 0x4064cc,   9, 0x04, 0x00000000 },
-       { 0x4064fc,   1, 0x04, 0x0000022a },
-       { 0x406500,   1, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_be_0[] = {
-       { 0x408800,   1, 0x04, 0x32882a3c },
-       { 0x408804,   1, 0x04, 0x00000040 },
-       { 0x408808,   1, 0x04, 0x1003e005 },
-       { 0x408840,   1, 0x04, 0x00000e0b },
-       { 0x408900,   1, 0x04, 0xb080b801 },
-       { 0x408904,   1, 0x04, 0x63038001 },
-       { 0x408908,   1, 0x04, 0x12c8502f },
-       { 0x408980,   1, 0x04, 0x0000011d },
-       {}
-};
-
-const struct gf100_gr_pack
-gm204_grctx_pack_hub[] = {
-       { gf100_grctx_init_main_0 },
-       { gm204_grctx_init_fe_0 },
-       { gk110_grctx_init_pri_0 },
-       { gk104_grctx_init_memfmt_0 },
-       { gm204_grctx_init_ds_0 },
-       { gm204_grctx_init_cwd_0 },
-       { gm204_grctx_init_pd_0 },
-       { gk208_grctx_init_rstr2d_0 },
-       { gk104_grctx_init_scc_0 },
-       { gm204_grctx_init_be_0 },
-       {}
-};
-
-const struct gf100_gr_init
-gm204_grctx_init_prop_0[] = {
-       { 0x418400,   1, 0x04, 0x38e01e00 },
-       { 0x418404,   1, 0x04, 0x70001fff },
-       { 0x41840c,   1, 0x04, 0x20001008 },
-       { 0x418410,   2, 0x04, 0x0fff0fff },
-       { 0x418418,   1, 0x04, 0x07ff07ff },
-       { 0x41841c,   1, 0x04, 0x3feffbff },
-       { 0x418450,   6, 0x04, 0x00000000 },
-       { 0x418468,   1, 0x04, 0x00000001 },
-       { 0x41846c,   2, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_gpc_unk_1[] = {
-       { 0x418600,   1, 0x04, 0x0000007f },
-       { 0x418684,   1, 0x04, 0x0000001f },
-       { 0x418700,   1, 0x04, 0x00000002 },
-       { 0x418704,   1, 0x04, 0x00000080 },
-       { 0x418708,   1, 0x04, 0x40000000 },
-       { 0x41870c,   2, 0x04, 0x00000000 },
-       { 0x418728,   1, 0x04, 0x00010000 },
-       {}
-};
-
-const struct gf100_gr_init
-gm204_grctx_init_setup_0[] = {
-       { 0x418800,   1, 0x04, 0x7006863a },
-       { 0x418808,   1, 0x04, 0x00000000 },
-       { 0x418810,   1, 0x04, 0x00000000 },
-       { 0x418828,   1, 0x04, 0x00000044 },
-       { 0x418830,   1, 0x04, 0x10000001 },
-       { 0x4188d8,   1, 0x04, 0x00000008 },
-       { 0x4188e0,   1, 0x04, 0x01000000 },
-       { 0x4188e8,   5, 0x04, 0x00000000 },
-       { 0x4188fc,   1, 0x04, 0x20100058 },
-       {}
-};
-
-const struct gf100_gr_init
-gm204_grctx_init_gpm_0[] = {
-       { 0x418c10,   8, 0x04, 0x00000000 },
-       { 0x418c40,   1, 0x04, 0xffffffff },
-       { 0x418c6c,   1, 0x04, 0x00000001 },
-       { 0x418c80,   1, 0x04, 0x20200000 },
-       {}
-};
-
-const struct gf100_gr_init
-gm204_grctx_init_gpc_unk_2[] = {
-       { 0x418e00,   1, 0x04, 0x90040000 },
-       { 0x418e24,   1, 0x04, 0x00000000 },
-       { 0x418e28,   1, 0x04, 0x00000030 },
-       { 0x418e2c,   1, 0x04, 0x00000100 },
-       { 0x418e30,   3, 0x04, 0x00000000 },
-       { 0x418e40,  22, 0x04, 0x00000000 },
-       { 0x418ea0,  12, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_pack
-gm204_grctx_pack_gpc[] = {
-       { gm107_grctx_init_gpc_unk_0 },
-       { gm204_grctx_init_prop_0 },
-       { gm204_grctx_init_gpc_unk_1 },
-       { gm204_grctx_init_setup_0 },
-       { gf100_grctx_init_zcull_0 },
-       { gk208_grctx_init_crstr_0 },
-       { gm204_grctx_init_gpm_0 },
-       { gm204_grctx_init_gpc_unk_2 },
-       { gf100_grctx_init_gcc_0 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_pe_0[] = {
-       { 0x419848,   1, 0x04, 0x00000000 },
-       { 0x419864,   1, 0x04, 0x00000029 },
-       { 0x419888,   1, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_tex_0[] = {
-       { 0x419a00,   1, 0x04, 0x000100f0 },
-       { 0x419a04,   1, 0x04, 0x00000005 },
-       { 0x419a08,   1, 0x04, 0x00000621 },
-       { 0x419a0c,   1, 0x04, 0x00320000 },
-       { 0x419a10,   1, 0x04, 0x00000000 },
-       { 0x419a14,   1, 0x04, 0x00000200 },
-       { 0x419a1c,   1, 0x04, 0x0010c000 },
-       { 0x419a20,   1, 0x04, 0x20008a00 },
-       { 0x419a30,   1, 0x04, 0x00000001 },
-       { 0x419a3c,   1, 0x04, 0x0000181e },
-       { 0x419ac4,   1, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_mpc_0[] = {
-       { 0x419c00,   1, 0x04, 0x0000009a },
-       { 0x419c04,   1, 0x04, 0x80000bd6 },
-       { 0x419c08,   1, 0x04, 0x00000002 },
-       { 0x419c20,   1, 0x04, 0x00000000 },
-       { 0x419c24,   1, 0x04, 0x00084210 },
-       { 0x419c28,   1, 0x04, 0x3efbefbe },
-       { 0x419c2c,   1, 0x04, 0x00000000 },
-       { 0x419c34,   1, 0x04, 0x71ff1ff3 },
-       { 0x419c3c,   1, 0x04, 0x00001919 },
-       { 0x419c50,   1, 0x04, 0x00000005 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_l1c_0[] = {
-       { 0x419c84,   1, 0x04, 0x0000003e },
-       { 0x419c90,   1, 0x04, 0x0000000a },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_sm_0[] = {
-       { 0x419e04,   3, 0x04, 0x00000000 },
-       { 0x419e10,   1, 0x04, 0x00001c02 },
-       { 0x419e44,   1, 0x04, 0x00d3eff2 },
-       { 0x419e48,   1, 0x04, 0x00000000 },
-       { 0x419e4c,   1, 0x04, 0x0000007f },
-       { 0x419e50,   1, 0x04, 0x00000000 },
-       { 0x419e58,   6, 0x04, 0x00000000 },
-       { 0x419e74,  10, 0x04, 0x00000000 },
-       { 0x419eac,   1, 0x04, 0x0001cf8b },
-       { 0x419eb0,   1, 0x04, 0x00030300 },
-       { 0x419eb8,   1, 0x04, 0x40000000 },
-       { 0x419ef0,  24, 0x04, 0x00000000 },
-       { 0x419f68,   2, 0x04, 0x00000000 },
-       { 0x419f70,   1, 0x04, 0x00000020 },
-       { 0x419f78,   1, 0x04, 0x00010beb },
-       { 0x419f7c,   1, 0x04, 0x00000000 },
-       {}
-};
-
-const struct gf100_gr_pack
-gm204_grctx_pack_tpc[] = {
-       { gm204_grctx_init_pe_0 },
-       { gm204_grctx_init_tex_0 },
-       { gm204_grctx_init_mpc_0 },
-       { gm204_grctx_init_l1c_0 },
-       { gm204_grctx_init_sm_0 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_pes_0[] = {
-       { 0x41be24,   1, 0x04, 0x0000000e },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_grctx_init_cbm_0[] = {
-       { 0x41bec0,   1, 0x04, 0x00000000 },
-       { 0x41bec4,   1, 0x04, 0x01030000 },
-       { 0x41bee4,   1, 0x04, 0x00000000 },
-       { 0x41bef0,   1, 0x04, 0x000003ff },
-       { 0x41bef4,   2, 0x04, 0x00000000 },
-       {}
-};
-
-const struct gf100_gr_pack
-gm204_grctx_pack_ppc[] = {
-       { gm204_grctx_init_pes_0 },
-       { gm204_grctx_init_cbm_0 },
-       { gm107_grctx_init_wwdx_0 },
-       {}
-};
-
-/*******************************************************************************
- * PGRAPH context implementation
- ******************************************************************************/
-
-void
-gm204_grctx_generate_tpcid(struct gf100_gr *gr)
-{
-       struct nvkm_device *device = gr->base.engine.subdev.device;
-       int gpc, tpc, id;
-
-       for (tpc = 0, id = 0; tpc < 4; tpc++) {
-               for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
-                       if (tpc < gr->tpc_nr[gpc]) {
-                               nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x698), id);
-                               nvkm_wr32(device, GPC_UNIT(gpc, 0x0c10 + tpc * 4), id);
-                               nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x088), id);
-                               id++;
-                       }
-               }
-       }
-}
-
-static void
-gm204_grctx_generate_rop_active_fbps(struct gf100_gr *gr)
-{
-       struct nvkm_device *device = gr->base.engine.subdev.device;
-       const u32 fbp_count = nvkm_rd32(device, 0x12006c);
-       nvkm_mask(device, 0x408850, 0x0000000f, fbp_count); /* zrop */
-       nvkm_mask(device, 0x408958, 0x0000000f, fbp_count); /* crop */
-}
-
-void
-gm204_grctx_generate_405b60(struct gf100_gr *gr)
-{
-       struct nvkm_device *device = gr->base.engine.subdev.device;
-       const u32 dist_nr = DIV_ROUND_UP(gr->tpc_total, 4);
-       u32 dist[TPC_MAX / 4] = {};
-       u32 gpcs[GPC_MAX] = {};
-       u8  tpcnr[GPC_MAX];
-       int tpc, gpc, i;
-
-       memcpy(tpcnr, gr->tpc_nr, sizeof(gr->tpc_nr));
-
-       /* won't result in the same distribution as the binary driver where
-        * some of the gpcs have more tpcs than others, but this shall do
-        * for the moment.  the code for earlier gpus has this issue too.
-        */
-       for (gpc = -1, i = 0; i < gr->tpc_total; i++) {
-               do {
-                       gpc = (gpc + 1) % gr->gpc_nr;
-               } while(!tpcnr[gpc]);
-               tpc = gr->tpc_nr[gpc] - tpcnr[gpc]--;
-
-               dist[i / 4] |= ((gpc << 4) | tpc) << ((i % 4) * 8);
-               gpcs[gpc] |= i << (tpc * 8);
-       }
-
-       for (i = 0; i < dist_nr; i++)
-               nvkm_wr32(device, 0x405b60 + (i * 4), dist[i]);
-       for (i = 0; i < gr->gpc_nr; i++)
-               nvkm_wr32(device, 0x405ba0 + (i * 4), gpcs[i]);
-}
-
-void
-gm204_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info)
-{
-       struct nvkm_device *device = gr->base.engine.subdev.device;
-       const struct gf100_grctx_func *grctx = gr->func->grctx;
-       u32 tmp;
-       int i;
-
-       gf100_gr_mmio(gr, grctx->hub);
-       gf100_gr_mmio(gr, grctx->gpc);
-       gf100_gr_mmio(gr, grctx->zcull);
-       gf100_gr_mmio(gr, grctx->tpc);
-       gf100_gr_mmio(gr, grctx->ppc);
-
-       nvkm_wr32(device, 0x404154, 0x00000000);
-
-       grctx->bundle(info);
-       grctx->pagepool(info);
-       grctx->attrib(info);
-       grctx->unkn(gr);
-
-       gm204_grctx_generate_tpcid(gr);
-       gf100_grctx_generate_r406028(gr);
-       gk104_grctx_generate_r418bb8(gr);
-
-       for (i = 0; i < 8; i++)
-               nvkm_wr32(device, 0x4064d0 + (i * 0x04), 0x00000000);
-       nvkm_wr32(device, 0x406500, 0x00000000);
-
-       nvkm_wr32(device, 0x405b00, (gr->tpc_total << 8) | gr->gpc_nr);
-
-       gm204_grctx_generate_rop_active_fbps(gr);
-
-       for (tmp = 0, i = 0; i < gr->gpc_nr; i++)
-               tmp |= ((1 << gr->tpc_nr[i]) - 1) << (i * 4);
-       nvkm_wr32(device, 0x4041c4, tmp);
-
-       gm204_grctx_generate_405b60(gr);
-
-       gf100_gr_icmd(gr, grctx->icmd);
-       nvkm_wr32(device, 0x404154, 0x00000800);
-       gf100_gr_mthd(gr, grctx->mthd);
-
-       nvkm_mask(device, 0x418e94, 0xffffffff, 0xc4230000);
-       nvkm_mask(device, 0x418e4c, 0xffffffff, 0x70000000);
-}
-
-const struct gf100_grctx_func
-gm204_grctx = {
-       .main  = gm204_grctx_generate_main,
-       .unkn  = gk104_grctx_generate_unkn,
-       .hub   = gm204_grctx_pack_hub,
-       .gpc   = gm204_grctx_pack_gpc,
-       .zcull = gf100_grctx_pack_zcull,
-       .tpc   = gm204_grctx_pack_tpc,
-       .ppc   = gm204_grctx_pack_ppc,
-       .icmd  = gm204_grctx_pack_icmd,
-       .mthd  = gm204_grctx_pack_mthd,
-       .bundle = gm107_grctx_generate_bundle,
-       .bundle_size = 0x3000,
-       .bundle_min_gpm_fifo_depth = 0x180,
-       .bundle_token_limit = 0x780,
-       .pagepool = gm107_grctx_generate_pagepool,
-       .pagepool_size = 0x20000,
-       .attrib = gm107_grctx_generate_attrib,
-       .attrib_nr_max = 0x600,
-       .attrib_nr = 0x400,
-       .alpha_nr_max = 0x1800,
-       .alpha_nr = 0x1000,
-};
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm206.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgm206.c
deleted file mode 100644 (file)
index d6be603..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs <bskeggs@redhat.com>
- */
-#include "ctxgf100.h"
-
-static const struct gf100_gr_init
-gm206_grctx_init_gpc_unk_1[] = {
-       { 0x418600,   1, 0x04, 0x0000007f },
-       { 0x418684,   1, 0x04, 0x0000001f },
-       { 0x418700,   1, 0x04, 0x00000002 },
-       { 0x418704,   1, 0x04, 0x00000080 },
-       { 0x418708,   1, 0x04, 0x40000000 },
-       { 0x41870c,   2, 0x04, 0x00000000 },
-       { 0x418728,   1, 0x04, 0x00300020 },
-       {}
-};
-
-static const struct gf100_gr_pack
-gm206_grctx_pack_gpc[] = {
-       { gm107_grctx_init_gpc_unk_0 },
-       { gm204_grctx_init_prop_0 },
-       { gm206_grctx_init_gpc_unk_1 },
-       { gm204_grctx_init_setup_0 },
-       { gf100_grctx_init_zcull_0 },
-       { gk208_grctx_init_crstr_0 },
-       { gm204_grctx_init_gpm_0 },
-       { gm204_grctx_init_gpc_unk_2 },
-       { gf100_grctx_init_gcc_0 },
-       {}
-};
-
-const struct gf100_grctx_func
-gm206_grctx = {
-       .main  = gm204_grctx_generate_main,
-       .unkn  = gk104_grctx_generate_unkn,
-       .hub   = gm204_grctx_pack_hub,
-       .gpc   = gm206_grctx_pack_gpc,
-       .zcull = gf100_grctx_pack_zcull,
-       .tpc   = gm204_grctx_pack_tpc,
-       .ppc   = gm204_grctx_pack_ppc,
-       .icmd  = gm204_grctx_pack_icmd,
-       .mthd  = gm204_grctx_pack_mthd,
-       .bundle = gm107_grctx_generate_bundle,
-       .bundle_size = 0x3000,
-       .bundle_min_gpm_fifo_depth = 0x180,
-       .bundle_token_limit = 0x780,
-       .pagepool = gm107_grctx_generate_pagepool,
-       .pagepool_size = 0x20000,
-       .attrib = gm107_grctx_generate_attrib,
-       .attrib_nr_max = 0x600,
-       .attrib_nr = 0x400,
-       .alpha_nr_max = 0x1800,
-       .alpha_nr = 0x1000,
-};
index 6702604..a8827ef 100644 (file)
@@ -54,7 +54,7 @@ gm20b_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info)
 
        grctx->unkn(gr);
 
-       gm204_grctx_generate_tpcid(gr);
+       gm200_grctx_generate_tpcid(gr);
        gm20b_grctx_generate_r406028(gr);
        gk104_grctx_generate_r418bb8(gr);
 
@@ -70,7 +70,7 @@ gm20b_grctx_generate_main(struct gf100_gr *gr, struct gf100_grctx *info)
                tmp |= ((1 << gr->tpc_nr[i]) - 1) << (i * 4);
        nvkm_wr32(device, 0x4041c4, tmp);
 
-       gm204_grctx_generate_405b60(gr);
+       gm200_grctx_generate_405b60(gr);
 
        gf100_gr_wait_idle(gr);
 
index e168b83..dc60509 100644 (file)
@@ -322,6 +322,7 @@ main:
 
 // interrupt handler
 ih:
+       push $r0
        push $r8
        mov $r8 $flags
        push $r8
@@ -358,6 +359,7 @@ ih:
        pop $r8
        mov $flags $r8
        pop $r8
+       pop $r0
        bclr $flags $p0
        iret
 
index 231f696..5f4ddfe 100644 (file)
@@ -382,56 +382,57 @@ uint32_t gf100_grgpc_code[] = {
        0xb60412fd,
        0x1efd01e4,
        0x0018fe05,
-       0x05b021f5,
+       0x05b421f5,
 /* 0x04eb: main_not_ctx_xfer */
        0x94d30ef4,
        0xf5f010ef,
        0x7e21f501,
        0xc60ef403,
 /* 0x04f8: ih */
-       0x88fe80f9,
-       0xf980f901,
-       0xf9a0f990,
-       0xf9d0f9b0,
-       0xbdf0f9e0,
-       0x00a7f104,
-       0x00a3f002,
-       0xc400aacf,
-       0x0bf404ab,
-       0x1cd7f02c,
-       0x1a00e7f1,
-       0xcf00e3f0,
-       0xf7f100ee,
-       0xf3f01900,
-       0x00ffcf00,
-       0xf00421f4,
-       0x07f101e7,
-       0x03f01d00,
-       0x000ed000,
-/* 0x0546: ih_no_fifo */
-       0x07f104bd,
-       0x03f00100,
-       0x000ad000,
-       0xf0fc04bd,
-       0xd0fce0fc,
-       0xa0fcb0fc,
-       0x80fc90fc,
-       0xfc0088fe,
-       0x0032f480,
-/* 0x056a: hub_barrier_done */
+       0x80f900f9,
+       0xf90188fe,
+       0xf990f980,
+       0xf9b0f9a0,
+       0xf9e0f9d0,
+       0xf104bdf0,
+       0xf00200a7,
+       0xaacf00a3,
+       0x04abc400,
+       0xf02c0bf4,
+       0xe7f11cd7,
+       0xe3f01a00,
+       0x00eecf00,
+       0x1900f7f1,
+       0xcf00f3f0,
+       0x21f400ff,
+       0x01e7f004,
+       0x1d0007f1,
+       0xd00003f0,
+       0x04bd000e,
+/* 0x0548: ih_no_fifo */
+       0x010007f1,
+       0xd00003f0,
+       0x04bd000a,
+       0xe0fcf0fc,
+       0xb0fcd0fc,
+       0x90fca0fc,
+       0x88fe80fc,
+       0xfc80fc00,
+       0x0032f400,
+/* 0x056e: hub_barrier_done */
        0xf7f001f8,
        0x040e9801,
        0xb904febb,
        0xe7f102ff,
        0xe3f09418,
        0x9d21f440,
-/* 0x0582: ctx_redswitch */
+/* 0x0586: ctx_redswitch */
        0xf7f000f8,
        0x0007f120,
        0x0103f085,
        0xbd000fd0,
        0x08e7f004,
-/* 0x0594: ctx_redswitch_delay */
+/* 0x0598: ctx_redswitch_delay */
        0xf401e2b6,
        0xf5f1fd1b,
        0xf5f10800,
@@ -439,13 +440,13 @@ uint32_t gf100_grgpc_code[] = {
        0x03f08500,
        0x000fd001,
        0x00f804bd,
-/* 0x05b0: ctx_xfer */
+/* 0x05b4: ctx_xfer */
        0x810007f1,
        0xd00203f0,
        0x04bd000f,
        0xf50711f4,
-/* 0x05c3: ctx_xfer_not_load */
-       0xf5058221,
+/* 0x05c7: ctx_xfer_not_load */
+       0xf5058621,
        0xbd026a21,
        0xfc07f124,
        0x0203f047,
@@ -475,12 +476,11 @@ uint32_t gf100_grgpc_code[] = {
        0x6f21f508,
        0x5e21f501,
        0x0601f402,
-/* 0x063b: ctx_xfer_post */
+/* 0x063f: ctx_xfer_post */
        0xf50712f4,
-/* 0x063f: ctx_xfer_done */
+/* 0x0643: ctx_xfer_done */
        0xf5027f21,
-       0xf8056a21,
-       0x00000000,
+       0xf8056e21,
        0x00000000,
        0x00000000,
        0x00000000,
index bb820ff..03381b1 100644 (file)
@@ -408,56 +408,57 @@ uint32_t gf117_grgpc_code[] = {
        0x0412fd20,
        0xfd01e4b6,
        0x18fe051e,
-       0xfd21f500,
-       0xd30ef405,
+       0x0121f500,
+       0xd30ef406,
 /* 0x0538: main_not_ctx_xfer */
        0xf010ef94,
        0x21f501f5,
        0x0ef4037e,
 /* 0x0545: ih */
-       0xfe80f9c6,
-       0x80f90188,
-       0xa0f990f9,
-       0xd0f9b0f9,
-       0xf0f9e0f9,
-       0xa7f104bd,
-       0xa3f00200,
-       0x00aacf00,
-       0xf404abc4,
-       0xd7f02c0b,
-       0x00e7f124,
-       0x00e3f01a,
-       0xf100eecf,
-       0xf01900f7,
-       0xffcf00f3,
-       0x0421f400,
-       0xf101e7f0,
-       0xf01d0007,
-       0x0ed00003,
-/* 0x0593: ih_no_fifo */
-       0xf104bd00,
-       0xf0010007,
-       0x0ad00003,
-       0xfc04bd00,
-       0xfce0fcf0,
-       0xfcb0fcd0,
-       0xfc90fca0,
-       0x0088fe80,
-       0x32f480fc,
-/* 0x05b7: hub_barrier_done */
+       0xf900f9c6,
+       0x0188fe80,
+       0x90f980f9,
+       0xb0f9a0f9,
+       0xe0f9d0f9,
+       0x04bdf0f9,
+       0x0200a7f1,
+       0xcf00a3f0,
+       0xabc400aa,
+       0x2c0bf404,
+       0xf124d7f0,
+       0xf01a00e7,
+       0xeecf00e3,
+       0x00f7f100,
+       0x00f3f019,
+       0xf400ffcf,
+       0xe7f00421,
+       0x0007f101,
+       0x0003f01d,
+       0xbd000ed0,
+/* 0x0595: ih_no_fifo */
+       0x0007f104,
+       0x0003f001,
+       0xbd000ad0,
+       0xfcf0fc04,
+       0xfcd0fce0,
+       0xfca0fcb0,
+       0xfe80fc90,
+       0x80fc0088,
+       0x32f400fc,
+/* 0x05bb: hub_barrier_done */
        0xf001f800,
        0x0e9801f7,
        0x04febb04,
        0xf102ffb9,
        0xf09418e7,
        0x21f440e3,
-/* 0x05cf: ctx_redswitch */
+/* 0x05d3: ctx_redswitch */
        0xf000f89d,
        0x07f120f7,
        0x03f08500,
        0x000fd001,
        0xe7f004bd,
-/* 0x05e1: ctx_redswitch_delay */
+/* 0x05e5: ctx_redswitch_delay */
        0x01e2b608,
        0xf1fd1bf4,
        0xf10800f5,
@@ -465,13 +466,13 @@ uint32_t gf117_grgpc_code[] = {
        0xf0850007,
        0x0fd00103,
        0xf804bd00,
-/* 0x05fd: ctx_xfer */
+/* 0x0601: ctx_xfer */
        0x0007f100,
        0x0203f081,
        0xbd000fd0,
        0x0711f404,
-       0x05cf21f5,
-/* 0x0610: ctx_xfer_not_load */
+       0x05d321f5,
+/* 0x0614: ctx_xfer_not_load */
        0x026a21f5,
        0x07f124bd,
        0x03f047fc,
@@ -511,10 +512,10 @@ uint32_t gf117_grgpc_code[] = {
        0x21f5016f,
        0x01f4025e,
        0x0712f406,
-/* 0x06ac: ctx_xfer_post */
+/* 0x06b0: ctx_xfer_post */
        0x027f21f5,
-/* 0x06b0: ctx_xfer_done */
-       0x05b721f5,
+/* 0x06b4: ctx_xfer_done */
+       0x05bb21f5,
        0x000000f8,
        0x00000000,
        0x00000000,
@@ -533,5 +534,4 @@ uint32_t gf117_grgpc_code[] = {
        0x00000000,
        0x00000000,
        0x00000000,
-       0x00000000,
 };
index 911976d..99d9b48 100644 (file)
@@ -408,56 +408,57 @@ uint32_t gk104_grgpc_code[] = {
        0x0412fd20,
        0xfd01e4b6,
        0x18fe051e,
-       0xfd21f500,
-       0xd30ef405,
+       0x0121f500,
+       0xd30ef406,
 /* 0x0538: main_not_ctx_xfer */
        0xf010ef94,
        0x21f501f5,
        0x0ef4037e,
 /* 0x0545: ih */
-       0xfe80f9c6,
-       0x80f90188,
-       0xa0f990f9,
-       0xd0f9b0f9,
-       0xf0f9e0f9,
-       0xa7f104bd,
-       0xa3f00200,
-       0x00aacf00,
-       0xf404abc4,
-       0xd7f02c0b,
-       0x00e7f124,
-       0x00e3f01a,
-       0xf100eecf,
-       0xf01900f7,
-       0xffcf00f3,
-       0x0421f400,
-       0xf101e7f0,
-       0xf01d0007,
-       0x0ed00003,
-/* 0x0593: ih_no_fifo */
-       0xf104bd00,
-       0xf0010007,
-       0x0ad00003,
-       0xfc04bd00,
-       0xfce0fcf0,
-       0xfcb0fcd0,
-       0xfc90fca0,
-       0x0088fe80,
-       0x32f480fc,
-/* 0x05b7: hub_barrier_done */
+       0xf900f9c6,
+       0x0188fe80,
+       0x90f980f9,
+       0xb0f9a0f9,
+       0xe0f9d0f9,
+       0x04bdf0f9,
+       0x0200a7f1,
+       0xcf00a3f0,
+       0xabc400aa,
+       0x2c0bf404,
+       0xf124d7f0,
+       0xf01a00e7,
+       0xeecf00e3,
+       0x00f7f100,
+       0x00f3f019,
+       0xf400ffcf,
+       0xe7f00421,
+       0x0007f101,
+       0x0003f01d,
+       0xbd000ed0,
+/* 0x0595: ih_no_fifo */
+       0x0007f104,
+       0x0003f001,
+       0xbd000ad0,
+       0xfcf0fc04,
+       0xfcd0fce0,
+       0xfca0fcb0,
+       0xfe80fc90,
+       0x80fc0088,
+       0x32f400fc,
+/* 0x05bb: hub_barrier_done */
        0xf001f800,
        0x0e9801f7,
        0x04febb04,
        0xf102ffb9,
        0xf09418e7,
        0x21f440e3,
-/* 0x05cf: ctx_redswitch */
+/* 0x05d3: ctx_redswitch */
        0xf000f89d,
        0x07f120f7,
        0x03f08500,
        0x000fd001,
        0xe7f004bd,
-/* 0x05e1: ctx_redswitch_delay */
+/* 0x05e5: ctx_redswitch_delay */
        0x01e2b608,
        0xf1fd1bf4,
        0xf10800f5,
@@ -465,13 +466,13 @@ uint32_t gk104_grgpc_code[] = {
        0xf0850007,
        0x0fd00103,
        0xf804bd00,
-/* 0x05fd: ctx_xfer */
+/* 0x0601: ctx_xfer */
        0x0007f100,
        0x0203f081,
        0xbd000fd0,
        0x0711f404,
-       0x05cf21f5,
-/* 0x0610: ctx_xfer_not_load */
+       0x05d321f5,
+/* 0x0614: ctx_xfer_not_load */
        0x026a21f5,
        0x07f124bd,
        0x03f047fc,
@@ -511,10 +512,10 @@ uint32_t gk104_grgpc_code[] = {
        0x21f5016f,
        0x01f4025e,
        0x0712f406,
-/* 0x06ac: ctx_xfer_post */
+/* 0x06b0: ctx_xfer_post */
        0x027f21f5,
-/* 0x06b0: ctx_xfer_done */
-       0x05b721f5,
+/* 0x06b4: ctx_xfer_done */
+       0x05bb21f5,
        0x000000f8,
        0x00000000,
        0x00000000,
@@ -533,5 +534,4 @@ uint32_t gk104_grgpc_code[] = {
        0x00000000,
        0x00000000,
        0x00000000,
-       0x00000000,
 };
index 1c6e11b..f726769 100644 (file)
@@ -408,56 +408,57 @@ uint32_t gk110_grgpc_code[] = {
        0x0412fd20,
        0xfd01e4b6,
        0x18fe051e,
-       0xfd21f500,
-       0xd30ef405,
+       0x0121f500,
+       0xd30ef406,
 /* 0x0538: main_not_ctx_xfer */
        0xf010ef94,
        0x21f501f5,
        0x0ef4037e,
 /* 0x0545: ih */
-       0xfe80f9c6,
-       0x80f90188,
-       0xa0f990f9,
-       0xd0f9b0f9,
-       0xf0f9e0f9,
-       0xa7f104bd,
-       0xa3f00200,
-       0x00aacf00,
-       0xf404abc4,
-       0xd7f02c0b,
-       0x00e7f124,
-       0x00e3f01a,
-       0xf100eecf,
-       0xf01900f7,
-       0xffcf00f3,
-       0x0421f400,
-       0xf101e7f0,
-       0xf01d0007,
-       0x0ed00003,
-/* 0x0593: ih_no_fifo */
-       0xf104bd00,
-       0xf0010007,
-       0x0ad00003,
-       0xfc04bd00,
-       0xfce0fcf0,
-       0xfcb0fcd0,
-       0xfc90fca0,
-       0x0088fe80,
-       0x32f480fc,
-/* 0x05b7: hub_barrier_done */
+       0xf900f9c6,
+       0x0188fe80,
+       0x90f980f9,
+       0xb0f9a0f9,
+       0xe0f9d0f9,
+       0x04bdf0f9,
+       0x0200a7f1,
+       0xcf00a3f0,
+       0xabc400aa,
+       0x2c0bf404,
+       0xf124d7f0,
+       0xf01a00e7,
+       0xeecf00e3,
+       0x00f7f100,
+       0x00f3f019,
+       0xf400ffcf,
+       0xe7f00421,
+       0x0007f101,
+       0x0003f01d,
+       0xbd000ed0,
+/* 0x0595: ih_no_fifo */
+       0x0007f104,
+       0x0003f001,
+       0xbd000ad0,
+       0xfcf0fc04,
+       0xfcd0fce0,
+       0xfca0fcb0,
+       0xfe80fc90,
+       0x80fc0088,
+       0x32f400fc,
+/* 0x05bb: hub_barrier_done */
        0xf001f800,
        0x0e9801f7,
        0x04febb04,
        0xf102ffb9,
        0xf09418e7,
        0x21f440e3,
-/* 0x05cf: ctx_redswitch */
+/* 0x05d3: ctx_redswitch */
        0xf000f89d,
        0x07f120f7,
        0x03f08500,
        0x000fd001,
        0xe7f004bd,
-/* 0x05e1: ctx_redswitch_delay */
+/* 0x05e5: ctx_redswitch_delay */
        0x01e2b608,
        0xf1fd1bf4,
        0xf10800f5,
@@ -465,13 +466,13 @@ uint32_t gk110_grgpc_code[] = {
        0xf0850007,
        0x0fd00103,
        0xf804bd00,
-/* 0x05fd: ctx_xfer */
+/* 0x0601: ctx_xfer */
        0x0007f100,
        0x0203f081,
        0xbd000fd0,
        0x0711f404,
-       0x05cf21f5,
-/* 0x0610: ctx_xfer_not_load */
+       0x05d321f5,
+/* 0x0614: ctx_xfer_not_load */
        0x026a21f5,
        0x07f124bd,
        0x03f047fc,
@@ -511,10 +512,10 @@ uint32_t gk110_grgpc_code[] = {
        0x21f5016f,
        0x01f4025e,
        0x0712f406,
-/* 0x06ac: ctx_xfer_post */
+/* 0x06b0: ctx_xfer_post */
        0x027f21f5,
-/* 0x06b0: ctx_xfer_done */
-       0x05b721f5,
+/* 0x06b4: ctx_xfer_done */
+       0x05bb21f5,
        0x000000f8,
        0x00000000,
        0x00000000,
@@ -533,5 +534,4 @@ uint32_t gk110_grgpc_code[] = {
        0x00000000,
        0x00000000,
        0x00000000,
-       0x00000000,
 };
index 84af7ec..387d1fa 100644 (file)
@@ -360,61 +360,62 @@ uint32_t gk208_grgpc_code[] = {
        0xb60412fd,
        0x1efd01e4,
        0x0018fe05,
-       0x00051b7e,
+       0x00051f7e,
 /* 0x0477: main_not_ctx_xfer */
        0x94d40ef4,
        0xf5f010ef,
        0x02f87e01,
        0xc70ef400,
 /* 0x0484: ih */
-       0x88fe80f9,
-       0xf980f901,
-       0xf9a0f990,
-       0xf9d0f9b0,
-       0xbdf0f9e0,
-       0x02004a04,
-       0xc400aacf,
-       0x0bf404ab,
-       0x4e240d1f,
-       0xeecf1a00,
-       0x19004f00,
-       0x7e00ffcf,
-       0x0e000004,
-       0x1d004001,
-       0xbd000ef6,
-/* 0x04c1: ih_no_fifo */
-       0x01004004,
-       0xbd000af6,
-       0xfcf0fc04,
-       0xfcd0fce0,
-       0xfca0fcb0,
-       0xfe80fc90,
-       0x80fc0088,
+       0x80f900f9,
+       0xf90188fe,
+       0xf990f980,
+       0xf9b0f9a0,
+       0xf9e0f9d0,
+       0x4a04bdf0,
+       0xaacf0200,
+       0x04abc400,
+       0x0d1f0bf4,
+       0x1a004e24,
+       0x4f00eecf,
+       0xffcf1900,
+       0x00047e00,
+       0x40010e00,
+       0x0ef61d00,
+/* 0x04c3: ih_no_fifo */
+       0x4004bd00,
+       0x0af60100,
+       0xfc04bd00,
+       0xfce0fcf0,
+       0xfcb0fcd0,
+       0xfc90fca0,
+       0x0088fe80,
+       0x00fc80fc,
        0xf80032f4,
-/* 0x04e1: hub_barrier_done */
+/* 0x04e5: hub_barrier_done */
        0x98010f01,
        0xfebb040e,
        0x8effb204,
        0x7e409418,
        0xf800008f,
-/* 0x04f5: ctx_redswitch */
+/* 0x04f9: ctx_redswitch */
        0x80200f00,
        0xf6018500,
        0x04bd000f,
-/* 0x0502: ctx_redswitch_delay */
+/* 0x0506: ctx_redswitch_delay */
        0xe2b6080e,
        0xfd1bf401,
        0x0800f5f1,
        0x0200f5f1,
        0x01850080,
        0xbd000ff6,
-/* 0x051b: ctx_xfer */
+/* 0x051f: ctx_xfer */
        0x8000f804,
        0xf6028100,
        0x04bd000f,
        0x7e0711f4,
-/* 0x052b: ctx_xfer_not_load */
-       0x7e0004f5,
+/* 0x052f: ctx_xfer_not_load */
+       0x7e0004f9,
        0xbd000216,
        0x47fc8024,
        0x0002f602,
@@ -449,10 +450,10 @@ uint32_t gk208_grgpc_code[] = {
        0x7e00013d,
        0xf400020a,
        0x12f40601,
-/* 0x05b5: ctx_xfer_post */
+/* 0x05b9: ctx_xfer_post */
        0x02277e07,
-/* 0x05b9: ctx_xfer_done */
-       0x04e17e00,
+/* 0x05bd: ctx_xfer_done */
+       0x04e57e00,
        0x0000f800,
        0x00000000,
        0x00000000,
@@ -469,5 +470,4 @@ uint32_t gk208_grgpc_code[] = {
        0x00000000,
        0x00000000,
        0x00000000,
-       0x00000000,
 };
index 5136f91..fa9f3c0 100644 (file)
@@ -438,48 +438,49 @@ uint32_t gm107_grgpc_code[] = {
        0x0412fd20,
        0xfd01e4b6,
        0x18fe051e,
-       0x06447e00,
+       0x06487e00,
        0xd40ef400,
 /* 0x05a0: main_not_ctx_xfer */
        0xf010ef94,
        0xf87e01f5,
        0x0ef40002,
 /* 0x05ad: ih */
-       0xfe80f9c7,
-       0x80f90188,
-       0xa0f990f9,
-       0xd0f9b0f9,
-       0xf0f9e0f9,
-       0x004a04bd,
-       0x00aacf02,
-       0xf404abc4,
-       0x240d1f0b,
-       0xcf1a004e,
-       0x004f00ee,
-       0x00ffcf19,
-       0x0000047e,
-       0x0040010e,
-       0x000ef61d,
-/* 0x05ea: ih_no_fifo */
-       0x004004bd,
-       0x000af601,
-       0xf0fc04bd,
-       0xd0fce0fc,
-       0xa0fcb0fc,
-       0x80fc90fc,
-       0xfc0088fe,
-       0x0032f480,
-/* 0x060a: hub_barrier_done */
+       0xf900f9c7,
+       0x0188fe80,
+       0x90f980f9,
+       0xb0f9a0f9,
+       0xe0f9d0f9,
+       0x04bdf0f9,
+       0xcf02004a,
+       0xabc400aa,
+       0x1f0bf404,
+       0x004e240d,
+       0x00eecf1a,
+       0xcf19004f,
+       0x047e00ff,
+       0x010e0000,
+       0xf61d0040,
+       0x04bd000e,
+/* 0x05ec: ih_no_fifo */
+       0xf6010040,
+       0x04bd000a,
+       0xe0fcf0fc,
+       0xb0fcd0fc,
+       0x90fca0fc,
+       0x88fe80fc,
+       0xfc80fc00,
+       0x0032f400,
+/* 0x060e: hub_barrier_done */
        0x010f01f8,
        0xbb040e98,
        0xffb204fe,
        0x4094188e,
        0x00008f7e,
-/* 0x061e: ctx_redswitch */
+/* 0x0622: ctx_redswitch */
        0x200f00f8,
        0x01850080,
        0xbd000ff6,
-/* 0x062b: ctx_redswitch_delay */
+/* 0x062f: ctx_redswitch_delay */
        0xb6080e04,
        0x1bf401e2,
        0x00f5f1fd,
@@ -487,15 +488,15 @@ uint32_t gm107_grgpc_code[] = {
        0x85008002,
        0x000ff601,
        0x00f804bd,
-/* 0x0644: ctx_xfer */
+/* 0x0648: ctx_xfer */
        0x02810080,
        0xbd000ff6,
        0x1dc48e04,
        0x01e5f050,
        0x8f7effb2,
        0x11f40000,
-       0x061e7e07,
-/* 0x0661: ctx_xfer_not_load */
+       0x06227e07,
+/* 0x0665: ctx_xfer_not_load */
        0x02167e00,
        0x8024bd00,
        0xf60247fc,
@@ -550,15 +551,15 @@ uint32_t gm107_grgpc_code[] = {
        0x7e00020a,
        0xf4000314,
        0x12f40601,
-/* 0x0739: ctx_xfer_post */
+/* 0x073d: ctx_xfer_post */
        0x02277e1a,
        0x8e0d0f00,
        0xf0501da8,
        0xffb201e5,
        0x00008f7e,
        0x0003147e,
-/* 0x0750: ctx_xfer_done */
-       0x00060a7e,
+/* 0x0754: ctx_xfer_done */
+       0x00060e7e,
        0x000000f8,
        0x00000000,
        0x00000000,
@@ -601,5 +602,4 @@ uint32_t gm107_grgpc_code[] = {
        0x00000000,
        0x00000000,
        0x00000000,
-       0x00000000,
 };
index 87f99e3..e3a2fb3 100644 (file)
@@ -306,6 +306,7 @@ main:
 
 // interrupt handler
 ih:
+       push $r0
        push $r8
        mov $r8 $flags
        push $r8
@@ -380,6 +381,7 @@ ih:
        pop $r8
        mov $flags $r8
        pop $r8
+       pop $r0
        bclr $flags $p0
        iret
 
index f6acda5..397921a 100644 (file)
@@ -528,10 +528,10 @@ uint32_t gf100_grhub_code[] = {
        0x0001d001,
        0x17f104bd,
        0xf7f00100,
-       0x0d21f502,
-       0x1f21f508,
+       0x1121f502,
+       0x2321f508,
        0x10f7f008,
-       0x086c21f5,
+       0x087021f5,
        0x98000e98,
        0x21f5010f,
        0x14950150,
@@ -574,9 +574,9 @@ uint32_t gf100_grhub_code[] = {
        0xb6800040,
        0x1bf40132,
        0x00f7f0be,
-       0x086c21f5,
+       0x087021f5,
        0xf500f7f0,
-       0xf1080d21,
+       0xf1081121,
        0xf0010007,
        0x01d00203,
        0xbd04bd00,
@@ -610,7 +610,7 @@ uint32_t gf100_grhub_code[] = {
        0x09d00203,
        0xf404bd00,
        0x31f40132,
-       0x4021f502,
+       0x4421f502,
        0xf094bd0a,
        0x07f10799,
        0x03f01700,
@@ -621,7 +621,7 @@ uint32_t gf100_grhub_code[] = {
        0x0203f00f,
        0xbd0009d0,
        0x0131f404,
-       0x0a4021f5,
+       0x0a4421f5,
        0x99f094bd,
        0x0007f106,
        0x0203f017,
@@ -631,7 +631,7 @@ uint32_t gf100_grhub_code[] = {
        0x12b920f9,
        0x0132f402,
        0xf50232f4,
-       0xfc0a4021,
+       0xfc0a4421,
        0x0007f120,
        0x0203f0c0,
        0xbd0002d0,
@@ -640,7 +640,7 @@ uint32_t gf100_grhub_code[] = {
        0xf41f23c8,
        0x31f40d0b,
        0x0232f401,
-       0x0a4021f5,
+       0x0a4421f5,
 /* 0x063c: chsw_done */
        0xf10127f0,
        0xf0c30007,
@@ -654,7 +654,7 @@ uint32_t gf100_grhub_code[] = {
 /* 0x0660: main_not_ctx_switch */
        0xf401e4b0,
        0xf2b90d1b,
-       0xd021f502,
+       0xd421f502,
        0x460ef409,
 /* 0x0670: main_not_ctx_chan */
        0xf402e4b0,
@@ -664,7 +664,7 @@ uint32_t gf100_grhub_code[] = {
        0x09d00203,
        0xf404bd00,
        0x32f40132,
-       0x4021f502,
+       0x4421f502,
        0xf094bd0a,
        0x07f10799,
        0x03f01700,
@@ -682,107 +682,108 @@ uint32_t gf100_grhub_code[] = {
        0x04bd0002,
        0xfea00ef5,
 /* 0x06c8: ih */
-       0x88fe80f9,
-       0xf980f901,
-       0xf9a0f990,
-       0xf9d0f9b0,
-       0xbdf0f9e0,
-       0x00a7f104,
-       0x00a3f002,
-       0xc400aacf,
-       0x0bf404ab,
-       0x10d7f030,
-       0x1a00e7f1,
-       0xcf00e3f0,
-       0xf7f100ee,
-       0xf3f01900,
-       0x00ffcf00,
-       0xb70421f4,
-       0xf00400b0,
-       0x07f101e7,
-       0x03f01d00,
-       0x000ed000,
-/* 0x071a: ih_no_fifo */
-       0xabe404bd,
-       0x0bf40100,
-       0x10d7f00d,
-       0x4001e7f1,
-/* 0x072b: ih_no_ctxsw */
-       0xe40421f4,
-       0xf40400ab,
-       0xe7f16c0b,
-       0xe3f00708,
-       0x6821f440,
-       0xf102ffb9,
-       0xf0040007,
-       0x0fd00203,
-       0xf104bd00,
-       0xf00704e7,
+       0x80f900f9,
+       0xf90188fe,
+       0xf990f980,
+       0xf9b0f9a0,
+       0xf9e0f9d0,
+       0xf104bdf0,
+       0xf00200a7,
+       0xaacf00a3,
+       0x04abc400,
+       0xf0300bf4,
+       0xe7f110d7,
+       0xe3f01a00,
+       0x00eecf00,
+       0x1900f7f1,
+       0xcf00f3f0,
+       0x21f400ff,
+       0x00b0b704,
+       0x01e7f004,
+       0x1d0007f1,
+       0xd00003f0,
+       0x04bd000e,
+/* 0x071c: ih_no_fifo */
+       0x0100abe4,
+       0xf00d0bf4,
+       0xe7f110d7,
+       0x21f44001,
+/* 0x072d: ih_no_ctxsw */
+       0x00abe404,
+       0x6c0bf404,
+       0x0708e7f1,
+       0xf440e3f0,
+       0xffb96821,
+       0x0007f102,
+       0x0203f004,
+       0xbd000fd0,
+       0x04e7f104,
+       0x40e3f007,
+       0xb96821f4,
+       0x07f102ff,
+       0x03f00300,
+       0x000fd002,
+       0xfec704bd,
+       0x02ee9450,
+       0x0700f7f1,
+       0xbb40f3f0,
+       0x21f400ef,
+       0x0007f168,
+       0x0203f002,
+       0xbd000fd0,
+       0x03f7f004,
+       0x037e21f5,
+       0x0100b7f1,
+       0xf102bfb9,
+       0xf00144e7,
        0x21f440e3,
-       0x02ffb968,
-       0x030007f1,
-       0xd00203f0,
-       0x04bd000f,
-       0x9450fec7,
-       0xf7f102ee,
-       0xf3f00700,
-       0x00efbb40,
-       0xf16821f4,
-       0xf0020007,
-       0x0fd00203,
-       0xf004bd00,
-       0x21f503f7,
-       0xb7f1037e,
-       0xbfb90100,
-       0x44e7f102,
-       0x40e3f001,
-/* 0x079b: ih_no_fwmthd */
-       0xf19d21f4,
-       0xbd0504b7,
-       0xb4abffb0,
-       0xf10f0bf4,
-       0xf0070007,
-       0x0bd00303,
-/* 0x07b3: ih_no_other */
-       0xf104bd00,
-       0xf0010007,
-       0x0ad00003,
-       0xfc04bd00,
-       0xfce0fcf0,
-       0xfcb0fcd0,
-       0xfc90fca0,
-       0x0088fe80,
-       0x32f480fc,
-/* 0x07d7: ctx_4160s */
+/* 0x079d: ih_no_fwmthd */
+       0x04b7f19d,
+       0xffb0bd05,
+       0x0bf4b4ab,
+       0x0007f10f,
+       0x0303f007,
+       0xbd000bd0,
+/* 0x07b5: ih_no_other */
+       0x0007f104,
+       0x0003f001,
+       0xbd000ad0,
+       0xfcf0fc04,
+       0xfcd0fce0,
+       0xfca0fcb0,
+       0xfe80fc90,
+       0x80fc0088,
+       0x32f400fc,
+/* 0x07db: ctx_4160s */
        0xf001f800,
        0xffb901f7,
        0x60e7f102,
        0x40e3f041,
-/* 0x07e7: ctx_4160s_wait */
+/* 0x07eb: ctx_4160s_wait */
        0xf19d21f4,
        0xf04160e7,
        0x21f440e3,
        0x02ffb968,
        0xf404ffc8,
        0x00f8f00b,
-/* 0x07fc: ctx_4160c */
+/* 0x0800: ctx_4160c */
        0xffb9f4bd,
        0x60e7f102,
        0x40e3f041,
        0xf89d21f4,
-/* 0x080d: ctx_4170s */
+/* 0x0811: ctx_4170s */
        0x10f5f000,
        0xf102ffb9,
        0xf04170e7,
        0x21f440e3,
-/* 0x081f: ctx_4170w */
+/* 0x0823: ctx_4170w */
        0xf100f89d,
        0xf04170e7,
        0x21f440e3,
        0x02ffb968,
        0xf410f4f0,
        0x00f8f01b,
-/* 0x0834: ctx_redswitch */
+/* 0x0838: ctx_redswitch */
        0x0200e7f1,
        0xf040e5f0,
        0xe5f020e5,
@@ -790,7 +791,7 @@ uint32_t gf100_grhub_code[] = {
        0x0103f085,
        0xbd000ed0,
        0x08f7f004,
-/* 0x0850: ctx_redswitch_delay */
+/* 0x0854: ctx_redswitch_delay */
        0xf401f2b6,
        0xe5f1fd1b,
        0xe5f10400,
@@ -798,7 +799,7 @@ uint32_t gf100_grhub_code[] = {
        0x03f08500,
        0x000ed001,
        0x00f804bd,
-/* 0x086c: ctx_86c */
+/* 0x0870: ctx_86c */
        0x1b0007f1,
        0xd00203f0,
        0x04bd000f,
@@ -809,16 +810,16 @@ uint32_t gf100_grhub_code[] = {
        0xa86ce7f1,
        0xf441e3f0,
        0x00f89d21,
-/* 0x0894: ctx_mem */
+/* 0x0898: ctx_mem */
        0x840007f1,
        0xd00203f0,
        0x04bd000f,
-/* 0x08a0: ctx_mem_wait */
+/* 0x08a4: ctx_mem_wait */
        0x8400f7f1,
        0xcf02f3f0,
        0xfffd00ff,
        0xf31bf405,
-/* 0x08b2: ctx_load */
+/* 0x08b6: ctx_load */
        0x94bd00f8,
        0xf10599f0,
        0xf00f0007,
@@ -836,7 +837,7 @@ uint32_t gf100_grhub_code[] = {
        0x02d00203,
        0xf004bd00,
        0x21f507f7,
-       0x07f10894,
+       0x07f10898,
        0x03f0c000,
        0x0002d002,
        0x0bfe04bd,
@@ -891,31 +892,31 @@ uint32_t gf100_grhub_code[] = {
        0x03f01700,
        0x0009d002,
        0x00f804bd,
-/* 0x09d0: ctx_chan */
-       0x07d721f5,
-       0x08b221f5,
+/* 0x09d4: ctx_chan */
+       0x07db21f5,
+       0x08b621f5,
        0xf40ca7f0,
        0xf7f0d021,
-       0x9421f505,
-       0xfc21f508,
-/* 0x09eb: ctx_mmio_exec */
-       0x9800f807,
+       0x9821f505,
+       0x0021f508,
+/* 0x09ef: ctx_mmio_exec */
+       0x9800f808,
        0x07f14103,
        0x03f08100,
        0x0003d002,
        0x34bd04bd,
-/* 0x09fc: ctx_mmio_loop */
+/* 0x0a00: ctx_mmio_loop */
        0xf4ff34c4,
        0x57f10f1b,
        0x53f00200,
        0x0535fa06,
-/* 0x0a0e: ctx_mmio_pull */
+/* 0x0a12: ctx_mmio_pull */
        0x4e9803f8,
        0x814f9880,
        0xb69d21f4,
        0x12b60830,
        0xdf1bf401,
-/* 0x0a20: ctx_mmio_done */
+/* 0x0a24: ctx_mmio_done */
        0xf1160398,
        0xf0810007,
        0x03d00203,
@@ -924,30 +925,30 @@ uint32_t gf100_grhub_code[] = {
        0x13f00100,
        0x0601fa06,
        0x00f803f8,
-/* 0x0a40: ctx_xfer */
+/* 0x0a44: ctx_xfer */
        0xf104e7f0,
        0xf0020007,
        0x0ed00303,
-/* 0x0a4f: ctx_xfer_idle */
+/* 0x0a53: ctx_xfer_idle */
        0xf104bd00,
        0xf00000e7,
        0xeecf03e3,
        0x00e4f100,
        0xf21bf420,
        0xf40611f4,
-/* 0x0a66: ctx_xfer_pre */
+/* 0x0a6a: ctx_xfer_pre */
        0xf7f01102,
-       0x6c21f510,
-       0xd721f508,
+       0x7021f510,
+       0xdb21f508,
        0x1c11f407,
-/* 0x0a74: ctx_xfer_pre_load */
+/* 0x0a78: ctx_xfer_pre_load */
        0xf502f7f0,
-       0xf5080d21,
-       0xf5081f21,
-       0xbd083421,
-       0x0d21f5f4,
-       0xb221f508,
-/* 0x0a8d: ctx_xfer_exec */
+       0xf5081121,
+       0xf5082321,
+       0xbd083821,
+       0x1121f5f4,
+       0xb621f508,
+/* 0x0a91: ctx_xfer_exec */
        0x16019808,
        0x07f124bd,
        0x03f00500,
@@ -982,24 +983,23 @@ uint32_t gf100_grhub_code[] = {
        0x1301f402,
        0xf40ca7f0,
        0xf7f0d021,
-       0x9421f505,
+       0x9821f505,
        0x3202f408,
-/* 0x0b1c: ctx_xfer_post */
+/* 0x0b20: ctx_xfer_post */
        0xf502f7f0,
-       0xbd080d21,
-       0x6c21f5f4,
+       0xbd081121,
+       0x7021f5f4,
        0x7f21f508,
-       0x1f21f502,
+       0x2321f502,
        0xf5f4bd08,
-       0xf4080d21,
+       0xf4081121,
        0x01981011,
        0x0511fd40,
        0xf5070bf4,
-/* 0x0b47: ctx_xfer_no_post_mmio */
-       0xf509eb21,
-/* 0x0b4b: ctx_xfer_done */
-       0xf807fc21,
-       0x00000000,
+/* 0x0b4b: ctx_xfer_no_post_mmio */
+       0xf509ef21,
+/* 0x0b4f: ctx_xfer_done */
+       0xf8080021,
        0x00000000,
        0x00000000,
        0x00000000,
index 7cb14e5..50c9716 100644 (file)
@@ -528,10 +528,10 @@ uint32_t gf117_grhub_code[] = {
        0x0001d001,
        0x17f104bd,
        0xf7f00100,
-       0x0d21f502,
-       0x1f21f508,
+       0x1121f502,
+       0x2321f508,
        0x10f7f008,
-       0x086c21f5,
+       0x087021f5,
        0x98000e98,
        0x21f5010f,
        0x14950150,
@@ -574,9 +574,9 @@ uint32_t gf117_grhub_code[] = {
        0xb6800040,
        0x1bf40132,
        0x00f7f0be,
-       0x086c21f5,
+       0x087021f5,
        0xf500f7f0,
-       0xf1080d21,
+       0xf1081121,
        0xf0010007,
        0x01d00203,
        0xbd04bd00,
@@ -610,7 +610,7 @@ uint32_t gf117_grhub_code[] = {
        0x09d00203,
        0xf404bd00,
        0x31f40132,
-       0x4021f502,
+       0x4421f502,
        0xf094bd0a,
        0x07f10799,
        0x03f01700,
@@ -621,7 +621,7 @@ uint32_t gf117_grhub_code[] = {
        0x0203f00f,
        0xbd0009d0,
        0x0131f404,
-       0x0a4021f5,
+       0x0a4421f5,
        0x99f094bd,
        0x0007f106,
        0x0203f017,
@@ -631,7 +631,7 @@ uint32_t gf117_grhub_code[] = {
        0x12b920f9,
        0x0132f402,
        0xf50232f4,
-       0xfc0a4021,
+       0xfc0a4421,
        0x0007f120,
        0x0203f0c0,
        0xbd0002d0,
@@ -640,7 +640,7 @@ uint32_t gf117_grhub_code[] = {
        0xf41f23c8,
        0x31f40d0b,
        0x0232f401,
-       0x0a4021f5,
+       0x0a4421f5,
 /* 0x063c: chsw_done */
        0xf10127f0,
        0xf0c30007,
@@ -654,7 +654,7 @@ uint32_t gf117_grhub_code[] = {
 /* 0x0660: main_not_ctx_switch */
        0xf401e4b0,
        0xf2b90d1b,
-       0xd021f502,
+       0xd421f502,
        0x460ef409,
 /* 0x0670: main_not_ctx_chan */
        0xf402e4b0,
@@ -664,7 +664,7 @@ uint32_t gf117_grhub_code[] = {
        0x09d00203,
        0xf404bd00,
        0x32f40132,
-       0x4021f502,
+       0x4421f502,
        0xf094bd0a,
        0x07f10799,
        0x03f01700,
@@ -682,107 +682,108 @@ uint32_t gf117_grhub_code[] = {
        0x04bd0002,
        0xfea00ef5,
 /* 0x06c8: ih */
-       0x88fe80f9,
-       0xf980f901,
-       0xf9a0f990,
-       0xf9d0f9b0,
-       0xbdf0f9e0,
-       0x00a7f104,
-       0x00a3f002,
-       0xc400aacf,
-       0x0bf404ab,
-       0x10d7f030,
-       0x1a00e7f1,
-       0xcf00e3f0,
-       0xf7f100ee,
-       0xf3f01900,
-       0x00ffcf00,
-       0xb70421f4,
-       0xf00400b0,
-       0x07f101e7,
-       0x03f01d00,
-       0x000ed000,
-/* 0x071a: ih_no_fifo */
-       0xabe404bd,
-       0x0bf40100,
-       0x10d7f00d,
-       0x4001e7f1,
-/* 0x072b: ih_no_ctxsw */
-       0xe40421f4,
-       0xf40400ab,
-       0xe7f16c0b,
-       0xe3f00708,
-       0x6821f440,
-       0xf102ffb9,
-       0xf0040007,
-       0x0fd00203,
-       0xf104bd00,
-       0xf00704e7,
+       0x80f900f9,
+       0xf90188fe,
+       0xf990f980,
+       0xf9b0f9a0,
+       0xf9e0f9d0,
+       0xf104bdf0,
+       0xf00200a7,
+       0xaacf00a3,
+       0x04abc400,
+       0xf0300bf4,
+       0xe7f110d7,
+       0xe3f01a00,
+       0x00eecf00,
+       0x1900f7f1,
+       0xcf00f3f0,
+       0x21f400ff,
+       0x00b0b704,
+       0x01e7f004,
+       0x1d0007f1,
+       0xd00003f0,
+       0x04bd000e,
+/* 0x071c: ih_no_fifo */
+       0x0100abe4,
+       0xf00d0bf4,
+       0xe7f110d7,
+       0x21f44001,
+/* 0x072d: ih_no_ctxsw */
+       0x00abe404,
+       0x6c0bf404,
+       0x0708e7f1,
+       0xf440e3f0,
+       0xffb96821,
+       0x0007f102,
+       0x0203f004,
+       0xbd000fd0,
+       0x04e7f104,
+       0x40e3f007,
+       0xb96821f4,
+       0x07f102ff,
+       0x03f00300,
+       0x000fd002,
+       0xfec704bd,
+       0x02ee9450,
+       0x0700f7f1,
+       0xbb40f3f0,
+       0x21f400ef,
+       0x0007f168,
+       0x0203f002,
+       0xbd000fd0,
+       0x03f7f004,
+       0x037e21f5,
+       0x0100b7f1,
+       0xf102bfb9,
+       0xf00144e7,
        0x21f440e3,
-       0x02ffb968,
-       0x030007f1,
-       0xd00203f0,
-       0x04bd000f,
-       0x9450fec7,
-       0xf7f102ee,
-       0xf3f00700,
-       0x00efbb40,
-       0xf16821f4,
-       0xf0020007,
-       0x0fd00203,
-       0xf004bd00,
-       0x21f503f7,
-       0xb7f1037e,
-       0xbfb90100,
-       0x44e7f102,
-       0x40e3f001,
-/* 0x079b: ih_no_fwmthd */
-       0xf19d21f4,
-       0xbd0504b7,
-       0xb4abffb0,
-       0xf10f0bf4,
-       0xf0070007,
-       0x0bd00303,
-/* 0x07b3: ih_no_other */
-       0xf104bd00,
-       0xf0010007,
-       0x0ad00003,
-       0xfc04bd00,
-       0xfce0fcf0,
-       0xfcb0fcd0,
-       0xfc90fca0,
-       0x0088fe80,
-       0x32f480fc,
-/* 0x07d7: ctx_4160s */
+/* 0x079d: ih_no_fwmthd */
+       0x04b7f19d,
+       0xffb0bd05,
+       0x0bf4b4ab,
+       0x0007f10f,
+       0x0303f007,
+       0xbd000bd0,
+/* 0x07b5: ih_no_other */
+       0x0007f104,
+       0x0003f001,
+       0xbd000ad0,
+       0xfcf0fc04,
+       0xfcd0fce0,
+       0xfca0fcb0,
+       0xfe80fc90,
+       0x80fc0088,
+       0x32f400fc,
+/* 0x07db: ctx_4160s */
        0xf001f800,
        0xffb901f7,
        0x60e7f102,
        0x40e3f041,
-/* 0x07e7: ctx_4160s_wait */
+/* 0x07eb: ctx_4160s_wait */
        0xf19d21f4,
        0xf04160e7,
        0x21f440e3,
        0x02ffb968,
        0xf404ffc8,
        0x00f8f00b,
-/* 0x07fc: ctx_4160c */
+/* 0x0800: ctx_4160c */
        0xffb9f4bd,
        0x60e7f102,
        0x40e3f041,
        0xf89d21f4,
-/* 0x080d: ctx_4170s */
+/* 0x0811: ctx_4170s */
        0x10f5f000,
        0xf102ffb9,
        0xf04170e7,
        0x21f440e3,
-/* 0x081f: ctx_4170w */
+/* 0x0823: ctx_4170w */
        0xf100f89d,
        0xf04170e7,
        0x21f440e3,
        0x02ffb968,
        0xf410f4f0,
        0x00f8f01b,
-/* 0x0834: ctx_redswitch */
+/* 0x0838: ctx_redswitch */
        0x0200e7f1,
        0xf040e5f0,
        0xe5f020e5,
@@ -790,7 +791,7 @@ uint32_t gf117_grhub_code[] = {
        0x0103f085,
        0xbd000ed0,
        0x08f7f004,
-/* 0x0850: ctx_redswitch_delay */
+/* 0x0854: ctx_redswitch_delay */
        0xf401f2b6,
        0xe5f1fd1b,
        0xe5f10400,
@@ -798,7 +799,7 @@ uint32_t gf117_grhub_code[] = {
        0x03f08500,
        0x000ed001,
        0x00f804bd,
-/* 0x086c: ctx_86c */
+/* 0x0870: ctx_86c */
        0x1b0007f1,
        0xd00203f0,
        0x04bd000f,
@@ -809,16 +810,16 @@ uint32_t gf117_grhub_code[] = {
        0xa86ce7f1,
        0xf441e3f0,
        0x00f89d21,
-/* 0x0894: ctx_mem */
+/* 0x0898: ctx_mem */
        0x840007f1,
        0xd00203f0,
        0x04bd000f,
-/* 0x08a0: ctx_mem_wait */
+/* 0x08a4: ctx_mem_wait */
        0x8400f7f1,
        0xcf02f3f0,
        0xfffd00ff,
        0xf31bf405,
-/* 0x08b2: ctx_load */
+/* 0x08b6: ctx_load */
        0x94bd00f8,
        0xf10599f0,
        0xf00f0007,
@@ -836,7 +837,7 @@ uint32_t gf117_grhub_code[] = {
        0x02d00203,
        0xf004bd00,
        0x21f507f7,
-       0x07f10894,
+       0x07f10898,
        0x03f0c000,
        0x0002d002,
        0x0bfe04bd,
@@ -891,31 +892,31 @@ uint32_t gf117_grhub_code[] = {
        0x03f01700,
        0x0009d002,
        0x00f804bd,
-/* 0x09d0: ctx_chan */
-       0x07d721f5,
-       0x08b221f5,
+/* 0x09d4: ctx_chan */
+       0x07db21f5,
+       0x08b621f5,
        0xf40ca7f0,
        0xf7f0d021,
-       0x9421f505,
-       0xfc21f508,
-/* 0x09eb: ctx_mmio_exec */
-       0x9800f807,
+       0x9821f505,
+       0x0021f508,
+/* 0x09ef: ctx_mmio_exec */
+       0x9800f808,
        0x07f14103,
        0x03f08100,
        0x0003d002,
        0x34bd04bd,
-/* 0x09fc: ctx_mmio_loop */
+/* 0x0a00: ctx_mmio_loop */
        0xf4ff34c4,
        0x57f10f1b,
        0x53f00200,
        0x0535fa06,
-/* 0x0a0e: ctx_mmio_pull */
+/* 0x0a12: ctx_mmio_pull */
        0x4e9803f8,
        0x814f9880,
        0xb69d21f4,
        0x12b60830,
        0xdf1bf401,
-/* 0x0a20: ctx_mmio_done */
+/* 0x0a24: ctx_mmio_done */
        0xf1160398,
        0xf0810007,
        0x03d00203,
@@ -924,30 +925,30 @@ uint32_t gf117_grhub_code[] = {
        0x13f00100,
        0x0601fa06,
        0x00f803f8,
-/* 0x0a40: ctx_xfer */
+/* 0x0a44: ctx_xfer */
        0xf104e7f0,
        0xf0020007,
        0x0ed00303,
-/* 0x0a4f: ctx_xfer_idle */
+/* 0x0a53: ctx_xfer_idle */
        0xf104bd00,
        0xf00000e7,
        0xeecf03e3,
        0x00e4f100,
        0xf21bf420,
        0xf40611f4,
-/* 0x0a66: ctx_xfer_pre */
+/* 0x0a6a: ctx_xfer_pre */
        0xf7f01102,
-       0x6c21f510,
-       0xd721f508,
+       0x7021f510,
+       0xdb21f508,
        0x1c11f407,
-/* 0x0a74: ctx_xfer_pre_load */
+/* 0x0a78: ctx_xfer_pre_load */
        0xf502f7f0,
-       0xf5080d21,
-       0xf5081f21,
-       0xbd083421,
-       0x0d21f5f4,
-       0xb221f508,
-/* 0x0a8d: ctx_xfer_exec */
+       0xf5081121,
+       0xf5082321,
+       0xbd083821,
+       0x1121f5f4,
+       0xb621f508,
+/* 0x0a91: ctx_xfer_exec */
        0x16019808,
        0x07f124bd,
        0x03f00500,
@@ -982,24 +983,23 @@ uint32_t gf117_grhub_code[] = {
        0x1301f402,
        0xf40ca7f0,
        0xf7f0d021,
-       0x9421f505,
+       0x9821f505,
        0x3202f408,
-/* 0x0b1c: ctx_xfer_post */
+/* 0x0b20: ctx_xfer_post */
        0xf502f7f0,
-       0xbd080d21,
-       0x6c21f5f4,
+       0xbd081121,
+       0x7021f5f4,
        0x7f21f508,
-       0x1f21f502,
+       0x2321f502,
        0xf5f4bd08,
-       0xf4080d21,
+       0xf4081121,
        0x01981011,
        0x0511fd40,
        0xf5070bf4,
-/* 0x0b47: ctx_xfer_no_post_mmio */
-       0xf509eb21,
-/* 0x0b4b: ctx_xfer_done */
-       0xf807fc21,
-       0x00000000,
+/* 0x0b4b: ctx_xfer_no_post_mmio */
+       0xf509ef21,
+/* 0x0b4f: ctx_xfer_done */
+       0xf8080021,
        0x00000000,
        0x00000000,
        0x00000000,
index 95ac151..125824b 100644 (file)
@@ -528,10 +528,10 @@ uint32_t gk104_grhub_code[] = {
        0x0001d001,
        0x17f104bd,
        0xf7f00100,
-       0xd721f502,
-       0xe921f507,
+       0xdb21f502,
+       0xed21f507,
        0x10f7f007,
-       0x083621f5,
+       0x083a21f5,
        0x98000e98,
        0x21f5010f,
        0x14950150,
@@ -574,9 +574,9 @@ uint32_t gk104_grhub_code[] = {
        0xb6800040,
        0x1bf40132,
        0x00f7f0be,
-       0x083621f5,
+       0x083a21f5,
        0xf500f7f0,
-       0xf107d721,
+       0xf107db21,
        0xf0010007,
        0x01d00203,
        0xbd04bd00,
@@ -610,7 +610,7 @@ uint32_t gk104_grhub_code[] = {
        0x09d00203,
        0xf404bd00,
        0x31f40132,
-       0x0221f502,
+       0x0621f502,
        0xf094bd0a,
        0x07f10799,
        0x03f01700,
@@ -621,7 +621,7 @@ uint32_t gk104_grhub_code[] = {
        0x0203f00f,
        0xbd0009d0,
        0x0131f404,
-       0x0a0221f5,
+       0x0a0621f5,
        0x99f094bd,
        0x0007f106,
        0x0203f017,
@@ -631,7 +631,7 @@ uint32_t gk104_grhub_code[] = {
        0x12b920f9,
        0x0132f402,
        0xf50232f4,
-       0xfc0a0221,
+       0xfc0a0621,
        0x0007f120,
        0x0203f0c0,
        0xbd0002d0,
@@ -640,7 +640,7 @@ uint32_t gk104_grhub_code[] = {
        0xf41f23c8,
        0x31f40d0b,
        0x0232f401,
-       0x0a0221f5,
+       0x0a0621f5,
 /* 0x063c: chsw_done */
        0xf10127f0,
        0xf0c30007,
@@ -654,7 +654,7 @@ uint32_t gk104_grhub_code[] = {
 /* 0x0660: main_not_ctx_switch */
        0xf401e4b0,
        0xf2b90d1b,
-       0x9a21f502,
+       0x9e21f502,
        0x460ef409,
 /* 0x0670: main_not_ctx_chan */
        0xf402e4b0,
@@ -664,7 +664,7 @@ uint32_t gk104_grhub_code[] = {
        0x09d00203,
        0xf404bd00,
        0x32f40132,
-       0x0221f502,
+       0x0621f502,
        0xf094bd0a,
        0x07f10799,
        0x03f01700,
@@ -682,90 +682,91 @@ uint32_t gk104_grhub_code[] = {
        0x04bd0002,
        0xfea00ef5,
 /* 0x06c8: ih */
-       0x88fe80f9,
-       0xf980f901,
-       0xf9a0f990,
-       0xf9d0f9b0,
-       0xbdf0f9e0,
-       0x00a7f104,
-       0x00a3f002,
-       0xc400aacf,
-       0x0bf404ab,
-       0x10d7f030,
-       0x1a00e7f1,
-       0xcf00e3f0,
-       0xf7f100ee,
-       0xf3f01900,
-       0x00ffcf00,
-       0xb70421f4,
-       0xf00400b0,
-       0x07f101e7,
-       0x03f01d00,
-       0x000ed000,
-/* 0x071a: ih_no_fifo */
-       0xabe404bd,
-       0x0bf40100,
-       0x10d7f00d,
-       0x4001e7f1,
-/* 0x072b: ih_no_ctxsw */
-       0xe40421f4,
-       0xf40400ab,
-       0xe7f16c0b,
-       0xe3f00708,
-       0x6821f440,
-       0xf102ffb9,
-       0xf0040007,
-       0x0fd00203,
-       0xf104bd00,
-       0xf00704e7,
+       0x80f900f9,
+       0xf90188fe,
+       0xf990f980,
+       0xf9b0f9a0,
+       0xf9e0f9d0,
+       0xf104bdf0,
+       0xf00200a7,
+       0xaacf00a3,
+       0x04abc400,
+       0xf0300bf4,
+       0xe7f110d7,
+       0xe3f01a00,
+       0x00eecf00,
+       0x1900f7f1,
+       0xcf00f3f0,
+       0x21f400ff,
+       0x00b0b704,
+       0x01e7f004,
+       0x1d0007f1,
+       0xd00003f0,
+       0x04bd000e,
+/* 0x071c: ih_no_fifo */
+       0x0100abe4,
+       0xf00d0bf4,
+       0xe7f110d7,
+       0x21f44001,
+/* 0x072d: ih_no_ctxsw */
+       0x00abe404,
+       0x6c0bf404,
+       0x0708e7f1,
+       0xf440e3f0,
+       0xffb96821,
+       0x0007f102,
+       0x0203f004,
+       0xbd000fd0,
+       0x04e7f104,
+       0x40e3f007,
+       0xb96821f4,
+       0x07f102ff,
+       0x03f00300,
+       0x000fd002,
+       0xfec704bd,
+       0x02ee9450,
+       0x0700f7f1,
+       0xbb40f3f0,
+       0x21f400ef,
+       0x0007f168,
+       0x0203f002,
+       0xbd000fd0,
+       0x03f7f004,
+       0x037e21f5,
+       0x0100b7f1,
+       0xf102bfb9,
+       0xf00144e7,
        0x21f440e3,
-       0x02ffb968,
-       0x030007f1,
-       0xd00203f0,
-       0x04bd000f,
-       0x9450fec7,
-       0xf7f102ee,
-       0xf3f00700,
-       0x00efbb40,
-       0xf16821f4,
-       0xf0020007,
-       0x0fd00203,
-       0xf004bd00,
-       0x21f503f7,
-       0xb7f1037e,
-       0xbfb90100,
-       0x44e7f102,
-       0x40e3f001,
-/* 0x079b: ih_no_fwmthd */
-       0xf19d21f4,
-       0xbd0504b7,
-       0xb4abffb0,
-       0xf10f0bf4,
-       0xf0070007,
-       0x0bd00303,
-/* 0x07b3: ih_no_other */
-       0xf104bd00,
-       0xf0010007,
-       0x0ad00003,
-       0xfc04bd00,
-       0xfce0fcf0,
-       0xfcb0fcd0,
-       0xfc90fca0,
-       0x0088fe80,
-       0x32f480fc,
-/* 0x07d7: ctx_4170s */
+/* 0x079d: ih_no_fwmthd */
+       0x04b7f19d,
+       0xffb0bd05,
+       0x0bf4b4ab,
+       0x0007f10f,
+       0x0303f007,
+       0xbd000bd0,
+/* 0x07b5: ih_no_other */
+       0x0007f104,
+       0x0003f001,
+       0xbd000ad0,
+       0xfcf0fc04,
+       0xfcd0fce0,
+       0xfca0fcb0,
+       0xfe80fc90,
+       0x80fc0088,
+       0x32f400fc,
+/* 0x07db: ctx_4170s */
        0xf001f800,
        0xffb910f5,
        0x70e7f102,
        0x40e3f041,
        0xf89d21f4,
-/* 0x07e9: ctx_4170w */
+/* 0x07ed: ctx_4170w */
        0x70e7f100,
        0x40e3f041,
        0xb96821f4,
        0xf4f002ff,
        0xf01bf410,
-/* 0x07fe: ctx_redswitch */
+/* 0x0802: ctx_redswitch */
        0xe7f100f8,
        0xe5f00200,
        0x20e5f040,
@@ -773,7 +774,7 @@ uint32_t gk104_grhub_code[] = {
        0xf0850007,
        0x0ed00103,
        0xf004bd00,
-/* 0x081a: ctx_redswitch_delay */
+/* 0x081e: ctx_redswitch_delay */
        0xf2b608f7,
        0xfd1bf401,
        0x0400e5f1,
@@ -781,7 +782,7 @@ uint32_t gk104_grhub_code[] = {
        0x850007f1,
        0xd00103f0,
        0x04bd000e,
-/* 0x0836: ctx_86c */
+/* 0x083a: ctx_86c */
        0x07f100f8,
        0x03f01b00,
        0x000fd002,
@@ -792,17 +793,17 @@ uint32_t gk104_grhub_code[] = {
        0xe7f102ff,
        0xe3f0a86c,
        0x9d21f441,
-/* 0x085e: ctx_mem */
+/* 0x0862: ctx_mem */
        0x07f100f8,
        0x03f08400,
        0x000fd002,
-/* 0x086a: ctx_mem_wait */
+/* 0x086e: ctx_mem_wait */
        0xf7f104bd,
        0xf3f08400,
        0x00ffcf02,
        0xf405fffd,
        0x00f8f31b,
-/* 0x087c: ctx_load */
+/* 0x0880: ctx_load */
        0x99f094bd,
        0x0007f105,
        0x0203f00f,
@@ -819,7 +820,7 @@ uint32_t gk104_grhub_code[] = {
        0x0203f083,
        0xbd0002d0,
        0x07f7f004,
-       0x085e21f5,
+       0x086221f5,
        0xc00007f1,
        0xd00203f0,
        0x04bd0002,
@@ -874,29 +875,29 @@ uint32_t gk104_grhub_code[] = {
        0x170007f1,
        0xd00203f0,
        0x04bd0009,
-/* 0x099a: ctx_chan */
+/* 0x099e: ctx_chan */
        0x21f500f8,
-       0xa7f0087c,
+       0xa7f00880,
        0xd021f40c,
        0xf505f7f0,
-       0xf8085e21,
-/* 0x09ad: ctx_mmio_exec */
+       0xf8086221,
+/* 0x09b1: ctx_mmio_exec */
        0x41039800,
        0x810007f1,
        0xd00203f0,
        0x04bd0003,
-/* 0x09be: ctx_mmio_loop */
+/* 0x09c2: ctx_mmio_loop */
        0x34c434bd,
        0x0f1bf4ff,
        0x020057f1,
        0xfa0653f0,
        0x03f80535,
-/* 0x09d0: ctx_mmio_pull */
+/* 0x09d4: ctx_mmio_pull */
        0x98804e98,
        0x21f4814f,
        0x0830b69d,
        0xf40112b6,
-/* 0x09e2: ctx_mmio_done */
+/* 0x09e6: ctx_mmio_done */
        0x0398df1b,
        0x0007f116,
        0x0203f081,
@@ -905,30 +906,30 @@ uint32_t gk104_grhub_code[] = {
        0x010017f1,
        0xfa0613f0,
        0x03f80601,
-/* 0x0a02: ctx_xfer */
+/* 0x0a06: ctx_xfer */
        0xe7f000f8,
        0x0007f104,
        0x0303f002,
        0xbd000ed0,
-/* 0x0a11: ctx_xfer_idle */
+/* 0x0a15: ctx_xfer_idle */
        0x00e7f104,
        0x03e3f000,
        0xf100eecf,
        0xf42000e4,
        0x11f4f21b,
        0x0d02f406,
-/* 0x0a28: ctx_xfer_pre */
+/* 0x0a2c: ctx_xfer_pre */
        0xf510f7f0,
-       0xf4083621,
-/* 0x0a32: ctx_xfer_pre_load */
+       0xf4083a21,
+/* 0x0a36: ctx_xfer_pre_load */
        0xf7f01c11,
-       0xd721f502,
-       0xe921f507,
-       0xfe21f507,
-       0xf5f4bd07,
-       0xf507d721,
-/* 0x0a4b: ctx_xfer_exec */
-       0x98087c21,
+       0xdb21f502,
+       0xed21f507,
+       0x0221f507,
+       0xf5f4bd08,
+       0xf507db21,
+/* 0x0a4f: ctx_xfer_exec */
+       0x98088021,
        0x24bd1601,
        0x050007f1,
        0xd00103f0,
@@ -963,21 +964,21 @@ uint32_t gk104_grhub_code[] = {
        0xa7f01301,
        0xd021f40c,
        0xf505f7f0,
-       0xf4085e21,
-/* 0x0ada: ctx_xfer_post */
+       0xf4086221,
+/* 0x0ade: ctx_xfer_post */
        0xf7f02e02,
-       0xd721f502,
+       0xdb21f502,
        0xf5f4bd07,
-       0xf5083621,
+       0xf5083a21,
        0xf5027f21,
-       0xbd07e921,
-       0xd721f5f4,
+       0xbd07ed21,
+       0xdb21f5f4,
        0x1011f407,
        0xfd400198,
        0x0bf40511,
-       0xad21f507,
-/* 0x0b05: ctx_xfer_no_post_mmio */
-/* 0x0b05: ctx_xfer_done */
+       0xb121f507,
+/* 0x0b09: ctx_xfer_no_post_mmio */
+/* 0x0b09: ctx_xfer_done */
        0x0000f809,
        0x00000000,
        0x00000000,
@@ -1040,5 +1041,4 @@ uint32_t gk104_grhub_code[] = {
        0x00000000,
        0x00000000,
        0x00000000,
-       0x00000000,
 };
index 8998687..0a1b8c0 100644 (file)
@@ -528,10 +528,10 @@ uint32_t gk110_grhub_code[] = {
        0x0001d001,
        0x17f104bd,
        0xf7f00100,
-       0xd721f502,
-       0xe921f507,
+       0xdb21f502,
+       0xed21f507,
        0x10f7f007,
-       0x083621f5,
+       0x083a21f5,
        0x98000e98,
        0x21f5010f,
        0x14950150,
@@ -574,9 +574,9 @@ uint32_t gk110_grhub_code[] = {
        0xb6800040,
        0x1bf40132,
        0x00f7f0be,
-       0x083621f5,
+       0x083a21f5,
        0xf500f7f0,
-       0xf107d721,
+       0xf107db21,
        0xf0010007,
        0x01d00203,
        0xbd04bd00,
@@ -610,7 +610,7 @@ uint32_t gk110_grhub_code[] = {
        0x09d00203,
        0xf404bd00,
        0x31f40132,
-       0x0221f502,
+       0x0621f502,
        0xf094bd0a,
        0x07f10799,
        0x03f01700,
@@ -621,7 +621,7 @@ uint32_t gk110_grhub_code[] = {
        0x0203f037,
        0xbd0009d0,
        0x0131f404,
-       0x0a0221f5,
+       0x0a0621f5,
        0x99f094bd,
        0x0007f106,
        0x0203f017,
@@ -631,7 +631,7 @@ uint32_t gk110_grhub_code[] = {
        0x12b920f9,
        0x0132f402,
        0xf50232f4,
-       0xfc0a0221,
+       0xfc0a0621,
        0x0007f120,
        0x0203f0c0,
        0xbd0002d0,
@@ -640,7 +640,7 @@ uint32_t gk110_grhub_code[] = {
        0xf41f23c8,
        0x31f40d0b,
        0x0232f401,
-       0x0a0221f5,
+       0x0a0621f5,
 /* 0x063c: chsw_done */
        0xf10127f0,
        0xf0c30007,
@@ -654,7 +654,7 @@ uint32_t gk110_grhub_code[] = {
 /* 0x0660: main_not_ctx_switch */
        0xf401e4b0,
        0xf2b90d1b,
-       0x9a21f502,
+       0x9e21f502,
        0x460ef409,
 /* 0x0670: main_not_ctx_chan */
        0xf402e4b0,
@@ -664,7 +664,7 @@ uint32_t gk110_grhub_code[] = {
        0x09d00203,
        0xf404bd00,
        0x32f40132,
-       0x0221f502,
+       0x0621f502,
        0xf094bd0a,
        0x07f10799,
        0x03f01700,
@@ -682,90 +682,91 @@ uint32_t gk110_grhub_code[] = {
        0x04bd0002,
        0xfea00ef5,
 /* 0x06c8: ih */
-       0x88fe80f9,
-       0xf980f901,
-       0xf9a0f990,
-       0xf9d0f9b0,
-       0xbdf0f9e0,
-       0x00a7f104,
-       0x00a3f002,
-       0xc400aacf,
-       0x0bf404ab,
-       0x10d7f030,
-       0x1a00e7f1,
-       0xcf00e3f0,
-       0xf7f100ee,
-       0xf3f01900,
-       0x00ffcf00,
-       0xb70421f4,
-       0xf00400b0,
-       0x07f101e7,
-       0x03f01d00,
-       0x000ed000,
-/* 0x071a: ih_no_fifo */
-       0xabe404bd,
-       0x0bf40100,
-       0x10d7f00d,
-       0x4001e7f1,
-/* 0x072b: ih_no_ctxsw */
-       0xe40421f4,
-       0xf40400ab,
-       0xe7f16c0b,
-       0xe3f00708,
-       0x6821f440,
-       0xf102ffb9,
-       0xf0040007,
-       0x0fd00203,
-       0xf104bd00,
-       0xf00704e7,
+       0x80f900f9,
+       0xf90188fe,
+       0xf990f980,
+       0xf9b0f9a0,
+       0xf9e0f9d0,
+       0xf104bdf0,
+       0xf00200a7,
+       0xaacf00a3,
+       0x04abc400,
+       0xf0300bf4,
+       0xe7f110d7,
+       0xe3f01a00,
+       0x00eecf00,
+       0x1900f7f1,
+       0xcf00f3f0,
+       0x21f400ff,
+       0x00b0b704,
+       0x01e7f004,
+       0x1d0007f1,
+       0xd00003f0,
+       0x04bd000e,
+/* 0x071c: ih_no_fifo */
+       0x0100abe4,
+       0xf00d0bf4,
+       0xe7f110d7,
+       0x21f44001,
+/* 0x072d: ih_no_ctxsw */
+       0x00abe404,
+       0x6c0bf404,
+       0x0708e7f1,
+       0xf440e3f0,
+       0xffb96821,
+       0x0007f102,
+       0x0203f004,
+       0xbd000fd0,
+       0x04e7f104,
+       0x40e3f007,
+       0xb96821f4,
+       0x07f102ff,
+       0x03f00300,
+       0x000fd002,
+       0xfec704bd,
+       0x02ee9450,
+       0x0700f7f1,
+       0xbb40f3f0,
+       0x21f400ef,
+       0x0007f168,
+       0x0203f002,
+       0xbd000fd0,
+       0x03f7f004,
+       0x037e21f5,
+       0x0100b7f1,
+       0xf102bfb9,
+       0xf00144e7,
        0x21f440e3,
-       0x02ffb968,
-       0x030007f1,
-       0xd00203f0,
-       0x04bd000f,
-       0x9450fec7,
-       0xf7f102ee,
-       0xf3f00700,
-       0x00efbb40,
-       0xf16821f4,
-       0xf0020007,
-       0x0fd00203,
-       0xf004bd00,
-       0x21f503f7,
-       0xb7f1037e,
-       0xbfb90100,
-       0x44e7f102,
-       0x40e3f001,
-/* 0x079b: ih_no_fwmthd */
-       0xf19d21f4,
-       0xbd0504b7,
-       0xb4abffb0,
-       0xf10f0bf4,
-       0xf0070007,
-       0x0bd00303,
-/* 0x07b3: ih_no_other */
-       0xf104bd00,
-       0xf0010007,
-       0x0ad00003,
-       0xfc04bd00,
-       0xfce0fcf0,
-       0xfcb0fcd0,
-       0xfc90fca0,
-       0x0088fe80,
-       0x32f480fc,
-/* 0x07d7: ctx_4170s */
+/* 0x079d: ih_no_fwmthd */
+       0x04b7f19d,
+       0xffb0bd05,
+       0x0bf4b4ab,
+       0x0007f10f,
+       0x0303f007,
+       0xbd000bd0,
+/* 0x07b5: ih_no_other */
+       0x0007f104,
+       0x0003f001,
+       0xbd000ad0,
+       0xfcf0fc04,
+       0xfcd0fce0,
+       0xfca0fcb0,
+       0xfe80fc90,
+       0x80fc0088,
+       0x32f400fc,
+/* 0x07db: ctx_4170s */
        0xf001f800,
        0xffb910f5,
        0x70e7f102,
        0x40e3f041,
        0xf89d21f4,
-/* 0x07e9: ctx_4170w */
+/* 0x07ed: ctx_4170w */
        0x70e7f100,
        0x40e3f041,
        0xb96821f4,
        0xf4f002ff,
        0xf01bf410,
-/* 0x07fe: ctx_redswitch */
+/* 0x0802: ctx_redswitch */
        0xe7f100f8,
        0xe5f00200,
        0x20e5f040,
@@ -773,7 +774,7 @@ uint32_t gk110_grhub_code[] = {
        0xf0850007,
        0x0ed00103,
        0xf004bd00,
-/* 0x081a: ctx_redswitch_delay */
+/* 0x081e: ctx_redswitch_delay */
        0xf2b608f7,
        0xfd1bf401,
        0x0400e5f1,
@@ -781,7 +782,7 @@ uint32_t gk110_grhub_code[] = {
        0x850007f1,
        0xd00103f0,
        0x04bd000e,
-/* 0x0836: ctx_86c */
+/* 0x083a: ctx_86c */
        0x07f100f8,
        0x03f02300,
        0x000fd002,
@@ -792,17 +793,17 @@ uint32_t gk110_grhub_code[] = {
        0xe7f102ff,
        0xe3f0a88c,
        0x9d21f441,
-/* 0x085e: ctx_mem */
+/* 0x0862: ctx_mem */
        0x07f100f8,
        0x03f08400,
        0x000fd002,
-/* 0x086a: ctx_mem_wait */
+/* 0x086e: ctx_mem_wait */
        0xf7f104bd,
        0xf3f08400,
        0x00ffcf02,
        0xf405fffd,
        0x00f8f31b,
-/* 0x087c: ctx_load */
+/* 0x0880: ctx_load */
        0x99f094bd,
        0x0007f105,
        0x0203f037,
@@ -819,7 +820,7 @@ uint32_t gk110_grhub_code[] = {
        0x0203f083,
        0xbd0002d0,
        0x07f7f004,
-       0x085e21f5,
+       0x086221f5,
        0xc00007f1,
        0xd00203f0,
        0x04bd0002,
@@ -874,29 +875,29 @@ uint32_t gk110_grhub_code[] = {
        0x170007f1,
        0xd00203f0,
        0x04bd0009,
-/* 0x099a: ctx_chan */
+/* 0x099e: ctx_chan */
        0x21f500f8,
-       0xa7f0087c,
+       0xa7f00880,
        0xd021f40c,
        0xf505f7f0,
-       0xf8085e21,
-/* 0x09ad: ctx_mmio_exec */
+       0xf8086221,
+/* 0x09b1: ctx_mmio_exec */
        0x41039800,
        0x810007f1,
        0xd00203f0,
        0x04bd0003,
-/* 0x09be: ctx_mmio_loop */
+/* 0x09c2: ctx_mmio_loop */
        0x34c434bd,
        0x0f1bf4ff,
        0x020057f1,
        0xfa0653f0,
        0x03f80535,
-/* 0x09d0: ctx_mmio_pull */
+/* 0x09d4: ctx_mmio_pull */
        0x98804e98,
        0x21f4814f,
        0x0830b69d,
        0xf40112b6,
-/* 0x09e2: ctx_mmio_done */
+/* 0x09e6: ctx_mmio_done */
        0x0398df1b,
        0x0007f116,
        0x0203f081,
@@ -905,30 +906,30 @@ uint32_t gk110_grhub_code[] = {
        0x010017f1,
        0xfa0613f0,
        0x03f80601,
-/* 0x0a02: ctx_xfer */
+/* 0x0a06: ctx_xfer */
        0xe7f000f8,
        0x0007f104,
        0x0303f002,
        0xbd000ed0,
-/* 0x0a11: ctx_xfer_idle */
+/* 0x0a15: ctx_xfer_idle */
        0x00e7f104,
        0x03e3f000,
        0xf100eecf,
        0xf42000e4,
        0x11f4f21b,
        0x0d02f406,
-/* 0x0a28: ctx_xfer_pre */
+/* 0x0a2c: ctx_xfer_pre */
        0xf510f7f0,
-       0xf4083621,
-/* 0x0a32: ctx_xfer_pre_load */
+       0xf4083a21,
+/* 0x0a36: ctx_xfer_pre_load */
        0xf7f01c11,
-       0xd721f502,
-       0xe921f507,
-       0xfe21f507,
-       0xf5f4bd07,
-       0xf507d721,
-/* 0x0a4b: ctx_xfer_exec */
-       0x98087c21,
+       0xdb21f502,
+       0xed21f507,
+       0x0221f507,
+       0xf5f4bd08,
+       0xf507db21,
+/* 0x0a4f: ctx_xfer_exec */
+       0x98088021,
        0x24bd1601,
        0x050007f1,
        0xd00103f0,
@@ -963,21 +964,21 @@ uint32_t gk110_grhub_code[] = {
        0xa7f01301,
        0xd021f40c,
        0xf505f7f0,
-       0xf4085e21,
-/* 0x0ada: ctx_xfer_post */
+       0xf4086221,
+/* 0x0ade: ctx_xfer_post */
        0xf7f02e02,
-       0xd721f502,
+       0xdb21f502,
        0xf5f4bd07,
-       0xf5083621,
+       0xf5083a21,
        0xf5027f21,
-       0xbd07e921,
-       0xd721f5f4,
+       0xbd07ed21,
+       0xdb21f5f4,
        0x1011f407,
        0xfd400198,
        0x0bf40511,
-       0xad21f507,
-/* 0x0b05: ctx_xfer_no_post_mmio */
-/* 0x0b05: ctx_xfer_done */
+       0xb121f507,
+/* 0x0b09: ctx_xfer_no_post_mmio */
+/* 0x0b09: ctx_xfer_done */
        0x0000f809,
        0x00000000,
        0x00000000,
@@ -1040,5 +1041,4 @@ uint32_t gk110_grhub_code[] = {
        0x00000000,
        0x00000000,
        0x00000000,
-       0x00000000,
 };
index 0e98fa4..16869d0 100644 (file)
@@ -478,10 +478,10 @@ uint32_t gk208_grhub_code[] = {
        0x01040080,
        0xbd0001f6,
        0x01004104,
-       0xa87e020f,
-       0xb77e0006,
+       0xac7e020f,
+       0xbb7e0006,
        0x100f0006,
-       0x0006f97e,
+       0x0006fd7e,
        0x98000e98,
        0x207e010f,
        0x14950001,
@@ -523,8 +523,8 @@ uint32_t gk208_grhub_code[] = {
        0x800040b7,
        0xf40132b6,
        0x000fb41b,
-       0x0006f97e,
-       0xa87e000f,
+       0x0006fd7e,
+       0xac7e000f,
        0x00800006,
        0x01f60201,
        0xbd04bd00,
@@ -554,7 +554,7 @@ uint32_t gk208_grhub_code[] = {
        0x0009f602,
        0x32f404bd,
        0x0231f401,
-       0x00087c7e,
+       0x0008807e,
        0x99f094bd,
        0x17008007,
        0x0009f602,
@@ -563,7 +563,7 @@ uint32_t gk208_grhub_code[] = {
        0x37008006,
        0x0009f602,
        0x31f404bd,
-       0x087c7e01,
+       0x08807e01,
        0xf094bd00,
        0x00800699,
        0x09f60217,
@@ -572,7 +572,7 @@ uint32_t gk208_grhub_code[] = {
        0x20f92f0e,
        0x32f412b2,
        0x0232f401,
-       0x00087c7e,
+       0x0008807e,
        0x008020fc,
        0x02f602c0,
        0xf404bd00,
@@ -580,7 +580,7 @@ uint32_t gk208_grhub_code[] = {
        0x23c8130e,
        0x0d0bf41f,
        0xf40131f4,
-       0x7c7e0232,
+       0x807e0232,
 /* 0x054e: chsw_done */
        0x01020008,
        0x02c30080,
@@ -593,7 +593,7 @@ uint32_t gk208_grhub_code[] = {
        0xb0ff2a0e,
        0x1bf401e4,
        0x7ef2b20c,
-       0xf400081c,
+       0xf4000820,
 /* 0x057a: main_not_ctx_chan */
        0xe4b0400e,
        0x2c1bf402,
@@ -602,7 +602,7 @@ uint32_t gk208_grhub_code[] = {
        0x0009f602,
        0x32f404bd,
        0x0232f401,
-       0x00087c7e,
+       0x0008807e,
        0x99f094bd,
        0x17008007,
        0x0009f602,
@@ -618,91 +618,92 @@ uint32_t gk208_grhub_code[] = {
        0xbd0002f6,
        0xcc0ef504,
 /* 0x05c9: ih */
-       0xfe80f9fe,
-       0x80f90188,
-       0xa0f990f9,
-       0xd0f9b0f9,
-       0xf0f9e0f9,
-       0x004a04bd,
-       0x00aacf02,
-       0xf404abc4,
-       0x100d230b,
-       0xcf1a004e,
-       0x004f00ee,
-       0x00ffcf19,
+       0xf900f9fe,
+       0x0188fe80,
+       0x90f980f9,
+       0xb0f9a0f9,
+       0xe0f9d0f9,
+       0x04bdf0f9,
+       0xcf02004a,
+       0xabc400aa,
+       0x230bf404,
+       0x004e100d,
+       0x00eecf1a,
+       0xcf19004f,
+       0x047e00ff,
+       0xb0b70000,
+       0x010e0400,
+       0xf61d0040,
+       0x04bd000e,
+/* 0x060c: ih_no_fifo */
+       0x0100abe4,
+       0x0d0c0bf4,
+       0x40014e10,
        0x0000047e,
-       0x0400b0b7,
-       0x0040010e,
-       0x000ef61d,
-/* 0x060a: ih_no_fifo */
-       0xabe404bd,
-       0x0bf40100,
-       0x4e100d0c,
-       0x047e4001,
-/* 0x061a: ih_no_ctxsw */
-       0xabe40000,
-       0x0bf40400,
-       0x07088e56,
-       0x00657e40,
-       0x80ffb200,
-       0xf6020400,
-       0x04bd000f,
-       0x4007048e,
-       0x0000657e,
-       0x0080ffb2,
-       0x0ff60203,
-       0xc704bd00,
-       0xee9450fe,
-       0x07008f02,
-       0x00efbb40,
-       0x0000657e,
-       0x02020080,
+/* 0x061c: ih_no_ctxsw */
+       0x0400abe4,
+       0x8e560bf4,
+       0x7e400708,
+       0xb2000065,
+       0x040080ff,
+       0x000ff602,
+       0x048e04bd,
+       0x657e4007,
+       0xffb20000,
+       0x02030080,
        0xbd000ff6,
-       0x7e030f04,
-       0x4b0002f8,
-       0xbfb20100,
-       0x4001448e,
-       0x00008f7e,
-/* 0x0674: ih_no_fwmthd */
-       0xbd05044b,
-       0xb4abffb0,
-       0x800c0bf4,
-       0xf6030700,
-       0x04bd000b,
-/* 0x0688: ih_no_other */
-       0xf6010040,
-       0x04bd000a,
-       0xe0fcf0fc,
-       0xb0fcd0fc,
-       0x90fca0fc,
-       0x88fe80fc,
-       0xf480fc00,
+       0x50fec704,
+       0x8f02ee94,
+       0xbb400700,
+       0x657e00ef,
+       0x00800000,
+       0x0ff60202,
+       0x0f04bd00,
+       0x02f87e03,
+       0x01004b00,
+       0x448ebfb2,
+       0x8f7e4001,
+/* 0x0676: ih_no_fwmthd */
+       0x044b0000,
+       0xffb0bd05,
+       0x0bf4b4ab,
+       0x0700800c,
+       0x000bf603,
+/* 0x068a: ih_no_other */
+       0x004004bd,
+       0x000af601,
+       0xf0fc04bd,
+       0xd0fce0fc,
+       0xa0fcb0fc,
+       0x80fc90fc,
+       0xfc0088fe,
+       0xf400fc80,
        0x01f80032,
-/* 0x06a8: ctx_4170s */
+/* 0x06ac: ctx_4170s */
        0xb210f5f0,
        0x41708eff,
        0x008f7e40,
-/* 0x06b7: ctx_4170w */
+/* 0x06bb: ctx_4170w */
        0x8e00f800,
        0x7e404170,
        0xb2000065,
        0x10f4f0ff,
        0xf8f31bf4,
-/* 0x06c9: ctx_redswitch */
+/* 0x06cd: ctx_redswitch */
        0x02004e00,
        0xf040e5f0,
        0xe5f020e5,
        0x85008010,
        0x000ef601,
        0x080f04bd,
-/* 0x06e0: ctx_redswitch_delay */
+/* 0x06e4: ctx_redswitch_delay */
        0xf401f2b6,
        0xe5f1fd1b,
        0xe5f10400,
        0x00800100,
        0x0ef60185,
        0xf804bd00,
-/* 0x06f9: ctx_86c */
+/* 0x06fd: ctx_86c */
        0x23008000,
        0x000ff602,
        0xffb204bd,
@@ -711,15 +712,15 @@ uint32_t gk208_grhub_code[] = {
        0x8c8effb2,
        0x8f7e41a8,
        0x00f80000,
-/* 0x0718: ctx_mem */
+/* 0x071c: ctx_mem */
        0x02840080,
        0xbd000ff6,
-/* 0x0721: ctx_mem_wait */
+/* 0x0725: ctx_mem_wait */
        0x84008f04,
        0x00ffcf02,
        0xf405fffd,
        0x00f8f61b,
-/* 0x0730: ctx_load */
+/* 0x0734: ctx_load */
        0x99f094bd,
        0x37008005,
        0x0009f602,
@@ -733,7 +734,7 @@ uint32_t gk208_grhub_code[] = {
        0x02830080,
        0xbd0002f6,
        0x7e070f04,
-       0x80000718,
+       0x8000071c,
        0xf602c000,
        0x04bd0002,
        0xf0000bfe,
@@ -779,28 +780,28 @@ uint32_t gk208_grhub_code[] = {
        0x17008005,
        0x0009f602,
        0x00f804bd,
-/* 0x081c: ctx_chan */
-       0x0007307e,
+/* 0x0820: ctx_chan */
+       0x0007347e,
        0xb87e0c0a,
        0x050f0000,
-       0x0007187e,
-/* 0x082e: ctx_mmio_exec */
+       0x00071c7e,
+/* 0x0832: ctx_mmio_exec */
        0x039800f8,
        0x81008041,
        0x0003f602,
        0x34bd04bd,
-/* 0x083c: ctx_mmio_loop */
+/* 0x0840: ctx_mmio_loop */
        0xf4ff34c4,
        0x00450e1b,
        0x0653f002,
        0xf80535fa,
-/* 0x084d: ctx_mmio_pull */
+/* 0x0851: ctx_mmio_pull */
        0x804e9803,
        0x7e814f98,
        0xb600008f,
        0x12b60830,
        0xdf1bf401,
-/* 0x0860: ctx_mmio_done */
+/* 0x0864: ctx_mmio_done */
        0x80160398,
        0xf6028100,
        0x04bd0003,
@@ -808,27 +809,27 @@ uint32_t gk208_grhub_code[] = {
        0x13f00100,
        0x0601fa06,
        0x00f803f8,
-/* 0x087c: ctx_xfer */
+/* 0x0880: ctx_xfer */
        0x0080040e,
        0x0ef60302,
-/* 0x0887: ctx_xfer_idle */
+/* 0x088b: ctx_xfer_idle */
        0x8e04bd00,
        0xcf030000,
        0xe4f100ee,
        0x1bf42000,
        0x0611f4f5,
-/* 0x089b: ctx_xfer_pre */
+/* 0x089f: ctx_xfer_pre */
        0x0f0c02f4,
-       0x06f97e10,
+       0x06fd7e10,
        0x1b11f400,
-/* 0x08a4: ctx_xfer_pre_load */
-       0xa87e020f,
-       0xb77e0006,
-       0xc97e0006,
+/* 0x08a8: ctx_xfer_pre_load */
+       0xac7e020f,
+       0xbb7e0006,
+       0xcd7e0006,
        0xf4bd0006,
-       0x0006a87e,
-       0x0007307e,
-/* 0x08bc: ctx_xfer_exec */
+       0x0006ac7e,
+       0x0007347e,
+/* 0x08c0: ctx_xfer_exec */
        0xbd160198,
        0x05008024,
        0x0002f601,
@@ -858,21 +859,21 @@ uint32_t gk208_grhub_code[] = {
        0x01f40002,
        0x7e0c0a12,
        0x0f0000b8,
-       0x07187e05,
+       0x071c7e05,
        0x2d02f400,
-/* 0x0938: ctx_xfer_post */
-       0xa87e020f,
+/* 0x093c: ctx_xfer_post */
+       0xac7e020f,
        0xf4bd0006,
-       0x0006f97e,
+       0x0006fd7e,
        0x0002277e,
-       0x0006b77e,
-       0xa87ef4bd,
+       0x0006bb7e,
+       0xac7ef4bd,
        0x11f40006,
        0x40019810,
        0xf40511fd,
-       0x2e7e070b,
-/* 0x0962: ctx_xfer_no_post_mmio */
-/* 0x0962: ctx_xfer_done */
+       0x327e070b,
+/* 0x0966: ctx_xfer_no_post_mmio */
+/* 0x0966: ctx_xfer_done */
        0x00f80008,
        0x00000000,
        0x00000000,
@@ -912,5 +913,4 @@ uint32_t gk208_grhub_code[] = {
        0x00000000,
        0x00000000,
        0x00000000,
-       0x00000000,
 };
index 5f953c5..d6343d2 100644 (file)
@@ -478,10 +478,10 @@ uint32_t gm107_grhub_code[] = {
        0x01040080,
        0xbd0001f6,
        0x01004104,
-       0xa87e020f,
-       0xb77e0006,
+       0xac7e020f,
+       0xbb7e0006,
        0x100f0006,
-       0x0006f97e,
+       0x0006fd7e,
        0x98000e98,
        0x207e010f,
        0x14950001,
@@ -523,8 +523,8 @@ uint32_t gm107_grhub_code[] = {
        0x800040b7,
        0xf40132b6,
        0x000fb41b,
-       0x0006f97e,
-       0xa87e000f,
+       0x0006fd7e,
+       0xac7e000f,
        0x00800006,
        0x01f60201,
        0xbd04bd00,
@@ -554,7 +554,7 @@ uint32_t gm107_grhub_code[] = {
        0x0009f602,
        0x32f404bd,
        0x0231f401,
-       0x00087c7e,
+       0x0008807e,
        0x99f094bd,
        0x17008007,
        0x0009f602,
@@ -563,7 +563,7 @@ uint32_t gm107_grhub_code[] = {
        0x37008006,
        0x0009f602,
        0x31f404bd,
-       0x087c7e01,
+       0x08807e01,
        0xf094bd00,
        0x00800699,
        0x09f60217,
@@ -572,7 +572,7 @@ uint32_t gm107_grhub_code[] = {
        0x20f92f0e,
        0x32f412b2,
        0x0232f401,
-       0x00087c7e,
+       0x0008807e,
        0x008020fc,
        0x02f602c0,
        0xf404bd00,
@@ -580,7 +580,7 @@ uint32_t gm107_grhub_code[] = {
        0x23c8130e,
        0x0d0bf41f,
        0xf40131f4,
-       0x7c7e0232,
+       0x807e0232,
 /* 0x054e: chsw_done */
        0x01020008,
        0x02c30080,
@@ -593,7 +593,7 @@ uint32_t gm107_grhub_code[] = {
        0xb0ff2a0e,
        0x1bf401e4,
        0x7ef2b20c,
-       0xf400081c,
+       0xf4000820,
 /* 0x057a: main_not_ctx_chan */
        0xe4b0400e,
        0x2c1bf402,
@@ -602,7 +602,7 @@ uint32_t gm107_grhub_code[] = {
        0x0009f602,
        0x32f404bd,
        0x0232f401,
-       0x00087c7e,
+       0x0008807e,
        0x99f094bd,
        0x17008007,
        0x0009f602,
@@ -618,91 +618,92 @@ uint32_t gm107_grhub_code[] = {
        0xbd0002f6,
        0xcc0ef504,
 /* 0x05c9: ih */
-       0xfe80f9fe,
-       0x80f90188,
-       0xa0f990f9,
-       0xd0f9b0f9,
-       0xf0f9e0f9,
-       0x004a04bd,
-       0x00aacf02,
-       0xf404abc4,
-       0x100d230b,
-       0xcf1a004e,
-       0x004f00ee,
-       0x00ffcf19,
+       0xf900f9fe,
+       0x0188fe80,
+       0x90f980f9,
+       0xb0f9a0f9,
+       0xe0f9d0f9,
+       0x04bdf0f9,
+       0xcf02004a,
+       0xabc400aa,
+       0x230bf404,
+       0x004e100d,
+       0x00eecf1a,
+       0xcf19004f,
+       0x047e00ff,
+       0xb0b70000,
+       0x010e0400,
+       0xf61d0040,
+       0x04bd000e,
+/* 0x060c: ih_no_fifo */
+       0x0100abe4,
+       0x0d0c0bf4,
+       0x40014e10,
        0x0000047e,
-       0x0400b0b7,
-       0x0040010e,
-       0x000ef61d,
-/* 0x060a: ih_no_fifo */
-       0xabe404bd,
-       0x0bf40100,
-       0x4e100d0c,
-       0x047e4001,
-/* 0x061a: ih_no_ctxsw */
-       0xabe40000,
-       0x0bf40400,
-       0x07088e56,
-       0x00657e40,
-       0x80ffb200,
-       0xf6020400,
-       0x04bd000f,
-       0x4007048e,
-       0x0000657e,
-       0x0080ffb2,
-       0x0ff60203,
-       0xc704bd00,
-       0xee9450fe,
-       0x07008f02,
-       0x00efbb40,
-       0x0000657e,
-       0x02020080,
+/* 0x061c: ih_no_ctxsw */
+       0x0400abe4,
+       0x8e560bf4,
+       0x7e400708,
+       0xb2000065,
+       0x040080ff,
+       0x000ff602,
+       0x048e04bd,
+       0x657e4007,
+       0xffb20000,
+       0x02030080,
        0xbd000ff6,
-       0x7e030f04,
-       0x4b0002f8,
-       0xbfb20100,
-       0x4001448e,
-       0x00008f7e,
-/* 0x0674: ih_no_fwmthd */
-       0xbd05044b,
-       0xb4abffb0,
-       0x800c0bf4,
-       0xf6030700,
-       0x04bd000b,
-/* 0x0688: ih_no_other */
-       0xf6010040,
-       0x04bd000a,
-       0xe0fcf0fc,
-       0xb0fcd0fc,
-       0x90fca0fc,
-       0x88fe80fc,
-       0xf480fc00,
+       0x50fec704,
+       0x8f02ee94,
+       0xbb400700,
+       0x657e00ef,
+       0x00800000,
+       0x0ff60202,
+       0x0f04bd00,
+       0x02f87e03,
+       0x01004b00,
+       0x448ebfb2,
+       0x8f7e4001,
+/* 0x0676: ih_no_fwmthd */
+       0x044b0000,
+       0xffb0bd05,
+       0x0bf4b4ab,
+       0x0700800c,
+       0x000bf603,
+/* 0x068a: ih_no_other */
+       0x004004bd,
+       0x000af601,
+       0xf0fc04bd,
+       0xd0fce0fc,
+       0xa0fcb0fc,
+       0x80fc90fc,
+       0xfc0088fe,
+       0xf400fc80,
        0x01f80032,
-/* 0x06a8: ctx_4170s */
+/* 0x06ac: ctx_4170s */
        0xb210f5f0,
        0x41708eff,
        0x008f7e40,
-/* 0x06b7: ctx_4170w */
+/* 0x06bb: ctx_4170w */
        0x8e00f800,
        0x7e404170,
        0xb2000065,
        0x10f4f0ff,
        0xf8f31bf4,
-/* 0x06c9: ctx_redswitch */
+/* 0x06cd: ctx_redswitch */
        0x02004e00,
        0xf040e5f0,
        0xe5f020e5,
        0x85008010,
        0x000ef601,
        0x080f04bd,
-/* 0x06e0: ctx_redswitch_delay */
+/* 0x06e4: ctx_redswitch_delay */
        0xf401f2b6,
        0xe5f1fd1b,
        0xe5f10400,
        0x00800100,
        0x0ef60185,
        0xf804bd00,
-/* 0x06f9: ctx_86c */
+/* 0x06fd: ctx_86c */
        0x23008000,
        0x000ff602,
        0xffb204bd,
@@ -711,15 +712,15 @@ uint32_t gm107_grhub_code[] = {
        0x8c8effb2,
        0x8f7e41a8,
        0x00f80000,
-/* 0x0718: ctx_mem */
+/* 0x071c: ctx_mem */
        0x02840080,
        0xbd000ff6,
-/* 0x0721: ctx_mem_wait */
+/* 0x0725: ctx_mem_wait */
        0x84008f04,
        0x00ffcf02,
        0xf405fffd,
        0x00f8f61b,
-/* 0x0730: ctx_load */
+/* 0x0734: ctx_load */
        0x99f094bd,
        0x37008005,
        0x0009f602,
@@ -733,7 +734,7 @@ uint32_t gm107_grhub_code[] = {
        0x02830080,
        0xbd0002f6,
        0x7e070f04,
-       0x80000718,
+       0x8000071c,
        0xf602c000,
        0x04bd0002,
        0xf0000bfe,
@@ -779,28 +780,28 @@ uint32_t gm107_grhub_code[] = {
        0x17008005,
        0x0009f602,
        0x00f804bd,
-/* 0x081c: ctx_chan */
-       0x0007307e,
+/* 0x0820: ctx_chan */
+       0x0007347e,
        0xb87e0c0a,
        0x050f0000,
-       0x0007187e,
-/* 0x082e: ctx_mmio_exec */
+       0x00071c7e,
+/* 0x0832: ctx_mmio_exec */
        0x039800f8,
        0x81008041,
        0x0003f602,
        0x34bd04bd,
-/* 0x083c: ctx_mmio_loop */
+/* 0x0840: ctx_mmio_loop */
        0xf4ff34c4,
        0x00450e1b,
        0x0653f002,
        0xf80535fa,
-/* 0x084d: ctx_mmio_pull */
+/* 0x0851: ctx_mmio_pull */
        0x804e9803,
        0x7e814f98,
        0xb600008f,
        0x12b60830,
        0xdf1bf401,
-/* 0x0860: ctx_mmio_done */
+/* 0x0864: ctx_mmio_done */
        0x80160398,
        0xf6028100,
        0x04bd0003,
@@ -808,27 +809,27 @@ uint32_t gm107_grhub_code[] = {
        0x13f00100,
        0x0601fa06,
        0x00f803f8,
-/* 0x087c: ctx_xfer */
+/* 0x0880: ctx_xfer */
        0x0080040e,
        0x0ef60302,
-/* 0x0887: ctx_xfer_idle */
+/* 0x088b: ctx_xfer_idle */
        0x8e04bd00,
        0xcf030000,
        0xe4f100ee,
        0x1bf42000,
        0x0611f4f5,
-/* 0x089b: ctx_xfer_pre */
+/* 0x089f: ctx_xfer_pre */
        0x0f0c02f4,
-       0x06f97e10,
+       0x06fd7e10,
        0x1b11f400,
-/* 0x08a4: ctx_xfer_pre_load */
-       0xa87e020f,
-       0xb77e0006,
-       0xc97e0006,
+/* 0x08a8: ctx_xfer_pre_load */
+       0xac7e020f,
+       0xbb7e0006,
+       0xcd7e0006,
        0xf4bd0006,
-       0x0006a87e,
-       0x0007307e,
-/* 0x08bc: ctx_xfer_exec */
+       0x0006ac7e,
+       0x0007347e,
+/* 0x08c0: ctx_xfer_exec */
        0xbd160198,
        0x05008024,
        0x0002f601,
@@ -858,21 +859,21 @@ uint32_t gm107_grhub_code[] = {
        0x01f40002,
        0x7e0c0a12,
        0x0f0000b8,
-       0x07187e05,
+       0x071c7e05,
        0x2d02f400,
-/* 0x0938: ctx_xfer_post */
-       0xa87e020f,
+/* 0x093c: ctx_xfer_post */
+       0xac7e020f,
        0xf4bd0006,
-       0x0006f97e,
+       0x0006fd7e,
        0x0002277e,
-       0x0006b77e,
-       0xa87ef4bd,
+       0x0006bb7e,
+       0xac7ef4bd,
        0x11f40006,
        0x40019810,
        0xf40511fd,
-       0x2e7e070b,
-/* 0x0962: ctx_xfer_no_post_mmio */
-/* 0x0962: ctx_xfer_done */
+       0x327e070b,
+/* 0x0966: ctx_xfer_no_post_mmio */
+/* 0x0966: ctx_xfer_done */
        0x00f80008,
        0x00000000,
        0x00000000,
@@ -912,5 +913,4 @@ uint32_t gm107_grhub_code[] = {
        0x00000000,
        0x00000000,
        0x00000000,
-       0x00000000,
 };
index 1f81069..c56a886 100644 (file)
@@ -27,6 +27,8 @@
 
 #include <core/client.h>
 #include <core/option.h>
+#include <core/firmware.h>
+#include <subdev/secboot.h>
 #include <subdev/fb.h>
 #include <subdev/mc.h>
 #include <subdev/pmu.h>
@@ -1427,21 +1429,40 @@ gf100_gr_init_ctxctl(struct gf100_gr *gr)
        const struct gf100_grctx_func *grctx = gr->func->grctx;
        struct nvkm_subdev *subdev = &gr->base.engine.subdev;
        struct nvkm_device *device = subdev->device;
+       struct nvkm_secboot *sb = device->secboot;
        int i;
 
        if (gr->firmware) {
                /* load fuc microcode */
                nvkm_mc_unk260(device->mc, 0);
-               gf100_gr_init_fw(gr, 0x409000, &gr->fuc409c, &gr->fuc409d);
-               gf100_gr_init_fw(gr, 0x41a000, &gr->fuc41ac, &gr->fuc41ad);
+
+               /* securely-managed falcons must be reset using secure boot */
+               if (nvkm_secboot_is_managed(sb, NVKM_SECBOOT_FALCON_FECS))
+                       nvkm_secboot_reset(sb, NVKM_SECBOOT_FALCON_FECS);
+               else
+                       gf100_gr_init_fw(gr, 0x409000, &gr->fuc409c,
+                                        &gr->fuc409d);
+               if (nvkm_secboot_is_managed(sb, NVKM_SECBOOT_FALCON_GPCCS))
+                       nvkm_secboot_reset(sb, NVKM_SECBOOT_FALCON_GPCCS);
+               else
+                       gf100_gr_init_fw(gr, 0x41a000, &gr->fuc41ac,
+                                        &gr->fuc41ad);
+
                nvkm_mc_unk260(device->mc, 1);
 
                /* start both of them running */
                nvkm_wr32(device, 0x409840, 0xffffffff);
                nvkm_wr32(device, 0x41a10c, 0x00000000);
                nvkm_wr32(device, 0x40910c, 0x00000000);
-               nvkm_wr32(device, 0x41a100, 0x00000002);
-               nvkm_wr32(device, 0x409100, 0x00000002);
+
+               if (nvkm_secboot_is_managed(sb, NVKM_SECBOOT_FALCON_GPCCS))
+                       nvkm_secboot_start(sb, NVKM_SECBOOT_FALCON_GPCCS);
+               else
+                       nvkm_wr32(device, 0x41a100, 0x00000002);
+               if (nvkm_secboot_is_managed(sb, NVKM_SECBOOT_FALCON_FECS))
+                       nvkm_secboot_start(sb, NVKM_SECBOOT_FALCON_FECS);
+               else
+                       nvkm_wr32(device, 0x409100, 0x00000002);
                if (nvkm_msec(device, 2000,
                        if (nvkm_rd32(device, 0x409800) & 0x00000001)
                                break;
@@ -1683,6 +1704,12 @@ gf100_gr_dtor_fw(struct gf100_gr_fuc *fuc)
        fuc->data = NULL;
 }
 
+static void
+gf100_gr_dtor_init(struct gf100_gr_pack *pack)
+{
+       vfree(pack);
+}
+
 void *
 gf100_gr_dtor(struct nvkm_gr *base)
 {
@@ -1697,6 +1724,11 @@ gf100_gr_dtor(struct nvkm_gr *base)
        gf100_gr_dtor_fw(&gr->fuc41ac);
        gf100_gr_dtor_fw(&gr->fuc41ad);
 
+       gf100_gr_dtor_init(gr->fuc_bundle);
+       gf100_gr_dtor_init(gr->fuc_method);
+       gf100_gr_dtor_init(gr->fuc_sw_ctx);
+       gf100_gr_dtor_init(gr->fuc_sw_nonctx);
+
        nvkm_memory_del(&gr->unk4188b8);
        nvkm_memory_del(&gr->unk4188b4);
        return gr;
@@ -1720,22 +1752,9 @@ gf100_gr_ctor_fw(struct gf100_gr *gr, const char *fwname,
        struct nvkm_subdev *subdev = &gr->base.engine.subdev;
        struct nvkm_device *device = subdev->device;
        const struct firmware *fw;
-       char f[64];
-       char cname[16];
        int ret;
-       int i;
 
-       /* Convert device name to lowercase */
-       strncpy(cname, device->chip->name, sizeof(cname));
-       cname[sizeof(cname) - 1] = '\0';
-       i = strlen(cname);
-       while (i) {
-               --i;
-               cname[i] = tolower(cname[i]);
-       }
-
-       snprintf(f, sizeof(f), "nvidia/%s/%s.bin", cname, fwname);
-       ret = request_firmware(&fw, f, device->dev);
+       ret = nvkm_firmware_get(device, fwname, &fw);
        if (ret) {
                nvkm_error(subdev, "failed to load %s\n", fwname);
                return ret;
@@ -1743,7 +1762,7 @@ gf100_gr_ctor_fw(struct gf100_gr *gr, const char *fwname,
 
        fuc->size = fw->size;
        fuc->data = kmemdup(fw->data, fuc->size, GFP_KERNEL);
-       release_firmware(fw);
+       nvkm_firmware_put(fw);
        return (fuc->data != NULL) ? 0 : -ENOMEM;
 }
 
@@ -1763,15 +1782,6 @@ gf100_gr_ctor(const struct gf100_gr_func *func, struct nvkm_device *device,
        if (ret)
                return ret;
 
-       if (gr->firmware) {
-               nvkm_info(&gr->base.engine.subdev, "using external firmware\n");
-               if (gf100_gr_ctor_fw(gr, "fecs_inst", &gr->fuc409c) ||
-                   gf100_gr_ctor_fw(gr, "fecs_data", &gr->fuc409d) ||
-                   gf100_gr_ctor_fw(gr, "gpccs_inst", &gr->fuc41ac) ||
-                   gf100_gr_ctor_fw(gr, "gpccs_data", &gr->fuc41ad))
-                       return -ENODEV;
-       }
-
        return 0;
 }
 
@@ -1780,10 +1790,25 @@ gf100_gr_new_(const struct gf100_gr_func *func, struct nvkm_device *device,
              int index, struct nvkm_gr **pgr)
 {
        struct gf100_gr *gr;
+       int ret;
+
        if (!(gr = kzalloc(sizeof(*gr), GFP_KERNEL)))
                return -ENOMEM;
        *pgr = &gr->base;
-       return gf100_gr_ctor(func, device, index, gr);
+
+       ret = gf100_gr_ctor(func, device, index, gr);
+       if (ret)
+               return ret;
+
+       if (gr->firmware) {
+               if (gf100_gr_ctor_fw(gr, "fecs_inst", &gr->fuc409c) ||
+                   gf100_gr_ctor_fw(gr, "fecs_data", &gr->fuc409d) ||
+                   gf100_gr_ctor_fw(gr, "gpccs_inst", &gr->fuc41ac) ||
+                   gf100_gr_ctor_fw(gr, "gpccs_data", &gr->fuc41ad))
+                       return -ENODEV;
+       }
+
+       return 0;
 }
 
 int
index 02e78b8..f0c6acb 100644 (file)
@@ -82,7 +82,7 @@ struct gf100_gr {
 
        /*
         * Used if the register packs are loaded from NVIDIA fw instead of
-        * using hardcoded arrays.
+        * using hardcoded arrays. To be allocated with vzalloc().
         */
        struct gf100_gr_pack *fuc_sw_nonctx;
        struct gf100_gr_pack *fuc_sw_ctx;
@@ -138,12 +138,9 @@ int gf100_gr_init(struct gf100_gr *);
 
 int gk104_gr_init(struct gf100_gr *);
 
-int gk20a_gr_new_(const struct gf100_gr_func *, struct nvkm_device *,
-                 int, struct nvkm_gr **);
-void gk20a_gr_dtor(struct gf100_gr *);
 int gk20a_gr_init(struct gf100_gr *);
 
-int gm204_gr_init(struct gf100_gr *);
+int gm200_gr_init(struct gf100_gr *);
 
 #define gf100_gr_chan(p) container_of((p), struct gf100_gr_chan, object)
 
@@ -204,6 +201,17 @@ void gf100_gr_icmd(struct gf100_gr *, const struct gf100_gr_pack *);
 void gf100_gr_mthd(struct gf100_gr *, const struct gf100_gr_pack *);
 int  gf100_gr_init_ctxctl(struct gf100_gr *);
 
+/* external bundles loading functions */
+int gk20a_gr_av_to_init(struct gf100_gr *, const char *,
+                       struct gf100_gr_pack **);
+int gk20a_gr_aiv_to_init(struct gf100_gr *, const char *,
+                        struct gf100_gr_pack **);
+int gk20a_gr_av_to_method(struct gf100_gr *, const char *,
+                         struct gf100_gr_pack **);
+
+int gm200_gr_new_(const struct gf100_gr_func *, struct nvkm_device *, int,
+                 struct nvkm_gr **);
+
 /* register init value lists */
 
 extern const struct gf100_gr_init gf100_gr_init_main_0[];
@@ -279,6 +287,4 @@ extern const struct gf100_gr_init gm107_gr_init_l1c_0[];
 extern const struct gf100_gr_init gm107_gr_init_wwdx_0[];
 extern const struct gf100_gr_init gm107_gr_init_cbm_0[];
 void gm107_gr_init_bios(struct gf100_gr *);
-
-extern const struct gf100_gr_pack gm204_gr_pack_mmio[];
 #endif
index b8758d3..7ffb8a6 100644 (file)
 
 #include <nvif/class.h>
 
-static void
-gk20a_gr_init_dtor(struct gf100_gr_pack *pack)
-{
-       vfree(pack);
-}
-
 struct gk20a_fw_av
 {
        u32 addr;
        u32 data;
 };
 
-static struct gf100_gr_pack *
-gk20a_gr_av_to_init(struct gf100_gr_fuc *fuc)
+int
+gk20a_gr_av_to_init(struct gf100_gr *gr, const char *fw_name,
+                   struct gf100_gr_pack **ppack)
 {
+       struct gf100_gr_fuc fuc;
        struct gf100_gr_init *init;
        struct gf100_gr_pack *pack;
-       const int nent = (fuc->size / sizeof(struct gk20a_fw_av));
+       int nent;
+       int ret;
        int i;
 
+       ret = gf100_gr_ctor_fw(gr, fw_name, &fuc);
+       if (ret)
+               return ret;
+
+       nent = (fuc.size / sizeof(struct gk20a_fw_av));
        pack = vzalloc((sizeof(*pack) * 2) + (sizeof(*init) * (nent + 1)));
-       if (!pack)
-               return ERR_PTR(-ENOMEM);
+       if (!pack) {
+               ret = -ENOMEM;
+               goto end;
+       }
 
        init = (void *)(pack + 2);
-
        pack[0].init = init;
 
        for (i = 0; i < nent; i++) {
                struct gf100_gr_init *ent = &init[i];
-               struct gk20a_fw_av *av = &((struct gk20a_fw_av *)fuc->data)[i];
+               struct gk20a_fw_av *av = &((struct gk20a_fw_av *)fuc.data)[i];
 
                ent->addr = av->addr;
                ent->data = av->data;
@@ -64,7 +67,11 @@ gk20a_gr_av_to_init(struct gf100_gr_fuc *fuc)
                ent->pitch = 1;
        }
 
-       return pack;
+       *ppack = pack;
+
+end:
+       gf100_gr_dtor_fw(&fuc);
+       return ret;
 }
 
 struct gk20a_fw_aiv
@@ -74,25 +81,34 @@ struct gk20a_fw_aiv
        u32 data;
 };
 
-static struct gf100_gr_pack *
-gk20a_gr_aiv_to_init(struct gf100_gr_fuc *fuc)
+int
+gk20a_gr_aiv_to_init(struct gf100_gr *gr, const char *fw_name,
+                    struct gf100_gr_pack **ppack)
 {
+       struct gf100_gr_fuc fuc;
        struct gf100_gr_init *init;
        struct gf100_gr_pack *pack;
-       const int nent = (fuc->size / sizeof(struct gk20a_fw_aiv));
+       int nent;
+       int ret;
        int i;
 
+       ret = gf100_gr_ctor_fw(gr, fw_name, &fuc);
+       if (ret)
+               return ret;
+
+       nent = (fuc.size / sizeof(struct gk20a_fw_aiv));
        pack = vzalloc((sizeof(*pack) * 2) + (sizeof(*init) * (nent + 1)));
-       if (!pack)
-               return ERR_PTR(-ENOMEM);
+       if (!pack) {
+               ret = -ENOMEM;
+               goto end;
+       }
 
        init = (void *)(pack + 2);
-
        pack[0].init = init;
 
        for (i = 0; i < nent; i++) {
                struct gf100_gr_init *ent = &init[i];
-               struct gk20a_fw_aiv *av = &((struct gk20a_fw_aiv *)fuc->data)[i];
+               struct gk20a_fw_aiv *av = &((struct gk20a_fw_aiv *)fuc.data)[i];
 
                ent->addr = av->addr;
                ent->data = av->data;
@@ -100,30 +116,45 @@ gk20a_gr_aiv_to_init(struct gf100_gr_fuc *fuc)
                ent->pitch = 1;
        }
 
-       return pack;
+       *ppack = pack;
+
+end:
+       gf100_gr_dtor_fw(&fuc);
+       return ret;
 }
 
-static struct gf100_gr_pack *
-gk20a_gr_av_to_method(struct gf100_gr_fuc *fuc)
+int
+gk20a_gr_av_to_method(struct gf100_gr *gr, const char *fw_name,
+                     struct gf100_gr_pack **ppack)
 {
+       struct gf100_gr_fuc fuc;
        struct gf100_gr_init *init;
        struct gf100_gr_pack *pack;
        /* We don't suppose we will initialize more than 16 classes here... */
        static const unsigned int max_classes = 16;
-       const int nent = (fuc->size / sizeof(struct gk20a_fw_av));
-       int i, classidx = 0;
-       u32 prevclass = 0;
+       u32 classidx = 0, prevclass = 0;
+       int nent;
+       int ret;
+       int i;
+
+       ret = gf100_gr_ctor_fw(gr, fw_name, &fuc);
+       if (ret)
+               return ret;
+
+       nent = (fuc.size / sizeof(struct gk20a_fw_av));
 
        pack = vzalloc((sizeof(*pack) * max_classes) +
                       (sizeof(*init) * (nent + 1)));
-       if (!pack)
-               return ERR_PTR(-ENOMEM);
+       if (!pack) {
+               ret = -ENOMEM;
+               goto end;
+       }
 
        init = (void *)(pack + max_classes);
 
        for (i = 0; i < nent; i++) {
                struct gf100_gr_init *ent = &init[i];
-               struct gk20a_fw_av *av = &((struct gk20a_fw_av *)fuc->data)[i];
+               struct gk20a_fw_av *av = &((struct gk20a_fw_av *)fuc.data)[i];
                u32 class = av->addr & 0xffff;
                u32 addr = (av->addr & 0xffff0000) >> 14;
 
@@ -133,7 +164,8 @@ gk20a_gr_av_to_method(struct gf100_gr_fuc *fuc)
                        prevclass = class;
                        if (++classidx >= max_classes) {
                                vfree(pack);
-                               return ERR_PTR(-ENOSPC);
+                               ret = -ENOSPC;
+                               goto end;
                        }
                }
 
@@ -143,7 +175,11 @@ gk20a_gr_av_to_method(struct gf100_gr_fuc *fuc)
                ent->pitch = 1;
        }
 
-       return pack;
+       *ppack = pack;
+
+end:
+       gf100_gr_dtor_fw(&fuc);
+       return ret;
 }
 
 static int
@@ -273,20 +309,24 @@ gk20a_gr_init(struct gf100_gr *gr)
        return gf100_gr_init_ctxctl(gr);
 }
 
-void
-gk20a_gr_dtor(struct gf100_gr *gr)
-{
-       gk20a_gr_init_dtor(gr->fuc_method);
-       gk20a_gr_init_dtor(gr->fuc_bundle);
-       gk20a_gr_init_dtor(gr->fuc_sw_ctx);
-       gk20a_gr_init_dtor(gr->fuc_sw_nonctx);
-}
+static const struct gf100_gr_func
+gk20a_gr = {
+       .init = gk20a_gr_init,
+       .set_hww_esr_report_mask = gk20a_gr_set_hww_esr_report_mask,
+       .ppc_nr = 1,
+       .grctx = &gk20a_grctx,
+       .sclass = {
+               { -1, -1, FERMI_TWOD_A },
+               { -1, -1, KEPLER_INLINE_TO_MEMORY_A },
+               { -1, -1, KEPLER_C, &gf100_fermi },
+               { -1, -1, KEPLER_COMPUTE_A },
+               {}
+       }
+};
 
 int
-gk20a_gr_new_(const struct gf100_gr_func *func, struct nvkm_device *device,
-             int index, struct nvkm_gr **pgr)
+gk20a_gr_new(struct nvkm_device *device, int index, struct nvkm_gr **pgr)
 {
-       struct gf100_gr_fuc fuc;
        struct gf100_gr *gr;
        int ret;
 
@@ -294,63 +334,32 @@ gk20a_gr_new_(const struct gf100_gr_func *func, struct nvkm_device *device,
                return -ENOMEM;
        *pgr = &gr->base;
 
-       ret = gf100_gr_ctor(func, device, index, gr);
+       ret = gf100_gr_ctor(&gk20a_gr, device, index, gr);
        if (ret)
                return ret;
 
-       ret = gf100_gr_ctor_fw(gr, "sw_nonctx", &fuc);
+       if (gf100_gr_ctor_fw(gr, "fecs_inst", &gr->fuc409c) ||
+           gf100_gr_ctor_fw(gr, "fecs_data", &gr->fuc409d) ||
+           gf100_gr_ctor_fw(gr, "gpccs_inst", &gr->fuc41ac) ||
+           gf100_gr_ctor_fw(gr, "gpccs_data", &gr->fuc41ad))
+               return -ENODEV;
+
+       ret = gk20a_gr_av_to_init(gr, "sw_nonctx", &gr->fuc_sw_nonctx);
        if (ret)
                return ret;
-       gr->fuc_sw_nonctx = gk20a_gr_av_to_init(&fuc);
-       gf100_gr_dtor_fw(&fuc);
-       if (IS_ERR(gr->fuc_sw_nonctx))
-               return PTR_ERR(gr->fuc_sw_nonctx);
 
-       ret = gf100_gr_ctor_fw(gr, "sw_ctx", &fuc);
+       ret = gk20a_gr_aiv_to_init(gr, "sw_ctx", &gr->fuc_sw_ctx);
        if (ret)
                return ret;
-       gr->fuc_sw_ctx = gk20a_gr_aiv_to_init(&fuc);
-       gf100_gr_dtor_fw(&fuc);
-       if (IS_ERR(gr->fuc_sw_ctx))
-               return PTR_ERR(gr->fuc_sw_ctx);
 
-       ret = gf100_gr_ctor_fw(gr, "sw_bundle_init", &fuc);
+       ret = gk20a_gr_av_to_init(gr, "sw_bundle_init", &gr->fuc_bundle);
        if (ret)
                return ret;
-       gr->fuc_bundle = gk20a_gr_av_to_init(&fuc);
-       gf100_gr_dtor_fw(&fuc);
-       if (IS_ERR(gr->fuc_bundle))
-               return PTR_ERR(gr->fuc_bundle);
 
-       ret = gf100_gr_ctor_fw(gr, "sw_method_init", &fuc);
+       ret = gk20a_gr_av_to_method(gr, "sw_method_init", &gr->fuc_method);
        if (ret)
                return ret;
-       gr->fuc_method = gk20a_gr_av_to_method(&fuc);
-       gf100_gr_dtor_fw(&fuc);
-       if (IS_ERR(gr->fuc_method))
-               return PTR_ERR(gr->fuc_method);
 
-       return 0;
-}
 
-static const struct gf100_gr_func
-gk20a_gr = {
-       .dtor = gk20a_gr_dtor,
-       .init = gk20a_gr_init,
-       .set_hww_esr_report_mask = gk20a_gr_set_hww_esr_report_mask,
-       .ppc_nr = 1,
-       .grctx = &gk20a_grctx,
-       .sclass = {
-               { -1, -1, FERMI_TWOD_A },
-               { -1, -1, KEPLER_INLINE_TO_MEMORY_A },
-               { -1, -1, KEPLER_C, &gf100_fermi },
-               { -1, -1, KEPLER_COMPUTE_A },
-               {}
-       }
-};
-
-int
-gk20a_gr_new(struct nvkm_device *device, int index, struct nvkm_gr **pgr)
-{
-       return gk20a_gr_new_(&gk20a_gr, device, index, pgr);
+       return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm200.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm200.c
new file mode 100644 (file)
index 0000000..058fc1d
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2015 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Ben Skeggs <bskeggs@redhat.com>
+ */
+#include "gf100.h"
+#include "ctxgf100.h"
+
+#include <subdev/secboot.h>
+
+#include <nvif/class.h>
+
+/*******************************************************************************
+ * PGRAPH engine/subdev functions
+ ******************************************************************************/
+
+int
+gm200_gr_init(struct gf100_gr *gr)
+{
+       struct nvkm_device *device = gr->base.engine.subdev.device;
+       const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total);
+       u32 data[TPC_MAX / 8] = {}, tmp;
+       u8  tpcnr[GPC_MAX];
+       int gpc, tpc, ppc, rop;
+       int i;
+
+       tmp = nvkm_rd32(device, 0x100c80); /*XXX: mask? */
+       nvkm_wr32(device, 0x418880, 0x00001000 | (tmp & 0x00000fff));
+       nvkm_wr32(device, 0x418890, 0x00000000);
+       nvkm_wr32(device, 0x418894, 0x00000000);
+       nvkm_wr32(device, 0x4188b4, nvkm_memory_addr(gr->unk4188b4) >> 8);
+       nvkm_wr32(device, 0x4188b8, nvkm_memory_addr(gr->unk4188b8) >> 8);
+       nvkm_mask(device, 0x4188b0, 0x00040000, 0x00040000);
+
+       /*XXX: belongs in fb */
+       nvkm_wr32(device, 0x100cc8, nvkm_memory_addr(gr->unk4188b4) >> 8);
+       nvkm_wr32(device, 0x100ccc, nvkm_memory_addr(gr->unk4188b8) >> 8);
+       nvkm_mask(device, 0x100cc4, 0x00040000, 0x00040000);
+
+       gf100_gr_mmio(gr, gr->fuc_sw_nonctx);
+
+       gm107_gr_init_bios(gr);
+
+       nvkm_wr32(device, GPC_UNIT(0, 0x3018), 0x00000001);
+
+       memset(data, 0x00, sizeof(data));
+       memcpy(tpcnr, gr->tpc_nr, sizeof(gr->tpc_nr));
+       for (i = 0, gpc = -1; i < gr->tpc_total; i++) {
+               do {
+                       gpc = (gpc + 1) % gr->gpc_nr;
+               } while (!tpcnr[gpc]);
+               tpc = gr->tpc_nr[gpc] - tpcnr[gpc]--;
+
+               data[i / 8] |= tpc << ((i % 8) * 4);
+       }
+
+       nvkm_wr32(device, GPC_BCAST(0x0980), data[0]);
+       nvkm_wr32(device, GPC_BCAST(0x0984), data[1]);
+       nvkm_wr32(device, GPC_BCAST(0x0988), data[2]);
+       nvkm_wr32(device, GPC_BCAST(0x098c), data[3]);
+
+       for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
+               nvkm_wr32(device, GPC_UNIT(gpc, 0x0914),
+                       gr->magic_not_rop_nr << 8 | gr->tpc_nr[gpc]);
+               nvkm_wr32(device, GPC_UNIT(gpc, 0x0910), 0x00040000 |
+                       gr->tpc_total);
+               nvkm_wr32(device, GPC_UNIT(gpc, 0x0918), magicgpc918);
+       }
+
+       nvkm_wr32(device, GPC_BCAST(0x3fd4), magicgpc918);
+       nvkm_wr32(device, GPC_BCAST(0x08ac), nvkm_rd32(device, 0x100800));
+       nvkm_wr32(device, GPC_BCAST(0x033c), nvkm_rd32(device, 0x100804));
+
+       nvkm_wr32(device, 0x400500, 0x00010001);
+       nvkm_wr32(device, 0x400100, 0xffffffff);
+       nvkm_wr32(device, 0x40013c, 0xffffffff);
+       nvkm_wr32(device, 0x400124, 0x00000002);
+       nvkm_wr32(device, 0x409c24, 0x000e0000);
+       nvkm_wr32(device, 0x405848, 0xc0000000);
+       nvkm_wr32(device, 0x40584c, 0x00000001);
+       nvkm_wr32(device, 0x404000, 0xc0000000);
+       nvkm_wr32(device, 0x404600, 0xc0000000);
+       nvkm_wr32(device, 0x408030, 0xc0000000);
+       nvkm_wr32(device, 0x404490, 0xc0000000);
+       nvkm_wr32(device, 0x406018, 0xc0000000);
+       nvkm_wr32(device, 0x407020, 0x40000000);
+       nvkm_wr32(device, 0x405840, 0xc0000000);
+       nvkm_wr32(device, 0x405844, 0x00ffffff);
+       nvkm_mask(device, 0x419cc0, 0x00000008, 0x00000008);
+
+       for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
+               for (ppc = 0; ppc < gr->ppc_nr[gpc]; ppc++)
+                       nvkm_wr32(device, PPC_UNIT(gpc, ppc, 0x038), 0xc0000000);
+               nvkm_wr32(device, GPC_UNIT(gpc, 0x0420), 0xc0000000);
+               nvkm_wr32(device, GPC_UNIT(gpc, 0x0900), 0xc0000000);
+               nvkm_wr32(device, GPC_UNIT(gpc, 0x1028), 0xc0000000);
+               nvkm_wr32(device, GPC_UNIT(gpc, 0x0824), 0xc0000000);
+               for (tpc = 0; tpc < gr->tpc_nr[gpc]; tpc++) {
+                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x508), 0xffffffff);
+                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x50c), 0xffffffff);
+                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x224), 0xc0000000);
+                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x48c), 0xc0000000);
+                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x084), 0xc0000000);
+                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x430), 0xc0000000);
+                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x644), 0x00dffffe);
+                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x64c), 0x00000005);
+               }
+               nvkm_wr32(device, GPC_UNIT(gpc, 0x2c90), 0xffffffff);
+               nvkm_wr32(device, GPC_UNIT(gpc, 0x2c94), 0xffffffff);
+       }
+
+       for (rop = 0; rop < gr->rop_nr; rop++) {
+               nvkm_wr32(device, ROP_UNIT(rop, 0x144), 0x40000000);
+               nvkm_wr32(device, ROP_UNIT(rop, 0x070), 0x40000000);
+               nvkm_wr32(device, ROP_UNIT(rop, 0x204), 0xffffffff);
+               nvkm_wr32(device, ROP_UNIT(rop, 0x208), 0xffffffff);
+       }
+
+       nvkm_wr32(device, 0x400108, 0xffffffff);
+       nvkm_wr32(device, 0x400138, 0xffffffff);
+       nvkm_wr32(device, 0x400118, 0xffffffff);
+       nvkm_wr32(device, 0x400130, 0xffffffff);
+       nvkm_wr32(device, 0x40011c, 0xffffffff);
+       nvkm_wr32(device, 0x400134, 0xffffffff);
+
+       nvkm_wr32(device, 0x400054, 0x2c350f63);
+
+       gf100_gr_zbc_init(gr);
+
+       return gf100_gr_init_ctxctl(gr);
+}
+
+int
+gm200_gr_new_(const struct gf100_gr_func *func, struct nvkm_device *device,
+             int index, struct nvkm_gr **pgr)
+{
+       struct gf100_gr *gr;
+       int ret;
+
+       if (!(gr = kzalloc(sizeof(*gr), GFP_KERNEL)))
+               return -ENOMEM;
+       *pgr = &gr->base;
+
+       ret = gf100_gr_ctor(func, device, index, gr);
+       if (ret)
+               return ret;
+
+       /* Load firmwares for non-secure falcons */
+       if (!nvkm_secboot_is_managed(device->secboot,
+                                    NVKM_SECBOOT_FALCON_FECS)) {
+               if ((ret = gf100_gr_ctor_fw(gr, "gr/fecs_inst", &gr->fuc409c)) ||
+                   (ret = gf100_gr_ctor_fw(gr, "gr/fecs_data", &gr->fuc409d)))
+                       return ret;
+       }
+       if (!nvkm_secboot_is_managed(device->secboot,
+                                    NVKM_SECBOOT_FALCON_GPCCS)) {
+               if ((ret = gf100_gr_ctor_fw(gr, "gr/gpccs_inst", &gr->fuc41ac)) ||
+                   (ret = gf100_gr_ctor_fw(gr, "gr/gpccs_data", &gr->fuc41ad)))
+                       return ret;
+       }
+
+       if ((ret = gk20a_gr_av_to_init(gr, "gr/sw_nonctx", &gr->fuc_sw_nonctx)) ||
+           (ret = gk20a_gr_aiv_to_init(gr, "gr/sw_ctx", &gr->fuc_sw_ctx)) ||
+           (ret = gk20a_gr_av_to_init(gr, "gr/sw_bundle_init", &gr->fuc_bundle)) ||
+           (ret = gk20a_gr_av_to_method(gr, "gr/sw_method_init", &gr->fuc_method)))
+               return ret;
+
+       return 0;
+}
+
+static const struct gf100_gr_func
+gm200_gr = {
+       .init = gm200_gr_init,
+       .ppc_nr = 2,
+       .grctx = &gm200_grctx,
+       .sclass = {
+               { -1, -1, FERMI_TWOD_A },
+               { -1, -1, KEPLER_INLINE_TO_MEMORY_B },
+               { -1, -1, MAXWELL_B, &gf100_fermi },
+               { -1, -1, MAXWELL_COMPUTE_B },
+               {}
+       }
+};
+
+int
+gm200_gr_new(struct nvkm_device *device, int index, struct nvkm_gr **pgr)
+{
+       return gm200_gr_new_(&gm200_gr, device, index, pgr);
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c b/drivers/gpu/drm/nouveau/nvkm/engine/gr/gm204.c
deleted file mode 100644 (file)
index 90381dd..0000000
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * Copyright 2015 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: Ben Skeggs <bskeggs@redhat.com>
- */
-#include "gf100.h"
-#include "ctxgf100.h"
-
-#include <nvif/class.h>
-
-/*******************************************************************************
- * PGRAPH register lists
- ******************************************************************************/
-
-static const struct gf100_gr_init
-gm204_gr_init_main_0[] = {
-       { 0x400080,   1, 0x04, 0x003003e2 },
-       { 0x400088,   1, 0x04, 0xe007bfe7 },
-       { 0x40008c,   1, 0x04, 0x00060000 },
-       { 0x400090,   1, 0x04, 0x00000030 },
-       { 0x40013c,   1, 0x04, 0x003901f3 },
-       { 0x400140,   1, 0x04, 0x00000100 },
-       { 0x400144,   1, 0x04, 0x00000000 },
-       { 0x400148,   1, 0x04, 0x00000110 },
-       { 0x400138,   1, 0x04, 0x00000000 },
-       { 0x400130,   2, 0x04, 0x00000000 },
-       { 0x400124,   1, 0x04, 0x00000002 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_fe_0[] = {
-       { 0x40415c,   1, 0x04, 0x00000000 },
-       { 0x404170,   1, 0x04, 0x00000000 },
-       { 0x4041b4,   1, 0x04, 0x00000000 },
-       { 0x4041b8,   1, 0x04, 0x00000010 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_ds_0[] = {
-       { 0x40583c,   1, 0x04, 0x00000000 },
-       { 0x405844,   1, 0x04, 0x00ffffff },
-       { 0x40584c,   1, 0x04, 0x00000001 },
-       { 0x405850,   1, 0x04, 0x00000000 },
-       { 0x405900,   1, 0x04, 0x00000000 },
-       { 0x405908,   1, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_sked_0[] = {
-       { 0x407010,   1, 0x04, 0x00000000 },
-       { 0x407040,   1, 0x04, 0x80440434 },
-       { 0x407048,   1, 0x04, 0x00000008 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_tpccs_0[] = {
-       { 0x419d60,   1, 0x04, 0x0000003f },
-       { 0x419d88,   3, 0x04, 0x00000000 },
-       { 0x419dc4,   1, 0x04, 0x00000000 },
-       { 0x419dc8,   1, 0x04, 0x00000501 },
-       { 0x419dd0,   1, 0x04, 0x00000000 },
-       { 0x419dd4,   1, 0x04, 0x00000100 },
-       { 0x419dd8,   1, 0x04, 0x00000001 },
-       { 0x419ddc,   1, 0x04, 0x00000002 },
-       { 0x419de0,   1, 0x04, 0x00000001 },
-       { 0x419de8,   1, 0x04, 0x000000cc },
-       { 0x419dec,   1, 0x04, 0x00000000 },
-       { 0x419df0,   1, 0x04, 0x000000cc },
-       { 0x419df4,   1, 0x04, 0x00000000 },
-       { 0x419d0c,   1, 0x04, 0x00000000 },
-       { 0x419d10,   1, 0x04, 0x00000014 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_pe_0[] = {
-       { 0x419900,   1, 0x04, 0x000000ff },
-       { 0x419810,   1, 0x04, 0x00000000 },
-       { 0x41980c,   1, 0x04, 0x00000010 },
-       { 0x419844,   1, 0x04, 0x00000000 },
-       { 0x419838,   1, 0x04, 0x000000ff },
-       { 0x419850,   1, 0x04, 0x00000004 },
-       { 0x419854,   2, 0x04, 0x00000000 },
-       { 0x419894,   3, 0x04, 0x00100401 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_sm_0[] = {
-       { 0x419e30,   1, 0x04, 0x000000ff },
-       { 0x419e00,   1, 0x04, 0x00000000 },
-       { 0x419ea0,   1, 0x04, 0x00000000 },
-       { 0x419ee4,   1, 0x04, 0x00000000 },
-       { 0x419ea4,   1, 0x04, 0x00000100 },
-       { 0x419ea8,   1, 0x04, 0x00000000 },
-       { 0x419ee8,   1, 0x04, 0x00000091 },
-       { 0x419eb4,   1, 0x04, 0x00000000 },
-       { 0x419ebc,   2, 0x04, 0x00000000 },
-       { 0x419edc,   1, 0x04, 0x000c1810 },
-       { 0x419ed8,   1, 0x04, 0x00000000 },
-       { 0x419ee0,   1, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_l1c_1[] = {
-       { 0x419cf8,   2, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_sm_1[] = {
-       { 0x419f74,   1, 0x04, 0x00055155 },
-       { 0x419f80,   4, 0x04, 0x00000000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_l1c_2[] = {
-       { 0x419ccc,   2, 0x04, 0x00000000 },
-       { 0x419c80,   1, 0x04, 0x3f006022 },
-       { 0x419c88,   1, 0x04, 0x00210000 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_pes_0[] = {
-       { 0x41be50,   1, 0x04, 0x000000ff },
-       { 0x41be04,   1, 0x04, 0x00000000 },
-       { 0x41be08,   1, 0x04, 0x00000004 },
-       { 0x41be0c,   1, 0x04, 0x00000008 },
-       { 0x41be10,   1, 0x04, 0x2e3b8bc7 },
-       { 0x41be14,   2, 0x04, 0x00000000 },
-       { 0x41be3c,   5, 0x04, 0x00100401 },
-       {}
-};
-
-static const struct gf100_gr_init
-gm204_gr_init_be_0[] = {
-       { 0x408890,   1, 0x04, 0x000000ff },
-       { 0x40880c,   1, 0x04, 0x00000000 },
-       { 0x408850,   1, 0x04, 0x00000004 },
-       { 0x408878,   1, 0x04, 0x01b4201c },
-       { 0x40887c,   1, 0x04, 0x80004c55 },
-       { 0x408880,   1, 0x04, 0x0018c258 },
-       { 0x408884,   1, 0x04, 0x0000160f },
-       { 0x408974,   1, 0x04, 0x000000ff },
-       { 0x408910,   9, 0x04, 0x00000000 },
-       { 0x408950,   1, 0x04, 0x00000000 },
-       { 0x408954,   1, 0x04, 0x0000ffff },
-       { 0x408958,   1, 0x04, 0x00000034 },
-       { 0x40895c,   1, 0x04, 0x84b17403 },
-       { 0x408960,   1, 0x04, 0x04c1884f },
-       { 0x408964,   1, 0x04, 0x04714445 },
-       { 0x408968,   1, 0x04, 0x0280802f },
-       { 0x40896c,   1, 0x04, 0x04304856 },
-       { 0x408970,   1, 0x04, 0x00012800 },
-       { 0x408984,   1, 0x04, 0x00000000 },
-       { 0x408988,   1, 0x04, 0x08040201 },
-       { 0x40898c,   1, 0x04, 0x80402010 },
-       {}
-};
-
-const struct gf100_gr_pack
-gm204_gr_pack_mmio[] = {
-       { gm204_gr_init_main_0 },
-       { gm204_gr_init_fe_0 },
-       { gf100_gr_init_pri_0 },
-       { gf100_gr_init_rstr2d_0 },
-       { gf100_gr_init_pd_0 },
-       { gm204_gr_init_ds_0 },
-       { gm107_gr_init_scc_0 },
-       { gm204_gr_init_sked_0 },
-       { gk110_gr_init_cwd_0 },
-       { gm107_gr_init_prop_0 },
-       { gk208_gr_init_gpc_unk_0 },
-       { gf100_gr_init_setup_0 },
-       { gf100_gr_init_crstr_0 },
-       { gm107_gr_init_setup_1 },
-       { gm107_gr_init_zcull_0 },
-       { gf100_gr_init_gpm_0 },
-       { gm107_gr_init_gpc_unk_1 },
-       { gf100_gr_init_gcc_0 },
-       { gm204_gr_init_tpccs_0 },
-       { gm107_gr_init_tex_0 },
-       { gm204_gr_init_pe_0 },
-       { gm107_gr_init_l1c_0 },
-       { gf100_gr_init_mpc_0 },
-       { gm204_gr_init_sm_0 },
-       { gm204_gr_init_l1c_1 },
-       { gm204_gr_init_sm_1 },
-       { gm204_gr_init_l1c_2 },
-       { gm204_gr_init_pes_0 },
-       { gm107_gr_init_wwdx_0 },
-       { gm107_gr_init_cbm_0 },
-       { gm204_gr_init_be_0 },
-       {}
-};
-
-const struct gf100_gr_pack *
-gm204_gr_data[] = {
-       gm204_gr_pack_mmio,
-       NULL
-};
-
-/*******************************************************************************
- * PGRAPH engine/subdev functions
- ******************************************************************************/
-
-static int
-gm204_gr_init_ctxctl(struct gf100_gr *gr)
-{
-       return 0;
-}
-
-int
-gm204_gr_init(struct gf100_gr *gr)
-{
-       struct nvkm_device *device = gr->base.engine.subdev.device;
-       const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, gr->tpc_total);
-       u32 data[TPC_MAX / 8] = {}, tmp;
-       u8  tpcnr[GPC_MAX];
-       int gpc, tpc, ppc, rop;
-       int i;
-
-       tmp = nvkm_rd32(device, 0x100c80); /*XXX: mask? */
-       nvkm_wr32(device, 0x418880, 0x00001000 | (tmp & 0x00000fff));
-       nvkm_wr32(device, 0x418890, 0x00000000);
-       nvkm_wr32(device, 0x418894, 0x00000000);
-       nvkm_wr32(device, 0x4188b4, nvkm_memory_addr(gr->unk4188b4) >> 8);
-       nvkm_wr32(device, 0x4188b8, nvkm_memory_addr(gr->unk4188b8) >> 8);
-       nvkm_mask(device, 0x4188b0, 0x00040000, 0x00040000);
-
-       /*XXX: belongs in fb */
-       nvkm_wr32(device, 0x100cc8, nvkm_memory_addr(gr->unk4188b4) >> 8);
-       nvkm_wr32(device, 0x100ccc, nvkm_memory_addr(gr->unk4188b8) >> 8);
-       nvkm_mask(device, 0x100cc4, 0x00040000, 0x00040000);
-
-       gf100_gr_mmio(gr, gr->func->mmio);
-
-       gm107_gr_init_bios(gr);
-
-       nvkm_wr32(device, GPC_UNIT(0, 0x3018), 0x00000001);
-
-       memset(data, 0x00, sizeof(data));
-       memcpy(tpcnr, gr->tpc_nr, sizeof(gr->tpc_nr));
-       for (i = 0, gpc = -1; i < gr->tpc_total; i++) {
-               do {
-                       gpc = (gpc + 1) % gr->gpc_nr;
-               } while (!tpcnr[gpc]);
-               tpc = gr->tpc_nr[gpc] - tpcnr[gpc]--;
-
-               data[i / 8] |= tpc << ((i % 8) * 4);
-       }
-
-       nvkm_wr32(device, GPC_BCAST(0x0980), data[0]);
-       nvkm_wr32(device, GPC_BCAST(0x0984), data[1]);
-       nvkm_wr32(device, GPC_BCAST(0x0988), data[2]);
-       nvkm_wr32(device, GPC_BCAST(0x098c), data[3]);
-
-       for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
-               nvkm_wr32(device, GPC_UNIT(gpc, 0x0914),
-                       gr->magic_not_rop_nr << 8 | gr->tpc_nr[gpc]);
-               nvkm_wr32(device, GPC_UNIT(gpc, 0x0910), 0x00040000 |
-                       gr->tpc_total);
-               nvkm_wr32(device, GPC_UNIT(gpc, 0x0918), magicgpc918);
-       }
-
-       nvkm_wr32(device, GPC_BCAST(0x3fd4), magicgpc918);
-       nvkm_wr32(device, GPC_BCAST(0x08ac), nvkm_rd32(device, 0x100800));
-       nvkm_wr32(device, GPC_BCAST(0x033c), nvkm_rd32(device, 0x100804));
-
-       nvkm_wr32(device, 0x400500, 0x00010001);
-       nvkm_wr32(device, 0x400100, 0xffffffff);
-       nvkm_wr32(device, 0x40013c, 0xffffffff);
-       nvkm_wr32(device, 0x400124, 0x00000002);
-       nvkm_wr32(device, 0x409c24, 0x000e0000);
-       nvkm_wr32(device, 0x405848, 0xc0000000);
-       nvkm_wr32(device, 0x40584c, 0x00000001);
-       nvkm_wr32(device, 0x404000, 0xc0000000);
-       nvkm_wr32(device, 0x404600, 0xc0000000);
-       nvkm_wr32(device, 0x408030, 0xc0000000);
-       nvkm_wr32(device, 0x404490, 0xc0000000);
-       nvkm_wr32(device, 0x406018, 0xc0000000);
-       nvkm_wr32(device, 0x407020, 0x40000000);
-       nvkm_wr32(device, 0x405840, 0xc0000000);
-       nvkm_wr32(device, 0x405844, 0x00ffffff);
-       nvkm_mask(device, 0x419cc0, 0x00000008, 0x00000008);
-
-       for (gpc = 0; gpc < gr->gpc_nr; gpc++) {
-               for (ppc = 0; ppc < gr->ppc_nr[gpc]; ppc++)
-                       nvkm_wr32(device, PPC_UNIT(gpc, ppc, 0x038), 0xc0000000);
-               nvkm_wr32(device, GPC_UNIT(gpc, 0x0420), 0xc0000000);
-               nvkm_wr32(device, GPC_UNIT(gpc, 0x0900), 0xc0000000);
-               nvkm_wr32(device, GPC_UNIT(gpc, 0x1028), 0xc0000000);
-               nvkm_wr32(device, GPC_UNIT(gpc, 0x0824), 0xc0000000);
-               for (tpc = 0; tpc < gr->tpc_nr[gpc]; tpc++) {
-                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x508), 0xffffffff);
-                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x50c), 0xffffffff);
-                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x224), 0xc0000000);
-                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x48c), 0xc0000000);
-                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x084), 0xc0000000);
-                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x430), 0xc0000000);
-                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x644), 0x00dffffe);
-                       nvkm_wr32(device, TPC_UNIT(gpc, tpc, 0x64c), 0x00000005);
-               }
-               nvkm_wr32(device, GPC_UNIT(gpc, 0x2c90), 0xffffffff);
-               nvkm_wr32(device, GPC_UNIT(gpc, 0x2c94), 0xffffffff);
-       }
-
-       for (rop = 0; rop < gr->rop_nr; rop++) {
-               nvkm_wr32(device, ROP_UNIT(rop, 0x144), 0x40000000);
-               nvkm_wr32(device, ROP_UNIT(rop, 0x070), 0x40000000);
-               nvkm_wr32(device, ROP_UNIT(rop, 0x204), 0xffffffff);
-               nvkm_wr32(device, ROP_UNIT(rop, 0x208), 0xffffffff);
-       }
-
-       nvkm_wr32(device, 0x400108, 0xffffffff);
-       nvkm_wr32(device, 0x400138, 0xffffffff);
-       nvkm_wr32(device, 0x400118, 0xffffffff);
-       nvkm_wr32(device, 0x400130, 0xffffffff);
-       nvkm_wr32(device, 0x40011c, 0xffffffff);
-       nvkm_wr32(device, 0x400134, 0xffffffff);
-
-       nvkm_wr32(device, 0x400054, 0x2c350f63);
-
-       gf100_gr_zbc_init(gr);
-
-       return gm204_gr_init_ctxctl(gr);
-}
-
-static const struct gf100_gr_func
-gm204_gr = {
-       .init = gm204_gr_init,
-       .mmio = gm204_gr_pack_mmio,
-       .ppc_nr = 2,
-       .grctx = &gm204_grctx,
-       .sclass = {
-               { -1, -1, FERMI_TWOD_A },
-               { -1, -1, KEPLER_INLINE_TO_MEMORY_B },
-               { -1, -1, MAXWELL_B, &gf100_fermi },
-               { -1, -1, MAXWELL_COMPUTE_B },
-               {}
-       }
-};
-
-int
-gm204_gr_new(struct nvkm_device *device, int index, struct nvkm_gr **pgr)
-{
-       return gf100_gr_new_(&gm204_gr, device, index, pgr);
-}
index 65b6e3d..29732bc 100644 (file)
@@ -32,12 +32,15 @@ gm20b_gr_init_gpc_mmu(struct gf100_gr *gr)
        struct nvkm_device *device = gr->base.engine.subdev.device;
        u32 val;
 
-       /* TODO this needs to be removed once secure boot works */
-       if (1) {
+       /* Bypass MMU check for non-secure boot */
+       if (!device->secboot) {
                nvkm_wr32(device, 0x100ce4, 0xffffffff);
+
+               if (nvkm_rd32(device, 0x100ce4) != 0xffffffff)
+                       nvdev_warn(device,
+                         "cannot bypass secure boot - expect failure soon!\n");
        }
 
-       /* TODO update once secure boot works */
        val = nvkm_rd32(device, 0x100c80);
        val &= 0xf000087f;
        nvkm_wr32(device, 0x418880, val);
@@ -61,7 +64,6 @@ gm20b_gr_set_hww_esr_report_mask(struct gf100_gr *gr)
 
 static const struct gf100_gr_func
 gm20b_gr = {
-       .dtor = gk20a_gr_dtor,
        .init = gk20a_gr_init,
        .init_gpc_mmu = gm20b_gr_init_gpc_mmu,
        .set_hww_esr_report_mask = gm20b_gr_set_hww_esr_report_mask,
@@ -79,5 +81,5 @@ gm20b_gr = {
 int
 gm20b_gr_new(struct nvkm_device *device, int index, struct nvkm_gr **pgr)
 {
-       return gk20a_gr_new_(&gm20b_gr, device, index, pgr);
+       return gm200_gr_new_(&gm20b_gr, device, index, pgr);
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/msenc/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/msenc/Kbuild
new file mode 100644 (file)
index 0000000..b511956
--- /dev/null
@@ -0,0 +1 @@
+#nvkm-y += nvkm/engine/msenc/base.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/nvdec/Kbuild
new file mode 100644 (file)
index 0000000..13b7c71
--- /dev/null
@@ -0,0 +1 @@
+#nvkm-y += nvkm/engine/nvdec/base.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/nvenc/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/nvenc/Kbuild
new file mode 100644 (file)
index 0000000..ad8f182
--- /dev/null
@@ -0,0 +1 @@
+#nvkm-y += nvkm/engine/nvenc/base.o
index 4bef72a..3fda594 100644 (file)
@@ -59,9 +59,11 @@ static void
 nv40_perfctr_next(struct nvkm_pm *pm, struct nvkm_perfdom *dom)
 {
        struct nvkm_device *device = pm->engine.subdev.device;
-       if (pm->sequence != pm->sequence) {
+       struct nv40_pm *nv40pm = container_of(pm, struct nv40_pm, base);
+
+       if (nv40pm->sequence != pm->sequence) {
                nvkm_wr32(device, 0x400084, 0x00000020);
-               pm->sequence = pm->sequence;
+               nv40pm->sequence = pm->sequence;
        }
 }
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/vic/Kbuild b/drivers/gpu/drm/nouveau/nvkm/engine/vic/Kbuild
new file mode 100644 (file)
index 0000000..ed4fb64
--- /dev/null
@@ -0,0 +1 @@
+#nvkm-y += nvkm/engine/vic/base.o
index ee2c38f..642d27d 100644 (file)
@@ -8,6 +8,7 @@ include $(src)/nvkm/subdev/fuse/Kbuild
 include $(src)/nvkm/subdev/gpio/Kbuild
 include $(src)/nvkm/subdev/i2c/Kbuild
 include $(src)/nvkm/subdev/ibus/Kbuild
+include $(src)/nvkm/subdev/iccsense/Kbuild
 include $(src)/nvkm/subdev/instmem/Kbuild
 include $(src)/nvkm/subdev/ltc/Kbuild
 include $(src)/nvkm/subdev/mc/Kbuild
@@ -15,6 +16,7 @@ include $(src)/nvkm/subdev/mmu/Kbuild
 include $(src)/nvkm/subdev/mxm/Kbuild
 include $(src)/nvkm/subdev/pci/Kbuild
 include $(src)/nvkm/subdev/pmu/Kbuild
+include $(src)/nvkm/subdev/secboot/Kbuild
 include $(src)/nvkm/subdev/therm/Kbuild
 include $(src)/nvkm/subdev/timer/Kbuild
 include $(src)/nvkm/subdev/volt/Kbuild
index 64730d5..dbcb0ef 100644 (file)
@@ -10,6 +10,7 @@ nvkm-y += nvkm/subdev/bios/extdev.o
 nvkm-y += nvkm/subdev/bios/fan.o
 nvkm-y += nvkm/subdev/bios/gpio.o
 nvkm-y += nvkm/subdev/bios/i2c.o
+nvkm-y += nvkm/subdev/bios/iccsense.o
 nvkm-y += nvkm/subdev/bios/image.o
 nvkm-y += nvkm/subdev/bios/init.o
 nvkm-y += nvkm/subdev/bios/mxm.o
index c9e6f6f..b857835 100644 (file)
@@ -32,7 +32,7 @@ extdev_table(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *len, u8 *cnt)
        u16 dcb, extdev = 0;
 
        dcb = dcb_table(bios, &dcb_ver, &dcb_hdr, &dcb_cnt, &dcb_len);
-       if (!dcb || (dcb_ver != 0x30 && dcb_ver != 0x40))
+       if (!dcb || (dcb_ver != 0x30 && dcb_ver != 0x40 && dcb_ver != 0x41))
                return 0x0000;
 
        extdev = nvbios_rd16(bios, dcb + 18);
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c
new file mode 100644 (file)
index 0000000..0843280
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2015 Martin Peres
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Martin Peres
+ */
+#include <subdev/bios.h>
+#include <subdev/bios/bit.h>
+#include <subdev/bios/iccsense.h>
+
+static u16
+nvbios_iccsense_table(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *cnt,
+                     u8 *len)
+{
+       struct bit_entry bit_P;
+       u16 iccsense;
+
+       if (bit_entry(bios, 'P', &bit_P) || bit_P.version != 2 ||
+           bit_P.length < 0x2c)
+               return 0;
+
+       iccsense = nvbios_rd16(bios, bit_P.offset + 0x28);
+       if (!iccsense)
+               return 0;
+
+       *ver = nvbios_rd08(bios, iccsense + 0);
+       switch (*ver) {
+       case 0x10:
+       case 0x20:
+               *hdr = nvbios_rd08(bios, iccsense + 1);
+               *len = nvbios_rd08(bios, iccsense + 2);
+               *cnt = nvbios_rd08(bios, iccsense + 3);
+               return iccsense;
+       default:
+               break;
+       }
+
+       return 0;
+}
+
+int
+nvbios_iccsense_parse(struct nvkm_bios *bios, struct nvbios_iccsense *iccsense)
+{
+       struct nvkm_subdev *subdev = &bios->subdev;
+       u8 ver, hdr, cnt, len, i;
+       u16 table, entry;
+
+       table = nvbios_iccsense_table(bios, &ver, &hdr, &cnt, &len);
+       if (!table || !cnt)
+               return -EINVAL;
+
+       if (ver != 0x10 && ver != 0x20) {
+               nvkm_error(subdev, "ICCSENSE version 0x%02x unknown\n", ver);
+               return -EINVAL;
+       }
+
+       iccsense->nr_entry = cnt;
+       iccsense->rail = kmalloc(sizeof(struct pwr_rail_t) * cnt, GFP_KERNEL);
+       if (!iccsense->rail)
+               return -ENOMEM;
+
+       for (i = 0; i < cnt; ++i) {
+               struct pwr_rail_t *rail = &iccsense->rail[i];
+               entry = table + hdr + i * len;
+
+               switch(ver) {
+               case 0x10:
+                       rail->mode = nvbios_rd08(bios, entry + 0x1);
+                       rail->extdev_id = nvbios_rd08(bios, entry + 0x2);
+                       rail->resistor_mohm = nvbios_rd08(bios, entry + 0x3);
+                       rail->rail = nvbios_rd08(bios, entry + 0x4);
+                       break;
+               case 0x20:
+                       rail->mode = nvbios_rd08(bios, entry);
+                       rail->extdev_id = nvbios_rd08(bios, entry + 0x1);
+                       rail->resistor_mohm = nvbios_rd08(bios, entry + 0x5);
+                       rail->rail = nvbios_rd08(bios, entry + 0x6);
+                       break;
+               };
+       }
+
+       return 0;
+}
index a7d69ce..38ed09f 100644 (file)
@@ -786,20 +786,20 @@ init_io_flag_condition(struct nvbios_init *init)
 }
 
 /**
- * INIT_DP_CONDITION - opcode 0x3a
+ * INIT_GENERIC_CONDITION - opcode 0x3a
  *
  */
 static void
-init_dp_condition(struct nvbios_init *init)
+init_generic_condition(struct nvbios_init *init)
 {
        struct nvkm_bios *bios = init->bios;
        struct nvbios_dpout info;
        u8  cond = nvbios_rd08(bios, init->offset + 1);
-       u8  unkn = nvbios_rd08(bios, init->offset + 2);
+       u8  size = nvbios_rd08(bios, init->offset + 2);
        u8  ver, hdr, cnt, len;
        u16 data;
 
-       trace("DP_CONDITION\t0x%02x 0x%02x\n", cond, unkn);
+       trace("GENERIC_CONDITION\t0x%02x 0x%02x\n", cond, size);
        init->offset += 3;
 
        switch (cond) {
@@ -828,7 +828,8 @@ init_dp_condition(struct nvbios_init *init)
                        init_exec_set(init, false);
                break;
        default:
-               warn("unknown dp condition 0x%02x\n", cond);
+               warn("INIT_GENERIC_CONDITON: unknown 0x%02x\n", cond);
+               init->offset += size;
                break;
        }
 }
@@ -2205,7 +2206,7 @@ static struct nvbios_init_opcode {
        [0x37] = { init_copy },
        [0x38] = { init_not },
        [0x39] = { init_io_flag_condition },
-       [0x3a] = { init_dp_condition },
+       [0x3a] = { init_generic_condition },
        [0x3b] = { init_io_mask_or },
        [0x3c] = { init_io_or },
        [0x47] = { init_andn_reg },
index ed7717b..87d9488 100644 (file)
@@ -8,6 +8,7 @@ nvkm-y += nvkm/subdev/clk/mcp77.o
 nvkm-y += nvkm/subdev/clk/gf100.o
 nvkm-y += nvkm/subdev/clk/gk104.o
 nvkm-y += nvkm/subdev/clk/gk20a.o
+nvkm-y += nvkm/subdev/clk/gm20b.o
 
 nvkm-y += nvkm/subdev/clk/pllnv04.o
 nvkm-y += nvkm/subdev/clk/pllgt215.o
index 5da2aa8..5f0ee24 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * Shamelessly ripped off from ChromeOS's gk20a/clk_pllg.c
  *
  */
-#define gk20a_clk(p) container_of((p), struct gk20a_clk, base)
 #include "priv.h"
+#include "gk20a.h"
 
 #include <core/tegra.h>
 #include <subdev/timer.h>
 
-#define MHZ (1000 * 1000)
+#define KHZ (1000)
+#define MHZ (KHZ * 1000)
 
 #define MASK(w)        ((1 << w) - 1)
 
-#define SYS_GPCPLL_CFG_BASE                    0x00137000
-#define GPC_BCASE_GPCPLL_CFG_BASE              0x00132800
-
 #define GPCPLL_CFG             (SYS_GPCPLL_CFG_BASE + 0)
 #define GPCPLL_CFG_ENABLE      BIT(0)
 #define GPCPLL_CFG_IDDQ                BIT(1)
@@ -56,6 +54,7 @@
 #define GPCPLL_CFG3                    (SYS_GPCPLL_CFG_BASE + 0x18)
 #define GPCPLL_CFG3_PLL_STEPB_SHIFT    16
 
+#define GPC_BCASE_GPCPLL_CFG_BASE              0x00132800
 #define GPCPLL_NDIV_SLOWDOWN                   (SYS_GPCPLL_CFG_BASE + 0x1c)
 #define GPCPLL_NDIV_SLOWDOWN_NDIV_LO_SHIFT     0
 #define GPCPLL_NDIV_SLOWDOWN_NDIV_MID_SHIFT    8
@@ -75,7 +74,7 @@
 #define GPC2CLK_OUT_VCODIV1            0
 #define GPC2CLK_OUT_VCODIV_MASK                (MASK(GPC2CLK_OUT_VCODIV_WIDTH) << \
                                        GPC2CLK_OUT_VCODIV_SHIFT)
-#define        GPC2CLK_OUT_BYPDIV_WIDTH        6
+#define GPC2CLK_OUT_BYPDIV_WIDTH       6
 #define GPC2CLK_OUT_BYPDIV_SHIFT       0
 #define GPC2CLK_OUT_BYPDIV31           0x3c
 #define GPC2CLK_OUT_INIT_MASK  ((MASK(GPC2CLK_OUT_SDIV14_INDIV4_WIDTH) << \
 #define GPC_BCAST_NDIV_SLOWDOWN_DEBUG_PLL_DYNRAMP_DONE_SYNCED_MASK \
            (0x1 << GPC_BCAST_NDIV_SLOWDOWN_DEBUG_PLL_DYNRAMP_DONE_SYNCED_SHIFT)
 
-static const u8 pl_to_div[] = {
+static const u8 _pl_to_div[] = {
 /* PL:   0, 1, 2, 3, 4, 5, 6,  7,  8,  9, 10, 11, 12, 13, 14 */
 /* p: */ 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 12, 16, 20, 24, 32,
 };
 
-/* All frequencies in Mhz */
-struct gk20a_clk_pllg_params {
-       u32 min_vco, max_vco;
-       u32 min_u, max_u;
-       u32 min_m, max_m;
-       u32 min_n, max_n;
-       u32 min_pl, max_pl;
-};
+static u32 pl_to_div(u32 pl)
+{
+       if (pl >= ARRAY_SIZE(_pl_to_div))
+               return 1;
+
+       return _pl_to_div[pl];
+}
+
+static u32 div_to_pl(u32 div)
+{
+       u32 pl;
+
+       for (pl = 0; pl < ARRAY_SIZE(_pl_to_div) - 1; pl++) {
+               if (_pl_to_div[pl] >= div)
+                       return pl;
+       }
+
+       return ARRAY_SIZE(_pl_to_div) - 1;
+}
 
 static const struct gk20a_clk_pllg_params gk20a_pllg_params = {
-       .min_vco = 1000, .max_vco = 2064,
-       .min_u = 12, .max_u = 38,
+       .min_vco = 1000000, .max_vco = 2064000,
+       .min_u = 12000, .max_u = 38000,
        .min_m = 1, .max_m = 255,
        .min_n = 8, .max_n = 255,
        .min_pl = 1, .max_pl = 32,
 };
 
-struct gk20a_clk {
-       struct nvkm_clk base;
-       const struct gk20a_clk_pllg_params *params;
-       u32 m, n, pl;
-       u32 parent_rate;
-};
-
 static void
-gk20a_pllg_read_mnp(struct gk20a_clk *clk)
+gk20a_pllg_read_mnp(struct gk20a_clk *clk, struct gk20a_pll *pll)
 {
        struct nvkm_device *device = clk->base.subdev.device;
        u32 val;
 
        val = nvkm_rd32(device, GPCPLL_COEFF);
-       clk->m = (val >> GPCPLL_COEFF_M_SHIFT) & MASK(GPCPLL_COEFF_M_WIDTH);
-       clk->n = (val >> GPCPLL_COEFF_N_SHIFT) & MASK(GPCPLL_COEFF_N_WIDTH);
-       clk->pl = (val >> GPCPLL_COEFF_P_SHIFT) & MASK(GPCPLL_COEFF_P_WIDTH);
+       pll->m = (val >> GPCPLL_COEFF_M_SHIFT) & MASK(GPCPLL_COEFF_M_WIDTH);
+       pll->n = (val >> GPCPLL_COEFF_N_SHIFT) & MASK(GPCPLL_COEFF_N_WIDTH);
+       pll->pl = (val >> GPCPLL_COEFF_P_SHIFT) & MASK(GPCPLL_COEFF_P_WIDTH);
 }
 
 static u32
@@ -139,8 +142,8 @@ gk20a_pllg_calc_rate(struct gk20a_clk *clk)
        u32 rate;
        u32 divider;
 
-       rate = clk->parent_rate * clk->n;
-       divider = clk->m * pl_to_div[clk->pl];
+       rate = clk->parent_rate * clk->pll.n;
+       divider = clk->pll.m * clk->pl_to_div(clk->pll.pl);
 
        return rate / divider / 2;
 }
@@ -152,15 +155,13 @@ gk20a_pllg_calc_mnp(struct gk20a_clk *clk, unsigned long rate)
        u32 target_clk_f, ref_clk_f, target_freq;
        u32 min_vco_f, max_vco_f;
        u32 low_pl, high_pl, best_pl;
-       u32 target_vco_f, vco_f;
+       u32 target_vco_f;
        u32 best_m, best_n;
-       u32 u_f;
-       u32 m, n, n2;
-       u32 delta, lwv, best_delta = ~0;
+       u32 best_delta = ~0;
        u32 pl;
 
-       target_clk_f = rate * 2 / MHZ;
-       ref_clk_f = clk->parent_rate / MHZ;
+       target_clk_f = rate * 2 / KHZ;
+       ref_clk_f = clk->parent_rate / KHZ;
 
        max_vco_f = clk->params->max_vco;
        min_vco_f = clk->params->min_vco;
@@ -176,33 +177,26 @@ gk20a_pllg_calc_mnp(struct gk20a_clk *clk, unsigned long rate)
        high_pl = (max_vco_f + target_vco_f - 1) / target_vco_f;
        high_pl = min(high_pl, clk->params->max_pl);
        high_pl = max(high_pl, clk->params->min_pl);
+       high_pl = clk->div_to_pl(high_pl);
 
        /* min_pl <= low_pl <= max_pl */
        low_pl = min_vco_f / target_vco_f;
        low_pl = min(low_pl, clk->params->max_pl);
        low_pl = max(low_pl, clk->params->min_pl);
-
-       /* Find Indices of high_pl and low_pl */
-       for (pl = 0; pl < ARRAY_SIZE(pl_to_div) - 1; pl++) {
-               if (pl_to_div[pl] >= low_pl) {
-                       low_pl = pl;
-                       break;
-               }
-       }
-       for (pl = 0; pl < ARRAY_SIZE(pl_to_div) - 1; pl++) {
-               if (pl_to_div[pl] >= high_pl) {
-                       high_pl = pl;
-                       break;
-               }
-       }
+       low_pl = clk->div_to_pl(low_pl);
 
        nvkm_debug(subdev, "low_PL %d(div%d), high_PL %d(div%d)", low_pl,
-                  pl_to_div[low_pl], high_pl, pl_to_div[high_pl]);
+                  clk->pl_to_div(low_pl), high_pl, clk->pl_to_div(high_pl));
 
        /* Select lowest possible VCO */
        for (pl = low_pl; pl <= high_pl; pl++) {
-               target_vco_f = target_clk_f * pl_to_div[pl];
+               u32 m, n, n2;
+
+               target_vco_f = target_clk_f * clk->pl_to_div(pl);
+
                for (m = clk->params->min_m; m <= clk->params->max_m; m++) {
+                       u32 u_f, vco_f;
+
                        u_f = ref_clk_f / m;
 
                        if (u_f < clk->params->min_u)
@@ -225,8 +219,10 @@ gk20a_pllg_calc_mnp(struct gk20a_clk *clk, unsigned long rate)
                                vco_f = ref_clk_f * n / m;
 
                                if (vco_f >= min_vco_f && vco_f <= max_vco_f) {
-                                       lwv = (vco_f + (pl_to_div[pl] / 2))
-                                               / pl_to_div[pl];
+                                       u32 delta, lwv;
+
+                                       lwv = (vco_f + (clk->pl_to_div(pl) / 2))
+                                               / clk->pl_to_div(pl);
                                        delta = abs(lwv - target_clk_f);
 
                                        if (delta < best_delta) {
@@ -249,17 +245,18 @@ found_match:
        if (best_delta != 0)
                nvkm_debug(subdev,
                           "no best match for target @ %dMHz on gpc_pll",
-                          target_clk_f);
+                          target_clk_f / KHZ);
 
-       clk->m = best_m;
-       clk->n = best_n;
-       clk->pl = best_pl;
+       clk->pll.m = best_m;
+       clk->pll.n = best_n;
+       clk->pll.pl = best_pl;
 
-       target_freq = gk20a_pllg_calc_rate(clk) / MHZ;
+       target_freq = gk20a_pllg_calc_rate(clk);
 
        nvkm_debug(subdev,
                   "actual target freq %d MHz, M %d, N %d, PL %d(div%d)\n",
-                  target_freq, clk->m, clk->n, clk->pl, pl_to_div[clk->pl]);
+                  target_freq / MHZ, clk->pll.m, clk->pll.n, clk->pll.pl,
+                  clk->pl_to_div(clk->pll.pl));
        return 0;
 }
 
@@ -323,17 +320,19 @@ gk20a_pllg_slide(struct gk20a_clk *clk, u32 n)
 }
 
 static void
-_gk20a_pllg_enable(struct gk20a_clk *clk)
+gk20a_pllg_enable(struct gk20a_clk *clk)
 {
        struct nvkm_device *device = clk->base.subdev.device;
+
        nvkm_mask(device, GPCPLL_CFG, GPCPLL_CFG_ENABLE, GPCPLL_CFG_ENABLE);
        nvkm_rd32(device, GPCPLL_CFG);
 }
 
 static void
-_gk20a_pllg_disable(struct gk20a_clk *clk)
+gk20a_pllg_disable(struct gk20a_clk *clk)
 {
        struct nvkm_device *device = clk->base.subdev.device;
+
        nvkm_mask(device, GPCPLL_CFG, GPCPLL_CFG_ENABLE, 0);
        nvkm_rd32(device, GPCPLL_CFG);
 }
@@ -344,25 +343,26 @@ _gk20a_pllg_program_mnp(struct gk20a_clk *clk, bool allow_slide)
        struct nvkm_subdev *subdev = &clk->base.subdev;
        struct nvkm_device *device = subdev->device;
        u32 val, cfg;
-       u32 m_old, pl_old, n_lo;
+       struct gk20a_pll old_pll;
+       u32 n_lo;
 
        /* get old coefficients */
-       val = nvkm_rd32(device, GPCPLL_COEFF);
-       m_old = (val >> GPCPLL_COEFF_M_SHIFT) & MASK(GPCPLL_COEFF_M_WIDTH);
-       pl_old = (val >> GPCPLL_COEFF_P_SHIFT) & MASK(GPCPLL_COEFF_P_WIDTH);
+       gk20a_pllg_read_mnp(clk, &old_pll);
 
        /* do NDIV slide if there is no change in M and PL */
        cfg = nvkm_rd32(device, GPCPLL_CFG);
-       if (allow_slide && clk->m == m_old && clk->pl == pl_old &&
-           (cfg & GPCPLL_CFG_ENABLE)) {
-               return gk20a_pllg_slide(clk, clk->n);
+       if (allow_slide && clk->pll.m == old_pll.m &&
+           clk->pll.pl == old_pll.pl && (cfg & GPCPLL_CFG_ENABLE)) {
+               return gk20a_pllg_slide(clk, clk->pll.n);
        }
 
        /* slide down to NDIV_LO */
-       n_lo = DIV_ROUND_UP(m_old * clk->params->min_vco,
-                           clk->parent_rate / MHZ);
        if (allow_slide && (cfg & GPCPLL_CFG_ENABLE)) {
-               int ret = gk20a_pllg_slide(clk, n_lo);
+               int ret;
+
+               n_lo = DIV_ROUND_UP(old_pll.m * clk->params->min_vco,
+                                   clk->parent_rate / KHZ);
+               ret = gk20a_pllg_slide(clk, n_lo);
 
                if (ret)
                        return ret;
@@ -387,19 +387,19 @@ _gk20a_pllg_program_mnp(struct gk20a_clk *clk, bool allow_slide)
                udelay(2);
        }
 
-       _gk20a_pllg_disable(clk);
+       gk20a_pllg_disable(clk);
 
        nvkm_debug(subdev, "%s: m=%d n=%d pl=%d\n", __func__,
-                  clk->m, clk->n, clk->pl);
+                  clk->pll.m, clk->pll.n, clk->pll.pl);
 
-       n_lo = DIV_ROUND_UP(clk->m * clk->params->min_vco,
-                           clk->parent_rate / MHZ);
-       val = clk->m << GPCPLL_COEFF_M_SHIFT;
-       val |= (allow_slide ? n_lo : clk->n) << GPCPLL_COEFF_N_SHIFT;
-       val |= clk->pl << GPCPLL_COEFF_P_SHIFT;
+       n_lo = DIV_ROUND_UP(clk->pll.m * clk->params->min_vco,
+                           clk->parent_rate / KHZ);
+       val = clk->pll.m << GPCPLL_COEFF_M_SHIFT;
+       val |= (allow_slide ? n_lo : clk->pll.n) << GPCPLL_COEFF_N_SHIFT;
+       val |= clk->pll.pl << GPCPLL_COEFF_P_SHIFT;
        nvkm_wr32(device, GPCPLL_COEFF, val);
 
-       _gk20a_pllg_enable(clk);
+       gk20a_pllg_enable(clk);
 
        val = nvkm_rd32(device, GPCPLL_CFG);
        if (val & GPCPLL_CFG_LOCK_DET_OFF) {
@@ -414,16 +414,24 @@ _gk20a_pllg_program_mnp(struct gk20a_clk *clk, bool allow_slide)
                return -ETIMEDOUT;
 
        /* switch to VCO mode */
-       nvkm_mask(device, SEL_VCO, 0, BIT(SEL_VCO_GPC2CLK_OUT_SHIFT));
+       nvkm_mask(device, SEL_VCO, BIT(SEL_VCO_GPC2CLK_OUT_SHIFT),
+                 BIT(SEL_VCO_GPC2CLK_OUT_SHIFT));
 
        /* restore out divider 1:1 */
        val = nvkm_rd32(device, GPC2CLK_OUT);
-       val &= ~GPC2CLK_OUT_VCODIV_MASK;
-       udelay(2);
-       nvkm_wr32(device, GPC2CLK_OUT, val);
+       if ((val & GPC2CLK_OUT_VCODIV_MASK) !=
+           (GPC2CLK_OUT_VCODIV1 << GPC2CLK_OUT_VCODIV_SHIFT)) {
+               val &= ~GPC2CLK_OUT_VCODIV_MASK;
+               val |= GPC2CLK_OUT_VCODIV1 << GPC2CLK_OUT_VCODIV_SHIFT;
+               udelay(2);
+               nvkm_wr32(device, GPC2CLK_OUT, val);
+               /* Intentional 2nd write to assure linear divider operation */
+               nvkm_wr32(device, GPC2CLK_OUT, val);
+               nvkm_rd32(device, GPC2CLK_OUT);
+       }
 
        /* slide up to new NDIV */
-       return allow_slide ? gk20a_pllg_slide(clk, clk->n) : 0;
+       return allow_slide ? gk20a_pllg_slide(clk, clk->pll.n) : 0;
 }
 
 static int
@@ -438,32 +446,6 @@ gk20a_pllg_program_mnp(struct gk20a_clk *clk)
        return err;
 }
 
-static void
-gk20a_pllg_disable(struct gk20a_clk *clk)
-{
-       struct nvkm_device *device = clk->base.subdev.device;
-       u32 val;
-
-       /* slide to VCO min */
-       val = nvkm_rd32(device, GPCPLL_CFG);
-       if (val & GPCPLL_CFG_ENABLE) {
-               u32 coeff, m, n_lo;
-
-               coeff = nvkm_rd32(device, GPCPLL_COEFF);
-               m = (coeff >> GPCPLL_COEFF_M_SHIFT) & MASK(GPCPLL_COEFF_M_WIDTH);
-               n_lo = DIV_ROUND_UP(m * clk->params->min_vco,
-                                   clk->parent_rate / MHZ);
-               gk20a_pllg_slide(clk, n_lo);
-       }
-
-       /* put PLL in bypass before disabling it */
-       nvkm_mask(device, SEL_VCO, BIT(SEL_VCO_GPC2CLK_OUT_SHIFT), 0);
-
-       _gk20a_pllg_disable(clk);
-}
-
-#define GK20A_CLK_GPC_MDIV 1000
-
 static struct nvkm_pstate
 gk20a_pstates[] = {
        {
@@ -558,7 +540,7 @@ gk20a_pstates[] = {
        },
 };
 
-static int
+int
 gk20a_clk_read(struct nvkm_clk *base, enum nv_clk_src src)
 {
        struct gk20a_clk *clk = gk20a_clk(base);
@@ -569,7 +551,7 @@ gk20a_clk_read(struct nvkm_clk *base, enum nv_clk_src src)
        case nv_clk_src_crystal:
                return device->crystal;
        case nv_clk_src_gpc:
-               gk20a_pllg_read_mnp(clk);
+               gk20a_pllg_read_mnp(clk, &clk->pll);
                return gk20a_pllg_calc_rate(clk) / GK20A_CLK_GPC_MDIV;
        default:
                nvkm_error(subdev, "invalid clock source %d\n", src);
@@ -577,7 +559,7 @@ gk20a_clk_read(struct nvkm_clk *base, enum nv_clk_src src)
        }
 }
 
-static int
+int
 gk20a_clk_calc(struct nvkm_clk *base, struct nvkm_cstate *cstate)
 {
        struct gk20a_clk *clk = gk20a_clk(base);
@@ -586,7 +568,7 @@ gk20a_clk_calc(struct nvkm_clk *base, struct nvkm_cstate *cstate)
                                         GK20A_CLK_GPC_MDIV);
 }
 
-static int
+int
 gk20a_clk_prog(struct nvkm_clk *base)
 {
        struct gk20a_clk *clk = gk20a_clk(base);
@@ -594,15 +576,33 @@ gk20a_clk_prog(struct nvkm_clk *base)
        return gk20a_pllg_program_mnp(clk);
 }
 
-static void
+void
 gk20a_clk_tidy(struct nvkm_clk *base)
 {
 }
 
-static void
+void
 gk20a_clk_fini(struct nvkm_clk *base)
 {
+       struct nvkm_device *device = base->subdev.device;
        struct gk20a_clk *clk = gk20a_clk(base);
+       u32 val;
+
+       /* slide to VCO min */
+       val = nvkm_rd32(device, GPCPLL_CFG);
+       if (val & GPCPLL_CFG_ENABLE) {
+               struct gk20a_pll pll;
+               u32 n_lo;
+
+               gk20a_pllg_read_mnp(clk, &pll);
+               n_lo = DIV_ROUND_UP(pll.m * clk->params->min_vco,
+                                   clk->parent_rate / KHZ);
+               gk20a_pllg_slide(clk, n_lo);
+       }
+
+       /* put PLL in bypass before disabling it */
+       nvkm_mask(device, SEL_VCO, BIT(SEL_VCO_GPC2CLK_OUT_SHIFT), 0);
+
        gk20a_pllg_disable(clk);
 }
 
@@ -614,9 +614,12 @@ gk20a_clk_init(struct nvkm_clk *base)
        struct nvkm_device *device = subdev->device;
        int ret;
 
-       nvkm_mask(device, GPC2CLK_OUT, GPC2CLK_OUT_INIT_MASK, GPC2CLK_OUT_INIT_VAL);
+       nvkm_mask(device, GPC2CLK_OUT, GPC2CLK_OUT_INIT_MASK,
+                 GPC2CLK_OUT_INIT_VAL);
 
-       ret = gk20a_clk_prog(&clk->base);
+       /* Start with lowest frequency */
+       base->func->calc(base, &base->func->pstates[0].base);
+       ret = base->func->prog(&clk->base);
        if (ret) {
                nvkm_error(subdev, "cannot initialize clock\n");
                return ret;
@@ -643,27 +646,50 @@ gk20a_clk = {
 };
 
 int
-gk20a_clk_new(struct nvkm_device *device, int index, struct nvkm_clk **pclk)
+_gk20a_clk_ctor(struct nvkm_device *device, int index,
+               const struct nvkm_clk_func *func,
+               const struct gk20a_clk_pllg_params *params,
+               struct gk20a_clk *clk)
 {
        struct nvkm_device_tegra *tdev = device->func->tegra(device);
+       int ret;
+       int i;
+
+       /* Finish initializing the pstates */
+       for (i = 0; i < func->nr_pstates; i++) {
+               INIT_LIST_HEAD(&func->pstates[i].list);
+               func->pstates[i].pstate = i + 1;
+       }
+
+       clk->params = params;
+       clk->parent_rate = clk_get_rate(tdev->clk);
+
+       ret = nvkm_clk_ctor(func, device, index, true, &clk->base);
+       if (ret)
+               return ret;
+
+       nvkm_debug(&clk->base.subdev, "parent clock rate: %d Khz\n",
+                  clk->parent_rate / KHZ);
+
+       return 0;
+}
+
+int
+gk20a_clk_new(struct nvkm_device *device, int index, struct nvkm_clk **pclk)
+{
        struct gk20a_clk *clk;
-       int ret, i;
+       int ret;
 
-       if (!(clk = kzalloc(sizeof(*clk), GFP_KERNEL)))
+       clk = kzalloc(sizeof(*clk), GFP_KERNEL);
+       if (!clk)
                return -ENOMEM;
        *pclk = &clk->base;
 
-       /* Finish initializing the pstates */
-       for (i = 0; i < ARRAY_SIZE(gk20a_pstates); i++) {
-               INIT_LIST_HEAD(&gk20a_pstates[i].list);
-               gk20a_pstates[i].pstate = i + 1;
-       }
+       ret = _gk20a_clk_ctor(device, index, &gk20a_clk, &gk20a_pllg_params,
+                             clk);
 
-       clk->params = &gk20a_pllg_params;
-       clk->parent_rate = clk_get_rate(tdev->clk);
+       clk->pl_to_div = pl_to_div;
+       clk->div_to_pl = div_to_pl;
 
-       ret = nvkm_clk_ctor(&gk20a_clk, device, index, true, &clk->base);
-       nvkm_info(&clk->base.subdev, "parent clock rate: %d Mhz\n",
-                 clk->parent_rate / MHZ);
        return ret;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.h b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.h
new file mode 100644 (file)
index 0000000..13c4674
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __NVKM_CLK_GK20A_H__
+#define __NVKM_CLK_GK20A_H__
+
+#define GK20A_CLK_GPC_MDIV 1000
+
+#define SYS_GPCPLL_CFG_BASE    0x00137000
+
+/* All frequencies in Khz */
+struct gk20a_clk_pllg_params {
+       u32 min_vco, max_vco;
+       u32 min_u, max_u;
+       u32 min_m, max_m;
+       u32 min_n, max_n;
+       u32 min_pl, max_pl;
+};
+
+struct gk20a_pll {
+       u32 m;
+       u32 n;
+       u32 pl;
+};
+
+struct gk20a_clk {
+       struct nvkm_clk base;
+       const struct gk20a_clk_pllg_params *params;
+       struct gk20a_pll pll;
+       u32 parent_rate;
+
+       u32 (*div_to_pl)(u32);
+       u32 (*pl_to_div)(u32);
+};
+#define gk20a_clk(p) container_of((p), struct gk20a_clk, base)
+
+int _gk20a_clk_ctor(struct nvkm_device *, int, const struct nvkm_clk_func *,
+                   const struct gk20a_clk_pllg_params *, struct gk20a_clk *);
+void gk20a_clk_fini(struct nvkm_clk *);
+int gk20a_clk_read(struct nvkm_clk *, enum nv_clk_src);
+int gk20a_clk_calc(struct nvkm_clk *, struct nvkm_cstate *);
+int gk20a_clk_prog(struct nvkm_clk *);
+void gk20a_clk_tidy(struct nvkm_clk *);
+
+#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gm20b.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gm20b.c
new file mode 100644 (file)
index 0000000..71b2bbb
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <subdev/clk.h>
+#include <core/device.h>
+
+#include "priv.h"
+#include "gk20a.h"
+
+#define KHZ (1000)
+#define MHZ (KHZ * 1000)
+
+#define MASK(w)        ((1 << w) - 1)
+
+#define BYPASSCTRL_SYS (SYS_GPCPLL_CFG_BASE + 0x340)
+#define BYPASSCTRL_SYS_GPCPLL_SHIFT    0
+#define BYPASSCTRL_SYS_GPCPLL_WIDTH    1
+
+static u32 pl_to_div(u32 pl)
+{
+       return pl;
+}
+
+static u32 div_to_pl(u32 div)
+{
+       return div;
+}
+
+static const struct gk20a_clk_pllg_params gm20b_pllg_params = {
+       .min_vco = 1300000, .max_vco = 2600000,
+       .min_u = 12000, .max_u = 38400,
+       .min_m = 1, .max_m = 255,
+       .min_n = 8, .max_n = 255,
+       .min_pl = 1, .max_pl = 31,
+};
+
+static struct nvkm_pstate
+gm20b_pstates[] = {
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 76800,
+                       .voltage = 0,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 153600,
+                       .voltage = 1,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 230400,
+                       .voltage = 2,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 307200,
+                       .voltage = 3,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 384000,
+                       .voltage = 4,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 460800,
+                       .voltage = 5,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 537600,
+                       .voltage = 6,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 614400,
+                       .voltage = 7,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 691200,
+                       .voltage = 8,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 768000,
+                       .voltage = 9,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 844800,
+                       .voltage = 10,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 921600,
+                       .voltage = 11,
+               },
+       },
+       {
+               .base = {
+                       .domain[nv_clk_src_gpc] = 998400,
+                       .voltage = 12,
+               },
+       },
+
+};
+
+static int
+gm20b_clk_init(struct nvkm_clk *base)
+{
+       struct gk20a_clk *clk = gk20a_clk(base);
+       struct nvkm_subdev *subdev = &clk->base.subdev;
+       struct nvkm_device *device = subdev->device;
+       int ret;
+
+       /* Set the global bypass control to VCO */
+       nvkm_mask(device, BYPASSCTRL_SYS,
+              MASK(BYPASSCTRL_SYS_GPCPLL_WIDTH) << BYPASSCTRL_SYS_GPCPLL_SHIFT,
+              0);
+
+       /* Start with lowest frequency */
+       base->func->calc(base, &base->func->pstates[0].base);
+       ret = base->func->prog(&clk->base);
+       if (ret) {
+               nvkm_error(subdev, "cannot initialize clock\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+static const struct nvkm_clk_func
+gm20b_clk_speedo0 = {
+       .init = gm20b_clk_init,
+       .fini = gk20a_clk_fini,
+       .read = gk20a_clk_read,
+       .calc = gk20a_clk_calc,
+       .prog = gk20a_clk_prog,
+       .tidy = gk20a_clk_tidy,
+       .pstates = gm20b_pstates,
+       .nr_pstates = ARRAY_SIZE(gm20b_pstates) - 1,
+       .domains = {
+               { nv_clk_src_crystal, 0xff },
+               { nv_clk_src_gpc, 0xff, 0, "core", GK20A_CLK_GPC_MDIV },
+               { nv_clk_src_max },
+       },
+};
+
+int
+gm20b_clk_new(struct nvkm_device *device, int index, struct nvkm_clk **pclk)
+{
+       struct gk20a_clk *clk;
+       int ret;
+
+       clk = kzalloc(sizeof(*clk), GFP_KERNEL);
+       if (!clk)
+               return -ENOMEM;
+       *pclk = &clk->base;
+
+       ret = _gk20a_clk_ctor(device, index, &gm20b_clk_speedo0,
+                             &gm20b_pllg_params, clk);
+
+       clk->pl_to_div = pl_to_div;
+       clk->div_to_pl = div_to_pl;
+
+       return ret;
+}
index 793e73d..eac88e3 100644 (file)
@@ -11,4 +11,4 @@ nvkm-y += nvkm/subdev/devinit/gt215.o
 nvkm-y += nvkm/subdev/devinit/mcp89.o
 nvkm-y += nvkm/subdev/devinit/gf100.o
 nvkm-y += nvkm/subdev/devinit/gm107.o
-nvkm-y += nvkm/subdev/devinit/gm204.o
+nvkm-y += nvkm/subdev/devinit/gm200.o
index 22b0140..2923598 100644 (file)
@@ -90,9 +90,21 @@ gf100_devinit_disable(struct nvkm_devinit *init)
        return disable;
 }
 
+void
+gf100_devinit_preinit(struct nvkm_devinit *base)
+{
+       struct nv50_devinit *init = nv50_devinit(base);
+       struct nvkm_subdev *subdev = &init->base.subdev;
+       struct nvkm_device *device = subdev->device;
+
+       /* This bit is set by devinit, and flips back to 0 on suspend */
+       if (!base->post)
+               base->post = ((nvkm_rd32(device, 0x2240c) & BIT(1)) == 0);
+}
+
 static const struct nvkm_devinit_func
 gf100_devinit = {
-       .preinit = nv50_devinit_preinit,
+       .preinit = gf100_devinit_preinit,
        .init = nv50_devinit_init,
        .post = nv04_devinit_post,
        .pll_set = gf100_devinit_pll_set,
index 2be98bd..28ca01b 100644 (file)
@@ -46,7 +46,7 @@ gm107_devinit_disable(struct nvkm_devinit *init)
 
 static const struct nvkm_devinit_func
 gm107_devinit = {
-       .preinit = nv50_devinit_preinit,
+       .preinit = gf100_devinit_preinit,
        .init = nv50_devinit_init,
        .post = nv04_devinit_post,
        .pll_set = gf100_devinit_pll_set,
@@ -107,7 +107,7 @@ pmu_load(struct nv50_devinit *init, u8 type, bool post,
 }
 
 static int
-gm204_devinit_post(struct nvkm_devinit *base, bool post)
+gm200_devinit_post(struct nvkm_devinit *base, bool post)
 {
        struct nv50_devinit *init = nv50_devinit(base);
        struct nvkm_subdev *subdev = &init->base.subdev;
@@ -165,17 +165,17 @@ gm204_devinit_post(struct nvkm_devinit *base, bool post)
 }
 
 static const struct nvkm_devinit_func
-gm204_devinit = {
-       .preinit = nv50_devinit_preinit,
+gm200_devinit = {
+       .preinit = gf100_devinit_preinit,
        .init = nv50_devinit_init,
-       .post = gm204_devinit_post,
+       .post = gm200_devinit_post,
        .pll_set = gf100_devinit_pll_set,
        .disable = gm107_devinit_disable,
 };
 
 int
-gm204_devinit_new(struct nvkm_device *device, int index,
+gm200_devinit_new(struct nvkm_device *device, int index,
                struct nvkm_devinit **pinit)
 {
-       return nv50_devinit_new_(&gm204_devinit, device, index, pinit);
+       return nv50_devinit_new_(&gm200_devinit, device, index, pinit);
 }
index 337c2c6..c714b09 100644 (file)
@@ -93,28 +93,27 @@ nv50_devinit_disable(struct nvkm_devinit *init)
 void
 nv50_devinit_preinit(struct nvkm_devinit *base)
 {
-       struct nv50_devinit *init = nv50_devinit(base);
-       struct nvkm_subdev *subdev = &init->base.subdev;
+       struct nvkm_subdev *subdev = &base->subdev;
        struct nvkm_device *device = subdev->device;
 
        /* our heuristics can't detect whether the board has had its
         * devinit scripts executed or not if the display engine is
         * missing, assume it's a secondary gpu which requires post
         */
-       if (!init->base.post) {
-               u64 disable = nvkm_devinit_disable(&init->base);
+       if (!base->post) {
+               u64 disable = nvkm_devinit_disable(base);
                if (disable & (1ULL << NVKM_ENGINE_DISP))
-                       init->base.post = true;
+                       base->post = true;
        }
 
        /* magic to detect whether or not x86 vbios code has executed
         * the devinit scripts to initialise the board
         */
-       if (!init->base.post) {
+       if (!base->post) {
                if (!nvkm_rdvgac(device, 0, 0x00) &&
                    !nvkm_rdvgac(device, 0, 0x1a)) {
                        nvkm_debug(subdev, "adaptor not initialised\n");
-                       init->base.post = true;
+                       base->post = true;
                }
        }
 }
index 5de70a8..25d2ae3 100644 (file)
@@ -20,6 +20,7 @@ int  gf100_devinit_ctor(struct nvkm_object *, struct nvkm_object *,
                        struct nvkm_oclass *, void *, u32,
                        struct nvkm_object **);
 int  gf100_devinit_pll_set(struct nvkm_devinit *, u32, u32);
+void gf100_devinit_preinit(struct nvkm_devinit *);
 
 u64  gm107_devinit_disable(struct nvkm_devinit *);
 #endif
index 1f73061..48f01e4 100644 (file)
@@ -6,7 +6,7 @@ nvkm-y += nvkm/subdev/i2c/g94.o
 nvkm-y += nvkm/subdev/i2c/gf117.o
 nvkm-y += nvkm/subdev/i2c/gf119.o
 nvkm-y += nvkm/subdev/i2c/gk104.o
-nvkm-y += nvkm/subdev/i2c/gm204.o
+nvkm-y += nvkm/subdev/i2c/gm200.o
 
 nvkm-y += nvkm/subdev/i2c/pad.o
 nvkm-y += nvkm/subdev/i2c/padnv04.o
@@ -14,7 +14,7 @@ nvkm-y += nvkm/subdev/i2c/padnv4e.o
 nvkm-y += nvkm/subdev/i2c/padnv50.o
 nvkm-y += nvkm/subdev/i2c/padg94.o
 nvkm-y += nvkm/subdev/i2c/padgf119.o
-nvkm-y += nvkm/subdev/i2c/padgm204.o
+nvkm-y += nvkm/subdev/i2c/padgm200.o
 
 nvkm-y += nvkm/subdev/i2c/bus.o
 nvkm-y += nvkm/subdev/i2c/busnv04.o
@@ -25,6 +25,6 @@ nvkm-y += nvkm/subdev/i2c/bit.o
 
 nvkm-y += nvkm/subdev/i2c/aux.o
 nvkm-y += nvkm/subdev/i2c/auxg94.o
-nvkm-y += nvkm/subdev/i2c/auxgm204.o
+nvkm-y += nvkm/subdev/i2c/auxgm200.o
 
 nvkm-y += nvkm/subdev/i2c/anx9805.o
index 35a892e..fc6b162 100644 (file)
@@ -18,7 +18,7 @@ int nvkm_i2c_aux_xfer(struct nvkm_i2c_aux *, bool retry, u8 type,
                      u32 addr, u8 *data, u8 size);
 
 int g94_i2c_aux_new(struct nvkm_i2c_pad *, int, u8, struct nvkm_i2c_aux **);
-int gm204_i2c_aux_new(struct nvkm_i2c_pad *, int, u8, struct nvkm_i2c_aux **);
+int gm200_i2c_aux_new(struct nvkm_i2c_pad *, int, u8, struct nvkm_i2c_aux **);
 
 #define AUX_MSG(b,l,f,a...) do {                                               \
        struct nvkm_i2c_aux *_aux = (b);                                       \
  *
  * Authors: Ben Skeggs <bskeggs@redhat.com>
  */
-#define gm204_i2c_aux(p) container_of((p), struct gm204_i2c_aux, base)
+#define gm200_i2c_aux(p) container_of((p), struct gm200_i2c_aux, base)
 #include "aux.h"
 
-struct gm204_i2c_aux {
+struct gm200_i2c_aux {
        struct nvkm_i2c_aux base;
        int ch;
 };
 
 static void
-gm204_i2c_aux_fini(struct gm204_i2c_aux *aux)
+gm200_i2c_aux_fini(struct gm200_i2c_aux *aux)
 {
        struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
        nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x00310000, 0x00000000);
 }
 
 static int
-gm204_i2c_aux_init(struct gm204_i2c_aux *aux)
+gm200_i2c_aux_init(struct gm200_i2c_aux *aux)
 {
        struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
        const u32 unksel = 1; /* nfi which to use, or if it matters.. */
@@ -64,7 +64,7 @@ gm204_i2c_aux_init(struct gm204_i2c_aux *aux)
                udelay(1);
                if (!timeout--) {
                        AUX_ERR(&aux->base, "magic wait %08x", ctrl);
-                       gm204_i2c_aux_fini(aux);
+                       gm200_i2c_aux_fini(aux);
                        return -EBUSY;
                }
        } while ((ctrl & 0x03000000) != urep);
@@ -73,10 +73,10 @@ gm204_i2c_aux_init(struct gm204_i2c_aux *aux)
 }
 
 static int
-gm204_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry,
+gm200_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry,
                   u8 type, u32 addr, u8 *data, u8 size)
 {
-       struct gm204_i2c_aux *aux = gm204_i2c_aux(obj);
+       struct gm200_i2c_aux *aux = gm200_i2c_aux(obj);
        struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
        const u32 base = aux->ch * 0x50;
        u32 ctrl, stat, timeout, retries;
@@ -85,7 +85,7 @@ gm204_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry,
 
        AUX_TRACE(&aux->base, "%d: %08x %d", type, addr, size);
 
-       ret = gm204_i2c_aux_init(aux);
+       ret = gm200_i2c_aux_init(aux);
        if (ret < 0)
                goto out;
 
@@ -155,26 +155,26 @@ gm204_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry,
        }
 
 out:
-       gm204_i2c_aux_fini(aux);
+       gm200_i2c_aux_fini(aux);
        return ret < 0 ? ret : (stat & 0x000f0000) >> 16;
 }
 
 static const struct nvkm_i2c_aux_func
-gm204_i2c_aux_func = {
-       .xfer = gm204_i2c_aux_xfer,
+gm200_i2c_aux_func = {
+       .xfer = gm200_i2c_aux_xfer,
 };
 
 int
-gm204_i2c_aux_new(struct nvkm_i2c_pad *pad, int index, u8 drive,
+gm200_i2c_aux_new(struct nvkm_i2c_pad *pad, int index, u8 drive,
                struct nvkm_i2c_aux **paux)
 {
-       struct gm204_i2c_aux *aux;
+       struct gm200_i2c_aux *aux;
 
        if (!(aux = kzalloc(sizeof(*aux), GFP_KERNEL)))
                return -ENOMEM;
        *paux = &aux->base;
 
-       nvkm_i2c_aux_ctor(&gm204_i2c_aux_func, pad, index, &aux->base);
+       nvkm_i2c_aux_ctor(&gm200_i2c_aux_func, pad, index, &aux->base);
        aux->ch = drive;
        aux->base.intr = 1 << aux->ch;
        return 0;
 #include "pad.h"
 
 static const struct nvkm_i2c_func
-gm204_i2c = {
+gm200_i2c = {
        .pad_x_new = gf119_i2c_pad_x_new,
-       .pad_s_new = gm204_i2c_pad_s_new,
+       .pad_s_new = gm200_i2c_pad_s_new,
        .aux = 8,
        .aux_stat = gk104_aux_stat,
        .aux_mask = gk104_aux_mask,
 };
 
 int
-gm204_i2c_new(struct nvkm_device *device, int index, struct nvkm_i2c **pi2c)
+gm200_i2c_new(struct nvkm_device *device, int index, struct nvkm_i2c **pi2c)
 {
-       return nvkm_i2c_new_(&gm204_i2c, device, index, pi2c);
+       return nvkm_i2c_new_(&gm200_i2c, device, index, pi2c);
 }
index 9eeb992..316c453 100644 (file)
@@ -49,11 +49,11 @@ int nv4e_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
 int nv50_i2c_pad_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
 int g94_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
 int gf119_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
-int gm204_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
+int gm200_i2c_pad_x_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
 
 int g94_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
 int gf119_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
-int gm204_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
+int gm200_i2c_pad_s_new(struct nvkm_i2c *, int, struct nvkm_i2c_pad **);
 
 int anx9805_pad_new(struct nvkm_i2c_bus *, int, u8, struct nvkm_i2c_pad **);
 
@@ -26,7 +26,7 @@
 #include "bus.h"
 
 static void
-gm204_i2c_pad_mode(struct nvkm_i2c_pad *pad, enum nvkm_i2c_pad_mode mode)
+gm200_i2c_pad_mode(struct nvkm_i2c_pad *pad, enum nvkm_i2c_pad_mode mode)
 {
        struct nvkm_subdev *subdev = &pad->i2c->subdev;
        struct nvkm_device *device = subdev->device;
@@ -51,26 +51,26 @@ gm204_i2c_pad_mode(struct nvkm_i2c_pad *pad, enum nvkm_i2c_pad_mode mode)
 }
 
 static const struct nvkm_i2c_pad_func
-gm204_i2c_pad_s_func = {
+gm200_i2c_pad_s_func = {
        .bus_new_4 = gf119_i2c_bus_new,
-       .aux_new_6 = gm204_i2c_aux_new,
-       .mode = gm204_i2c_pad_mode,
+       .aux_new_6 = gm200_i2c_aux_new,
+       .mode = gm200_i2c_pad_mode,
 };
 
 int
-gm204_i2c_pad_s_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad)
+gm200_i2c_pad_s_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad)
 {
-       return nvkm_i2c_pad_new_(&gm204_i2c_pad_s_func, i2c, id, ppad);
+       return nvkm_i2c_pad_new_(&gm200_i2c_pad_s_func, i2c, id, ppad);
 }
 
 static const struct nvkm_i2c_pad_func
-gm204_i2c_pad_x_func = {
+gm200_i2c_pad_x_func = {
        .bus_new_4 = gf119_i2c_bus_new,
-       .aux_new_6 = gm204_i2c_aux_new,
+       .aux_new_6 = gm200_i2c_aux_new,
 };
 
 int
-gm204_i2c_pad_x_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad)
+gm200_i2c_pad_x_new(struct nvkm_i2c *i2c, int id, struct nvkm_i2c_pad **ppad)
 {
-       return nvkm_i2c_pad_new_(&gm204_i2c_pad_x_func, i2c, id, ppad);
+       return nvkm_i2c_pad_new_(&gm200_i2c_pad_x_func, i2c, id, ppad);
 }
index 7e77a74..ad572d3 100644 (file)
@@ -2,4 +2,4 @@ nvkm-y += nvkm/subdev/ibus/gf100.o
 nvkm-y += nvkm/subdev/ibus/gf117.o
 nvkm-y += nvkm/subdev/ibus/gk104.o
 nvkm-y += nvkm/subdev/ibus/gk20a.o
-nvkm-y += nvkm/subdev/ibus/gm204.o
+nvkm-y += nvkm/subdev/ibus/gm200.o
 #include "priv.h"
 
 static const struct nvkm_subdev_func
-gm204_ibus = {
+gm200_ibus = {
        .intr = gk104_ibus_intr,
 };
 
 int
-gm204_ibus_new(struct nvkm_device *device, int index,
+gm200_ibus_new(struct nvkm_device *device, int index,
               struct nvkm_subdev **pibus)
 {
        struct nvkm_subdev *ibus;
        if (!(ibus = *pibus = kzalloc(sizeof(*ibus), GFP_KERNEL)))
                return -ENOMEM;
-       nvkm_subdev_ctor(&gm204_ibus, device, index, 0, ibus);
+       nvkm_subdev_ctor(&gm200_ibus, device, index, 0, ibus);
        return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/Kbuild
new file mode 100644 (file)
index 0000000..98a4bd3
--- /dev/null
@@ -0,0 +1,2 @@
+nvkm-y += nvkm/subdev/iccsense/base.o
+nvkm-y += nvkm/subdev/iccsense/gf100.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
new file mode 100644 (file)
index 0000000..c44a852
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * Copyright 2015 Martin Peres
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Martin Peres
+ */
+#include "priv.h"
+
+#include <subdev/bios.h>
+#include <subdev/bios/extdev.h>
+#include <subdev/bios/iccsense.h>
+#include <subdev/i2c.h>
+
+static bool
+nvkm_iccsense_validate_device(struct i2c_adapter *i2c, u8 addr,
+                             enum nvbios_extdev_type type, u8 rail)
+{
+       switch (type) {
+       case NVBIOS_EXTDEV_INA209:
+       case NVBIOS_EXTDEV_INA219:
+               return rail == 0 && nv_rd16i2cr(i2c, addr, 0x0) >= 0;
+       case NVBIOS_EXTDEV_INA3221:
+               return rail <= 3 &&
+                      nv_rd16i2cr(i2c, addr, 0xff) == 0x3220 &&
+                      nv_rd16i2cr(i2c, addr, 0xfe) == 0x5449;
+       default:
+               return false;
+       }
+}
+
+static int
+nvkm_iccsense_poll_lane(struct i2c_adapter *i2c, u8 addr, u8 shunt_reg,
+                       u8 shunt_shift, u8 bus_reg, u8 bus_shift, u8 shunt,
+                       u16 lsb)
+{
+       int vshunt = nv_rd16i2cr(i2c, addr, shunt_reg);
+       int vbus = nv_rd16i2cr(i2c, addr, bus_reg);
+
+       if (vshunt < 0 || vbus < 0)
+               return -EINVAL;
+
+       vshunt >>= shunt_shift;
+       vbus >>= bus_shift;
+
+       return vbus * vshunt * lsb / shunt;
+}
+
+static int
+nvkm_iccsense_ina2x9_read(struct nvkm_iccsense *iccsense,
+                          struct nvkm_iccsense_rail *rail,
+                         u8 shunt_reg, u8 bus_reg)
+{
+       return nvkm_iccsense_poll_lane(rail->i2c, rail->addr, shunt_reg, 0,
+                                      bus_reg, 3, rail->mohm, 10 * 4);
+}
+
+static int
+nvkm_iccsense_ina209_read(struct nvkm_iccsense *iccsense,
+                         struct nvkm_iccsense_rail *rail)
+{
+       return nvkm_iccsense_ina2x9_read(iccsense, rail, 3, 4);
+}
+
+static int
+nvkm_iccsense_ina219_read(struct nvkm_iccsense *iccsense,
+                         struct nvkm_iccsense_rail *rail)
+{
+       return nvkm_iccsense_ina2x9_read(iccsense, rail, 1, 2);
+}
+
+static int
+nvkm_iccsense_ina3221_read(struct nvkm_iccsense *iccsense,
+                          struct nvkm_iccsense_rail *rail)
+{
+       return nvkm_iccsense_poll_lane(rail->i2c, rail->addr,
+                                      1 + (rail->rail * 2), 3,
+                                      2 + (rail->rail * 2), 3, rail->mohm,
+                                      40 * 8);
+}
+
+int
+nvkm_iccsense_read(struct nvkm_iccsense *iccsense, u8 idx)
+{
+       struct nvkm_iccsense_rail *rail;
+
+       if (!iccsense || idx >= iccsense->rail_count)
+               return -EINVAL;
+
+       rail = &iccsense->rails[idx];
+       if (!rail->read)
+               return -ENODEV;
+
+       return rail->read(iccsense, rail);
+}
+
+int
+nvkm_iccsense_read_all(struct nvkm_iccsense *iccsense)
+{
+       int result = 0, i;
+       for (i = 0; i < iccsense->rail_count; ++i) {
+               int res = nvkm_iccsense_read(iccsense, i);
+               if (res >= 0)
+                       result += res;
+               else
+                       return res;
+       }
+       return result;
+}
+
+static void *
+nvkm_iccsense_dtor(struct nvkm_subdev *subdev)
+{
+       struct nvkm_iccsense *iccsense = nvkm_iccsense(subdev);
+
+       if (iccsense->rails)
+               kfree(iccsense->rails);
+
+       return iccsense;
+}
+
+static int
+nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
+{
+       struct nvkm_iccsense *iccsense = nvkm_iccsense(subdev);
+       struct nvkm_bios *bios = subdev->device->bios;
+       struct nvkm_i2c *i2c = subdev->device->i2c;
+       struct nvbios_iccsense stbl;
+       int i;
+
+       if (!i2c || !bios || nvbios_iccsense_parse(bios, &stbl)
+           || !stbl.nr_entry)
+               return 0;
+
+       iccsense->rails = kmalloc(sizeof(*iccsense->rails) * stbl.nr_entry,
+                                 GFP_KERNEL);
+       if (!iccsense->rails)
+               return -ENOMEM;
+
+       iccsense->data_valid = true;
+       for (i = 0; i < stbl.nr_entry; ++i) {
+               struct pwr_rail_t *r = &stbl.rail[i];
+               struct nvbios_extdev_func extdev;
+               struct nvkm_iccsense_rail *rail;
+               struct nvkm_i2c_bus *i2c_bus;
+               u8 addr;
+
+               if (!r->mode || r->resistor_mohm == 0)
+                       continue;
+
+               if (nvbios_extdev_parse(bios, r->extdev_id, &extdev))
+                       continue;
+
+               if (extdev.type == 0xff)
+                       continue;
+
+               if (extdev.bus)
+                       i2c_bus = nvkm_i2c_bus_find(i2c, NVKM_I2C_BUS_SEC);
+               else
+                       i2c_bus = nvkm_i2c_bus_find(i2c, NVKM_I2C_BUS_PRI);
+               if (!i2c_bus)
+                       continue;
+
+               addr = extdev.addr >> 1;
+               if (!nvkm_iccsense_validate_device(&i2c_bus->i2c, addr,
+                                                  extdev.type, r->rail)) {
+                       iccsense->data_valid = false;
+                       nvkm_warn(subdev, "found unknown or invalid rail entry"
+                                 " type 0x%x rail %i, power reading might be"
+                                 " invalid\n", extdev.type, r->rail);
+                       continue;
+               }
+
+               rail = &iccsense->rails[iccsense->rail_count];
+               switch (extdev.type) {
+               case NVBIOS_EXTDEV_INA209:
+                       rail->read = nvkm_iccsense_ina209_read;
+                       break;
+               case NVBIOS_EXTDEV_INA219:
+                       rail->read = nvkm_iccsense_ina219_read;
+                       break;
+               case NVBIOS_EXTDEV_INA3221:
+                       rail->read = nvkm_iccsense_ina3221_read;
+                       break;
+               }
+
+               rail->addr = addr;
+               rail->rail = r->rail;
+               rail->mohm = r->resistor_mohm;
+               rail->i2c = &i2c_bus->i2c;
+               ++iccsense->rail_count;
+       }
+       return 0;
+}
+
+struct nvkm_subdev_func iccsense_func = {
+       .oneinit = nvkm_iccsense_oneinit,
+       .dtor = nvkm_iccsense_dtor,
+};
+
+void
+nvkm_iccsense_ctor(struct nvkm_device *device, int index,
+                  struct nvkm_iccsense *iccsense)
+{
+       nvkm_subdev_ctor(&iccsense_func, device, index, 0, &iccsense->subdev);
+}
+
+int
+nvkm_iccsense_new_(struct nvkm_device *device, int index,
+                  struct nvkm_iccsense **iccsense)
+{
+       if (!(*iccsense = kzalloc(sizeof(**iccsense), GFP_KERNEL)))
+               return -ENOMEM;
+       nvkm_iccsense_ctor(device, index, *iccsense);
+       return 0;
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/gf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/gf100.c
new file mode 100644 (file)
index 0000000..cccff1c
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2015 Karol Herbst
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Karol Herbst
+ */
+#include "priv.h"
+
+int
+gf100_iccsense_new(struct nvkm_device *device, int index,
+                  struct nvkm_iccsense **piccsense)
+{
+       return nvkm_iccsense_new_(device, index, piccsense);
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/priv.h
new file mode 100644 (file)
index 0000000..ed398b8
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __NVKM_ICCSENSE_PRIV_H__
+#define __NVKM_ICCSENSE_PRIV_H__
+#define nvkm_iccsense(p) container_of((p), struct nvkm_iccsense, subdev)
+#include <subdev/iccsense.h>
+
+struct nvkm_iccsense_rail {
+       int (*read)(struct nvkm_iccsense *, struct nvkm_iccsense_rail *);
+       struct i2c_adapter *i2c;
+       u8 addr;
+       u8 rail;
+       u8 mohm;
+};
+
+void nvkm_iccsense_ctor(struct nvkm_device *, int, struct nvkm_iccsense *);
+int nvkm_iccsense_new_(struct nvkm_device *, int, struct nvkm_iccsense **);
+#endif
index 4c20fec..6b8f2a1 100644 (file)
@@ -228,6 +228,8 @@ gk20a_instobj_release_dma(struct nvkm_memory *memory)
        struct gk20a_instmem *imem = node->imem;
        struct nvkm_ltc *ltc = imem->base.subdev.device->ltc;
 
+       /* in case we got a write-combined mapping */
+       wmb();
        nvkm_ltc_invalidate(ltc);
 }
 
index f8108df..932b366 100644 (file)
@@ -2,4 +2,4 @@ nvkm-y += nvkm/subdev/ltc/base.o
 nvkm-y += nvkm/subdev/ltc/gf100.o
 nvkm-y += nvkm/subdev/ltc/gk104.o
 nvkm-y += nvkm/subdev/ltc/gm107.o
-nvkm-y += nvkm/subdev/ltc/gm204.o
+nvkm-y += nvkm/subdev/ltc/gm200.o
index fb0de83..c9eb677 100644 (file)
@@ -129,9 +129,7 @@ gf100_ltc_invalidate(struct nvkm_ltc *ltc)
        s64 taken;
 
        nvkm_wr32(device, 0x70004, 0x00000001);
-       taken = nvkm_wait_msec(device, 2, 0x70004, 0x00000003, 0x00000000);
-       if (taken < 0)
-               nvkm_warn(&ltc->subdev, "LTC invalidate timeout\n");
+       taken = nvkm_wait_msec(device, 2000, 0x70004, 0x00000003, 0x00000000);
 
        if (taken > 0)
                nvkm_debug(&ltc->subdev, "LTC invalidate took %lld ns\n", taken);
@@ -144,9 +142,7 @@ gf100_ltc_flush(struct nvkm_ltc *ltc)
        s64 taken;
 
        nvkm_wr32(device, 0x70010, 0x00000001);
-       taken = nvkm_wait_msec(device, 2, 0x70010, 0x00000003, 0x00000000);
-       if (taken < 0)
-               nvkm_warn(&ltc->subdev, "LTC flush timeout\n");
+       taken = nvkm_wait_msec(device, 2000, 0x70010, 0x00000003, 0x00000000);
 
        if (taken > 0)
                nvkm_debug(&ltc->subdev, "LTC flush took %lld ns\n", taken);
index 2af1f9e..e292f56 100644 (file)
@@ -43,10 +43,8 @@ gm107_ltc_cbc_wait(struct nvkm_ltc *ltc)
        for (c = 0; c < ltc->ltc_nr; c++) {
                for (s = 0; s < ltc->lts_nr; s++) {
                        const u32 addr = 0x14046c + (c * 0x2000) + (s * 0x200);
-                       nvkm_msec(device, 2000,
-                               if (!nvkm_rd32(device, addr))
-                                       break;
-                       );
+                       nvkm_wait_msec(device, 2000, addr,
+                                      0x00000004, 0x00000000);
                }
        }
 }
@@ -75,7 +73,7 @@ gm107_ltc_lts_isr(struct nvkm_ltc *ltc, int c, int s)
 {
        struct nvkm_subdev *subdev = &ltc->subdev;
        struct nvkm_device *device = subdev->device;
-       u32 base = 0x140000 + (c * 0x2000) + (s * 0x400);
+       u32 base = 0x140000 + (c * 0x2000) + (s * 0x200);
        u32 stat = nvkm_rd32(device, base + 0x00c);
 
        if (stat) {
@@ -27,7 +27,7 @@
 #include <subdev/timer.h>
 
 static int
-gm204_ltc_oneinit(struct nvkm_ltc *ltc)
+gm200_ltc_oneinit(struct nvkm_ltc *ltc)
 {
        struct nvkm_device *device = ltc->subdev.device;
 
@@ -37,15 +37,15 @@ gm204_ltc_oneinit(struct nvkm_ltc *ltc)
        return gf100_ltc_oneinit_tag_ram(ltc);
 }
 static void
-gm204_ltc_init(struct nvkm_ltc *ltc)
+gm200_ltc_init(struct nvkm_ltc *ltc)
 {
        nvkm_wr32(ltc->subdev.device, 0x17e278, ltc->tag_base);
 }
 
 static const struct nvkm_ltc_func
-gm204_ltc = {
-       .oneinit = gm204_ltc_oneinit,
-       .init = gm204_ltc_init,
+gm200_ltc = {
+       .oneinit = gm200_ltc_oneinit,
+       .init = gm200_ltc_init,
        .intr = gm107_ltc_intr, /*XXX: not validated */
        .cbc_clear = gm107_ltc_cbc_clear,
        .cbc_wait = gm107_ltc_cbc_wait,
@@ -57,7 +57,7 @@ gm204_ltc = {
 };
 
 int
-gm204_ltc_new(struct nvkm_device *device, int index, struct nvkm_ltc **pltc)
+gm200_ltc_new(struct nvkm_device *device, int index, struct nvkm_ltc **pltc)
 {
-       return nvkm_ltc_new_(&gm204_ltc, device, index, pltc);
+       return nvkm_ltc_new_(&gm200_ltc, device, index, pltc);
 }
index 7702944..e2faccf 100644 (file)
@@ -24,8 +24,8 @@ uint32_t gf100_pmu_data[] = {
        0x00000000,
 /* 0x0058: proc_list_head */
        0x54534f48,
-       0x00000507,
-       0x000004a4,
+       0x0000050a,
+       0x000004a7,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -46,8 +46,8 @@ uint32_t gf100_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x584d454d,
-       0x00000753,
-       0x00000745,
+       0x00000756,
+       0x00000748,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -68,8 +68,8 @@ uint32_t gf100_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x46524550,
-       0x00000757,
-       0x00000755,
+       0x0000075a,
+       0x00000758,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -90,8 +90,8 @@ uint32_t gf100_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x5f433249,
-       0x00000b87,
-       0x00000a2a,
+       0x00000b8a,
+       0x00000a2d,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -112,8 +112,8 @@ uint32_t gf100_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x54534554,
-       0x00000bb0,
-       0x00000b89,
+       0x00000bb3,
+       0x00000b8c,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -134,8 +134,8 @@ uint32_t gf100_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x454c4449,
-       0x00000bbc,
-       0x00000bba,
+       0x00000bbf,
+       0x00000bbd,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -229,26 +229,26 @@ uint32_t gf100_pmu_data[] = {
 /* 0x0370: memx_func_head */
        0x00000001,
        0x00000000,
-       0x00000546,
+       0x00000549,
 /* 0x037c: memx_func_next */
        0x00000002,
        0x00000000,
-       0x000005d0,
+       0x000005d3,
        0x00000003,
        0x00000002,
-       0x0000069a,
+       0x0000069d,
        0x00040004,
        0x00000000,
-       0x000006b6,
+       0x000006b9,
        0x00010005,
        0x00000000,
-       0x000006d3,
+       0x000006d6,
        0x00010006,
        0x00000000,
-       0x00000658,
+       0x0000065b,
        0x00000007,
        0x00000000,
-       0x000006de,
+       0x000006e1,
 /* 0x03c4: memx_func_tail */
 /* 0x03c4: memx_ts_start */
        0x00000000,
@@ -917,887 +917,887 @@ uint32_t gf100_pmu_data[] = {
 };
 
 uint32_t gf100_pmu_code[] = {
-       0x03930ef5,
+       0x03920ef5,
 /* 0x0004: rd32 */
        0x07a007f1,
        0xd00604b6,
        0x04bd000e,
-       0xf001d7f0,
-       0x07f101d3,
-       0x04b607ac,
-       0x000dd006,
-/* 0x0022: rd32_wait */
-       0xd7f104bd,
-       0xd4b607ac,
-       0x00ddcf06,
-       0x7000d4f1,
-       0xf1f21bf4,
-       0xb607a4d7,
-       0xddcf06d4,
-/* 0x003f: wr32 */
-       0xf100f800,
-       0xb607a007,
-       0x0ed00604,
-       0xf104bd00,
-       0xb607a407,
+       0x0001d7f1,
+       0xf101d3f0,
+       0xb607ac07,
        0x0dd00604,
-       0xf004bd00,
-       0xd5f002d7,
-       0x01d3f0f0,
-       0x07ac07f1,
+/* 0x0023: rd32_wait */
+       0xf104bd00,
+       0xb607acd7,
+       0xddcf06d4,
+       0x00d4f100,
+       0xf21bf470,
+       0x07a4d7f1,
+       0xcf06d4b6,
+       0x00f800dd,
+/* 0x0040: wr32 */
+       0x07a007f1,
+       0xd00604b6,
+       0x04bd000e,
+       0x07a407f1,
        0xd00604b6,
        0x04bd000d,
-/* 0x006c: wr32_wait */
-       0x07acd7f1,
-       0xcf06d4b6,
-       0xd4f100dd,
-       0x1bf47000,
-/* 0x007f: nsec */
-       0xf900f8f2,
-       0xf080f990,
-       0x84b62c87,
-       0x0088cf06,
-/* 0x008c: nsec_loop */
-       0xb62c97f0,
-       0x99cf0694,
-       0x0298bb00,
-       0xf4069eb8,
-       0x80fcf11e,
-       0x00f890fc,
-/* 0x00a4: wait */
-       0x80f990f9,
-       0xb62c87f0,
-       0x88cf0684,
-/* 0x00b1: wait_loop */
-       0x02eeb900,
-       0xb90421f4,
-       0xadfd02da,
-       0x06acb804,
-       0xf0150bf4,
+       0x00f2d7f1,
+       0xf101d3f0,
+       0xb607ac07,
+       0x0dd00604,
+/* 0x006b: wr32_wait */
+       0xf104bd00,
+       0xb607acd7,
+       0xddcf06d4,
+       0x00d4f100,
+       0xf21bf470,
+/* 0x007e: nsec */
+       0x90f900f8,
+       0x87f080f9,
+       0x0684b62c,
+/* 0x008b: nsec_loop */
+       0xf00088cf,
        0x94b62c97,
        0x0099cf06,
        0xb80298bb,
-       0x1ef4069b,
-/* 0x00d5: wait_done */
-       0xfc80fcdf,
-/* 0x00db: intr_watchdog */
-       0x9800f890,
-       0x96b003e9,
-       0x2a0bf400,
-       0xbb9a0a98,
-       0x1cf4029a,
-       0x01d7f00f,
-       0x02d221f5,
-       0x0ef494bd,
-/* 0x00f9: intr_watchdog_next_time */
-       0x9b0a9815,
-       0xf400a6b0,
-       0x9ab8090b,
-       0x061cf406,
-/* 0x0108: intr_watchdog_next_time_set */
-/* 0x010b: intr_watchdog_next_proc */
-       0x809b0980,
-       0xe0b603e9,
-       0x68e6b158,
-       0xc61bf402,
-/* 0x011a: intr */
-       0x00f900f8,
-       0x80f904bd,
-       0xa0f990f9,
-       0xc0f9b0f9,
-       0xe0f9d0f9,
-       0xf7f0f0f9,
-       0x0188fe00,
-       0x87f180f9,
-       0x84b605d0,
+       0x1ef4069e,
+       0xfc80fcf1,
+/* 0x00a3: wait */
+       0xf900f890,
+       0xf080f990,
+       0x84b62c87,
        0x0088cf06,
-       0xf10180b6,
-       0xb605d007,
+/* 0x00b0: wait_loop */
+       0xf402eeb9,
+       0xdab90421,
+       0x04adfd02,
+       0xf406acb8,
+       0x97f0150b,
+       0x0694b62c,
+       0xbb0099cf,
+       0x9bb80298,
+       0xdf1ef406,
+/* 0x00d4: wait_done */
+       0x90fc80fc,
+/* 0x00da: intr_watchdog */
+       0xe99800f8,
+       0x0096b003,
+       0x982a0bf4,
+       0x9abb9a0a,
+       0x0f1cf402,
+       0xf501d7f0,
+       0xbd02d121,
+       0x150ef494,
+/* 0x00f8: intr_watchdog_next_time */
+       0xb09b0a98,
+       0x0bf400a6,
+       0x069ab809,
+/* 0x0107: intr_watchdog_next_time_set */
+       0x80061cf4,
+/* 0x010a: intr_watchdog_next_proc */
+       0xe9809b09,
+       0x58e0b603,
+       0x0268e6b1,
+       0xf8c61bf4,
+/* 0x0119: intr */
+       0xbd00f900,
+       0xf980f904,
+       0xf9a0f990,
+       0xf9c0f9b0,
+       0xf9e0f9d0,
+       0x00f7f0f0,
+       0xf90188fe,
+       0xd087f180,
+       0x0684b605,
+       0xb60088cf,
+       0x07f10180,
+       0x04b605d0,
+       0x0008d006,
+       0x87f004bd,
+       0x0684b608,
+       0xc40088cf,
+       0x0bf40289,
+       0x9b008023,
+       0xf458e7f0,
+       0x0998da21,
+       0x0096b09b,
+       0xf0110bf4,
+       0x04b63407,
+       0x0009d006,
+       0x098004bd,
+/* 0x017d: intr_skip_watchdog */
+       0x0089e49a,
+       0x480bf408,
+       0x068897f1,
+       0xcf0694b6,
+       0x9ac40099,
+       0x2c0bf402,
+       0x04c0c7f1,
+       0xcf06c4b6,
+       0xc0f900cc,
+       0x4f48e7f1,
+       0x5453e3f1,
+       0xf500d7f0,
+       0xfc033621,
+       0xc007f1c0,
+       0x0604b604,
+       0xbd000cd0,
+/* 0x01bd: intr_subintr_skip_fifo */
+       0x8807f104,
+       0x0604b606,
+       0xbd0009d0,
+/* 0x01c9: intr_skip_subintr */
+       0xe097f104,
+       0xfd90bd00,
+       0x07f00489,
+       0x0604b604,
+       0xbd0008d0,
+       0xfe80fc04,
+       0xf0fc0088,
+       0xd0fce0fc,
+       0xb0fcc0fc,
+       0x90fca0fc,
+       0x00fc80fc,
+       0xf80032f4,
+/* 0x01f9: ticks_from_ns */
+       0xf9c0f901,
+       0xcbd7f1b0,
+       0x00d3f000,
+       0x040b21f5,
+       0x03e8ccec,
+       0xf400b4b0,
+       0xeeec120b,
+       0xd7f103e8,
+       0xd3f000cb,
+       0x0b21f500,
+/* 0x0221: ticks_from_ns_quit */
+       0x02ceb904,
+       0xc0fcb0fc,
+/* 0x022a: ticks_from_us */
+       0xc0f900f8,
+       0xd7f1b0f9,
+       0xd3f000cb,
+       0x0b21f500,
+       0x02ceb904,
+       0xf400b4b0,
+       0xe4bd050b,
+/* 0x0244: ticks_from_us_quit */
+       0xc0fcb0fc,
+/* 0x024a: ticks_to_us */
+       0xd7f100f8,
+       0xd3f000cb,
+       0xecedff00,
+/* 0x0256: timer */
+       0x90f900f8,
+       0x32f480f9,
+       0x03f89810,
+       0xf40086b0,
+       0x84bd651c,
+       0xb63807f0,
        0x08d00604,
        0xf004bd00,
-       0x84b60887,
+       0x84b63487,
        0x0088cf06,
-       0xf40289c4,
-       0x0080230b,
-       0x58e7f09b,
-       0x98db21f4,
-       0x96b09b09,
-       0x110bf400,
+       0xbb9a0998,
+       0xe9bb0298,
+       0x03fe8000,
+       0xb60887f0,
+       0x88cf0684,
+       0x0284f000,
+       0xf0261bf4,
+       0x84b63487,
+       0x0088cf06,
+       0xf406e0b8,
+       0xe8b8090b,
+       0x111cf406,
+/* 0x02ac: timer_reset */
        0xb63407f0,
-       0x09d00604,
+       0x0ed00604,
        0x8004bd00,
-/* 0x017e: intr_skip_watchdog */
-       0x89e49a09,
-       0x0bf40800,
-       0x8897f148,
-       0x0694b606,
-       0xc40099cf,
-       0x0bf4029a,
-       0xc0c7f12c,
-       0x06c4b604,
-       0xf900cccf,
-       0x48e7f1c0,
-       0x53e3f14f,
-       0x00d7f054,
-       0x033721f5,
-       0x07f1c0fc,
-       0x04b604c0,
-       0x000cd006,
-/* 0x01be: intr_subintr_skip_fifo */
-       0x07f104bd,
-       0x04b60688,
-       0x0009d006,
-/* 0x01ca: intr_skip_subintr */
-       0x97f104bd,
-       0x90bd00e0,
-       0xf00489fd,
-       0x04b60407,
-       0x0008d006,
-       0x80fc04bd,
-       0xfc0088fe,
-       0xfce0fcf0,
-       0xfcc0fcd0,
-       0xfca0fcb0,
-       0xfc80fc90,
-       0x0032f400,
-/* 0x01fa: ticks_from_ns */
-       0xc0f901f8,
-       0xd7f1b0f9,
-       0xd3f000cb,
-       0x0821f500,
-       0xe8ccec04,
-       0x00b4b003,
-       0xec120bf4,
-       0xf103e8ee,
-       0xf000cbd7,
-       0x21f500d3,
-/* 0x0222: ticks_from_ns_quit */
-       0xceb90408,
-       0xfcb0fc02,
-/* 0x022b: ticks_from_us */
-       0xf900f8c0,
-       0xf1b0f9c0,
-       0xf000cbd7,
-       0x21f500d3,
-       0xceb90408,
-       0x00b4b002,
-       0xbd050bf4,
-/* 0x0245: ticks_from_us_quit */
-       0xfcb0fce4,
-/* 0x024b: ticks_to_us */
-       0xf100f8c0,
-       0xf000cbd7,
-       0xedff00d3,
-/* 0x0257: timer */
-       0xf900f8ec,
-       0xf480f990,
-       0xf8981032,
-       0x0086b003,
-       0xbd651cf4,
-       0x3807f084,
+/* 0x02ba: timer_enable */
+       0x87f09a0e,
+       0x3807f001,
        0xd00604b6,
        0x04bd0008,
-       0xb63487f0,
-       0x88cf0684,
-       0x9a099800,
-       0xbb0298bb,
-       0xfe8000e9,
-       0x0887f003,
-       0xcf0684b6,
-       0x84f00088,
-       0x261bf402,
-       0xb63487f0,
-       0x88cf0684,
-       0x06e0b800,
-       0xb8090bf4,
-       0x1cf406e8,
-/* 0x02ad: timer_reset */
-       0x3407f011,
-       0xd00604b6,
-       0x04bd000e,
-/* 0x02bb: timer_enable */
-       0xf09a0e80,
-       0x07f00187,
-       0x0604b638,
-       0xbd0008d0,
-/* 0x02c9: timer_done */
-       0x1031f404,
+/* 0x02c8: timer_done */
+       0xfc1031f4,
+       0xf890fc80,
+/* 0x02d1: send_proc */
+       0xf980f900,
+       0x05e89890,
+       0xf004e998,
+       0x89b80486,
+       0x2a0bf406,
+       0x940398c4,
+       0x80b60488,
+       0x008ebb18,
+       0x8000fa98,
+       0x8d80008a,
+       0x028c8001,
+       0xb6038b80,
+       0x94f00190,
+       0x04e98007,
+/* 0x030b: send_done */
+       0xfc0231f4,
+       0xf880fc90,
+/* 0x0311: find */
+       0xf080f900,
+       0x31f45887,
+/* 0x0319: find_loop */
+       0x008a9801,
+       0xf406aeb8,
+       0x80b6100b,
+       0x6886b158,
+       0xf01bf402,
+/* 0x032f: find_done */
+       0xb90132f4,
+       0x80fc028e,
+/* 0x0336: send */
+       0x21f500f8,
+       0x01f40311,
+/* 0x033f: recv */
+       0xf900f897,
+       0x9880f990,
+       0xe99805e8,
+       0x0132f404,
+       0xf40689b8,
+       0x89c43d0b,
+       0x0180b603,
+       0x800784f0,
+       0xea9805e8,
+       0xfef0f902,
+       0xf0f9018f,
+       0x9402efb9,
+       0xe9bb0499,
+       0x18e0b600,
+       0x9803eb98,
+       0xed9802ec,
+       0x00ee9801,
+       0xf0fca5f9,
+       0xf400f8fe,
+       0xf0fc0131,
+/* 0x038c: recv_done */
        0x90fc80fc,
-/* 0x02d2: send_proc */
-       0x80f900f8,
-       0xe89890f9,
-       0x04e99805,
-       0xb80486f0,
-       0x0bf40689,
-       0x0398c42a,
-       0xb6048894,
-       0x8ebb1880,
-       0x00fa9800,
-       0x80008a80,
-       0x8c80018d,
-       0x038b8002,
-       0xf00190b6,
-       0xe9800794,
-       0x0231f404,
-/* 0x030c: send_done */
-       0x80fc90fc,
-/* 0x0312: find */
-       0x80f900f8,
-       0xf45887f0,
-/* 0x031a: find_loop */
-       0x8a980131,
-       0x06aeb800,
-       0xb6100bf4,
-       0x86b15880,
-       0x1bf40268,
-       0x0132f4f0,
-/* 0x0330: find_done */
-       0xfc028eb9,
-/* 0x0337: send */
-       0xf500f880,
-       0xf4031221,
-       0x00f89701,
-/* 0x0340: recv */
-       0x80f990f9,
-       0x9805e898,
-       0x32f404e9,
-       0x0689b801,
-       0xc43d0bf4,
-       0x80b60389,
-       0x0784f001,
-       0x9805e880,
-       0xf0f902ea,
-       0xf9018ffe,
-       0x02efb9f0,
-       0xbb049994,
-       0xe0b600e9,
-       0x03eb9818,
-       0x9802ec98,
-       0xee9801ed,
-       0xfca5f900,
-       0x00f8fef0,
-       0xfc0131f4,
-/* 0x038d: recv_done */
-       0xfc80fcf0,
-/* 0x0393: init */
-       0xf100f890,
-       0xb6010817,
-       0x11cf0614,
-       0x0911e700,
-       0x0814b601,
-       0xf10014fe,
-       0xf000e017,
-       0x07f00013,
-       0x0604b61c,
-       0xbd0001d0,
-       0xff17f004,
-       0xb61407f0,
-       0x01d00604,
-       0xf004bd00,
-       0x15f10217,
-       0x07f00800,
-       0x0604b610,
-       0xbd0001d0,
-       0x1a17f104,
-       0x0013f001,
-       0xf40010fe,
-       0x17f01031,
-       0x3807f001,
+/* 0x0392: init */
+       0x17f100f8,
+       0x14b60108,
+       0x0011cf06,
+       0x010911e7,
+       0xfe0814b6,
+       0x17f10014,
+       0x13f000e0,
+       0x1c07f000,
+       0xd00604b6,
+       0x04bd0001,
+       0xf0ff17f0,
+       0x04b61407,
+       0x0001d006,
+       0x17f004bd,
+       0x0015f102,
+       0x1007f008,
        0xd00604b6,
        0x04bd0001,
-/* 0x03f7: init_proc */
-       0x9858f7f0,
-       0x16b001f1,
-       0xfa0bf400,
-       0xf0b615f9,
-       0xf20ef458,
-/* 0x0408: mulu32_32_64 */
-       0x20f910f9,
-       0x40f930f9,
-       0x9510e195,
-       0xc4bd10d2,
-       0xedffb4bd,
-       0x301dffc0,
-       0xf10234b9,
-       0xb6ffff34,
-       0x45b61034,
-       0x00c3bb10,
-       0xff01b4bb,
-       0x34b930e2,
-       0xff34f102,
-       0x1034b6ff,
-       0xbb1045b6,
-       0xb4bb00c3,
-       0x3012ff01,
-       0xfc00b3bb,
-       0xfc30fc40,
-       0xf810fc20,
-/* 0x0459: host_send */
-       0xb017f100,
+       0x011917f1,
+       0xf10013f0,
+       0xfeffff14,
+       0x31f40010,
+       0x0117f010,
+       0xb63807f0,
+       0x01d00604,
+       0xf004bd00,
+/* 0x03fa: init_proc */
+       0xf19858f7,
+       0x0016b001,
+       0xf9fa0bf4,
+       0x58f0b615,
+/* 0x040b: mulu32_32_64 */
+       0xf9f20ef4,
+       0xf920f910,
+       0x9540f930,
+       0xd29510e1,
+       0xbdc4bd10,
+       0xc0edffb4,
+       0xb9301dff,
+       0x34f10234,
+       0x34b6ffff,
+       0x1045b610,
+       0xbb00c3bb,
+       0xe2ff01b4,
+       0x0234b930,
+       0xffff34f1,
+       0xb61034b6,
+       0xc3bb1045,
+       0x01b4bb00,
+       0xbb3012ff,
+       0x40fc00b3,
+       0x20fc30fc,
+       0x00f810fc,
+/* 0x045c: host_send */
+       0x04b017f1,
+       0xcf0614b6,
+       0x27f10011,
+       0x24b604a0,
+       0x0022cf06,
+       0xf40612b8,
+       0x1ec4320b,
+       0x04ee9407,
+       0x0270e0b7,
+       0x9803eb98,
+       0xed9802ec,
+       0x00ee9801,
+       0x033621f5,
+       0xc40110b6,
+       0x07f10f1e,
+       0x04b604b0,
+       0x000ed006,
+       0x0ef404bd,
+/* 0x04a5: host_send_done */
+/* 0x04a7: host_recv */
+       0xf100f8ba,
+       0xf14e4917,
+       0xb8525413,
+       0x0bf406e1,
+/* 0x04b5: host_recv_wait */
+       0xcc17f1aa,
        0x0614b604,
        0xf10011cf,
-       0xb604a027,
+       0xb604c827,
        0x22cf0624,
-       0x0612b800,
-       0xc4320bf4,
-       0xee94071e,
-       0x70e0b704,
-       0x03eb9802,
-       0x9802ec98,
-       0xee9801ed,
-       0x3721f500,
-       0x0110b603,
-       0xf10f1ec4,
-       0xb604b007,
-       0x0ed00604,
-       0xf404bd00,
-/* 0x04a2: host_send_done */
-       0x00f8ba0e,
-/* 0x04a4: host_recv */
-       0x4e4917f1,
-       0x525413f1,
-       0xf406e1b8,
-/* 0x04b2: host_recv_wait */
-       0x17f1aa0b,
-       0x14b604cc,
-       0x0011cf06,
-       0x04c827f1,
-       0xcf0624b6,
-       0x16f00022,
-       0x0612b808,
-       0xc4e60bf4,
-       0x34b60723,
-       0xf030b704,
-       0x033b8002,
-       0x80023c80,
-       0x3e80013d,
-       0x0120b600,
-       0xf10f24f0,
-       0xb604c807,
-       0x02d00604,
-       0xf004bd00,
-       0x07f04027,
-       0x0604b600,
-       0xbd0002d0,
-/* 0x0507: host_init */
-       0xf100f804,
-       0xb6008017,
-       0x15f11014,
-       0x07f10270,
-       0x04b604d0,
-       0x0001d006,
-       0x17f104bd,
+       0x0816f000,
+       0xf40612b8,
+       0x23c4e60b,
+       0x0434b607,
+       0x02f030b7,
+       0x80033b80,
+       0x3d80023c,
+       0x003e8001,
+       0xf00120b6,
+       0x07f10f24,
+       0x04b604c8,
+       0x0002d006,
+       0x27f004bd,
+       0x0007f040,
+       0xd00604b6,
+       0x04bd0002,
+/* 0x050a: host_init */
+       0x17f100f8,
        0x14b60080,
-       0xf015f110,
-       0xdc07f102,
+       0x7015f110,
+       0xd007f102,
        0x0604b604,
        0xbd0001d0,
-       0x0117f004,
-       0x04c407f1,
+       0x8017f104,
+       0x1014b600,
+       0x02f015f1,
+       0x04dc07f1,
        0xd00604b6,
        0x04bd0001,
-/* 0x0546: memx_func_enter */
-       0x67f100f8,
-       0x77f11620,
-       0x73f1f55d,
-       0x6eb9ffff,
-       0x0421f402,
-       0xfd02d8b9,
-       0x60f90487,
-       0xd0fc80f9,
-       0x21f4e0fc,
-       0xfe77f13f,
-       0xff73f1ff,
+       0xf10117f0,
+       0xb604c407,
+       0x01d00604,
+       0xf804bd00,
+/* 0x0549: memx_func_enter */
+       0x2067f100,
+       0x5d77f116,
+       0xff73f1f5,
        0x026eb9ff,
        0xb90421f4,
        0x87fd02d8,
        0xf960f904,
        0xfcd0fc80,
-       0x3f21f4e0,
-       0x26f067f1,
+       0x4021f4e0,
+       0xfffe77f1,
+       0xffff73f1,
        0xf4026eb9,
        0xd8b90421,
        0x0487fd02,
        0x80f960f9,
        0xe0fcd0fc,
-       0xf03f21f4,
+       0xf14021f4,
+       0xb926f067,
+       0x21f4026e,
+       0x02d8b904,
+       0xf90487fd,
+       0xfc80f960,
+       0xf4e0fcd0,
+       0x67f04021,
+       0xe007f104,
+       0x0604b607,
+       0xbd0006d0,
+/* 0x05b5: memx_func_enter_wait */
+       0xc067f104,
+       0x0664b607,
+       0xf00066cf,
+       0x0bf40464,
+       0x2c67f0f3,
+       0xcf0664b6,
+       0x06800066,
+/* 0x05d3: memx_func_leave */
+       0xf000f8f1,
+       0x64b62c67,
+       0x0066cf06,
+       0xf0f20680,
        0x07f10467,
-       0x04b607e0,
+       0x04b607e4,
        0x0006d006,
-/* 0x05b2: memx_func_enter_wait */
+/* 0x05ee: memx_func_leave_wait */
        0x67f104bd,
        0x64b607c0,
        0x0066cf06,
        0xf40464f0,
-       0x67f0f30b,
-       0x0664b62c,
-       0x800066cf,
-       0x00f8f106,
-/* 0x05d0: memx_func_leave */
-       0xb62c67f0,
-       0x66cf0664,
-       0xf2068000,
-       0xf10467f0,
-       0xb607e407,
-       0x06d00604,
-/* 0x05eb: memx_func_leave_wait */
-       0xf104bd00,
-       0xb607c067,
-       0x66cf0664,
-       0x0464f000,
-       0xf1f31bf4,
-       0xf126f067,
-       0xf0000177,
+       0x67f1f31b,
+       0x77f126f0,
+       0x73f00001,
+       0x026eb900,
+       0xb90421f4,
+       0x87fd02d8,
+       0xf960f905,
+       0xfcd0fc80,
+       0x4021f4e0,
+       0x162067f1,
+       0xf4026eb9,
+       0xd8b90421,
+       0x0587fd02,
+       0x80f960f9,
+       0xe0fcd0fc,
+       0xf14021f4,
+       0xf00aa277,
        0x6eb90073,
        0x0421f402,
        0xfd02d8b9,
        0x60f90587,
        0xd0fc80f9,
        0x21f4e0fc,
-       0x2067f13f,
-       0x026eb916,
-       0xb90421f4,
-       0x87fd02d8,
-       0xf960f905,
-       0xfcd0fc80,
-       0x3f21f4e0,
-       0x0aa277f1,
-       0xb90073f0,
-       0x21f4026e,
-       0x02d8b904,
-       0xf90587fd,
-       0xfc80f960,
-       0xf4e0fcd0,
-       0x00f83f21,
-/* 0x0658: memx_func_wait_vblank */
-       0xb0001698,
-       0x0bf40066,
-       0x0166b013,
-       0xf4060bf4,
-/* 0x066a: memx_func_wait_vblank_head1 */
-       0x77f12e0e,
-       0x0ef40020,
-/* 0x0671: memx_func_wait_vblank_head0 */
-       0x0877f107,
-/* 0x0675: memx_func_wait_vblank_0 */
-       0xc467f100,
-       0x0664b607,
-       0xfd0066cf,
-       0x1bf40467,
-/* 0x0685: memx_func_wait_vblank_1 */
-       0xc467f1f3,
-       0x0664b607,
-       0xfd0066cf,
-       0x0bf40467,
-/* 0x0695: memx_func_wait_vblank_fini */
-       0x0410b6f3,
-/* 0x069a: memx_func_wr32 */
-       0x169800f8,
-       0x01159800,
-       0xf90810b6,
-       0xfc50f960,
-       0xf4e0fcd0,
-       0x42b63f21,
-       0xe91bf402,
-/* 0x06b6: memx_func_wait */
-       0x87f000f8,
-       0x0684b62c,
-       0x980088cf,
-       0x1d98001e,
-       0x021c9801,
-       0xb6031b98,
-       0x21f41010,
-/* 0x06d3: memx_func_delay */
-       0x9800f8a4,
-       0x10b6001e,
-       0x7f21f404,
-/* 0x06de: memx_func_train */
-       0x00f800f8,
-/* 0x06e0: memx_exec */
-       0xd0f9e0f9,
-       0xb902c1b9,
-/* 0x06ea: memx_exec_next */
-       0x139802b2,
+/* 0x065b: memx_func_wait_vblank */
+       0x9800f840,
+       0x66b00016,
+       0x130bf400,
+       0xf40166b0,
+       0x0ef4060b,
+/* 0x066d: memx_func_wait_vblank_head1 */
+       0x2077f12e,
+       0x070ef400,
+/* 0x0674: memx_func_wait_vblank_head0 */
+       0x000877f1,
+/* 0x0678: memx_func_wait_vblank_0 */
+       0x07c467f1,
+       0xcf0664b6,
+       0x67fd0066,
+       0xf31bf404,
+/* 0x0688: memx_func_wait_vblank_1 */
+       0x07c467f1,
+       0xcf0664b6,
+       0x67fd0066,
+       0xf30bf404,
+/* 0x0698: memx_func_wait_vblank_fini */
+       0xf80410b6,
+/* 0x069d: memx_func_wr32 */
+       0x00169800,
+       0xb6011598,
+       0x60f90810,
+       0xd0fc50f9,
+       0x21f4e0fc,
+       0x0242b640,
+       0xf8e91bf4,
+/* 0x06b9: memx_func_wait */
+       0x2c87f000,
+       0xcf0684b6,
+       0x1e980088,
+       0x011d9800,
+       0x98021c98,
+       0x10b6031b,
+       0xa321f410,
+/* 0x06d6: memx_func_delay */
+       0x1e9800f8,
        0x0410b600,
-       0x01f034e7,
-       0x01e033e7,
-       0xf00132b6,
-       0x35980c30,
-       0xb855f9de,
-       0x1ef40612,
-       0xf10b98e4,
-       0xbbf20c98,
-       0xb7f102cb,
-       0xb4b607c4,
-       0x00bbcf06,
-       0xe0fcd0fc,
-       0x033721f5,
-/* 0x0726: memx_info */
-       0xc67000f8,
-       0x0e0bf401,
-/* 0x072c: memx_info_data */
-       0x03ccc7f1,
-       0x0800b7f1,
-/* 0x0737: memx_info_train */
-       0xf10b0ef4,
-       0xf10bccc7,
-/* 0x073f: memx_info_send */
-       0xf50100b7,
-       0xf8033721,
-/* 0x0745: memx_recv */
-       0x01d6b000,
-       0xb0980bf4,
-       0x0bf400d6,
-/* 0x0753: memx_init */
-       0xf800f8d8,
-/* 0x0755: perf_recv */
-/* 0x0757: perf_init */
-       0xf800f800,
-/* 0x0759: i2c_drive_scl */
-       0x0036b000,
-       0xf1110bf4,
-       0xb607e007,
-       0x01d00604,
-       0xf804bd00,
-/* 0x076d: i2c_drive_scl_lo */
-       0xe407f100,
-       0x0604b607,
-       0xbd0001d0,
-/* 0x077b: i2c_drive_sda */
-       0xb000f804,
-       0x0bf40036,
-       0xe007f111,
-       0x0604b607,
-       0xbd0002d0,
-/* 0x078f: i2c_drive_sda_lo */
-       0xf100f804,
-       0xb607e407,
-       0x02d00604,
-       0xf804bd00,
-/* 0x079d: i2c_sense_scl */
-       0x0132f400,
-       0x07c437f1,
-       0xcf0634b6,
-       0x31fd0033,
-       0x060bf404,
-/* 0x07b3: i2c_sense_scl_done */
-       0xf80131f4,
-/* 0x07b5: i2c_sense_sda */
-       0x0132f400,
-       0x07c437f1,
-       0xcf0634b6,
-       0x32fd0033,
-       0x060bf404,
-/* 0x07cb: i2c_sense_sda_done */
-       0xf80131f4,
-/* 0x07cd: i2c_raise_scl */
-       0xf140f900,
-       0xf0089847,
-       0x21f50137,
-/* 0x07da: i2c_raise_scl_wait */
-       0xe7f10759,
-       0x21f403e8,
-       0x9d21f57f,
-       0x0901f407,
-       0xf40142b6,
-/* 0x07ee: i2c_raise_scl_done */
-       0x40fcef1b,
-/* 0x07f2: i2c_start */
-       0x21f500f8,
-       0x11f4079d,
-       0xb521f50d,
-       0x0611f407,
-/* 0x0803: i2c_start_rep */
-       0xf0300ef4,
-       0x21f50037,
-       0x37f00759,
-       0x7b21f501,
-       0x0076bb07,
-       0xf90465b6,
-       0x04659450,
-       0xbd0256bb,
-       0x0475fd50,
-       0x21f550fc,
-       0x64b607cd,
-       0x1f11f404,
-/* 0x0830: i2c_start_send */
-       0xf50037f0,
-       0xf1077b21,
-       0xf41388e7,
-       0x37f07f21,
-       0x5921f500,
-       0x88e7f107,
-       0x7f21f413,
-/* 0x084c: i2c_start_out */
-/* 0x084e: i2c_stop */
-       0x37f000f8,
-       0x5921f500,
-       0x0037f007,
-       0x077b21f5,
-       0x03e8e7f1,
-       0xf07f21f4,
-       0x21f50137,
-       0xe7f10759,
-       0x21f41388,
-       0x0137f07f,
-       0x077b21f5,
-       0x1388e7f1,
-       0xf87f21f4,
-/* 0x0881: i2c_bitw */
-       0x7b21f500,
-       0xe8e7f107,
-       0x7f21f403,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0xcd21f550,
-       0x0464b607,
-       0xf11811f4,
-       0xf41388e7,
-       0x37f07f21,
-       0x5921f500,
-       0x88e7f107,
-       0x7f21f413,
-/* 0x08c0: i2c_bitw_out */
-/* 0x08c2: i2c_bitr */
-       0x37f000f8,
-       0x7b21f501,
+       0xf87e21f4,
+/* 0x06e1: memx_func_train */
+/* 0x06e3: memx_exec */
+       0xf900f800,
+       0xb9d0f9e0,
+       0xb2b902c1,
+/* 0x06ed: memx_exec_next */
+       0x00139802,
+       0xe70410b6,
+       0xe701f034,
+       0xb601e033,
+       0x30f00132,
+       0xde35980c,
+       0x12b855f9,
+       0xe41ef406,
+       0x98f10b98,
+       0xcbbbf20c,
+       0xc4b7f102,
+       0x06b4b607,
+       0xfc00bbcf,
+       0xf5e0fcd0,
+       0xf8033621,
+/* 0x0729: memx_info */
+       0x01c67000,
+/* 0x072f: memx_info_data */
+       0xf10e0bf4,
+       0xf103ccc7,
+       0xf40800b7,
+/* 0x073a: memx_info_train */
+       0xc7f10b0e,
+       0xb7f10bcc,
+/* 0x0742: memx_info_send */
+       0x21f50100,
+       0x00f80336,
+/* 0x0748: memx_recv */
+       0xf401d6b0,
+       0xd6b0980b,
+       0xd80bf400,
+/* 0x0756: memx_init */
+       0x00f800f8,
+/* 0x0758: perf_recv */
+/* 0x075a: perf_init */
+       0x00f800f8,
+/* 0x075c: i2c_drive_scl */
+       0xf40036b0,
+       0x07f1110b,
+       0x04b607e0,
+       0x0001d006,
+       0x00f804bd,
+/* 0x0770: i2c_drive_scl_lo */
+       0x07e407f1,
+       0xd00604b6,
+       0x04bd0001,
+/* 0x077e: i2c_drive_sda */
+       0x36b000f8,
+       0x110bf400,
+       0x07e007f1,
+       0xd00604b6,
+       0x04bd0002,
+/* 0x0792: i2c_drive_sda_lo */
+       0x07f100f8,
+       0x04b607e4,
+       0x0002d006,
+       0x00f804bd,
+/* 0x07a0: i2c_sense_scl */
+       0xf10132f4,
+       0xb607c437,
+       0x33cf0634,
+       0x0431fd00,
+       0xf4060bf4,
+/* 0x07b6: i2c_sense_scl_done */
+       0x00f80131,
+/* 0x07b8: i2c_sense_sda */
+       0xf10132f4,
+       0xb607c437,
+       0x33cf0634,
+       0x0432fd00,
+       0xf4060bf4,
+/* 0x07ce: i2c_sense_sda_done */
+       0x00f80131,
+/* 0x07d0: i2c_raise_scl */
+       0x47f140f9,
+       0x37f00898,
+       0x5c21f501,
+/* 0x07dd: i2c_raise_scl_wait */
        0xe8e7f107,
-       0x7f21f403,
+       0x7e21f403,
+       0x07a021f5,
+       0xb60901f4,
+       0x1bf40142,
+/* 0x07f1: i2c_raise_scl_done */
+       0xf840fcef,
+/* 0x07f5: i2c_start */
+       0xa021f500,
+       0x0d11f407,
+       0x07b821f5,
+       0xf40611f4,
+/* 0x0806: i2c_start_rep */
+       0x37f0300e,
+       0x5c21f500,
+       0x0137f007,
+       0x077e21f5,
        0xb60076bb,
        0x50f90465,
        0xbb046594,
        0x50bd0256,
        0xfc0475fd,
-       0xcd21f550,
+       0xd021f550,
        0x0464b607,
-       0xf51b11f4,
-       0xf007b521,
+/* 0x0833: i2c_start_send */
+       0xf01f11f4,
        0x21f50037,
-       0xe7f10759,
+       0xe7f1077e,
        0x21f41388,
-       0x013cf07f,
-/* 0x0907: i2c_bitr_done */
-       0xf80131f4,
-/* 0x0909: i2c_get_byte */
-       0x0057f000,
-/* 0x090f: i2c_get_byte_next */
-       0xb60847f0,
-       0x76bb0154,
-       0x0465b600,
-       0x659450f9,
-       0x0256bb04,
-       0x75fd50bd,
-       0xf550fc04,
-       0xb608c221,
-       0x11f40464,
-       0x0553fd2b,
-       0xf40142b6,
-       0x37f0d81b,
+       0x0037f07e,
+       0x075c21f5,
+       0x1388e7f1,
+/* 0x084f: i2c_start_out */
+       0xf87e21f4,
+/* 0x0851: i2c_stop */
+       0x0037f000,
+       0x075c21f5,
+       0xf50037f0,
+       0xf1077e21,
+       0xf403e8e7,
+       0x37f07e21,
+       0x5c21f501,
+       0x88e7f107,
+       0x7e21f413,
+       0xf50137f0,
+       0xf1077e21,
+       0xf41388e7,
+       0x00f87e21,
+/* 0x0884: i2c_bitw */
+       0x077e21f5,
+       0x03e8e7f1,
+       0xbb7e21f4,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x07d021f5,
+       0xf40464b6,
+       0xe7f11811,
+       0x21f41388,
+       0x0037f07e,
+       0x075c21f5,
+       0x1388e7f1,
+/* 0x08c3: i2c_bitw_out */
+       0xf87e21f4,
+/* 0x08c5: i2c_bitr */
+       0x0137f000,
+       0x077e21f5,
+       0x03e8e7f1,
+       0xbb7e21f4,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x07d021f5,
+       0xf40464b6,
+       0x21f51b11,
+       0x37f007b8,
+       0x5c21f500,
+       0x88e7f107,
+       0x7e21f413,
+       0xf4013cf0,
+/* 0x090a: i2c_bitr_done */
+       0x00f80131,
+/* 0x090c: i2c_get_byte */
+       0xf00057f0,
+/* 0x0912: i2c_get_byte_next */
+       0x54b60847,
        0x0076bb01,
        0xf90465b6,
        0x04659450,
        0xbd0256bb,
        0x0475fd50,
        0x21f550fc,
-       0x64b60881,
-/* 0x0959: i2c_get_byte_done */
-/* 0x095b: i2c_put_byte */
-       0xf000f804,
-/* 0x095e: i2c_put_byte_next */
-       0x42b60847,
-       0x3854ff01,
+       0x64b608c5,
+       0x2b11f404,
+       0xb60553fd,
+       0x1bf40142,
+       0x0137f0d8,
+       0xb60076bb,
+       0x50f90465,
+       0xbb046594,
+       0x50bd0256,
+       0xfc0475fd,
+       0x8421f550,
+       0x0464b608,
+/* 0x095c: i2c_get_byte_done */
+/* 0x095e: i2c_put_byte */
+       0x47f000f8,
+/* 0x0961: i2c_put_byte_next */
+       0x0142b608,
+       0xbb3854ff,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x088421f5,
+       0xf40464b6,
+       0x46b03411,
+       0xd81bf400,
        0xb60076bb,
        0x50f90465,
        0xbb046594,
        0x50bd0256,
        0xfc0475fd,
-       0x8121f550,
+       0xc521f550,
        0x0464b608,
-       0xb03411f4,
-       0x1bf40046,
-       0x0076bbd8,
+       0xbb0f11f4,
+       0x36b00076,
+       0x061bf401,
+/* 0x09b7: i2c_put_byte_done */
+       0xf80132f4,
+/* 0x09b9: i2c_addr */
+       0x0076bb00,
        0xf90465b6,
        0x04659450,
        0xbd0256bb,
        0x0475fd50,
        0x21f550fc,
-       0x64b608c2,
-       0x0f11f404,
-       0xb00076bb,
-       0x1bf40136,
-       0x0132f406,
-/* 0x09b4: i2c_put_byte_done */
-/* 0x09b6: i2c_addr */
-       0x76bb00f8,
+       0x64b607f5,
+       0x2911f404,
+       0x012ec3e7,
+       0xfd0134b6,
+       0x76bb0553,
        0x0465b600,
        0x659450f9,
        0x0256bb04,
        0x75fd50bd,
        0xf550fc04,
-       0xb607f221,
-       0x11f40464,
-       0x2ec3e729,
-       0x0134b601,
-       0xbb0553fd,
+       0xb6095e21,
+/* 0x09fe: i2c_addr_done */
+       0x00f80464,
+/* 0x0a00: i2c_acquire_addr */
+       0xb6f8cec7,
+       0xe0b702e4,
+       0xee980d1c,
+/* 0x0a0f: i2c_acquire */
+       0xf500f800,
+       0xf40a0021,
+       0xd9f00421,
+       0x4021f403,
+/* 0x0a1e: i2c_release */
+       0x21f500f8,
+       0x21f40a00,
+       0x03daf004,
+       0xf84021f4,
+/* 0x0a2d: i2c_recv */
+       0x0132f400,
+       0xb6f8c1c7,
+       0x16b00214,
+       0x3a1ff528,
+       0xf413a001,
+       0x0032980c,
+       0x0ccc13a0,
+       0xf4003198,
+       0xd0f90231,
+       0xd0f9e0f9,
+       0x000067f1,
+       0x100063f1,
+       0xbb016792,
        0x65b60076,
        0x9450f904,
        0x56bb0465,
        0xfd50bd02,
        0x50fc0475,
-       0x095b21f5,
-/* 0x09fb: i2c_addr_done */
-       0xf80464b6,
-/* 0x09fd: i2c_acquire_addr */
-       0xf8cec700,
-       0xb702e4b6,
-       0x980d1ce0,
-       0x00f800ee,
-/* 0x0a0c: i2c_acquire */
-       0x09fd21f5,
-       0xf00421f4,
-       0x21f403d9,
-/* 0x0a1b: i2c_release */
-       0xf500f83f,
-       0xf409fd21,
-       0xdaf00421,
-       0x3f21f403,
-/* 0x0a2a: i2c_recv */
-       0x32f400f8,
-       0xf8c1c701,
-       0xb00214b6,
-       0x1ff52816,
-       0x13a0013a,
-       0x32980cf4,
-       0xcc13a000,
-       0x0031980c,
-       0xf90231f4,
-       0xf9e0f9d0,
-       0x0067f1d0,
-       0x0063f100,
-       0x01679210,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0x0c21f550,
-       0x0464b60a,
-       0xd6b0d0fc,
-       0xb31bf500,
-       0x0057f000,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0xb621f550,
-       0x0464b609,
-       0x00d011f5,
-       0xbbe0c5c7,
+       0x0a0f21f5,
+       0xfc0464b6,
+       0x00d6b0d0,
+       0x00b31bf5,
+       0xbb0057f0,
        0x65b60076,
        0x9450f904,
        0x56bb0465,
        0xfd50bd02,
        0x50fc0475,
-       0x095b21f5,
+       0x09b921f5,
        0xf50464b6,
-       0xf000ad11,
-       0x76bb0157,
+       0xc700d011,
+       0x76bbe0c5,
        0x0465b600,
        0x659450f9,
        0x0256bb04,
        0x75fd50bd,
        0xf550fc04,
-       0xb609b621,
+       0xb6095e21,
        0x11f50464,
-       0x76bb008a,
-       0x0465b600,
-       0x659450f9,
-       0x0256bb04,
-       0x75fd50bd,
-       0xf550fc04,
-       0xb6090921,
-       0x11f40464,
-       0xe05bcb6a,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0x4e21f550,
-       0x0464b608,
-       0xbd025bb9,
-       0x430ef474,
-/* 0x0b30: i2c_recv_not_rd08 */
-       0xf401d6b0,
-       0x57f03d1b,
-       0xb621f500,
-       0x3311f409,
-       0xf5e0c5c7,
-       0xf4095b21,
-       0x57f02911,
-       0xb621f500,
-       0x1f11f409,
-       0xf5e0b5c7,
-       0xf4095b21,
-       0x21f51511,
-       0x74bd084e,
-       0xf408c5c7,
-       0x32f4091b,
-       0x030ef402,
-/* 0x0b70: i2c_recv_not_wr08 */
-/* 0x0b70: i2c_recv_done */
-       0xf5f8cec7,
-       0xfc0a1b21,
-       0xf4d0fce0,
-       0x7cb90a12,
-       0x3721f502,
-/* 0x0b85: i2c_recv_exit */
-/* 0x0b87: i2c_init */
-       0xf800f803,
-/* 0x0b89: test_recv */
-       0xd817f100,
-       0x0614b605,
-       0xb60011cf,
-       0x07f10110,
-       0x04b605d8,
-       0x0001d006,
-       0xe7f104bd,
-       0xe3f1d900,
-       0x21f5134f,
-       0x00f80257,
-/* 0x0bb0: test_init */
-       0x0800e7f1,
-       0x025721f5,
-/* 0x0bba: idle_recv */
+       0x57f000ad,
+       0x0076bb01,
+       0xf90465b6,
+       0x04659450,
+       0xbd0256bb,
+       0x0475fd50,
+       0x21f550fc,
+       0x64b609b9,
+       0x8a11f504,
+       0x0076bb00,
+       0xf90465b6,
+       0x04659450,
+       0xbd0256bb,
+       0x0475fd50,
+       0x21f550fc,
+       0x64b6090c,
+       0x6a11f404,
+       0xbbe05bcb,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x085121f5,
+       0xb90464b6,
+       0x74bd025b,
+/* 0x0b33: i2c_recv_not_rd08 */
+       0xb0430ef4,
+       0x1bf401d6,
+       0x0057f03d,
+       0x09b921f5,
+       0xc73311f4,
+       0x21f5e0c5,
+       0x11f4095e,
+       0x0057f029,
+       0x09b921f5,
+       0xc71f11f4,
+       0x21f5e0b5,
+       0x11f4095e,
+       0x5121f515,
+       0xc774bd08,
+       0x1bf408c5,
+       0x0232f409,
+/* 0x0b73: i2c_recv_not_wr08 */
+/* 0x0b73: i2c_recv_done */
+       0xc7030ef4,
+       0x21f5f8ce,
+       0xe0fc0a1e,
+       0x12f4d0fc,
+       0x027cb90a,
+       0x033621f5,
+/* 0x0b88: i2c_recv_exit */
+/* 0x0b8a: i2c_init */
        0x00f800f8,
-/* 0x0bbc: idle */
-       0xf10031f4,
-       0xb605d417,
-       0x11cf0614,
-       0x0110b600,
-       0x05d407f1,
-       0xd00604b6,
-       0x04bd0001,
-/* 0x0bd8: idle_loop */
-       0xf45817f0,
-/* 0x0bde: idle_proc */
-/* 0x0bde: idle_proc_exec */
-       0x10f90232,
-       0xf5021eb9,
-       0xfc034021,
-       0x0911f410,
-       0xf40231f4,
-/* 0x0bf2: idle_proc_next */
-       0x10b6ef0e,
-       0x061fb858,
-       0xf4e61bf4,
-       0x28f4dd02,
-       0xbb0ef400,
-       0x00000000,
+/* 0x0b8c: test_recv */
+       0x05d817f1,
+       0xcf0614b6,
+       0x10b60011,
+       0xd807f101,
+       0x0604b605,
+       0xbd0001d0,
+       0x00e7f104,
+       0x4fe3f1d9,
+       0x5621f513,
+/* 0x0bb3: test_init */
+       0xf100f802,
+       0xf50800e7,
+       0xf8025621,
+/* 0x0bbd: idle_recv */
+/* 0x0bbf: idle */
+       0xf400f800,
+       0x17f10031,
+       0x14b605d4,
+       0x0011cf06,
+       0xf10110b6,
+       0xb605d407,
+       0x01d00604,
+/* 0x0bdb: idle_loop */
+       0xf004bd00,
+       0x32f45817,
+/* 0x0be1: idle_proc */
+/* 0x0be1: idle_proc_exec */
+       0xb910f902,
+       0x21f5021e,
+       0x10fc033f,
+       0xf40911f4,
+       0x0ef40231,
+/* 0x0bf5: idle_proc_next */
+       0x5810b6ef,
+       0xf4061fb8,
+       0x02f4e61b,
+       0x0028f4dd,
+       0x00bb0ef4,
        0x00000000,
        0x00000000,
        0x00000000,
index 7bf6b39..2d5bdc5 100644 (file)
@@ -24,8 +24,8 @@ uint32_t gf119_pmu_data[] = {
        0x00000000,
 /* 0x0058: proc_list_head */
        0x54534f48,
-       0x00000492,
-       0x0000043b,
+       0x00000495,
+       0x0000043e,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -46,8 +46,8 @@ uint32_t gf119_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x584d454d,
-       0x00000680,
-       0x00000672,
+       0x00000683,
+       0x00000675,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -68,8 +68,8 @@ uint32_t gf119_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x46524550,
-       0x00000684,
-       0x00000682,
+       0x00000687,
+       0x00000685,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -90,8 +90,8 @@ uint32_t gf119_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x5f433249,
-       0x00000a9f,
-       0x00000942,
+       0x00000aa2,
+       0x00000945,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -112,8 +112,8 @@ uint32_t gf119_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x54534554,
-       0x00000ac2,
-       0x00000aa1,
+       0x00000ac5,
+       0x00000aa4,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -134,8 +134,8 @@ uint32_t gf119_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x454c4449,
-       0x00000ace,
-       0x00000acc,
+       0x00000ad1,
+       0x00000acf,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -229,26 +229,26 @@ uint32_t gf119_pmu_data[] = {
 /* 0x0370: memx_func_head */
        0x00000001,
        0x00000000,
-       0x000004c8,
+       0x000004cb,
 /* 0x037c: memx_func_next */
        0x00000002,
        0x00000000,
-       0x00000549,
+       0x0000054c,
        0x00000003,
        0x00000002,
-       0x000005cd,
+       0x000005d0,
        0x00040004,
        0x00000000,
-       0x000005e9,
+       0x000005ec,
        0x00010005,
        0x00000000,
-       0x00000603,
+       0x00000606,
        0x00010006,
        0x00000000,
-       0x000005c8,
+       0x000005cb,
        0x00000007,
        0x00000000,
-       0x0000060e,
+       0x00000611,
 /* 0x03c4: memx_func_tail */
 /* 0x03c4: memx_ts_start */
        0x00000000,
@@ -916,821 +916,821 @@ uint32_t gf119_pmu_data[] = {
 };
 
 uint32_t gf119_pmu_code[] = {
-       0x03420ef5,
+       0x03410ef5,
 /* 0x0004: rd32 */
        0x07a007f1,
        0xbd000ed0,
-       0x01d7f004,
-       0xf101d3f0,
-       0xd007ac07,
-       0x04bd000d,
-/* 0x001c: rd32_wait */
-       0x07acd7f1,
-       0xf100ddcf,
-       0xf47000d4,
-       0xd7f1f51b,
-       0xddcf07a4,
-/* 0x0033: wr32 */
-       0xf100f800,
-       0xd007a007,
-       0x04bd000e,
-       0x07a407f1,
+       0x01d7f104,
+       0x01d3f000,
+       0x07ac07f1,
        0xbd000dd0,
-       0x02d7f004,
-       0xf0f0d5f0,
-       0x07f101d3,
-       0x0dd007ac,
-/* 0x0057: wr32_wait */
-       0xf104bd00,
-       0xcf07acd7,
-       0xd4f100dd,
-       0x1bf47000,
-/* 0x0067: nsec */
-       0xf900f8f5,
-       0xf080f990,
-       0x88cf2c87,
-/* 0x0071: nsec_loop */
-       0x2c97f000,
-       0xbb0099cf,
-       0x9eb80298,
-       0xf41ef406,
-       0x90fc80fc,
-/* 0x0086: wait */
+/* 0x001d: rd32_wait */
+       0xacd7f104,
+       0x00ddcf07,
+       0x7000d4f1,
+       0xf1f51bf4,
+       0xcf07a4d7,
+       0x00f800dd,
+/* 0x0034: wr32 */
+       0x07a007f1,
+       0xbd000ed0,
+       0xa407f104,
+       0x000dd007,
+       0xd7f104bd,
+       0xd3f000f2,
+       0xac07f101,
+       0x000dd007,
+/* 0x0056: wr32_wait */
+       0xd7f104bd,
+       0xddcf07ac,
+       0x00d4f100,
+       0xf51bf470,
+/* 0x0066: nsec */
        0x90f900f8,
        0x87f080f9,
        0x0088cf2c,
-/* 0x0090: wait_loop */
-       0xf402eeb9,
-       0xdab90421,
-       0x04adfd02,
-       0xf406acb8,
-       0x97f0120b,
-       0x0099cf2c,
-       0xb80298bb,
-       0x1ef4069b,
-/* 0x00b1: wait_done */
-       0xfc80fce2,
-/* 0x00b7: intr_watchdog */
-       0x9800f890,
-       0x96b003e9,
-       0x2a0bf400,
-       0xbb9a0a98,
-       0x1cf4029a,
-       0x01d7f00f,
-       0x028121f5,
-       0x0ef494bd,
-/* 0x00d5: intr_watchdog_next_time */
-       0x9b0a9815,
-       0xf400a6b0,
-       0x9ab8090b,
-       0x061cf406,
-/* 0x00e4: intr_watchdog_next_time_set */
-/* 0x00e7: intr_watchdog_next_proc */
-       0x809b0980,
-       0xe0b603e9,
-       0x68e6b158,
-       0xc61bf402,
-/* 0x00f6: intr */
-       0x00f900f8,
-       0x80f904bd,
-       0xa0f990f9,
-       0xc0f9b0f9,
-       0xe0f9d0f9,
-       0xf7f0f0f9,
-       0x0188fe00,
-       0x87f180f9,
-       0x88cf05d0,
-       0x0180b600,
-       0x05d007f1,
-       0xbd0008d0,
-       0x0887f004,
-       0xc40088cf,
-       0x0bf40289,
-       0x9b008020,
-       0xf458e7f0,
-       0x0998b721,
-       0x0096b09b,
-       0xf00e0bf4,
-       0x09d03407,
-       0x8004bd00,
-/* 0x014e: intr_skip_watchdog */
-       0x89e49a09,
-       0x0bf40800,
-       0x8897f13c,
-       0x0099cf06,
-       0xf4029ac4,
-       0xc7f1260b,
-       0xcccf04c0,
-       0xf1c0f900,
-       0xf14f48e7,
-       0xf05453e3,
-       0x21f500d7,
-       0xc0fc02e6,
-       0x04c007f1,
-       0xbd000cd0,
-/* 0x0185: intr_subintr_skip_fifo */
-       0x8807f104,
-       0x0009d006,
-/* 0x018e: intr_skip_subintr */
-       0x97f104bd,
-       0x90bd00e0,
-       0xf00489fd,
-       0x08d00407,
-       0xfc04bd00,
-       0x0088fe80,
-       0xe0fcf0fc,
-       0xc0fcd0fc,
-       0xa0fcb0fc,
-       0x80fc90fc,
-       0x32f400fc,
-/* 0x01bb: ticks_from_ns */
-       0xf901f800,
+/* 0x0070: nsec_loop */
+       0xcf2c97f0,
+       0x98bb0099,
+       0x069eb802,
+       0xfcf41ef4,
+       0xf890fc80,
+/* 0x0085: wait */
+       0xf990f900,
+       0x2c87f080,
+/* 0x008f: wait_loop */
+       0xb90088cf,
+       0x21f402ee,
+       0x02dab904,
+       0xb804adfd,
+       0x0bf406ac,
+       0x2c97f012,
+       0xbb0099cf,
+       0x9bb80298,
+       0xe21ef406,
+/* 0x00b0: wait_done */
+       0x90fc80fc,
+/* 0x00b6: intr_watchdog */
+       0xe99800f8,
+       0x0096b003,
+       0x982a0bf4,
+       0x9abb9a0a,
+       0x0f1cf402,
+       0xf501d7f0,
+       0xbd028021,
+       0x150ef494,
+/* 0x00d4: intr_watchdog_next_time */
+       0xb09b0a98,
+       0x0bf400a6,
+       0x069ab809,
+/* 0x00e3: intr_watchdog_next_time_set */
+       0x80061cf4,
+/* 0x00e6: intr_watchdog_next_proc */
+       0xe9809b09,
+       0x58e0b603,
+       0x0268e6b1,
+       0xf8c61bf4,
+/* 0x00f5: intr */
+       0xbd00f900,
+       0xf980f904,
+       0xf9a0f990,
+       0xf9c0f9b0,
+       0xf9e0f9d0,
+       0x00f7f0f0,
+       0xf90188fe,
+       0xd087f180,
+       0x0088cf05,
+       0xf10180b6,
+       0xd005d007,
+       0x04bd0008,
+       0xcf0887f0,
+       0x89c40088,
+       0x200bf402,
+       0xf09b0080,
+       0x21f458e7,
+       0x9b0998b6,
+       0xf40096b0,
+       0x07f00e0b,
+       0x0009d034,
+       0x098004bd,
+/* 0x014d: intr_skip_watchdog */
+       0x0089e49a,
+       0x3c0bf408,
+       0x068897f1,
+       0xc40099cf,
+       0x0bf4029a,
+       0xc0c7f126,
+       0x00cccf04,
+       0xe7f1c0f9,
+       0xe3f14f48,
+       0xd7f05453,
+       0xe521f500,
+       0xf1c0fc02,
+       0xd004c007,
+       0x04bd000c,
+/* 0x0184: intr_subintr_skip_fifo */
+       0x068807f1,
+       0xbd0009d0,
+/* 0x018d: intr_skip_subintr */
+       0xe097f104,
+       0xfd90bd00,
+       0x07f00489,
+       0x0008d004,
+       0x80fc04bd,
+       0xfc0088fe,
+       0xfce0fcf0,
+       0xfcc0fcd0,
+       0xfca0fcb0,
+       0xfc80fc90,
+       0x0032f400,
+/* 0x01ba: ticks_from_ns */
+       0xc0f901f8,
+       0xd7f1b0f9,
+       0xd3f00144,
+       0xab21f500,
+       0xe8ccec03,
+       0x00b4b003,
+       0xec120bf4,
+       0xf103e8ee,
+       0xf00144d7,
+       0x21f500d3,
+/* 0x01e2: ticks_from_ns_quit */
+       0xceb903ab,
+       0xfcb0fc02,
+/* 0x01eb: ticks_from_us */
+       0xf900f8c0,
        0xf1b0f9c0,
        0xf00144d7,
        0x21f500d3,
-       0xccec03a8,
-       0xb4b003e8,
-       0x120bf400,
-       0x03e8eeec,
-       0x0144d7f1,
-       0xf500d3f0,
-/* 0x01e3: ticks_from_ns_quit */
-       0xb903a821,
-       0xb0fc02ce,
-       0x00f8c0fc,
-/* 0x01ec: ticks_from_us */
-       0xb0f9c0f9,
-       0x0144d7f1,
-       0xf500d3f0,
-       0xb903a821,
-       0xb4b002ce,
-       0x050bf400,
-/* 0x0206: ticks_from_us_quit */
-       0xb0fce4bd,
-       0x00f8c0fc,
-/* 0x020c: ticks_to_us */
-       0x0144d7f1,
-       0xff00d3f0,
-       0x00f8eced,
-/* 0x0218: timer */
-       0x80f990f9,
-       0x981032f4,
-       0x86b003f8,
-       0x531cf400,
-       0x07f084bd,
-       0x0008d038,
-       0x87f004bd,
-       0x0088cf34,
-       0xbb9a0998,
-       0xe9bb0298,
-       0x03fe8000,
-       0xcf0887f0,
-       0x84f00088,
-       0x201bf402,
-       0xcf3487f0,
-       0xe0b80088,
-       0x090bf406,
-       0xf406e8b8,
-/* 0x0262: timer_reset */
-       0x07f00e1c,
-       0x000ed034,
-       0x0e8004bd,
-/* 0x026d: timer_enable */
-       0x0187f09a,
-       0xd03807f0,
-       0x04bd0008,
-/* 0x0278: timer_done */
-       0xfc1031f4,
+       0xceb903ab,
+       0x00b4b002,
+       0xbd050bf4,
+/* 0x0205: ticks_from_us_quit */
+       0xfcb0fce4,
+/* 0x020b: ticks_to_us */
+       0xf100f8c0,
+       0xf00144d7,
+       0xedff00d3,
+/* 0x0217: timer */
+       0xf900f8ec,
+       0xf480f990,
+       0xf8981032,
+       0x0086b003,
+       0xbd531cf4,
+       0x3807f084,
+       0xbd0008d0,
+       0x3487f004,
+       0x980088cf,
+       0x98bb9a09,
+       0x00e9bb02,
+       0xf003fe80,
+       0x88cf0887,
+       0x0284f000,
+       0xf0201bf4,
+       0x88cf3487,
+       0x06e0b800,
+       0xb8090bf4,
+       0x1cf406e8,
+/* 0x0261: timer_reset */
+       0x3407f00e,
+       0xbd000ed0,
+       0x9a0e8004,
+/* 0x026c: timer_enable */
+       0xf00187f0,
+       0x08d03807,
+/* 0x0277: timer_done */
+       0xf404bd00,
+       0x80fc1031,
+       0x00f890fc,
+/* 0x0280: send_proc */
+       0x90f980f9,
+       0x9805e898,
+       0x86f004e9,
+       0x0689b804,
+       0xc42a0bf4,
+       0x88940398,
+       0x1880b604,
+       0x98008ebb,
+       0x8a8000fa,
+       0x018d8000,
+       0x80028c80,
+       0x90b6038b,
+       0x0794f001,
+       0xf404e980,
+/* 0x02ba: send_done */
+       0x90fc0231,
+       0x00f880fc,
+/* 0x02c0: find */
+       0x87f080f9,
+       0x0131f458,
+/* 0x02c8: find_loop */
+       0xb8008a98,
+       0x0bf406ae,
+       0x5880b610,
+       0x026886b1,
+       0xf4f01bf4,
+/* 0x02de: find_done */
+       0x8eb90132,
+       0xf880fc02,
+/* 0x02e5: send */
+       0xc021f500,
+       0x9701f402,
+/* 0x02ee: recv */
+       0x90f900f8,
+       0xe89880f9,
+       0x04e99805,
+       0xb80132f4,
+       0x0bf40689,
+       0x0389c43d,
+       0xf00180b6,
+       0xe8800784,
+       0x02ea9805,
+       0x8ffef0f9,
+       0xb9f0f901,
+       0x999402ef,
+       0x00e9bb04,
+       0x9818e0b6,
+       0xec9803eb,
+       0x01ed9802,
+       0xf900ee98,
+       0xfef0fca5,
+       0x31f400f8,
+/* 0x033b: recv_done */
+       0xfcf0fc01,
        0xf890fc80,
-/* 0x0281: send_proc */
-       0xf980f900,
-       0x05e89890,
-       0xf004e998,
-       0x89b80486,
-       0x2a0bf406,
-       0x940398c4,
-       0x80b60488,
-       0x008ebb18,
-       0x8000fa98,
-       0x8d80008a,
-       0x028c8001,
-       0xb6038b80,
-       0x94f00190,
-       0x04e98007,
-/* 0x02bb: send_done */
-       0xfc0231f4,
-       0xf880fc90,
-/* 0x02c1: find */
-       0xf080f900,
-       0x31f45887,
-/* 0x02c9: find_loop */
-       0x008a9801,
-       0xf406aeb8,
-       0x80b6100b,
-       0x6886b158,
-       0xf01bf402,
-/* 0x02df: find_done */
-       0xb90132f4,
-       0x80fc028e,
-/* 0x02e6: send */
-       0x21f500f8,
-       0x01f402c1,
-/* 0x02ef: recv */
-       0xf900f897,
-       0x9880f990,
-       0xe99805e8,
-       0x0132f404,
-       0xf40689b8,
-       0x89c43d0b,
-       0x0180b603,
-       0x800784f0,
-       0xea9805e8,
-       0xfef0f902,
-       0xf0f9018f,
-       0x9402efb9,
-       0xe9bb0499,
-       0x18e0b600,
-       0x9803eb98,
-       0xed9802ec,
-       0x00ee9801,
-       0xf0fca5f9,
-       0xf400f8fe,
-       0xf0fc0131,
-/* 0x033c: recv_done */
-       0x90fc80fc,
-/* 0x0342: init */
-       0x17f100f8,
-       0x11cf0108,
-       0x0911e700,
-       0x0814b601,
-       0xf10014fe,
-       0xf000e017,
-       0x07f00013,
-       0x0001d01c,
-       0x17f004bd,
-       0x1407f0ff,
+/* 0x0341: init */
+       0x0817f100,
+       0x0011cf01,
+       0x010911e7,
+       0xfe0814b6,
+       0x17f10014,
+       0x13f000e0,
+       0x1c07f000,
        0xbd0001d0,
-       0x0217f004,
-       0x080015f1,
-       0xd01007f0,
-       0x04bd0001,
-       0x00f617f1,
-       0xfe0013f0,
-       0x31f40010,
-       0x0117f010,
-       0xd03807f0,
+       0xff17f004,
+       0xd01407f0,
        0x04bd0001,
-/* 0x0397: init_proc */
-       0x9858f7f0,
-       0x16b001f1,
-       0xfa0bf400,
-       0xf0b615f9,
-       0xf20ef458,
-/* 0x03a8: mulu32_32_64 */
-       0x20f910f9,
-       0x40f930f9,
-       0x9510e195,
-       0xc4bd10d2,
-       0xedffb4bd,
-       0x301dffc0,
-       0xf10234b9,
-       0xb6ffff34,
-       0x45b61034,
-       0x00c3bb10,
-       0xff01b4bb,
-       0x34b930e2,
-       0xff34f102,
-       0x1034b6ff,
-       0xbb1045b6,
-       0xb4bb00c3,
-       0x3012ff01,
-       0xfc00b3bb,
-       0xfc30fc40,
-       0xf810fc20,
-/* 0x03f9: host_send */
-       0xb017f100,
-       0x0011cf04,
-       0x04a027f1,
-       0xb80022cf,
-       0x0bf40612,
-       0x071ec42f,
-       0xb704ee94,
-       0x980270e0,
-       0xec9803eb,
-       0x01ed9802,
-       0xf500ee98,
-       0xb602e621,
-       0x1ec40110,
-       0xb007f10f,
-       0x000ed004,
-       0x0ef404bd,
-/* 0x0439: host_send_done */
-/* 0x043b: host_recv */
-       0xf100f8c3,
-       0xf14e4917,
-       0xb8525413,
-       0x0bf406e1,
-/* 0x0449: host_recv_wait */
-       0xcc17f1b3,
-       0x0011cf04,
-       0x04c827f1,
-       0xf00022cf,
-       0x12b80816,
-       0xec0bf406,
-       0xb60723c4,
-       0x30b70434,
-       0x3b8002f0,
-       0x023c8003,
-       0x80013d80,
-       0x20b6003e,
-       0x0f24f001,
-       0x04c807f1,
-       0xbd0002d0,
-       0x4027f004,
-       0xd00007f0,
-       0x04bd0002,
-/* 0x0492: host_init */
+       0xf10217f0,
+       0xf0080015,
+       0x01d01007,
+       0xf104bd00,
+       0xf000f517,
+       0x14f10013,
+       0x10feffff,
+       0x1031f400,
+       0xf00117f0,
+       0x01d03807,
+       0xf004bd00,
+/* 0x039a: init_proc */
+       0xf19858f7,
+       0x0016b001,
+       0xf9fa0bf4,
+       0x58f0b615,
+/* 0x03ab: mulu32_32_64 */
+       0xf9f20ef4,
+       0xf920f910,
+       0x9540f930,
+       0xd29510e1,
+       0xbdc4bd10,
+       0xc0edffb4,
+       0xb9301dff,
+       0x34f10234,
+       0x34b6ffff,
+       0x1045b610,
+       0xbb00c3bb,
+       0xe2ff01b4,
+       0x0234b930,
+       0xffff34f1,
+       0xb61034b6,
+       0xc3bb1045,
+       0x01b4bb00,
+       0xbb3012ff,
+       0x40fc00b3,
+       0x20fc30fc,
+       0x00f810fc,
+/* 0x03fc: host_send */
+       0x04b017f1,
+       0xf10011cf,
+       0xcf04a027,
+       0x12b80022,
+       0x2f0bf406,
+       0x94071ec4,
+       0xe0b704ee,
+       0xeb980270,
+       0x02ec9803,
+       0x9801ed98,
+       0x21f500ee,
+       0x10b602e5,
+       0x0f1ec401,
+       0x04b007f1,
+       0xbd000ed0,
+       0xc30ef404,
+/* 0x043c: host_send_done */
+/* 0x043e: host_recv */
        0x17f100f8,
-       0x14b60080,
-       0x7015f110,
-       0xd007f102,
-       0x0001d004,
-       0x17f104bd,
-       0x14b60080,
-       0xf015f110,
-       0xdc07f102,
-       0x0001d004,
-       0x17f004bd,
-       0xc407f101,
-       0x0001d004,
-       0x00f804bd,
-/* 0x04c8: memx_func_enter */
-       0x162067f1,
-       0xf55d77f1,
-       0xffff73f1,
-       0xf4026eb9,
-       0xd8b90421,
-       0x0487fd02,
-       0x80f960f9,
-       0xe0fcd0fc,
-       0xf13321f4,
-       0xf1fffe77,
+       0x13f14e49,
+       0xe1b85254,
+       0xb30bf406,
+/* 0x044c: host_recv_wait */
+       0x04cc17f1,
+       0xf10011cf,
+       0xcf04c827,
+       0x16f00022,
+       0x0612b808,
+       0xc4ec0bf4,
+       0x34b60723,
+       0xf030b704,
+       0x033b8002,
+       0x80023c80,
+       0x3e80013d,
+       0x0120b600,
+       0xf10f24f0,
+       0xd004c807,
+       0x04bd0002,
+       0xf04027f0,
+       0x02d00007,
+       0xf804bd00,
+/* 0x0495: host_init */
+       0x8017f100,
+       0x1014b600,
+       0x027015f1,
+       0x04d007f1,
+       0xbd0001d0,
+       0x8017f104,
+       0x1014b600,
+       0x02f015f1,
+       0x04dc07f1,
+       0xbd0001d0,
+       0x0117f004,
+       0x04c407f1,
+       0xbd0001d0,
+/* 0x04cb: memx_func_enter */
+       0xf100f804,
+       0xf1162067,
+       0xf1f55d77,
        0xb9ffff73,
        0x21f4026e,
        0x02d8b904,
        0xf90487fd,
        0xfc80f960,
        0xf4e0fcd0,
-       0x67f13321,
-       0x6eb926f0,
+       0x77f13421,
+       0x73f1fffe,
+       0x6eb9ffff,
        0x0421f402,
        0xfd02d8b9,
        0x60f90487,
        0xd0fc80f9,
        0x21f4e0fc,
-       0x0467f033,
-       0x07e007f1,
+       0xf067f134,
+       0x026eb926,
+       0xb90421f4,
+       0x87fd02d8,
+       0xf960f904,
+       0xfcd0fc80,
+       0x3421f4e0,
+       0xf10467f0,
+       0xd007e007,
+       0x04bd0006,
+/* 0x0534: memx_func_enter_wait */
+       0x07c067f1,
+       0xf00066cf,
+       0x0bf40464,
+       0x2c67f0f6,
+       0x800066cf,
+       0x00f8f106,
+/* 0x054c: memx_func_leave */
+       0xcf2c67f0,
+       0x06800066,
+       0x0467f0f2,
+       0x07e407f1,
        0xbd0006d0,
-/* 0x0531: memx_func_enter_wait */
+/* 0x0561: memx_func_leave_wait */
        0xc067f104,
        0x0066cf07,
        0xf40464f0,
-       0x67f0f60b,
-       0x0066cf2c,
-       0xf8f10680,
-/* 0x0549: memx_func_leave */
-       0x2c67f000,
-       0x800066cf,
-       0x67f0f206,
-       0xe407f104,
-       0x0006d007,
-/* 0x055e: memx_func_leave_wait */
-       0x67f104bd,
-       0x66cf07c0,
-       0x0464f000,
-       0xf1f61bf4,
-       0xf126f067,
-       0xf0000177,
+       0x67f1f61b,
+       0x77f126f0,
+       0x73f00001,
+       0x026eb900,
+       0xb90421f4,
+       0x87fd02d8,
+       0xf960f905,
+       0xfcd0fc80,
+       0x3421f4e0,
+       0x162067f1,
+       0xf4026eb9,
+       0xd8b90421,
+       0x0587fd02,
+       0x80f960f9,
+       0xe0fcd0fc,
+       0xf13421f4,
+       0xf00aa277,
        0x6eb90073,
        0x0421f402,
        0xfd02d8b9,
        0x60f90587,
        0xd0fc80f9,
        0x21f4e0fc,
-       0x2067f133,
-       0x026eb916,
-       0xb90421f4,
-       0x87fd02d8,
-       0xf960f905,
-       0xfcd0fc80,
-       0x3321f4e0,
-       0x0aa277f1,
-       0xb90073f0,
-       0x21f4026e,
-       0x02d8b904,
-       0xf90587fd,
-       0xfc80f960,
-       0xf4e0fcd0,
-       0x00f83321,
-/* 0x05c8: memx_func_wait_vblank */
-       0xf80410b6,
-/* 0x05cd: memx_func_wr32 */
-       0x00169800,
-       0xb6011598,
-       0x60f90810,
-       0xd0fc50f9,
-       0x21f4e0fc,
-       0x0242b633,
-       0xf8e91bf4,
-/* 0x05e9: memx_func_wait */
-       0x2c87f000,
-       0x980088cf,
-       0x1d98001e,
-       0x021c9801,
-       0xb6031b98,
-       0x21f41010,
-/* 0x0603: memx_func_delay */
-       0x9800f886,
-       0x10b6001e,
-       0x6721f404,
-/* 0x060e: memx_func_train */
-       0x00f800f8,
-/* 0x0610: memx_exec */
-       0xd0f9e0f9,
-       0xb902c1b9,
-/* 0x061a: memx_exec_next */
-       0x139802b2,
+/* 0x05cb: memx_func_wait_vblank */
+       0xb600f834,
+       0x00f80410,
+/* 0x05d0: memx_func_wr32 */
+       0x98001698,
+       0x10b60115,
+       0xf960f908,
+       0xfcd0fc50,
+       0x3421f4e0,
+       0xf40242b6,
+       0x00f8e91b,
+/* 0x05ec: memx_func_wait */
+       0xcf2c87f0,
+       0x1e980088,
+       0x011d9800,
+       0x98021c98,
+       0x10b6031b,
+       0x8521f410,
+/* 0x0606: memx_func_delay */
+       0x1e9800f8,
        0x0410b600,
-       0x01f034e7,
-       0x01e033e7,
-       0xf00132b6,
-       0x35980c30,
-       0xb855f9de,
-       0x1ef40612,
-       0xf10b98e4,
-       0xbbf20c98,
-       0xb7f102cb,
-       0xbbcf07c4,
-       0xfcd0fc00,
-       0xe621f5e0,
-/* 0x0653: memx_info */
-       0x7000f802,
-       0x0bf401c6,
-/* 0x0659: memx_info_data */
-       0xccc7f10e,
-       0x00b7f103,
-       0x0b0ef408,
-/* 0x0664: memx_info_train */
-       0x0bccc7f1,
-       0x0100b7f1,
-/* 0x066c: memx_info_send */
-       0x02e621f5,
-/* 0x0672: memx_recv */
-       0xd6b000f8,
-       0x9b0bf401,
-       0xf400d6b0,
-       0x00f8d80b,
-/* 0x0680: memx_init */
-/* 0x0682: perf_recv */
-       0x00f800f8,
-/* 0x0684: perf_init */
-/* 0x0686: i2c_drive_scl */
-       0x36b000f8,
-       0x0e0bf400,
-       0x07e007f1,
-       0xbd0001d0,
-/* 0x0697: i2c_drive_scl_lo */
-       0xf100f804,
-       0xd007e407,
+       0xf86621f4,
+/* 0x0611: memx_func_train */
+/* 0x0613: memx_exec */
+       0xf900f800,
+       0xb9d0f9e0,
+       0xb2b902c1,
+/* 0x061d: memx_exec_next */
+       0x00139802,
+       0xe70410b6,
+       0xe701f034,
+       0xb601e033,
+       0x30f00132,
+       0xde35980c,
+       0x12b855f9,
+       0xe41ef406,
+       0x98f10b98,
+       0xcbbbf20c,
+       0xc4b7f102,
+       0x00bbcf07,
+       0xe0fcd0fc,
+       0x02e521f5,
+/* 0x0656: memx_info */
+       0xc67000f8,
+       0x0e0bf401,
+/* 0x065c: memx_info_data */
+       0x03ccc7f1,
+       0x0800b7f1,
+/* 0x0667: memx_info_train */
+       0xf10b0ef4,
+       0xf10bccc7,
+/* 0x066f: memx_info_send */
+       0xf50100b7,
+       0xf802e521,
+/* 0x0675: memx_recv */
+       0x01d6b000,
+       0xb09b0bf4,
+       0x0bf400d6,
+/* 0x0683: memx_init */
+       0xf800f8d8,
+/* 0x0685: perf_recv */
+/* 0x0687: perf_init */
+       0xf800f800,
+/* 0x0689: i2c_drive_scl */
+       0x0036b000,
+       0xf10e0bf4,
+       0xd007e007,
        0x04bd0001,
-/* 0x06a2: i2c_drive_sda */
-       0x36b000f8,
-       0x0e0bf400,
-       0x07e007f1,
-       0xbd0002d0,
-/* 0x06b3: i2c_drive_sda_lo */
-       0xf100f804,
-       0xd007e407,
+/* 0x069a: i2c_drive_scl_lo */
+       0x07f100f8,
+       0x01d007e4,
+       0xf804bd00,
+/* 0x06a5: i2c_drive_sda */
+       0x0036b000,
+       0xf10e0bf4,
+       0xd007e007,
        0x04bd0002,
-/* 0x06be: i2c_sense_scl */
+/* 0x06b6: i2c_drive_sda_lo */
+       0x07f100f8,
+       0x02d007e4,
+       0xf804bd00,
+/* 0x06c1: i2c_sense_scl */
+       0x0132f400,
+       0x07c437f1,
+       0xfd0033cf,
+       0x0bf40431,
+       0x0131f406,
+/* 0x06d4: i2c_sense_scl_done */
+/* 0x06d6: i2c_sense_sda */
        0x32f400f8,
        0xc437f101,
        0x0033cf07,
-       0xf40431fd,
+       0xf40432fd,
        0x31f4060b,
-/* 0x06d1: i2c_sense_scl_done */
-/* 0x06d3: i2c_sense_sda */
-       0xf400f801,
-       0x37f10132,
-       0x33cf07c4,
-       0x0432fd00,
-       0xf4060bf4,
-/* 0x06e6: i2c_sense_sda_done */
-       0x00f80131,
-/* 0x06e8: i2c_raise_scl */
-       0x47f140f9,
-       0x37f00898,
-       0x8621f501,
-/* 0x06f5: i2c_raise_scl_wait */
-       0xe8e7f106,
-       0x6721f403,
-       0x06be21f5,
-       0xb60901f4,
-       0x1bf40142,
-/* 0x0709: i2c_raise_scl_done */
-       0xf840fcef,
-/* 0x070d: i2c_start */
-       0xbe21f500,
-       0x0d11f406,
-       0x06d321f5,
-       0xf40611f4,
-/* 0x071e: i2c_start_rep */
-       0x37f0300e,
-       0x8621f500,
-       0x0137f006,
-       0x06a221f5,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0xe821f550,
-       0x0464b606,
-/* 0x074b: i2c_start_send */
-       0xf01f11f4,
-       0x21f50037,
-       0xe7f106a2,
-       0x21f41388,
-       0x0037f067,
-       0x068621f5,
-       0x1388e7f1,
-/* 0x0767: i2c_start_out */
-       0xf86721f4,
-/* 0x0769: i2c_stop */
-       0x0037f000,
-       0x068621f5,
-       0xf50037f0,
-       0xf106a221,
-       0xf403e8e7,
-       0x37f06721,
-       0x8621f501,
-       0x88e7f106,
-       0x6721f413,
-       0xf50137f0,
-       0xf106a221,
-       0xf41388e7,
-       0x00f86721,
-/* 0x079c: i2c_bitw */
-       0x06a221f5,
+/* 0x06e9: i2c_sense_sda_done */
+/* 0x06eb: i2c_raise_scl */
+       0xf900f801,
+       0x9847f140,
+       0x0137f008,
+       0x068921f5,
+/* 0x06f8: i2c_raise_scl_wait */
        0x03e8e7f1,
-       0xbb6721f4,
+       0xf56621f4,
+       0xf406c121,
+       0x42b60901,
+       0xef1bf401,
+/* 0x070c: i2c_raise_scl_done */
+       0x00f840fc,
+/* 0x0710: i2c_start */
+       0x06c121f5,
+       0xf50d11f4,
+       0xf406d621,
+       0x0ef40611,
+/* 0x0721: i2c_start_rep */
+       0x0037f030,
+       0x068921f5,
+       0xf50137f0,
+       0xbb06a521,
        0x65b60076,
        0x9450f904,
        0x56bb0465,
        0xfd50bd02,
        0x50fc0475,
-       0x06e821f5,
+       0x06eb21f5,
        0xf40464b6,
-       0xe7f11811,
+/* 0x074e: i2c_start_send */
+       0x37f01f11,
+       0xa521f500,
+       0x88e7f106,
+       0x6621f413,
+       0xf50037f0,
+       0xf1068921,
+       0xf41388e7,
+/* 0x076a: i2c_start_out */
+       0x00f86621,
+/* 0x076c: i2c_stop */
+       0xf50037f0,
+       0xf0068921,
+       0x21f50037,
+       0xe7f106a5,
+       0x21f403e8,
+       0x0137f066,
+       0x068921f5,
+       0x1388e7f1,
+       0xf06621f4,
+       0x21f50137,
+       0xe7f106a5,
        0x21f41388,
-       0x0037f067,
-       0x068621f5,
+/* 0x079f: i2c_bitw */
+       0xf500f866,
+       0xf106a521,
+       0xf403e8e7,
+       0x76bb6621,
+       0x0465b600,
+       0x659450f9,
+       0x0256bb04,
+       0x75fd50bd,
+       0xf550fc04,
+       0xb606eb21,
+       0x11f40464,
+       0x88e7f118,
+       0x6621f413,
+       0xf50037f0,
+       0xf1068921,
+       0xf41388e7,
+/* 0x07de: i2c_bitw_out */
+       0x00f86621,
+/* 0x07e0: i2c_bitr */
+       0xf50137f0,
+       0xf106a521,
+       0xf403e8e7,
+       0x76bb6621,
+       0x0465b600,
+       0x659450f9,
+       0x0256bb04,
+       0x75fd50bd,
+       0xf550fc04,
+       0xb606eb21,
+       0x11f40464,
+       0xd621f51b,
+       0x0037f006,
+       0x068921f5,
        0x1388e7f1,
-/* 0x07db: i2c_bitw_out */
-       0xf86721f4,
-/* 0x07dd: i2c_bitr */
-       0x0137f000,
-       0x06a221f5,
-       0x03e8e7f1,
-       0xbb6721f4,
-       0x65b60076,
-       0x9450f904,
-       0x56bb0465,
-       0xfd50bd02,
-       0x50fc0475,
-       0x06e821f5,
-       0xf40464b6,
-       0x21f51b11,
-       0x37f006d3,
-       0x8621f500,
-       0x88e7f106,
-       0x6721f413,
-       0xf4013cf0,
-/* 0x0822: i2c_bitr_done */
-       0x00f80131,
-/* 0x0824: i2c_get_byte */
-       0xf00057f0,
-/* 0x082a: i2c_get_byte_next */
-       0x54b60847,
-       0x0076bb01,
-       0xf90465b6,
-       0x04659450,
-       0xbd0256bb,
-       0x0475fd50,
-       0x21f550fc,
-       0x64b607dd,
-       0x2b11f404,
-       0xb60553fd,
-       0x1bf40142,
-       0x0137f0d8,
+       0xf06621f4,
+       0x31f4013c,
+/* 0x0825: i2c_bitr_done */
+/* 0x0827: i2c_get_byte */
+       0xf000f801,
+       0x47f00057,
+/* 0x082d: i2c_get_byte_next */
+       0x0154b608,
        0xb60076bb,
        0x50f90465,
        0xbb046594,
        0x50bd0256,
        0xfc0475fd,
-       0x9c21f550,
+       0xe021f550,
        0x0464b607,
-/* 0x0874: i2c_get_byte_done */
-/* 0x0876: i2c_put_byte */
-       0x47f000f8,
-/* 0x0879: i2c_put_byte_next */
-       0x0142b608,
-       0xbb3854ff,
+       0xfd2b11f4,
+       0x42b60553,
+       0xd81bf401,
+       0xbb0137f0,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x079f21f5,
+/* 0x0877: i2c_get_byte_done */
+       0xf80464b6,
+/* 0x0879: i2c_put_byte */
+       0x0847f000,
+/* 0x087c: i2c_put_byte_next */
+       0xff0142b6,
+       0x76bb3854,
+       0x0465b600,
+       0x659450f9,
+       0x0256bb04,
+       0x75fd50bd,
+       0xf550fc04,
+       0xb6079f21,
+       0x11f40464,
+       0x0046b034,
+       0xbbd81bf4,
        0x65b60076,
        0x9450f904,
        0x56bb0465,
        0xfd50bd02,
        0x50fc0475,
-       0x079c21f5,
+       0x07e021f5,
        0xf40464b6,
-       0x46b03411,
-       0xd81bf400,
+       0x76bb0f11,
+       0x0136b000,
+       0xf4061bf4,
+/* 0x08d2: i2c_put_byte_done */
+       0x00f80132,
+/* 0x08d4: i2c_addr */
        0xb60076bb,
        0x50f90465,
        0xbb046594,
        0x50bd0256,
        0xfc0475fd,
-       0xdd21f550,
+       0x1021f550,
        0x0464b607,
-       0xbb0f11f4,
-       0x36b00076,
-       0x061bf401,
-/* 0x08cf: i2c_put_byte_done */
-       0xf80132f4,
-/* 0x08d1: i2c_addr */
-       0x0076bb00,
+       0xe72911f4,
+       0xb6012ec3,
+       0x53fd0134,
+       0x0076bb05,
        0xf90465b6,
        0x04659450,
        0xbd0256bb,
        0x0475fd50,
        0x21f550fc,
-       0x64b6070d,
-       0x2911f404,
-       0x012ec3e7,
-       0xfd0134b6,
-       0x76bb0553,
-       0x0465b600,
-       0x659450f9,
-       0x0256bb04,
-       0x75fd50bd,
-       0xf550fc04,
-       0xb6087621,
-/* 0x0916: i2c_addr_done */
-       0x00f80464,
-/* 0x0918: i2c_acquire_addr */
-       0xb6f8cec7,
-       0xe0b705e4,
-       0x00f8d014,
-/* 0x0924: i2c_acquire */
-       0x091821f5,
-       0xf00421f4,
-       0x21f403d9,
-/* 0x0933: i2c_release */
-       0xf500f833,
-       0xf4091821,
-       0xdaf00421,
-       0x3321f403,
-/* 0x0942: i2c_recv */
-       0x32f400f8,
-       0xf8c1c701,
-       0xb00214b6,
-       0x1ff52816,
-       0x13a0013a,
-       0x32980cf4,
-       0xcc13a000,
-       0x0031980c,
-       0xf90231f4,
-       0xf9e0f9d0,
-       0x0067f1d0,
-       0x0063f100,
-       0x01679210,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0x2421f550,
-       0x0464b609,
-       0xd6b0d0fc,
-       0xb31bf500,
-       0x0057f000,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0xd121f550,
-       0x0464b608,
-       0x00d011f5,
-       0xbbe0c5c7,
+       0x64b60879,
+/* 0x0919: i2c_addr_done */
+/* 0x091b: i2c_acquire_addr */
+       0xc700f804,
+       0xe4b6f8ce,
+       0x14e0b705,
+/* 0x0927: i2c_acquire */
+       0xf500f8d0,
+       0xf4091b21,
+       0xd9f00421,
+       0x3421f403,
+/* 0x0936: i2c_release */
+       0x21f500f8,
+       0x21f4091b,
+       0x03daf004,
+       0xf83421f4,
+/* 0x0945: i2c_recv */
+       0x0132f400,
+       0xb6f8c1c7,
+       0x16b00214,
+       0x3a1ff528,
+       0xf413a001,
+       0x0032980c,
+       0x0ccc13a0,
+       0xf4003198,
+       0xd0f90231,
+       0xd0f9e0f9,
+       0x000067f1,
+       0x100063f1,
+       0xbb016792,
        0x65b60076,
        0x9450f904,
        0x56bb0465,
        0xfd50bd02,
        0x50fc0475,
-       0x087621f5,
+       0x092721f5,
+       0xfc0464b6,
+       0x00d6b0d0,
+       0x00b31bf5,
+       0xbb0057f0,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x08d421f5,
        0xf50464b6,
-       0xf000ad11,
-       0x76bb0157,
+       0xc700d011,
+       0x76bbe0c5,
        0x0465b600,
        0x659450f9,
        0x0256bb04,
        0x75fd50bd,
        0xf550fc04,
-       0xb608d121,
+       0xb6087921,
        0x11f50464,
-       0x76bb008a,
-       0x0465b600,
-       0x659450f9,
-       0x0256bb04,
-       0x75fd50bd,
-       0xf550fc04,
-       0xb6082421,
-       0x11f40464,
-       0xe05bcb6a,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0x6921f550,
-       0x0464b607,
-       0xbd025bb9,
-       0x430ef474,
-/* 0x0a48: i2c_recv_not_rd08 */
-       0xf401d6b0,
-       0x57f03d1b,
-       0xd121f500,
-       0x3311f408,
-       0xf5e0c5c7,
-       0xf4087621,
-       0x57f02911,
-       0xd121f500,
-       0x1f11f408,
-       0xf5e0b5c7,
-       0xf4087621,
-       0x21f51511,
-       0x74bd0769,
-       0xf408c5c7,
-       0x32f4091b,
-       0x030ef402,
-/* 0x0a88: i2c_recv_not_wr08 */
-/* 0x0a88: i2c_recv_done */
-       0xf5f8cec7,
-       0xfc093321,
-       0xf4d0fce0,
-       0x7cb90a12,
-       0xe621f502,
-/* 0x0a9d: i2c_recv_exit */
-/* 0x0a9f: i2c_init */
+       0x57f000ad,
+       0x0076bb01,
+       0xf90465b6,
+       0x04659450,
+       0xbd0256bb,
+       0x0475fd50,
+       0x21f550fc,
+       0x64b608d4,
+       0x8a11f504,
+       0x0076bb00,
+       0xf90465b6,
+       0x04659450,
+       0xbd0256bb,
+       0x0475fd50,
+       0x21f550fc,
+       0x64b60827,
+       0x6a11f404,
+       0xbbe05bcb,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x076c21f5,
+       0xb90464b6,
+       0x74bd025b,
+/* 0x0a4b: i2c_recv_not_rd08 */
+       0xb0430ef4,
+       0x1bf401d6,
+       0x0057f03d,
+       0x08d421f5,
+       0xc73311f4,
+       0x21f5e0c5,
+       0x11f40879,
+       0x0057f029,
+       0x08d421f5,
+       0xc71f11f4,
+       0x21f5e0b5,
+       0x11f40879,
+       0x6c21f515,
+       0xc774bd07,
+       0x1bf408c5,
+       0x0232f409,
+/* 0x0a8b: i2c_recv_not_wr08 */
+/* 0x0a8b: i2c_recv_done */
+       0xc7030ef4,
+       0x21f5f8ce,
+       0xe0fc0936,
+       0x12f4d0fc,
+       0x027cb90a,
+       0x02e521f5,
+/* 0x0aa0: i2c_recv_exit */
+/* 0x0aa2: i2c_init */
+       0x00f800f8,
+/* 0x0aa4: test_recv */
+       0x05d817f1,
+       0xb60011cf,
+       0x07f10110,
+       0x01d005d8,
+       0xf104bd00,
+       0xf1d900e7,
+       0xf5134fe3,
+       0xf8021721,
+/* 0x0ac5: test_init */
+       0x00e7f100,
+       0x1721f508,
+/* 0x0acf: idle_recv */
        0xf800f802,
-/* 0x0aa1: test_recv */
-       0xd817f100,
-       0x0011cf05,
-       0xf10110b6,
-       0xd005d807,
-       0x04bd0001,
-       0xd900e7f1,
-       0x134fe3f1,
-       0x021821f5,
-/* 0x0ac2: test_init */
-       0xe7f100f8,
-       0x21f50800,
-       0x00f80218,
-/* 0x0acc: idle_recv */
-/* 0x0ace: idle */
-       0x31f400f8,
-       0xd417f100,
-       0x0011cf05,
-       0xf10110b6,
-       0xd005d407,
-       0x04bd0001,
-/* 0x0ae4: idle_loop */
-       0xf45817f0,
-/* 0x0aea: idle_proc */
-/* 0x0aea: idle_proc_exec */
-       0x10f90232,
-       0xf5021eb9,
-       0xfc02ef21,
-       0x0911f410,
-       0xf40231f4,
-/* 0x0afe: idle_proc_next */
-       0x10b6ef0e,
-       0x061fb858,
-       0xf4e61bf4,
-       0x28f4dd02,
-       0xc10ef400,
-       0x00000000,
+/* 0x0ad1: idle */
+       0x0031f400,
+       0x05d417f1,
+       0xb60011cf,
+       0x07f10110,
+       0x01d005d4,
+/* 0x0ae7: idle_loop */
+       0xf004bd00,
+       0x32f45817,
+/* 0x0aed: idle_proc */
+/* 0x0aed: idle_proc_exec */
+       0xb910f902,
+       0x21f5021e,
+       0x10fc02ee,
+       0xf40911f4,
+       0x0ef40231,
+/* 0x0b01: idle_proc_next */
+       0x5810b6ef,
+       0xf4061fb8,
+       0x02f4e61b,
+       0x0028f4dd,
+       0x00c10ef4,
        0x00000000,
        0x00000000,
        0x00000000,
index 8a2b628..3c731ff 100644 (file)
@@ -24,8 +24,8 @@ uint32_t gk208_pmu_data[] = {
        0x00000000,
 /* 0x0058: proc_list_head */
        0x54534f48,
-       0x00000447,
-       0x000003f8,
+       0x0000042c,
+       0x000003df,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -46,8 +46,8 @@ uint32_t gk208_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x584d454d,
-       0x00000621,
-       0x00000613,
+       0x000005f3,
+       0x000005e5,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -68,8 +68,8 @@ uint32_t gk208_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x46524550,
-       0x00000625,
-       0x00000623,
+       0x000005f7,
+       0x000005f5,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -90,8 +90,8 @@ uint32_t gk208_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x5f433249,
-       0x00000a29,
-       0x000008d0,
+       0x000009f8,
+       0x000008a2,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -112,8 +112,8 @@ uint32_t gk208_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x54534554,
-       0x00000a4a,
-       0x00000a2b,
+       0x00000a16,
+       0x000009fa,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -134,8 +134,8 @@ uint32_t gk208_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x454c4449,
-       0x00000a55,
-       0x00000a53,
+       0x00000a21,
+       0x00000a1f,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -229,26 +229,26 @@ uint32_t gk208_pmu_data[] = {
 /* 0x0370: memx_func_head */
        0x00000001,
        0x00000000,
-       0x00000477,
+       0x0000045c,
 /* 0x037c: memx_func_next */
        0x00000002,
        0x00000000,
-       0x000004f4,
+       0x000004cf,
        0x00000003,
        0x00000002,
-       0x00000574,
+       0x00000546,
        0x00040004,
        0x00000000,
-       0x00000591,
+       0x00000563,
        0x00010005,
        0x00000000,
-       0x000005ab,
+       0x0000057d,
        0x00010006,
        0x00000000,
-       0x0000056f,
+       0x00000541,
        0x00000007,
        0x00000000,
-       0x000005b7,
+       0x00000589,
 /* 0x03c4: memx_func_tail */
 /* 0x03c4: memx_ts_start */
        0x00000000,
@@ -916,784 +916,771 @@ uint32_t gk208_pmu_data[] = {
 };
 
 uint32_t gk208_pmu_code[] = {
-       0x03100ef5,
+       0x02f90ef5,
 /* 0x0004: rd32 */
        0xf607a040,
        0x04bd000e,
-       0xd3f0010d,
+       0x0100018d,
+       0xf607ac40,
+       0x04bd000d,
+/* 0x0018: rd32_wait */
+       0xcf07ac4d,
+       0xd4f100dd,
+       0x1bf47000,
+       0x07a44df6,
+       0xf800ddcf,
+/* 0x002d: wr32 */
+       0x07a04000,
+       0xbd000ef6,
+       0x07a44004,
+       0xbd000df6,
+       0x00f28d04,
        0x07ac4001,
        0xbd000df6,
-/* 0x0019: rd32_wait */
+/* 0x0049: wr32_wait */
        0x07ac4d04,
        0xf100ddcf,
        0xf47000d4,
-       0xa44df61b,
-       0x00ddcf07,
-/* 0x002e: wr32 */
-       0xa04000f8,
-       0x000ef607,
-       0xa44004bd,
-       0x000df607,
-       0x020d04bd,
-       0xf0f0d5f0,
-       0xac4001d3,
-       0x000df607,
-/* 0x004e: wr32_wait */
-       0xac4d04bd,
-       0x00ddcf07,
-       0x7000d4f1,
-       0xf8f61bf4,
-/* 0x005d: nsec */
-       0xf990f900,
-       0xcf2c0880,
-/* 0x0066: nsec_loop */
-       0x2c090088,
-       0xbb0099cf,
-       0x9ea60298,
-       0xfcf61ef4,
-       0xf890fc80,
-/* 0x0079: wait */
-       0xf990f900,
-       0xcf2c0880,
-/* 0x0082: wait_loop */
-       0xeeb20088,
-       0x0000047e,
-       0xadfddab2,
-       0xf4aca604,
-       0x2c09100b,
-       0xbb0099cf,
-       0x9ba60298,
-/* 0x009f: wait_done */
-       0xfce61ef4,
-       0xf890fc80,
-/* 0x00a5: intr_watchdog */
-       0x03e99800,
+       0x00f8f61b,
+/* 0x0058: nsec */
+       0x80f990f9,
+       0x88cf2c08,
+/* 0x0061: nsec_loop */
+       0xcf2c0900,
+       0x98bb0099,
+       0xf49ea602,
+       0x80fcf61e,
+       0x00f890fc,
+/* 0x0074: wait */
+       0x80f990f9,
+       0x88cf2c08,
+/* 0x007d: wait_loop */
+       0x7eeeb200,
+       0xb2000004,
+       0x04adfdda,
+       0x0bf4aca6,
+       0xcf2c0910,
+       0x98bb0099,
+       0xf49ba602,
+/* 0x009a: wait_done */
+       0x80fce61e,
+       0x00f890fc,
+/* 0x00a0: intr_watchdog */
+       0xb003e998,
+       0x0bf40096,
+       0x9a0a9828,
+       0xf4029abb,
+       0x010d0e1c,
+       0x00023e7e,
+       0x0ef494bd,
+/* 0x00bd: intr_watchdog_next_time */
+       0x9b0a9814,
+       0xf400a6b0,
+       0x9aa6080b,
+/* 0x00cb: intr_watchdog_next_time_set */
+       0xb5061cf4,
+/* 0x00ce: intr_watchdog_next_proc */
+       0xe9b59b09,
+       0x58e0b603,
+       0x0268e6b1,
+       0xf8c81bf4,
+/* 0x00dd: intr */
+       0xbd00f900,
+       0xf980f904,
+       0xf9a0f990,
+       0xf9c0f9b0,
+       0xf9e0f9d0,
+       0xfe000ff0,
+       0x80f90188,
+       0xcf045048,
+       0x80b60088,
+       0x04504001,
+       0xbd0008f6,
+       0xcf080804,
+       0x89c40088,
+       0x1f0bf402,
+       0x0e9b00b5,
+       0x00a07e58,
+       0x9b099800,
        0xf40096b0,
-       0x0a98280b,
-       0x029abb9a,
-       0x0d0e1cf4,
-       0x02557e01,
-       0xf494bd00,
-/* 0x00c2: intr_watchdog_next_time */
-       0x0a98140e,
-       0x00a6b09b,
-       0xa6080bf4,
-       0x061cf49a,
-/* 0x00d0: intr_watchdog_next_time_set */
-/* 0x00d3: intr_watchdog_next_proc */
-       0xb59b09b5,
-       0xe0b603e9,
-       0x68e6b158,
-       0xc81bf402,
-/* 0x00e2: intr */
-       0x00f900f8,
-       0x80f904bd,
-       0xa0f990f9,
-       0xc0f9b0f9,
-       0xe0f9d0f9,
-       0x000ff0f9,
-       0xf90188fe,
-       0x04504880,
-       0xb60088cf,
-       0x50400180,
-       0x0008f604,
-       0x080804bd,
-       0xc40088cf,
-       0x0bf40289,
-       0x9b00b51f,
-       0xa57e580e,
-       0x09980000,
-       0x0096b09b,
-       0x000d0bf4,
-       0x0009f634,
-       0x09b504bd,
-/* 0x0135: intr_skip_watchdog */
-       0x0089e49a,
-       0x360bf408,
-       0xcf068849,
-       0x9ac40099,
-       0x220bf402,
-       0xcf04c04c,
-       0xc0f900cc,
-       0xf14f484e,
-       0x0d5453e3,
-       0x02b67e00,
-       0x40c0fc00,
-       0x0cf604c0,
-/* 0x0167: intr_subintr_skip_fifo */
-       0x4004bd00,
-       0x09f60688,
-/* 0x016f: intr_skip_subintr */
-       0x4904bd00,
-       0x90bd00e0,
-       0x000489fd,
-       0x0008f604,
-       0x80fc04bd,
-       0xfc0088fe,
-       0xfce0fcf0,
-       0xfcc0fcd0,
-       0xfca0fcb0,
-       0xfc80fc90,
-       0x0032f400,
-/* 0x019a: ticks_from_ns */
-       0xc0f901f8,
-       0xd7f1b0f9,
-       0xd3f00144,
-       0x6b21f500,
-       0xe8ccec03,
-       0x00b4b003,
-       0xec120bf4,
-       0xf103e8ee,
-       0xf00144d7,
-       0x21f500d3,
-/* 0x01c2: ticks_from_ns_quit */
-       0xceb2036b,
+       0x34000d0b,
+       0xbd0009f6,
+       0x9a09b504,
+/* 0x0130: intr_skip_watchdog */
+       0x080089e4,
+       0x49340bf4,
+       0x99cf0688,
+       0x029ac400,
+       0x4c200bf4,
+       0xcccf04c0,
+       0xdec0f900,
+       0x54534f48,
+       0x9f7e000d,
+       0xc0fc0002,
+       0xf604c040,
+       0x04bd000c,
+/* 0x0160: intr_subintr_skip_fifo */
+       0xf6068840,
+       0x04bd0009,
+/* 0x0168: intr_skip_subintr */
+       0xbd00e049,
+       0x0489fd90,
+       0x08f60400,
+       0xfc04bd00,
+       0x0088fe80,
+       0xe0fcf0fc,
+       0xc0fcd0fc,
+       0xa0fcb0fc,
+       0x80fc90fc,
+       0x32f400fc,
+/* 0x0193: ticks_from_ns */
+       0xf901f800,
+       0x4db0f9c0,
+       0x527e0144,
+       0xccec0003,
+       0xb4b003e8,
+       0x0e0bf400,
+       0x03e8eeec,
+       0x7e01444d,
+/* 0x01b3: ticks_from_ns_quit */
+       0xb2000352,
+       0xfcb0fcce,
+/* 0x01bb: ticks_from_us */
+       0xf900f8c0,
+       0x4db0f9c0,
+       0x527e0144,
+       0xceb20003,
+       0xf400b4b0,
+       0xe4bd050b,
+/* 0x01d0: ticks_from_us_quit */
        0xc0fcb0fc,
-/* 0x01ca: ticks_from_us */
-       0xc0f900f8,
-       0xd7f1b0f9,
-       0xd3f00144,
-       0x6b21f500,
-       0xb0ceb203,
-       0x0bf400b4,
-/* 0x01e3: ticks_from_us_quit */
-       0xfce4bd05,
-       0xf8c0fcb0,
-/* 0x01e9: ticks_to_us */
-       0x44d7f100,
-       0x00d3f001,
-       0xf8ecedff,
-/* 0x01f5: timer */
-       0xf990f900,
-       0x1032f480,
-       0xb003f898,
-       0x1cf40086,
-       0x0084bd4a,
-       0x0008f638,
-       0x340804bd,
-       0x980088cf,
-       0x98bb9a09,
-       0x00e9bb02,
-       0x0803feb5,
-       0x0088cf08,
-       0xf40284f0,
-       0x34081c1b,
-       0xa60088cf,
-       0x080bf4e0,
-       0x1cf4e8a6,
-/* 0x0239: timer_reset */
-       0xf634000d,
-       0x04bd000e,
-/* 0x0243: timer_enable */
-       0x089a0eb5,
-       0xf6380001,
-       0x04bd0008,
-/* 0x024c: timer_done */
-       0xfc1031f4,
+/* 0x01d6: ticks_to_us */
+       0x444d00f8,
+       0xecedff01,
+/* 0x01de: timer */
+       0x90f900f8,
+       0x32f480f9,
+       0x03f89810,
+       0xf40086b0,
+       0x84bd4a1c,
+       0x08f63800,
+       0x0804bd00,
+       0x0088cf34,
+       0xbb9a0998,
+       0xe9bb0298,
+       0x03feb500,
+       0x88cf0808,
+       0x0284f000,
+       0x081c1bf4,
+       0x0088cf34,
+       0x0bf4e0a6,
+       0xf4e8a608,
+/* 0x0222: timer_reset */
+       0x34000d1c,
+       0xbd000ef6,
+       0x9a0eb504,
+/* 0x022c: timer_enable */
+       0x38000108,
+       0xbd0008f6,
+/* 0x0235: timer_done */
+       0x1031f404,
+       0x90fc80fc,
+/* 0x023e: send_proc */
+       0x80f900f8,
+       0xe89890f9,
+       0x04e99805,
+       0xa60486f0,
+       0x2a0bf489,
+       0x940398c4,
+       0x80b60488,
+       0x008ebb18,
+       0xb500fa98,
+       0x8db5008a,
+       0x028cb501,
+       0xb6038bb5,
+       0x94f00190,
+       0x04e9b507,
+/* 0x0277: send_done */
+       0xfc0231f4,
+       0xf880fc90,
+/* 0x027d: find */
+       0x0880f900,
+       0x0131f458,
+/* 0x0284: find_loop */
+       0xa6008a98,
+       0x100bf4ae,
+       0xb15880b6,
+       0xf4026886,
+       0x32f4f11b,
+/* 0x0299: find_done */
+       0xfc8eb201,
+/* 0x029f: send */
+       0x7e00f880,
+       0xf400027d,
+       0x00f89b01,
+/* 0x02a8: recv */
+       0x80f990f9,
+       0x9805e898,
+       0x32f404e9,
+       0xf489a601,
+       0x89c43c0b,
+       0x0180b603,
+       0xb50784f0,
+       0xea9805e8,
+       0xfef0f902,
+       0xf0f9018f,
+       0x9994efb2,
+       0x00e9bb04,
+       0x9818e0b6,
+       0xec9803eb,
+       0x01ed9802,
+       0xf900ee98,
+       0xfef0fca5,
+       0x31f400f8,
+/* 0x02f3: recv_done */
+       0xfcf0fc01,
        0xf890fc80,
-/* 0x0255: send_proc */
-       0xf980f900,
-       0x05e89890,
-       0xf004e998,
-       0x89a60486,
-       0xc42a0bf4,
-       0x88940398,
-       0x1880b604,
-       0x98008ebb,
-       0x8ab500fa,
-       0x018db500,
-       0xb5028cb5,
-       0x90b6038b,
-       0x0794f001,
-       0xf404e9b5,
-/* 0x028e: send_done */
-       0x90fc0231,
-       0x00f880fc,
-/* 0x0294: find */
-       0x580880f9,
-/* 0x029b: find_loop */
-       0x980131f4,
-       0xaea6008a,
-       0xb6100bf4,
-       0x86b15880,
-       0x1bf40268,
-       0x0132f4f1,
-/* 0x02b0: find_done */
-       0x80fc8eb2,
-/* 0x02b6: send */
-       0x947e00f8,
-       0x01f40002,
-/* 0x02bf: recv */
-       0xf900f89b,
-       0x9880f990,
-       0xe99805e8,
-       0x0132f404,
-       0x0bf489a6,
-       0x0389c43c,
-       0xf00180b6,
-       0xe8b50784,
-       0x02ea9805,
-       0x8ffef0f9,
-       0xb2f0f901,
-       0x049994ef,
-       0xb600e9bb,
-       0xeb9818e0,
-       0x02ec9803,
-       0x9801ed98,
-       0xa5f900ee,
-       0xf8fef0fc,
-       0x0131f400,
-/* 0x030a: recv_done */
-       0x80fcf0fc,
-       0x00f890fc,
-/* 0x0310: init */
-       0xcf010841,
-       0x11e70011,
-       0x14b60109,
-       0x0014fe08,
-       0xf000e041,
-       0x1c000013,
-       0xbd0001f6,
-       0x00ff0104,
-       0x0001f614,
-       0x020104bd,
-       0x080015f1,
-       0x01f61000,
-       0x4104bd00,
-       0x13f000e2,
-       0x0010fe00,
-       0x011031f4,
-       0xf6380001,
+/* 0x02f9: init */
+       0x01084100,
+       0xe70011cf,
+       0xb6010911,
+       0x14fe0814,
+       0x00e04100,
+       0x01f61c00,
+       0x0104bd00,
+       0xf61400ff,
        0x04bd0001,
-/* 0x035a: init_proc */
-       0xf198580f,
-       0x0016b001,
-       0xf9fa0bf4,
-       0x58f0b615,
-/* 0x036b: mulu32_32_64 */
-       0xf9f20ef4,
-       0xf920f910,
-       0x9540f930,
-       0xd29510e1,
-       0xbdc4bd10,
-       0xc0edffb4,
-       0xb2301dff,
+       0x15f10201,
+       0x10000800,
+       0xbd0001f6,
+       0x00dd4104,
+       0xffff14f1,
+       0xf40010fe,
+       0x01011031,
+       0x01f63800,
+       0x0f04bd00,
+/* 0x0341: init_proc */
+       0x01f19858,
+       0xf40016b0,
+       0x15f9fa0b,
+       0xf458f0b6,
+/* 0x0352: mulu32_32_64 */
+       0x10f9f20e,
+       0x30f920f9,
+       0xe19540f9,
+       0x10d29510,
+       0xb4bdc4bd,
+       0xffc0edff,
+       0x34b2301d,
+       0xffff34f1,
+       0xb61034b6,
+       0xc3bb1045,
+       0x01b4bb00,
+       0xb230e2ff,
        0xff34f134,
        0x1034b6ff,
        0xbb1045b6,
        0xb4bb00c3,
-       0x30e2ff01,
-       0x34f134b2,
-       0x34b6ffff,
-       0x1045b610,
-       0xbb00c3bb,
-       0x12ff01b4,
-       0x00b3bb30,
-       0x30fc40fc,
-       0x10fc20fc,
-/* 0x03ba: host_send */
-       0xb04100f8,
-       0x0011cf04,
-       0xcf04a042,
-       0x12a60022,
-       0xc42e0bf4,
-       0xee94071e,
-       0x70e0b704,
-       0x03eb9802,
-       0x9802ec98,
-       0xee9801ed,
-       0x02b67e00,
-       0x0110b600,
-       0x400f1ec4,
-       0x0ef604b0,
-       0xf404bd00,
-/* 0x03f6: host_send_done */
-       0x00f8c70e,
-/* 0x03f8: host_recv */
-       0xf14e4941,
-       0xa6525413,
-       0xb90bf4e1,
-/* 0x0404: host_recv_wait */
-       0xcf04cc41,
-       0xc8420011,
-       0x0022cf04,
-       0xa60816f0,
-       0xef0bf412,
-       0xb60723c4,
-       0x30b70434,
-       0x3bb502f0,
-       0x023cb503,
-       0xb5013db5,
-       0x20b6003e,
-       0x0f24f001,
-       0xf604c840,
-       0x04bd0002,
-       0x00004002,
+       0x3012ff01,
+       0xfc00b3bb,
+       0xfc30fc40,
+       0xf810fc20,
+/* 0x03a1: host_send */
+       0x04b04100,
+       0x420011cf,
+       0x22cf04a0,
+       0xf412a600,
+       0x1ec42e0b,
+       0x04ee9407,
+       0x0270e0b7,
+       0x9803eb98,
+       0xed9802ec,
+       0x00ee9801,
+       0x00029f7e,
+       0xc40110b6,
+       0xb0400f1e,
+       0x000ef604,
+       0x0ef404bd,
+/* 0x03dd: host_send_done */
+/* 0x03df: host_recv */
+       0xd100f8c7,
+       0x52544e49,
+       0x0bf4e1a6,
+/* 0x03e9: host_recv_wait */
+       0x04cc41bb,
+       0x420011cf,
+       0x22cf04c8,
+       0x0816f000,
+       0x0bf412a6,
+       0x0723c4ef,
+       0xb70434b6,
+       0xb502f030,
+       0x3cb5033b,
+       0x013db502,
+       0xb6003eb5,
+       0x24f00120,
+       0x04c8400f,
        0xbd0002f6,
-/* 0x0447: host_init */
-       0x4100f804,
-       0x14b60080,
-       0x7015f110,
-       0x04d04002,
-       0xbd0001f6,
-       0x00804104,
-       0xf11014b6,
-       0x4002f015,
-       0x01f604dc,
-       0x0104bd00,
-       0x04c44001,
-       0xbd0001f6,
-/* 0x0477: memx_func_enter */
-       0xf100f804,
-       0xf1162067,
-       0xf1f55d77,
-       0xb2ffff73,
-       0x00047e6e,
-       0xfdd8b200,
-       0x60f90487,
-       0xd0fc80f9,
-       0x2e7ee0fc,
-       0x77f10000,
-       0x73f1fffe,
-       0x6eb2ffff,
-       0x0000047e,
-       0x87fdd8b2,
-       0xf960f904,
-       0xfcd0fc80,
-       0x002e7ee0,
-       0xf067f100,
-       0x7e6eb226,
+       0x00400204,
+       0x0002f600,
+       0x00f804bd,
+/* 0x042c: host_init */
+       0xb6008041,
+       0x15f11014,
+       0xd0400270,
+       0x0001f604,
+       0x804104bd,
+       0x1014b600,
+       0x02f015f1,
+       0xf604dc40,
+       0x04bd0001,
+       0xc4400101,
+       0x0001f604,
+       0x00f804bd,
+/* 0x045c: memx_func_enter */
+       0x162067f1,
+       0xf55d77f1,
+       0x047e6eb2,
+       0xd8b20000,
+       0xf90487fd,
+       0xfc80f960,
+       0x7ee0fcd0,
+       0x0700002d,
+       0x7e6eb2fe,
        0xb2000004,
        0x0487fdd8,
        0x80f960f9,
        0xe0fcd0fc,
-       0x00002e7e,
-       0xe0400406,
-       0x0006f607,
-/* 0x04de: memx_func_enter_wait */
-       0xc04604bd,
-       0x0066cf07,
-       0xf40464f0,
-       0x2c06f70b,
-       0xb50066cf,
-       0x00f8f106,
-/* 0x04f4: memx_func_leave */
-       0x66cf2c06,
-       0xf206b500,
-       0xe4400406,
-       0x0006f607,
-/* 0x0506: memx_func_leave_wait */
-       0xc04604bd,
-       0x0066cf07,
-       0xf40464f0,
-       0x67f1f71b,
-       0x77f126f0,
-       0x73f00001,
-       0x7e6eb200,
-       0xb2000004,
-       0x0587fdd8,
-       0x80f960f9,
-       0xe0fcd0fc,
-       0x00002e7e,
-       0x162067f1,
+       0x00002d7e,
+       0x26f067f1,
        0x047e6eb2,
        0xd8b20000,
-       0xf90587fd,
+       0xf90487fd,
        0xfc80f960,
        0x7ee0fcd0,
-       0xf100002e,
-       0xf00aa277,
-       0x6eb20073,
+       0x0600002d,
+       0x07e04004,
+       0xbd0006f6,
+/* 0x04b9: memx_func_enter_wait */
+       0x07c04604,
+       0xf00066cf,
+       0x0bf40464,
+       0xcf2c06f7,
+       0x06b50066,
+/* 0x04cf: memx_func_leave */
+       0x0600f8f1,
+       0x0066cf2c,
+       0x06f206b5,
+       0x07e44004,
+       0xbd0006f6,
+/* 0x04e1: memx_func_leave_wait */
+       0x07c04604,
+       0xf00066cf,
+       0x1bf40464,
+       0xf067f1f7,
+       0xb2010726,
+       0x00047e6e,
+       0xfdd8b200,
+       0x60f90587,
+       0xd0fc80f9,
+       0x2d7ee0fc,
+       0x67f10000,
+       0x6eb21620,
        0x0000047e,
        0x87fdd8b2,
        0xf960f905,
        0xfcd0fc80,
-       0x002e7ee0,
-/* 0x056f: memx_func_wait_vblank */
-       0xb600f800,
-       0x00f80410,
-/* 0x0574: memx_func_wr32 */
-       0x98001698,
-       0x10b60115,
-       0xf960f908,
-       0xfcd0fc50,
-       0x002e7ee0,
-       0x0242b600,
-       0xf8e81bf4,
-/* 0x0591: memx_func_wait */
-       0xcf2c0800,
-       0x1e980088,
-       0x011d9800,
-       0x98021c98,
-       0x10b6031b,
-       0x00797e10,
-/* 0x05ab: memx_func_delay */
-       0x9800f800,
-       0x10b6001e,
-       0x005d7e04,
-/* 0x05b7: memx_func_train */
-       0xf800f800,
-/* 0x05b9: memx_exec */
-       0xf9e0f900,
-       0xb2c1b2d0,
-/* 0x05c1: memx_exec_next */
-       0x001398b2,
-       0xe70410b6,
-       0xe701f034,
-       0xb601e033,
-       0x30f00132,
-       0xde35980c,
-       0x12a655f9,
-       0x98e51ef4,
-       0x0c98f10b,
-       0x02cbbbf2,
-       0xcf07c44b,
-       0xd0fc00bb,
-       0xb67ee0fc,
-       0x00f80002,
-/* 0x05f8: memx_info */
-       0xf401c670,
-/* 0x05fe: memx_info_data */
-       0xcc4c0c0b,
-       0x08004b03,
-/* 0x0607: memx_info_train */
-       0x4c090ef4,
-       0x004b0bcc,
-/* 0x060d: memx_info_send */
-       0x02b67e01,
-/* 0x0613: memx_recv */
-       0xb000f800,
-       0x0bf401d6,
-       0x00d6b0a3,
-       0xf8dc0bf4,
-/* 0x0621: memx_init */
-/* 0x0623: perf_recv */
+       0x002d7ee0,
+       0x0aa24700,
+       0x047e6eb2,
+       0xd8b20000,
+       0xf90587fd,
+       0xfc80f960,
+       0x7ee0fcd0,
+       0xf800002d,
+/* 0x0541: memx_func_wait_vblank */
+       0x0410b600,
+/* 0x0546: memx_func_wr32 */
+       0x169800f8,
+       0x01159800,
+       0xf90810b6,
+       0xfc50f960,
+       0x7ee0fcd0,
+       0xb600002d,
+       0x1bf40242,
+/* 0x0563: memx_func_wait */
+       0x0800f8e8,
+       0x0088cf2c,
+       0x98001e98,
+       0x1c98011d,
+       0x031b9802,
+       0x7e1010b6,
+       0xf8000074,
+/* 0x057d: memx_func_delay */
+       0x001e9800,
+       0x7e0410b6,
+       0xf8000058,
+/* 0x0589: memx_func_train */
+/* 0x058b: memx_exec */
+       0xf900f800,
+       0xb2d0f9e0,
+/* 0x0593: memx_exec_next */
+       0x98b2b2c1,
+       0x10b60013,
+       0xf034e704,
+       0xe033e701,
+       0x0132b601,
+       0x980c30f0,
+       0x55f9de35,
+       0x1ef412a6,
+       0xf10b98e5,
+       0xbbf20c98,
+       0xc44b02cb,
+       0x00bbcf07,
+       0xe0fcd0fc,
+       0x00029f7e,
+/* 0x05ca: memx_info */
+       0xc67000f8,
+       0x0c0bf401,
+/* 0x05d0: memx_info_data */
+       0x4b03cc4c,
+       0x0ef40800,
+/* 0x05d9: memx_info_train */
+       0x0bcc4c09,
+/* 0x05df: memx_info_send */
+       0x7e01004b,
+       0xf800029f,
+/* 0x05e5: memx_recv */
+       0x01d6b000,
+       0xb0a30bf4,
+       0x0bf400d6,
+/* 0x05f3: memx_init */
+       0xf800f8dc,
+/* 0x05f5: perf_recv */
+/* 0x05f7: perf_init */
        0xf800f800,
-/* 0x0625: perf_init */
-/* 0x0627: i2c_drive_scl */
-       0xb000f800,
-       0x0bf40036,
-       0x07e0400d,
-       0xbd0001f6,
-/* 0x0637: i2c_drive_scl_lo */
-       0x4000f804,
-       0x01f607e4,
-       0xf804bd00,
-/* 0x0641: i2c_drive_sda */
+/* 0x05f9: i2c_drive_scl */
        0x0036b000,
        0x400d0bf4,
-       0x02f607e0,
+       0x01f607e0,
        0xf804bd00,
-/* 0x0651: i2c_drive_sda_lo */
+/* 0x0609: i2c_drive_scl_lo */
        0x07e44000,
+       0xbd0001f6,
+/* 0x0613: i2c_drive_sda */
+       0xb000f804,
+       0x0bf40036,
+       0x07e0400d,
        0xbd0002f6,
-/* 0x065b: i2c_sense_scl */
-       0xf400f804,
-       0xc4430132,
-       0x0033cf07,
-       0xf40431fd,
-       0x31f4060b,
-/* 0x066d: i2c_sense_scl_done */
-/* 0x066f: i2c_sense_sda */
-       0xf400f801,
-       0xc4430132,
-       0x0033cf07,
-       0xf40432fd,
-       0x31f4060b,
-/* 0x0681: i2c_sense_sda_done */
-/* 0x0683: i2c_raise_scl */
-       0xf900f801,
-       0x08984440,
-       0x277e0103,
-/* 0x068e: i2c_raise_scl_wait */
-       0xe84e0006,
-       0x005d7e03,
-       0x065b7e00,
-       0x0901f400,
-       0xf40142b6,
-/* 0x06a2: i2c_raise_scl_done */
-       0x40fcef1b,
-/* 0x06a6: i2c_start */
-       0x5b7e00f8,
-       0x11f40006,
-       0x066f7e0d,
-       0x0611f400,
-/* 0x06b7: i2c_start_rep */
-       0x032e0ef4,
-       0x06277e00,
-       0x7e010300,
-       0xbb000641,
-       0x65b60076,
-       0x9450f904,
-       0x56bb0465,
-       0xfd50bd02,
-       0x50fc0475,
-       0x0006837e,
-       0xf40464b6,
-/* 0x06e2: i2c_start_send */
-       0x00031d11,
-       0x0006417e,
-       0x7e13884e,
-       0x0300005d,
-       0x06277e00,
+/* 0x0623: i2c_drive_sda_lo */
+       0x4000f804,
+       0x02f607e4,
+       0xf804bd00,
+/* 0x062d: i2c_sense_scl */
+       0x0132f400,
+       0xcf07c443,
+       0x31fd0033,
+       0x060bf404,
+/* 0x063f: i2c_sense_scl_done */
+       0xf80131f4,
+/* 0x0641: i2c_sense_sda */
+       0x0132f400,
+       0xcf07c443,
+       0x32fd0033,
+       0x060bf404,
+/* 0x0653: i2c_sense_sda_done */
+       0xf80131f4,
+/* 0x0655: i2c_raise_scl */
+       0x4440f900,
+       0x01030898,
+       0x0005f97e,
+/* 0x0660: i2c_raise_scl_wait */
+       0x7e03e84e,
+       0x7e000058,
+       0xf400062d,
+       0x42b60901,
+       0xef1bf401,
+/* 0x0674: i2c_raise_scl_done */
+       0x00f840fc,
+/* 0x0678: i2c_start */
+       0x00062d7e,
+       0x7e0d11f4,
+       0xf4000641,
+       0x0ef40611,
+/* 0x0689: i2c_start_rep */
+       0x7e00032e,
+       0x030005f9,
+       0x06137e01,
+       0x0076bb00,
+       0xf90465b6,
+       0x04659450,
+       0xbd0256bb,
+       0x0475fd50,
+       0x557e50fc,
+       0x64b60006,
+       0x1d11f404,
+/* 0x06b4: i2c_start_send */
+       0x137e0003,
+       0x884e0006,
+       0x00587e13,
+       0x7e000300,
+       0x4e0005f9,
+       0x587e1388,
+/* 0x06ce: i2c_start_out */
+       0x00f80000,
+/* 0x06d0: i2c_stop */
+       0xf97e0003,
+       0x00030005,
+       0x0006137e,
+       0x7e03e84e,
+       0x03000058,
+       0x05f97e01,
        0x13884e00,
-       0x00005d7e,
-/* 0x06fc: i2c_start_out */
-/* 0x06fe: i2c_stop */
-       0x000300f8,
-       0x0006277e,
-       0x417e0003,
-       0xe84e0006,
-       0x005d7e03,
-       0x7e010300,
-       0x4e000627,
-       0x5d7e1388,
-       0x01030000,
-       0x0006417e,
-       0x7e13884e,
-       0xf800005d,
-/* 0x072d: i2c_bitw */
-       0x06417e00,
-       0x03e84e00,
-       0x00005d7e,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0x06837e50,
-       0x0464b600,
-       0x4e1711f4,
-       0x5d7e1388,
-       0x00030000,
-       0x0006277e,
-       0x7e13884e,
-/* 0x076b: i2c_bitw_out */
-       0xf800005d,
-/* 0x076d: i2c_bitr */
-       0x7e010300,
-       0x4e000641,
-       0x5d7e03e8,
+       0x0000587e,
+       0x137e0103,
+       0x884e0006,
+       0x00587e13,
+/* 0x06ff: i2c_bitw */
+       0x7e00f800,
+       0x4e000613,
+       0x587e03e8,
        0x76bb0000,
        0x0465b600,
        0x659450f9,
        0x0256bb04,
        0x75fd50bd,
        0x7e50fc04,
-       0xb6000683,
+       0xb6000655,
        0x11f40464,
-       0x066f7e1a,
-       0x7e000300,
-       0x4e000627,
-       0x5d7e1388,
-       0x3cf00000,
-       0x0131f401,
-/* 0x07b0: i2c_bitr_done */
-/* 0x07b2: i2c_get_byte */
-       0x000500f8,
-/* 0x07b6: i2c_get_byte_next */
-       0x54b60804,
-       0x0076bb01,
-       0xf90465b6,
-       0x04659450,
-       0xbd0256bb,
-       0x0475fd50,
-       0x6d7e50fc,
-       0x64b60007,
-       0x2a11f404,
-       0xb60553fd,
-       0x1bf40142,
-       0xbb0103d8,
+       0x13884e17,
+       0x0000587e,
+       0xf97e0003,
+       0x884e0005,
+       0x00587e13,
+/* 0x073d: i2c_bitw_out */
+/* 0x073f: i2c_bitr */
+       0x0300f800,
+       0x06137e01,
+       0x03e84e00,
+       0x0000587e,
+       0xb60076bb,
+       0x50f90465,
+       0xbb046594,
+       0x50bd0256,
+       0xfc0475fd,
+       0x06557e50,
+       0x0464b600,
+       0x7e1a11f4,
+       0x03000641,
+       0x05f97e00,
+       0x13884e00,
+       0x0000587e,
+       0xf4013cf0,
+/* 0x0782: i2c_bitr_done */
+       0x00f80131,
+/* 0x0784: i2c_get_byte */
+       0x08040005,
+/* 0x0788: i2c_get_byte_next */
+       0xbb0154b6,
        0x65b60076,
        0x9450f904,
        0x56bb0465,
        0xfd50bd02,
        0x50fc0475,
-       0x00072d7e,
-/* 0x07ff: i2c_get_byte_done */
-       0xf80464b6,
-/* 0x0801: i2c_put_byte */
-/* 0x0803: i2c_put_byte_next */
-       0xb6080400,
-       0x54ff0142,
-       0x0076bb38,
+       0x00073f7e,
+       0xf40464b6,
+       0x53fd2a11,
+       0x0142b605,
+       0x03d81bf4,
+       0x0076bb01,
        0xf90465b6,
        0x04659450,
        0xbd0256bb,
        0x0475fd50,
-       0x2d7e50fc,
-       0x64b60007,
-       0x3411f404,
-       0xf40046b0,
-       0x76bbd81b,
-       0x0465b600,
-       0x659450f9,
-       0x0256bb04,
-       0x75fd50bd,
-       0x7e50fc04,
-       0xb600076d,
-       0x11f40464,
-       0x0076bb0f,
-       0xf40136b0,
-       0x32f4061b,
-/* 0x0859: i2c_put_byte_done */
-/* 0x085b: i2c_addr */
-       0xbb00f801,
+       0xff7e50fc,
+       0x64b60006,
+/* 0x07d1: i2c_get_byte_done */
+/* 0x07d3: i2c_put_byte */
+       0x0400f804,
+/* 0x07d5: i2c_put_byte_next */
+       0x0142b608,
+       0xbb3854ff,
        0x65b60076,
        0x9450f904,
        0x56bb0465,
        0xfd50bd02,
        0x50fc0475,
-       0x0006a67e,
+       0x0006ff7e,
        0xf40464b6,
-       0xc3e72911,
-       0x34b6012e,
-       0x0553fd01,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0x08017e50,
-       0x0464b600,
-/* 0x08a0: i2c_addr_done */
-/* 0x08a2: i2c_acquire_addr */
-       0xcec700f8,
-       0x05e4b6f8,
-       0xd014e0b7,
-/* 0x08ae: i2c_acquire */
-       0xa27e00f8,
-       0x047e0008,
-       0xd9f00000,
-       0x002e7e03,
-/* 0x08bf: i2c_release */
-       0x7e00f800,
-       0x7e0008a2,
-       0xf0000004,
-       0x2e7e03da,
-       0x00f80000,
-/* 0x08d0: i2c_recv */
-       0xc70132f4,
-       0x14b6f8c1,
-       0x2816b002,
-       0x01371ff5,
-       0x0cf413b8,
-       0x00329800,
-       0x0ccc13b8,
-       0x00319800,
-       0xf90231f4,
-       0xf9e0f9d0,
-       0x0067f1d0,
-       0x0063f100,
-       0x01679210,
+       0x46b03411,
+       0xd81bf400,
        0xb60076bb,
        0x50f90465,
        0xbb046594,
        0x50bd0256,
        0xfc0475fd,
-       0x08ae7e50,
+       0x073f7e50,
        0x0464b600,
-       0xd6b0d0fc,
-       0xb01bf500,
-       0xbb000500,
+       0xbb0f11f4,
+       0x36b00076,
+       0x061bf401,
+/* 0x082b: i2c_put_byte_done */
+       0xf80132f4,
+/* 0x082d: i2c_addr */
+       0x0076bb00,
+       0xf90465b6,
+       0x04659450,
+       0xbd0256bb,
+       0x0475fd50,
+       0x787e50fc,
+       0x64b60006,
+       0x2911f404,
+       0x012ec3e7,
+       0xfd0134b6,
+       0x76bb0553,
+       0x0465b600,
+       0x659450f9,
+       0x0256bb04,
+       0x75fd50bd,
+       0x7e50fc04,
+       0xb60007d3,
+/* 0x0872: i2c_addr_done */
+       0x00f80464,
+/* 0x0874: i2c_acquire_addr */
+       0xb6f8cec7,
+       0xe0b705e4,
+       0x00f8d014,
+/* 0x0880: i2c_acquire */
+       0x0008747e,
+       0x0000047e,
+       0x7e03d9f0,
+       0xf800002d,
+/* 0x0891: i2c_release */
+       0x08747e00,
+       0x00047e00,
+       0x03daf000,
+       0x00002d7e,
+/* 0x08a2: i2c_recv */
+       0x32f400f8,
+       0xf8c1c701,
+       0xb00214b6,
+       0x1ff52816,
+       0x13b80134,
+       0x98000cf4,
+       0x13b80032,
+       0x98000ccc,
+       0x31f40031,
+       0xf9d0f902,
+       0xd6d0f9e0,
+       0x10000000,
+       0xbb016792,
        0x65b60076,
        0x9450f904,
        0x56bb0465,
        0xfd50bd02,
        0x50fc0475,
-       0x00085b7e,
-       0xf50464b6,
-       0xc700cc11,
-       0x76bbe0c5,
+       0x0008807e,
+       0xfc0464b6,
+       0x00d6b0d0,
+       0x00b01bf5,
+       0x76bb0005,
        0x0465b600,
        0x659450f9,
        0x0256bb04,
        0x75fd50bd,
        0x7e50fc04,
-       0xb6000801,
+       0xb600082d,
        0x11f50464,
-       0x010500a9,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0x085b7e50,
-       0x0464b600,
-       0x008711f5,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0x07b27e50,
-       0x0464b600,
-       0xcb6711f4,
-       0x76bbe05b,
-       0x0465b600,
-       0x659450f9,
-       0x0256bb04,
-       0x75fd50bd,
-       0x7e50fc04,
-       0xb60006fe,
-       0x5bb20464,
-       0x0ef474bd,
-/* 0x09d5: i2c_recv_not_rd08 */
-       0x01d6b041,
-       0x053b1bf4,
-       0x085b7e00,
-       0x3211f400,
-       0x7ee0c5c7,
-       0xf4000801,
-       0x00052811,
-       0x00085b7e,
-       0xc71f11f4,
-       0x017ee0b5,
-       0x11f40008,
-       0x06fe7e15,
-       0xc774bd00,
-       0x1bf408c5,
-       0x0232f409,
-/* 0x0a13: i2c_recv_not_wr08 */
-/* 0x0a13: i2c_recv_done */
-       0xc7030ef4,
-       0xbf7ef8ce,
-       0xe0fc0008,
-       0x12f4d0fc,
-       0x7e7cb209,
-/* 0x0a27: i2c_recv_exit */
-       0xf80002b6,
-/* 0x0a29: i2c_init */
-/* 0x0a2b: test_recv */
-       0x4100f800,
-       0x11cf0458,
-       0x0110b600,
-       0xf6045840,
-       0x04bd0001,
-       0xd900e7f1,
-       0x134fe3f1,
-       0x0001f57e,
-/* 0x0a4a: test_init */
+       0xc5c700cc,
+       0x0076bbe0,
+       0xf90465b6,
+       0x04659450,
+       0xbd0256bb,
+       0x0475fd50,
+       0xd37e50fc,
+       0x64b60007,
+       0xa911f504,
+       0xbb010500,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x00082d7e,
+       0xf50464b6,
+       0xbb008711,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x0007847e,
+       0xf40464b6,
+       0x5bcb6711,
+       0x0076bbe0,
+       0xf90465b6,
+       0x04659450,
+       0xbd0256bb,
+       0x0475fd50,
+       0xd07e50fc,
+       0x64b60006,
+       0xbd5bb204,
+       0x410ef474,
+/* 0x09a4: i2c_recv_not_rd08 */
+       0xf401d6b0,
+       0x00053b1b,
+       0x00082d7e,
+       0xc73211f4,
+       0xd37ee0c5,
+       0x11f40007,
+       0x7e000528,
+       0xf400082d,
+       0xb5c71f11,
+       0x07d37ee0,
+       0x1511f400,
+       0x0006d07e,
+       0xc5c774bd,
+       0x091bf408,
+       0xf40232f4,
+/* 0x09e2: i2c_recv_not_wr08 */
+/* 0x09e2: i2c_recv_done */
+       0xcec7030e,
+       0x08917ef8,
+       0xfce0fc00,
+       0x0912f4d0,
+       0x9f7e7cb2,
+/* 0x09f6: i2c_recv_exit */
+       0x00f80002,
+/* 0x09f8: i2c_init */
+/* 0x09fa: test_recv */
+       0x584100f8,
+       0x0011cf04,
+       0x400110b6,
+       0x01f60458,
+       0xde04bd00,
+       0x134fd900,
+       0x0001de7e,
+/* 0x0a16: test_init */
        0x004e00f8,
-       0x01f57e08,
-/* 0x0a53: idle_recv */
+       0x01de7e08,
+/* 0x0a1f: idle_recv */
        0xf800f800,
-/* 0x0a55: idle */
+/* 0x0a21: idle */
        0x0031f400,
        0xcf045441,
        0x10b60011,
        0x04544001,
        0xbd0001f6,
-/* 0x0a69: idle_loop */
+/* 0x0a35: idle_loop */
        0xf4580104,
-/* 0x0a6e: idle_proc */
-/* 0x0a6e: idle_proc_exec */
+/* 0x0a3a: idle_proc */
+/* 0x0a3a: idle_proc_exec */
        0x10f90232,
-       0xbf7e1eb2,
+       0xa87e1eb2,
        0x10fc0002,
        0xf40911f4,
        0x0ef40231,
-/* 0x0a81: idle_proc_next */
+/* 0x0a4d: idle_proc_next */
        0x5810b6f0,
        0x1bf41fa6,
        0xe002f4e8,
@@ -1726,4 +1713,17 @@ uint32_t gk208_pmu_code[] = {
        0x00000000,
        0x00000000,
        0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
+       0x00000000,
 };
index 5165692..e833418 100644 (file)
@@ -24,8 +24,8 @@ uint32_t gt215_pmu_data[] = {
        0x00000000,
 /* 0x0058: proc_list_head */
        0x54534f48,
-       0x00000507,
-       0x000004a4,
+       0x0000050a,
+       0x000004a7,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -46,8 +46,8 @@ uint32_t gt215_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x584d454d,
-       0x00000837,
-       0x00000829,
+       0x0000083a,
+       0x0000082c,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -68,8 +68,8 @@ uint32_t gt215_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x46524550,
-       0x0000083b,
-       0x00000839,
+       0x0000083e,
+       0x0000083c,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -90,8 +90,8 @@ uint32_t gt215_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x5f433249,
-       0x00000c6b,
-       0x00000b0e,
+       0x00000c6e,
+       0x00000b11,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -112,8 +112,8 @@ uint32_t gt215_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x54534554,
-       0x00000c94,
-       0x00000c6d,
+       0x00000c97,
+       0x00000c70,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -134,8 +134,8 @@ uint32_t gt215_pmu_data[] = {
        0x00000000,
        0x00000000,
        0x454c4449,
-       0x00000ca0,
-       0x00000c9e,
+       0x00000ca3,
+       0x00000ca1,
        0x00000000,
        0x00000000,
        0x00000000,
@@ -229,26 +229,26 @@ uint32_t gt215_pmu_data[] = {
 /* 0x0370: memx_func_head */
        0x00000001,
        0x00000000,
-       0x00000546,
+       0x00000549,
 /* 0x037c: memx_func_next */
        0x00000002,
        0x00000000,
-       0x0000059d,
+       0x000005a0,
        0x00000003,
        0x00000002,
-       0x0000062f,
+       0x00000632,
        0x00040004,
        0x00000000,
-       0x0000064b,
+       0x0000064e,
        0x00010005,
        0x00000000,
-       0x00000668,
+       0x0000066b,
        0x00010006,
        0x00000000,
-       0x000005ed,
+       0x000005f0,
        0x00000007,
        0x00000000,
-       0x00000673,
+       0x00000676,
 /* 0x03c4: memx_func_tail */
 /* 0x03c4: memx_ts_start */
        0x00000000,
@@ -917,947 +917,947 @@ uint32_t gt215_pmu_data[] = {
 };
 
 uint32_t gt215_pmu_code[] = {
-       0x03930ef5,
+       0x03920ef5,
 /* 0x0004: rd32 */
        0x07a007f1,
        0xd00604b6,
        0x04bd000e,
-       0xf001d7f0,
-       0x07f101d3,
-       0x04b607ac,
-       0x000dd006,
-/* 0x0022: rd32_wait */
-       0xd7f104bd,
-       0xd4b607ac,
-       0x00ddcf06,
-       0x7000d4f1,
-       0xf1f21bf4,
-       0xb607a4d7,
-       0xddcf06d4,
-/* 0x003f: wr32 */
-       0xf100f800,
-       0xb607a007,
-       0x0ed00604,
-       0xf104bd00,
-       0xb607a407,
+       0x0001d7f1,
+       0xf101d3f0,
+       0xb607ac07,
        0x0dd00604,
-       0xf004bd00,
-       0xd5f002d7,
-       0x01d3f0f0,
-       0x07ac07f1,
+/* 0x0023: rd32_wait */
+       0xf104bd00,
+       0xb607acd7,
+       0xddcf06d4,
+       0x00d4f100,
+       0xf21bf470,
+       0x07a4d7f1,
+       0xcf06d4b6,
+       0x00f800dd,
+/* 0x0040: wr32 */
+       0x07a007f1,
+       0xd00604b6,
+       0x04bd000e,
+       0x07a407f1,
        0xd00604b6,
        0x04bd000d,
-/* 0x006c: wr32_wait */
-       0x07acd7f1,
-       0xcf06d4b6,
-       0xd4f100dd,
-       0x1bf47000,
-/* 0x007f: nsec */
-       0xf900f8f2,
-       0xf080f990,
-       0x84b62c87,
-       0x0088cf06,
-/* 0x008c: nsec_loop */
-       0xb62c97f0,
-       0x99cf0694,
-       0x0298bb00,
-       0xf4069eb8,
-       0x80fcf11e,
-       0x00f890fc,
-/* 0x00a4: wait */
-       0x80f990f9,
-       0xb62c87f0,
-       0x88cf0684,
-/* 0x00b1: wait_loop */
-       0x02eeb900,
-       0xb90421f4,
-       0xadfd02da,
-       0x06acb804,
-       0xf0150bf4,
+       0x00f2d7f1,
+       0xf101d3f0,
+       0xb607ac07,
+       0x0dd00604,
+/* 0x006b: wr32_wait */
+       0xf104bd00,
+       0xb607acd7,
+       0xddcf06d4,
+       0x00d4f100,
+       0xf21bf470,
+/* 0x007e: nsec */
+       0x90f900f8,
+       0x87f080f9,
+       0x0684b62c,
+/* 0x008b: nsec_loop */
+       0xf00088cf,
        0x94b62c97,
        0x0099cf06,
        0xb80298bb,
-       0x1ef4069b,
-/* 0x00d5: wait_done */
-       0xfc80fcdf,
-/* 0x00db: intr_watchdog */
-       0x9800f890,
-       0x96b003e9,
-       0x2a0bf400,
-       0xbb9a0a98,
-       0x1cf4029a,
-       0x01d7f00f,
-       0x02d221f5,
-       0x0ef494bd,
-/* 0x00f9: intr_watchdog_next_time */
-       0x9b0a9815,
-       0xf400a6b0,
-       0x9ab8090b,
-       0x061cf406,
-/* 0x0108: intr_watchdog_next_time_set */
-/* 0x010b: intr_watchdog_next_proc */
-       0x809b0980,
-       0xe0b603e9,
-       0x68e6b158,
-       0xc61bf402,
-/* 0x011a: intr */
-       0x00f900f8,
-       0x80f904bd,
-       0xa0f990f9,
-       0xc0f9b0f9,
-       0xe0f9d0f9,
-       0xf7f0f0f9,
-       0x0188fe00,
-       0x87f180f9,
-       0x84b605d0,
+       0x1ef4069e,
+       0xfc80fcf1,
+/* 0x00a3: wait */
+       0xf900f890,
+       0xf080f990,
+       0x84b62c87,
        0x0088cf06,
-       0xf10180b6,
-       0xb605d007,
+/* 0x00b0: wait_loop */
+       0xf402eeb9,
+       0xdab90421,
+       0x04adfd02,
+       0xf406acb8,
+       0x97f0150b,
+       0x0694b62c,
+       0xbb0099cf,
+       0x9bb80298,
+       0xdf1ef406,
+/* 0x00d4: wait_done */
+       0x90fc80fc,
+/* 0x00da: intr_watchdog */
+       0xe99800f8,
+       0x0096b003,
+       0x982a0bf4,
+       0x9abb9a0a,
+       0x0f1cf402,
+       0xf501d7f0,
+       0xbd02d121,
+       0x150ef494,
+/* 0x00f8: intr_watchdog_next_time */
+       0xb09b0a98,
+       0x0bf400a6,
+       0x069ab809,
+/* 0x0107: intr_watchdog_next_time_set */
+       0x80061cf4,
+/* 0x010a: intr_watchdog_next_proc */
+       0xe9809b09,
+       0x58e0b603,
+       0x0268e6b1,
+       0xf8c61bf4,
+/* 0x0119: intr */
+       0xbd00f900,
+       0xf980f904,
+       0xf9a0f990,
+       0xf9c0f9b0,
+       0xf9e0f9d0,
+       0x00f7f0f0,
+       0xf90188fe,
+       0xd087f180,
+       0x0684b605,
+       0xb60088cf,
+       0x07f10180,
+       0x04b605d0,
+       0x0008d006,
+       0x87f004bd,
+       0x0684b608,
+       0xc40088cf,
+       0x0bf40289,
+       0x9b008023,
+       0xf458e7f0,
+       0x0998da21,
+       0x0096b09b,
+       0xf0110bf4,
+       0x04b63407,
+       0x0009d006,
+       0x098004bd,
+/* 0x017d: intr_skip_watchdog */
+       0x0089e49a,
+       0x480bf408,
+       0x068897f1,
+       0xcf0694b6,
+       0x9ac40099,
+       0x2c0bf402,
+       0x04c0c7f1,
+       0xcf06c4b6,
+       0xc0f900cc,
+       0x4f48e7f1,
+       0x5453e3f1,
+       0xf500d7f0,
+       0xfc033621,
+       0xc007f1c0,
+       0x0604b604,
+       0xbd000cd0,
+/* 0x01bd: intr_subintr_skip_fifo */
+       0x8807f104,
+       0x0604b606,
+       0xbd0009d0,
+/* 0x01c9: intr_skip_subintr */
+       0xe097f104,
+       0xfd90bd00,
+       0x07f00489,
+       0x0604b604,
+       0xbd0008d0,
+       0xfe80fc04,
+       0xf0fc0088,
+       0xd0fce0fc,
+       0xb0fcc0fc,
+       0x90fca0fc,
+       0x00fc80fc,
+       0xf80032f4,
+/* 0x01f9: ticks_from_ns */
+       0xf9c0f901,
+       0xcbd7f1b0,
+       0x00d3f000,
+       0x040b21f5,
+       0x03e8ccec,
+       0xf400b4b0,
+       0xeeec120b,
+       0xd7f103e8,
+       0xd3f000cb,
+       0x0b21f500,
+/* 0x0221: ticks_from_ns_quit */
+       0x02ceb904,
+       0xc0fcb0fc,
+/* 0x022a: ticks_from_us */
+       0xc0f900f8,
+       0xd7f1b0f9,
+       0xd3f000cb,
+       0x0b21f500,
+       0x02ceb904,
+       0xf400b4b0,
+       0xe4bd050b,
+/* 0x0244: ticks_from_us_quit */
+       0xc0fcb0fc,
+/* 0x024a: ticks_to_us */
+       0xd7f100f8,
+       0xd3f000cb,
+       0xecedff00,
+/* 0x0256: timer */
+       0x90f900f8,
+       0x32f480f9,
+       0x03f89810,
+       0xf40086b0,
+       0x84bd651c,
+       0xb63807f0,
        0x08d00604,
        0xf004bd00,
-       0x84b60887,
+       0x84b63487,
        0x0088cf06,
-       0xf40289c4,
-       0x0080230b,
-       0x58e7f09b,
-       0x98db21f4,
-       0x96b09b09,
-       0x110bf400,
+       0xbb9a0998,
+       0xe9bb0298,
+       0x03fe8000,
+       0xb60887f0,
+       0x88cf0684,
+       0x0284f000,
+       0xf0261bf4,
+       0x84b63487,
+       0x0088cf06,
+       0xf406e0b8,
+       0xe8b8090b,
+       0x111cf406,
+/* 0x02ac: timer_reset */
        0xb63407f0,
-       0x09d00604,
+       0x0ed00604,
        0x8004bd00,
-/* 0x017e: intr_skip_watchdog */
-       0x89e49a09,
-       0x0bf40800,
-       0x8897f148,
-       0x0694b606,
-       0xc40099cf,
-       0x0bf4029a,
-       0xc0c7f12c,
-       0x06c4b604,
-       0xf900cccf,
-       0x48e7f1c0,
-       0x53e3f14f,
-       0x00d7f054,
-       0x033721f5,
-       0x07f1c0fc,
-       0x04b604c0,
-       0x000cd006,
-/* 0x01be: intr_subintr_skip_fifo */
-       0x07f104bd,
-       0x04b60688,
-       0x0009d006,
-/* 0x01ca: intr_skip_subintr */
-       0x97f104bd,
-       0x90bd00e0,
-       0xf00489fd,
-       0x04b60407,
-       0x0008d006,
-       0x80fc04bd,
-       0xfc0088fe,
-       0xfce0fcf0,
-       0xfcc0fcd0,
-       0xfca0fcb0,
-       0xfc80fc90,
-       0x0032f400,
-/* 0x01fa: ticks_from_ns */
-       0xc0f901f8,
-       0xd7f1b0f9,
-       0xd3f000cb,
-       0x0821f500,
-       0xe8ccec04,
-       0x00b4b003,
-       0xec120bf4,
-       0xf103e8ee,
-       0xf000cbd7,
-       0x21f500d3,
-/* 0x0222: ticks_from_ns_quit */
-       0xceb90408,
-       0xfcb0fc02,
-/* 0x022b: ticks_from_us */
-       0xf900f8c0,
-       0xf1b0f9c0,
-       0xf000cbd7,
-       0x21f500d3,
-       0xceb90408,
-       0x00b4b002,
-       0xbd050bf4,
-/* 0x0245: ticks_from_us_quit */
-       0xfcb0fce4,
-/* 0x024b: ticks_to_us */
-       0xf100f8c0,
-       0xf000cbd7,
-       0xedff00d3,
-/* 0x0257: timer */
-       0xf900f8ec,
-       0xf480f990,
-       0xf8981032,
-       0x0086b003,
-       0xbd651cf4,
-       0x3807f084,
+/* 0x02ba: timer_enable */
+       0x87f09a0e,
+       0x3807f001,
        0xd00604b6,
        0x04bd0008,
-       0xb63487f0,
-       0x88cf0684,
-       0x9a099800,
-       0xbb0298bb,
-       0xfe8000e9,
-       0x0887f003,
-       0xcf0684b6,
-       0x84f00088,
-       0x261bf402,
-       0xb63487f0,
-       0x88cf0684,
-       0x06e0b800,
-       0xb8090bf4,
-       0x1cf406e8,
-/* 0x02ad: timer_reset */
-       0x3407f011,
-       0xd00604b6,
-       0x04bd000e,
-/* 0x02bb: timer_enable */
-       0xf09a0e80,
-       0x07f00187,
-       0x0604b638,
-       0xbd0008d0,
-/* 0x02c9: timer_done */
-       0x1031f404,
+/* 0x02c8: timer_done */
+       0xfc1031f4,
+       0xf890fc80,
+/* 0x02d1: send_proc */
+       0xf980f900,
+       0x05e89890,
+       0xf004e998,
+       0x89b80486,
+       0x2a0bf406,
+       0x940398c4,
+       0x80b60488,
+       0x008ebb18,
+       0x8000fa98,
+       0x8d80008a,
+       0x028c8001,
+       0xb6038b80,
+       0x94f00190,
+       0x04e98007,
+/* 0x030b: send_done */
+       0xfc0231f4,
+       0xf880fc90,
+/* 0x0311: find */
+       0xf080f900,
+       0x31f45887,
+/* 0x0319: find_loop */
+       0x008a9801,
+       0xf406aeb8,
+       0x80b6100b,
+       0x6886b158,
+       0xf01bf402,
+/* 0x032f: find_done */
+       0xb90132f4,
+       0x80fc028e,
+/* 0x0336: send */
+       0x21f500f8,
+       0x01f40311,
+/* 0x033f: recv */
+       0xf900f897,
+       0x9880f990,
+       0xe99805e8,
+       0x0132f404,
+       0xf40689b8,
+       0x89c43d0b,
+       0x0180b603,
+       0x800784f0,
+       0xea9805e8,
+       0xfef0f902,
+       0xf0f9018f,
+       0x9402efb9,
+       0xe9bb0499,
+       0x18e0b600,
+       0x9803eb98,
+       0xed9802ec,
+       0x00ee9801,
+       0xf0fca5f9,
+       0xf400f8fe,
+       0xf0fc0131,
+/* 0x038c: recv_done */
        0x90fc80fc,
-/* 0x02d2: send_proc */
-       0x80f900f8,
-       0xe89890f9,
-       0x04e99805,
-       0xb80486f0,
-       0x0bf40689,
-       0x0398c42a,
-       0xb6048894,
-       0x8ebb1880,
-       0x00fa9800,
-       0x80008a80,
-       0x8c80018d,
-       0x038b8002,
-       0xf00190b6,
-       0xe9800794,
-       0x0231f404,
-/* 0x030c: send_done */
-       0x80fc90fc,
-/* 0x0312: find */
-       0x80f900f8,
-       0xf45887f0,
-/* 0x031a: find_loop */
-       0x8a980131,
-       0x06aeb800,
-       0xb6100bf4,
-       0x86b15880,
-       0x1bf40268,
-       0x0132f4f0,
-/* 0x0330: find_done */
-       0xfc028eb9,
-/* 0x0337: send */
-       0xf500f880,
-       0xf4031221,
-       0x00f89701,
-/* 0x0340: recv */
-       0x80f990f9,
-       0x9805e898,
-       0x32f404e9,
-       0x0689b801,
-       0xc43d0bf4,
-       0x80b60389,
-       0x0784f001,
-       0x9805e880,
-       0xf0f902ea,
-       0xf9018ffe,
-       0x02efb9f0,
-       0xbb049994,
-       0xe0b600e9,
-       0x03eb9818,
-       0x9802ec98,
-       0xee9801ed,
-       0xfca5f900,
-       0x00f8fef0,
-       0xfc0131f4,
-/* 0x038d: recv_done */
-       0xfc80fcf0,
-/* 0x0393: init */
-       0xf100f890,
-       0xb6010817,
-       0x11cf0614,
-       0x0911e700,
-       0x0814b601,
-       0xf10014fe,
-       0xf000e017,
-       0x07f00013,
-       0x0604b61c,
-       0xbd0001d0,
-       0xff17f004,
-       0xb61407f0,
-       0x01d00604,
-       0xf004bd00,
-       0x15f10217,
-       0x07f00800,
-       0x0604b610,
-       0xbd0001d0,
-       0x1a17f104,
-       0x0013f001,
-       0xf40010fe,
-       0x17f01031,
-       0x3807f001,
+/* 0x0392: init */
+       0x17f100f8,
+       0x14b60108,
+       0x0011cf06,
+       0x010911e7,
+       0xfe0814b6,
+       0x17f10014,
+       0x13f000e0,
+       0x1c07f000,
+       0xd00604b6,
+       0x04bd0001,
+       0xf0ff17f0,
+       0x04b61407,
+       0x0001d006,
+       0x17f004bd,
+       0x0015f102,
+       0x1007f008,
        0xd00604b6,
        0x04bd0001,
-/* 0x03f7: init_proc */
-       0x9858f7f0,
-       0x16b001f1,
-       0xfa0bf400,
-       0xf0b615f9,
-       0xf20ef458,
-/* 0x0408: mulu32_32_64 */
-       0x20f910f9,
-       0x40f930f9,
-       0x9510e195,
-       0xc4bd10d2,
-       0xedffb4bd,
-       0x301dffc0,
-       0xf10234b9,
-       0xb6ffff34,
-       0x45b61034,
-       0x00c3bb10,
-       0xff01b4bb,
-       0x34b930e2,
-       0xff34f102,
-       0x1034b6ff,
-       0xbb1045b6,
-       0xb4bb00c3,
-       0x3012ff01,
-       0xfc00b3bb,
-       0xfc30fc40,
-       0xf810fc20,
-/* 0x0459: host_send */
-       0xb017f100,
+       0x011917f1,
+       0xf10013f0,
+       0xfeffff14,
+       0x31f40010,
+       0x0117f010,
+       0xb63807f0,
+       0x01d00604,
+       0xf004bd00,
+/* 0x03fa: init_proc */
+       0xf19858f7,
+       0x0016b001,
+       0xf9fa0bf4,
+       0x58f0b615,
+/* 0x040b: mulu32_32_64 */
+       0xf9f20ef4,
+       0xf920f910,
+       0x9540f930,
+       0xd29510e1,
+       0xbdc4bd10,
+       0xc0edffb4,
+       0xb9301dff,
+       0x34f10234,
+       0x34b6ffff,
+       0x1045b610,
+       0xbb00c3bb,
+       0xe2ff01b4,
+       0x0234b930,
+       0xffff34f1,
+       0xb61034b6,
+       0xc3bb1045,
+       0x01b4bb00,
+       0xbb3012ff,
+       0x40fc00b3,
+       0x20fc30fc,
+       0x00f810fc,
+/* 0x045c: host_send */
+       0x04b017f1,
+       0xcf0614b6,
+       0x27f10011,
+       0x24b604a0,
+       0x0022cf06,
+       0xf40612b8,
+       0x1ec4320b,
+       0x04ee9407,
+       0x0270e0b7,
+       0x9803eb98,
+       0xed9802ec,
+       0x00ee9801,
+       0x033621f5,
+       0xc40110b6,
+       0x07f10f1e,
+       0x04b604b0,
+       0x000ed006,
+       0x0ef404bd,
+/* 0x04a5: host_send_done */
+/* 0x04a7: host_recv */
+       0xf100f8ba,
+       0xf14e4917,
+       0xb8525413,
+       0x0bf406e1,
+/* 0x04b5: host_recv_wait */
+       0xcc17f1aa,
        0x0614b604,
        0xf10011cf,
-       0xb604a027,
+       0xb604c827,
        0x22cf0624,
-       0x0612b800,
-       0xc4320bf4,
-       0xee94071e,
-       0x70e0b704,
-       0x03eb9802,
-       0x9802ec98,
-       0xee9801ed,
-       0x3721f500,
-       0x0110b603,
-       0xf10f1ec4,
-       0xb604b007,
-       0x0ed00604,
-       0xf404bd00,
-/* 0x04a2: host_send_done */
-       0x00f8ba0e,
-/* 0x04a4: host_recv */
-       0x4e4917f1,
-       0x525413f1,
-       0xf406e1b8,
-/* 0x04b2: host_recv_wait */
-       0x17f1aa0b,
-       0x14b604cc,
-       0x0011cf06,
-       0x04c827f1,
-       0xcf0624b6,
-       0x16f00022,
-       0x0612b808,
-       0xc4e60bf4,
-       0x34b60723,
-       0xf030b704,
-       0x033b8002,
-       0x80023c80,
-       0x3e80013d,
-       0x0120b600,
-       0xf10f24f0,
-       0xb604c807,
-       0x02d00604,
-       0xf004bd00,
-       0x07f04027,
-       0x0604b600,
-       0xbd0002d0,
-/* 0x0507: host_init */
-       0xf100f804,
-       0xb6008017,
-       0x15f11014,
-       0x07f10270,
-       0x04b604d0,
-       0x0001d006,
-       0x17f104bd,
+       0x0816f000,
+       0xf40612b8,
+       0x23c4e60b,
+       0x0434b607,
+       0x02f030b7,
+       0x80033b80,
+       0x3d80023c,
+       0x003e8001,
+       0xf00120b6,
+       0x07f10f24,
+       0x04b604c8,
+       0x0002d006,
+       0x27f004bd,
+       0x0007f040,
+       0xd00604b6,
+       0x04bd0002,
+/* 0x050a: host_init */
+       0x17f100f8,
        0x14b60080,
-       0xf015f110,
-       0xdc07f102,
+       0x7015f110,
+       0xd007f102,
        0x0604b604,
        0xbd0001d0,
-       0x0117f004,
-       0x04c407f1,
+       0x8017f104,
+       0x1014b600,
+       0x02f015f1,
+       0x04dc07f1,
        0xd00604b6,
        0x04bd0001,
-/* 0x0546: memx_func_enter */
-       0x87f100f8,
-       0x8eb91610,
-       0x0421f402,
-       0xf102d7b9,
-       0xf1fffc67,
-       0xfdffff63,
-       0x67f10476,
-       0x76fd0002,
-       0xf980f905,
-       0xfcd0fc70,
-       0x3f21f4e0,
+       0xf10117f0,
+       0xb604c407,
+       0x01d00604,
+       0xf804bd00,
+/* 0x0549: memx_func_enter */
+       0x1087f100,
+       0x028eb916,
+       0xb90421f4,
+       0x67f102d7,
+       0x63f1fffc,
+       0x76fdffff,
+       0x0267f104,
+       0x0576fd00,
+       0x70f980f9,
+       0xe0fcd0fc,
+       0xf04021f4,
+       0x07f10467,
+       0x04b607e0,
+       0x0006d006,
+/* 0x0582: memx_func_enter_wait */
+       0x67f104bd,
+       0x64b607c0,
+       0x0066cf06,
+       0xf40464f0,
+       0x67f0f30b,
+       0x0664b62c,
+       0x800066cf,
+       0x00f8f106,
+/* 0x05a0: memx_func_leave */
+       0xb62c67f0,
+       0x66cf0664,
+       0xf2068000,
        0xf10467f0,
-       0xb607e007,
+       0xb607e407,
        0x06d00604,
-/* 0x057f: memx_func_enter_wait */
+/* 0x05bb: memx_func_leave_wait */
        0xf104bd00,
        0xb607c067,
        0x66cf0664,
        0x0464f000,
-       0xf0f30bf4,
-       0x64b62c67,
-       0x0066cf06,
-       0xf8f10680,
-/* 0x059d: memx_func_leave */
-       0x2c67f000,
-       0xcf0664b6,
-       0x06800066,
-       0x0467f0f2,
-       0x07e407f1,
-       0xd00604b6,
-       0x04bd0006,
-/* 0x05b8: memx_func_leave_wait */
-       0x07c067f1,
-       0xcf0664b6,
-       0x64f00066,
-       0xf31bf404,
-       0x161087f1,
-       0xf4028eb9,
-       0xd7b90421,
-       0xcc67f102,
-       0xff63f1ff,
-       0x0476fdff,
-       0x70f980f9,
-       0xe0fcd0fc,
-       0xf83f21f4,
-/* 0x05ed: memx_func_wait_vblank */
-       0x00169800,
-       0xf40066b0,
-       0x66b0130b,
-       0x060bf401,
-/* 0x05ff: memx_func_wait_vblank_head1 */
-       0xf12e0ef4,
-       0xf4002077,
-/* 0x0606: memx_func_wait_vblank_head0 */
-       0x77f1070e,
-/* 0x060a: memx_func_wait_vblank_0 */
-       0x67f10008,
-       0x64b607c4,
-       0x0066cf06,
-       0xf40467fd,
-/* 0x061a: memx_func_wait_vblank_1 */
-       0x67f1f31b,
-       0x64b607c4,
-       0x0066cf06,
-       0xf40467fd,
-/* 0x062a: memx_func_wait_vblank_fini */
-       0x10b6f30b,
-/* 0x062f: memx_func_wr32 */
-       0x9800f804,
-       0x15980016,
-       0x0810b601,
-       0x50f960f9,
-       0xe0fcd0fc,
-       0xb63f21f4,
-       0x1bf40242,
-/* 0x064b: memx_func_wait */
-       0xf000f8e9,
-       0x84b62c87,
-       0x0088cf06,
-       0x98001e98,
-       0x1c98011d,
-       0x031b9802,
-       0xf41010b6,
-       0x00f8a421,
-/* 0x0668: memx_func_delay */
-       0xb6001e98,
-       0x21f40410,
-/* 0x0673: memx_func_train */
-       0xf100f87f,
-       0xf1000357,
-       0xf1000077,
-       0xf0000097,
-       0x9eb97093,
-       0x0421f402,
-       0xf102d8b9,
-       0xf42710e7,
-/* 0x0692: memx_func_train_loop_outer */
-       0x58e07f21,
-       0x83f10101,
-       0x97f10200,
-       0x93f011e0,
-       0xf990f911,
-       0xfcd0fc80,
-       0x3f21f4e0,
-       0x67f150f9,
-/* 0x06b2: memx_func_train_loop_inner */
-       0x87f10000,
-       0x68ff1111,
-       0x10989490,
-       0xf10589fd,
-       0xf0072097,
-       0x90f91093,
-       0xd0fc80f9,
-       0x21f4e0fc,
-       0x8097f13f,
-       0x1093f000,
-       0xf4029eb9,
-       0xd8b90421,
-       0x2088c502,
+       0xf1f31bf4,
+       0xb9161087,
+       0x21f4028e,
+       0x02d7b904,
+       0xffcc67f1,
+       0xffff63f1,
+       0xf90476fd,
+       0xfc70f980,
+       0xf4e0fcd0,
+       0x00f84021,
+/* 0x05f0: memx_func_wait_vblank */
+       0xb0001698,
+       0x0bf40066,
+       0x0166b013,
+       0xf4060bf4,
+/* 0x0602: memx_func_wait_vblank_head1 */
+       0x77f12e0e,
+       0x0ef40020,
+/* 0x0609: memx_func_wait_vblank_head0 */
+       0x0877f107,
+/* 0x060d: memx_func_wait_vblank_0 */
+       0xc467f100,
+       0x0664b607,
+       0xfd0066cf,
+       0x1bf40467,
+/* 0x061d: memx_func_wait_vblank_1 */
+       0xc467f1f3,
+       0x0664b607,
+       0xfd0066cf,
+       0x0bf40467,
+/* 0x062d: memx_func_wait_vblank_fini */
+       0x0410b6f3,
+/* 0x0632: memx_func_wr32 */
+       0x169800f8,
+       0x01159800,
+       0xf90810b6,
+       0xfc50f960,
+       0xf4e0fcd0,
+       0x42b64021,
+       0xe91bf402,
+/* 0x064e: memx_func_wait */
+       0x87f000f8,
+       0x0684b62c,
+       0x980088cf,
+       0x1d98001e,
+       0x021c9801,
+       0xb6031b98,
+       0x21f41010,
+/* 0x066b: memx_func_delay */
+       0x9800f8a3,
+       0x10b6001e,
+       0x7e21f404,
+/* 0x0676: memx_func_train */
+       0x57f100f8,
+       0x77f10003,
+       0x97f10000,
+       0x93f00000,
+       0x029eb970,
+       0xb90421f4,
+       0xe7f102d8,
+       0x21f42710,
+/* 0x0695: memx_func_train_loop_outer */
+       0x0158e07e,
+       0x0083f101,
+       0xe097f102,
+       0x1193f011,
        0x80f990f9,
        0xe0fcd0fc,
-       0xf13f21f4,
-       0xf0053c97,
-       0x87f11093,
-       0x83f13002,
-       0x90f98000,
-       0xd0fc80f9,
-       0x21f4e0fc,
-       0x60e7f13f,
-       0x10e3f005,
-       0x0000d7f1,
-       0x8000d3f1,
-       0xf100dc90,
-       0xf08480b7,
-       0x21f41eb3,
-       0x0057f1a4,
-       0xff97f100,
-       0x0093f1ff,
-/* 0x0731: memx_func_train_loop_4x */
-       0x80a7f183,
-       0x10a3f000,
-       0xf402aeb9,
-       0xd8b90421,
-       0xdfb7f102,
-       0xffb3f1ff,
-       0x048bfdff,
-       0x80f9a0f9,
-       0xe0fcd0fc,
-       0xf13f21f4,
-       0xf0053ca7,
-       0x87f110a3,
-       0x83f13002,
-       0xa0f98000,
-       0xd0fc80f9,
-       0x21f4e0fc,
-       0x60e7f13f,
-       0x10e3f005,
-       0x0000d7f1,
-       0x8000d3f1,
-       0xf102dcb9,
-       0xf02710b7,
-       0x21f400b3,
-       0x02eeb9a4,
-       0xb90421f4,
-       0x9dff02dd,
-       0x0150b694,
-       0xf4045670,
-       0x7aa0921e,
-       0xa9800bcc,
-       0x0160b600,
-       0x700470b6,
-       0x1ef51066,
-       0x50fcff00,
+       0xf94021f4,
+       0x0067f150,
+/* 0x06b5: memx_func_train_loop_inner */
+       0x1187f100,
+       0x9068ff11,
+       0xfd109894,
+       0x97f10589,
+       0x93f00720,
+       0xf990f910,
+       0xfcd0fc80,
+       0x4021f4e0,
+       0x008097f1,
+       0xb91093f0,
+       0x21f4029e,
+       0x02d8b904,
+       0xf92088c5,
+       0xfc80f990,
+       0xf4e0fcd0,
+       0x97f14021,
+       0x93f0053c,
+       0x0287f110,
+       0x0083f130,
+       0xf990f980,
+       0xfcd0fc80,
+       0x4021f4e0,
+       0x0560e7f1,
+       0xf110e3f0,
+       0xf10000d7,
+       0x908000d3,
+       0xb7f100dc,
+       0xb3f08480,
+       0xa321f41e,
+       0x000057f1,
+       0xffff97f1,
+       0x830093f1,
+/* 0x0734: memx_func_train_loop_4x */
+       0x0080a7f1,
+       0xb910a3f0,
+       0x21f402ae,
+       0x02d8b904,
+       0xffdfb7f1,
+       0xffffb3f1,
+       0xf9048bfd,
+       0xfc80f9a0,
+       0xf4e0fcd0,
+       0xa7f14021,
+       0xa3f0053c,
+       0x0287f110,
+       0x0083f130,
+       0xf9a0f980,
+       0xfcd0fc80,
+       0x4021f4e0,
+       0x0560e7f1,
+       0xf110e3f0,
+       0xf10000d7,
+       0xb98000d3,
+       0xb7f102dc,
+       0xb3f02710,
+       0xa321f400,
+       0xf402eeb9,
+       0xddb90421,
+       0x949dff02,
        0x700150b6,
-       0x1ef50756,
-       0x00f8fed4,
-/* 0x07c4: memx_exec */
-       0xd0f9e0f9,
-       0xb902c1b9,
-/* 0x07ce: memx_exec_next */
-       0x139802b2,
-       0x0410b600,
-       0x01f034e7,
-       0x01e033e7,
-       0xf00132b6,
-       0x35980c30,
-       0xb855f9de,
-       0x1ef40612,
-       0xf10b98e4,
-       0xbbf20c98,
-       0xb7f102cb,
-       0xb4b607c4,
-       0x00bbcf06,
-       0xe0fcd0fc,
-       0x033721f5,
-/* 0x080a: memx_info */
-       0xc67000f8,
-       0x0e0bf401,
-/* 0x0810: memx_info_data */
-       0x03ccc7f1,
-       0x0800b7f1,
-/* 0x081b: memx_info_train */
-       0xf10b0ef4,
-       0xf10bccc7,
-/* 0x0823: memx_info_send */
-       0xf50100b7,
-       0xf8033721,
-/* 0x0829: memx_recv */
-       0x01d6b000,
-       0xb0980bf4,
-       0x0bf400d6,
-/* 0x0837: memx_init */
-       0xf800f8d8,
-/* 0x0839: perf_recv */
-/* 0x083b: perf_init */
-       0xf800f800,
-/* 0x083d: i2c_drive_scl */
-       0x0036b000,
-       0xf1110bf4,
-       0xb607e007,
-       0x01d00604,
-       0xf804bd00,
-/* 0x0851: i2c_drive_scl_lo */
-       0xe407f100,
-       0x0604b607,
-       0xbd0001d0,
-/* 0x085f: i2c_drive_sda */
-       0xb000f804,
-       0x0bf40036,
-       0xe007f111,
-       0x0604b607,
-       0xbd0002d0,
-/* 0x0873: i2c_drive_sda_lo */
-       0xf100f804,
-       0xb607e407,
-       0x02d00604,
-       0xf804bd00,
-/* 0x0881: i2c_sense_scl */
-       0x0132f400,
-       0x07c437f1,
-       0xcf0634b6,
-       0x31fd0033,
-       0x060bf404,
-/* 0x0897: i2c_sense_scl_done */
-       0xf80131f4,
-/* 0x0899: i2c_sense_sda */
-       0x0132f400,
-       0x07c437f1,
-       0xcf0634b6,
-       0x32fd0033,
-       0x060bf404,
-/* 0x08af: i2c_sense_sda_done */
-       0xf80131f4,
-/* 0x08b1: i2c_raise_scl */
-       0xf140f900,
-       0xf0089847,
-       0x21f50137,
-/* 0x08be: i2c_raise_scl_wait */
-       0xe7f1083d,
-       0x21f403e8,
-       0x8121f57f,
-       0x0901f408,
-       0xf40142b6,
-/* 0x08d2: i2c_raise_scl_done */
-       0x40fcef1b,
-/* 0x08d6: i2c_start */
-       0x21f500f8,
-       0x11f40881,
-       0x9921f50d,
-       0x0611f408,
-/* 0x08e7: i2c_start_rep */
-       0xf0300ef4,
-       0x21f50037,
-       0x37f0083d,
-       0x5f21f501,
-       0x0076bb08,
-       0xf90465b6,
-       0x04659450,
-       0xbd0256bb,
-       0x0475fd50,
-       0x21f550fc,
-       0x64b608b1,
-       0x1f11f404,
-/* 0x0914: i2c_start_send */
-       0xf50037f0,
-       0xf1085f21,
-       0xf41388e7,
-       0x37f07f21,
-       0x3d21f500,
-       0x88e7f108,
-       0x7f21f413,
-/* 0x0930: i2c_start_out */
-/* 0x0932: i2c_stop */
-       0x37f000f8,
-       0x3d21f500,
-       0x0037f008,
-       0x085f21f5,
-       0x03e8e7f1,
-       0xf07f21f4,
-       0x21f50137,
-       0xe7f1083d,
-       0x21f41388,
-       0x0137f07f,
-       0x085f21f5,
-       0x1388e7f1,
-       0xf87f21f4,
-/* 0x0965: i2c_bitw */
-       0x5f21f500,
-       0xe8e7f108,
-       0x7f21f403,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0xb121f550,
-       0x0464b608,
-       0xf11811f4,
-       0xf41388e7,
-       0x37f07f21,
-       0x3d21f500,
-       0x88e7f108,
-       0x7f21f413,
-/* 0x09a4: i2c_bitw_out */
-/* 0x09a6: i2c_bitr */
-       0x37f000f8,
-       0x5f21f501,
+       0x1ef40456,
+       0xcc7aa092,
+       0x00a9800b,
+       0xb60160b6,
+       0x66700470,
+       0x001ef510,
+       0xb650fcff,
+       0x56700150,
+       0xd41ef507,
+/* 0x07c7: memx_exec */
+       0xf900f8fe,
+       0xb9d0f9e0,
+       0xb2b902c1,
+/* 0x07d1: memx_exec_next */
+       0x00139802,
+       0xe70410b6,
+       0xe701f034,
+       0xb601e033,
+       0x30f00132,
+       0xde35980c,
+       0x12b855f9,
+       0xe41ef406,
+       0x98f10b98,
+       0xcbbbf20c,
+       0xc4b7f102,
+       0x06b4b607,
+       0xfc00bbcf,
+       0xf5e0fcd0,
+       0xf8033621,
+/* 0x080d: memx_info */
+       0x01c67000,
+/* 0x0813: memx_info_data */
+       0xf10e0bf4,
+       0xf103ccc7,
+       0xf40800b7,
+/* 0x081e: memx_info_train */
+       0xc7f10b0e,
+       0xb7f10bcc,
+/* 0x0826: memx_info_send */
+       0x21f50100,
+       0x00f80336,
+/* 0x082c: memx_recv */
+       0xf401d6b0,
+       0xd6b0980b,
+       0xd80bf400,
+/* 0x083a: memx_init */
+       0x00f800f8,
+/* 0x083c: perf_recv */
+/* 0x083e: perf_init */
+       0x00f800f8,
+/* 0x0840: i2c_drive_scl */
+       0xf40036b0,
+       0x07f1110b,
+       0x04b607e0,
+       0x0001d006,
+       0x00f804bd,
+/* 0x0854: i2c_drive_scl_lo */
+       0x07e407f1,
+       0xd00604b6,
+       0x04bd0001,
+/* 0x0862: i2c_drive_sda */
+       0x36b000f8,
+       0x110bf400,
+       0x07e007f1,
+       0xd00604b6,
+       0x04bd0002,
+/* 0x0876: i2c_drive_sda_lo */
+       0x07f100f8,
+       0x04b607e4,
+       0x0002d006,
+       0x00f804bd,
+/* 0x0884: i2c_sense_scl */
+       0xf10132f4,
+       0xb607c437,
+       0x33cf0634,
+       0x0431fd00,
+       0xf4060bf4,
+/* 0x089a: i2c_sense_scl_done */
+       0x00f80131,
+/* 0x089c: i2c_sense_sda */
+       0xf10132f4,
+       0xb607c437,
+       0x33cf0634,
+       0x0432fd00,
+       0xf4060bf4,
+/* 0x08b2: i2c_sense_sda_done */
+       0x00f80131,
+/* 0x08b4: i2c_raise_scl */
+       0x47f140f9,
+       0x37f00898,
+       0x4021f501,
+/* 0x08c1: i2c_raise_scl_wait */
        0xe8e7f108,
-       0x7f21f403,
+       0x7e21f403,
+       0x088421f5,
+       0xb60901f4,
+       0x1bf40142,
+/* 0x08d5: i2c_raise_scl_done */
+       0xf840fcef,
+/* 0x08d9: i2c_start */
+       0x8421f500,
+       0x0d11f408,
+       0x089c21f5,
+       0xf40611f4,
+/* 0x08ea: i2c_start_rep */
+       0x37f0300e,
+       0x4021f500,
+       0x0137f008,
+       0x086221f5,
        0xb60076bb,
        0x50f90465,
        0xbb046594,
        0x50bd0256,
        0xfc0475fd,
-       0xb121f550,
+       0xb421f550,
        0x0464b608,
-       0xf51b11f4,
-       0xf0089921,
+/* 0x0917: i2c_start_send */
+       0xf01f11f4,
        0x21f50037,
-       0xe7f1083d,
+       0xe7f10862,
        0x21f41388,
-       0x013cf07f,
-/* 0x09eb: i2c_bitr_done */
-       0xf80131f4,
-/* 0x09ed: i2c_get_byte */
-       0x0057f000,
-/* 0x09f3: i2c_get_byte_next */
-       0xb60847f0,
-       0x76bb0154,
-       0x0465b600,
-       0x659450f9,
-       0x0256bb04,
-       0x75fd50bd,
-       0xf550fc04,
-       0xb609a621,
-       0x11f40464,
-       0x0553fd2b,
-       0xf40142b6,
-       0x37f0d81b,
+       0x0037f07e,
+       0x084021f5,
+       0x1388e7f1,
+/* 0x0933: i2c_start_out */
+       0xf87e21f4,
+/* 0x0935: i2c_stop */
+       0x0037f000,
+       0x084021f5,
+       0xf50037f0,
+       0xf1086221,
+       0xf403e8e7,
+       0x37f07e21,
+       0x4021f501,
+       0x88e7f108,
+       0x7e21f413,
+       0xf50137f0,
+       0xf1086221,
+       0xf41388e7,
+       0x00f87e21,
+/* 0x0968: i2c_bitw */
+       0x086221f5,
+       0x03e8e7f1,
+       0xbb7e21f4,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x08b421f5,
+       0xf40464b6,
+       0xe7f11811,
+       0x21f41388,
+       0x0037f07e,
+       0x084021f5,
+       0x1388e7f1,
+/* 0x09a7: i2c_bitw_out */
+       0xf87e21f4,
+/* 0x09a9: i2c_bitr */
+       0x0137f000,
+       0x086221f5,
+       0x03e8e7f1,
+       0xbb7e21f4,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x08b421f5,
+       0xf40464b6,
+       0x21f51b11,
+       0x37f0089c,
+       0x4021f500,
+       0x88e7f108,
+       0x7e21f413,
+       0xf4013cf0,
+/* 0x09ee: i2c_bitr_done */
+       0x00f80131,
+/* 0x09f0: i2c_get_byte */
+       0xf00057f0,
+/* 0x09f6: i2c_get_byte_next */
+       0x54b60847,
        0x0076bb01,
        0xf90465b6,
        0x04659450,
        0xbd0256bb,
        0x0475fd50,
        0x21f550fc,
-       0x64b60965,
-/* 0x0a3d: i2c_get_byte_done */
-/* 0x0a3f: i2c_put_byte */
-       0xf000f804,
-/* 0x0a42: i2c_put_byte_next */
-       0x42b60847,
-       0x3854ff01,
+       0x64b609a9,
+       0x2b11f404,
+       0xb60553fd,
+       0x1bf40142,
+       0x0137f0d8,
        0xb60076bb,
        0x50f90465,
        0xbb046594,
        0x50bd0256,
        0xfc0475fd,
-       0x6521f550,
+       0x6821f550,
        0x0464b609,
-       0xb03411f4,
-       0x1bf40046,
-       0x0076bbd8,
+/* 0x0a40: i2c_get_byte_done */
+/* 0x0a42: i2c_put_byte */
+       0x47f000f8,
+/* 0x0a45: i2c_put_byte_next */
+       0x0142b608,
+       0xbb3854ff,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x096821f5,
+       0xf40464b6,
+       0x46b03411,
+       0xd81bf400,
+       0xb60076bb,
+       0x50f90465,
+       0xbb046594,
+       0x50bd0256,
+       0xfc0475fd,
+       0xa921f550,
+       0x0464b609,
+       0xbb0f11f4,
+       0x36b00076,
+       0x061bf401,
+/* 0x0a9b: i2c_put_byte_done */
+       0xf80132f4,
+/* 0x0a9d: i2c_addr */
+       0x0076bb00,
        0xf90465b6,
        0x04659450,
        0xbd0256bb,
        0x0475fd50,
        0x21f550fc,
-       0x64b609a6,
-       0x0f11f404,
-       0xb00076bb,
-       0x1bf40136,
-       0x0132f406,
-/* 0x0a98: i2c_put_byte_done */
-/* 0x0a9a: i2c_addr */
-       0x76bb00f8,
+       0x64b608d9,
+       0x2911f404,
+       0x012ec3e7,
+       0xfd0134b6,
+       0x76bb0553,
        0x0465b600,
        0x659450f9,
        0x0256bb04,
        0x75fd50bd,
        0xf550fc04,
-       0xb608d621,
-       0x11f40464,
-       0x2ec3e729,
-       0x0134b601,
-       0xbb0553fd,
+       0xb60a4221,
+/* 0x0ae2: i2c_addr_done */
+       0x00f80464,
+/* 0x0ae4: i2c_acquire_addr */
+       0xb6f8cec7,
+       0xe0b702e4,
+       0xee980d1c,
+/* 0x0af3: i2c_acquire */
+       0xf500f800,
+       0xf40ae421,
+       0xd9f00421,
+       0x4021f403,
+/* 0x0b02: i2c_release */
+       0x21f500f8,
+       0x21f40ae4,
+       0x03daf004,
+       0xf84021f4,
+/* 0x0b11: i2c_recv */
+       0x0132f400,
+       0xb6f8c1c7,
+       0x16b00214,
+       0x3a1ff528,
+       0xf413a001,
+       0x0032980c,
+       0x0ccc13a0,
+       0xf4003198,
+       0xd0f90231,
+       0xd0f9e0f9,
+       0x000067f1,
+       0x100063f1,
+       0xbb016792,
        0x65b60076,
        0x9450f904,
        0x56bb0465,
        0xfd50bd02,
        0x50fc0475,
-       0x0a3f21f5,
-/* 0x0adf: i2c_addr_done */
-       0xf80464b6,
-/* 0x0ae1: i2c_acquire_addr */
-       0xf8cec700,
-       0xb702e4b6,
-       0x980d1ce0,
-       0x00f800ee,
-/* 0x0af0: i2c_acquire */
-       0x0ae121f5,
-       0xf00421f4,
-       0x21f403d9,
-/* 0x0aff: i2c_release */
-       0xf500f83f,
-       0xf40ae121,
-       0xdaf00421,
-       0x3f21f403,
-/* 0x0b0e: i2c_recv */
-       0x32f400f8,
-       0xf8c1c701,
-       0xb00214b6,
-       0x1ff52816,
-       0x13a0013a,
-       0x32980cf4,
-       0xcc13a000,
-       0x0031980c,
-       0xf90231f4,
-       0xf9e0f9d0,
-       0x0067f1d0,
-       0x0063f100,
-       0x01679210,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0xf021f550,
-       0x0464b60a,
-       0xd6b0d0fc,
-       0xb31bf500,
-       0x0057f000,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0x9a21f550,
-       0x0464b60a,
-       0x00d011f5,
-       0xbbe0c5c7,
+       0x0af321f5,
+       0xfc0464b6,
+       0x00d6b0d0,
+       0x00b31bf5,
+       0xbb0057f0,
        0x65b60076,
        0x9450f904,
        0x56bb0465,
        0xfd50bd02,
        0x50fc0475,
-       0x0a3f21f5,
+       0x0a9d21f5,
        0xf50464b6,
-       0xf000ad11,
-       0x76bb0157,
+       0xc700d011,
+       0x76bbe0c5,
        0x0465b600,
        0x659450f9,
        0x0256bb04,
        0x75fd50bd,
        0xf550fc04,
-       0xb60a9a21,
+       0xb60a4221,
        0x11f50464,
-       0x76bb008a,
-       0x0465b600,
-       0x659450f9,
-       0x0256bb04,
-       0x75fd50bd,
-       0xf550fc04,
-       0xb609ed21,
-       0x11f40464,
-       0xe05bcb6a,
-       0xb60076bb,
-       0x50f90465,
-       0xbb046594,
-       0x50bd0256,
-       0xfc0475fd,
-       0x3221f550,
-       0x0464b609,
-       0xbd025bb9,
-       0x430ef474,
-/* 0x0c14: i2c_recv_not_rd08 */
-       0xf401d6b0,
-       0x57f03d1b,
-       0x9a21f500,
-       0x3311f40a,
-       0xf5e0c5c7,
-       0xf40a3f21,
-       0x57f02911,
-       0x9a21f500,
-       0x1f11f40a,
-       0xf5e0b5c7,
-       0xf40a3f21,
-       0x21f51511,
-       0x74bd0932,
-       0xf408c5c7,
-       0x32f4091b,
-       0x030ef402,
-/* 0x0c54: i2c_recv_not_wr08 */
-/* 0x0c54: i2c_recv_done */
-       0xf5f8cec7,
-       0xfc0aff21,
-       0xf4d0fce0,
-       0x7cb90a12,
-       0x3721f502,
-/* 0x0c69: i2c_recv_exit */
-/* 0x0c6b: i2c_init */
-       0xf800f803,
-/* 0x0c6d: test_recv */
-       0xd817f100,
-       0x0614b605,
-       0xb60011cf,
-       0x07f10110,
-       0x04b605d8,
-       0x0001d006,
-       0xe7f104bd,
-       0xe3f1d900,
-       0x21f5134f,
-       0x00f80257,
-/* 0x0c94: test_init */
-       0x0800e7f1,
-       0x025721f5,
-/* 0x0c9e: idle_recv */
+       0x57f000ad,
+       0x0076bb01,
+       0xf90465b6,
+       0x04659450,
+       0xbd0256bb,
+       0x0475fd50,
+       0x21f550fc,
+       0x64b60a9d,
+       0x8a11f504,
+       0x0076bb00,
+       0xf90465b6,
+       0x04659450,
+       0xbd0256bb,
+       0x0475fd50,
+       0x21f550fc,
+       0x64b609f0,
+       0x6a11f404,
+       0xbbe05bcb,
+       0x65b60076,
+       0x9450f904,
+       0x56bb0465,
+       0xfd50bd02,
+       0x50fc0475,
+       0x093521f5,
+       0xb90464b6,
+       0x74bd025b,
+/* 0x0c17: i2c_recv_not_rd08 */
+       0xb0430ef4,
+       0x1bf401d6,
+       0x0057f03d,
+       0x0a9d21f5,
+       0xc73311f4,
+       0x21f5e0c5,
+       0x11f40a42,
+       0x0057f029,
+       0x0a9d21f5,
+       0xc71f11f4,
+       0x21f5e0b5,
+       0x11f40a42,
+       0x3521f515,
+       0xc774bd09,
+       0x1bf408c5,
+       0x0232f409,
+/* 0x0c57: i2c_recv_not_wr08 */
+/* 0x0c57: i2c_recv_done */
+       0xc7030ef4,
+       0x21f5f8ce,
+       0xe0fc0b02,
+       0x12f4d0fc,
+       0x027cb90a,
+       0x033621f5,
+/* 0x0c6c: i2c_recv_exit */
+/* 0x0c6e: i2c_init */
        0x00f800f8,
-/* 0x0ca0: idle */
-       0xf10031f4,
-       0xb605d417,
-       0x11cf0614,
-       0x0110b600,
-       0x05d407f1,
-       0xd00604b6,
-       0x04bd0001,
-/* 0x0cbc: idle_loop */
-       0xf45817f0,
-/* 0x0cc2: idle_proc */
-/* 0x0cc2: idle_proc_exec */
-       0x10f90232,
-       0xf5021eb9,
-       0xfc034021,
-       0x0911f410,
-       0xf40231f4,
-/* 0x0cd6: idle_proc_next */
-       0x10b6ef0e,
-       0x061fb858,
-       0xf4e61bf4,
-       0x28f4dd02,
-       0xbb0ef400,
-       0x00000000,
+/* 0x0c70: test_recv */
+       0x05d817f1,
+       0xcf0614b6,
+       0x10b60011,
+       0xd807f101,
+       0x0604b605,
+       0xbd0001d0,
+       0x00e7f104,
+       0x4fe3f1d9,
+       0x5621f513,
+/* 0x0c97: test_init */
+       0xf100f802,
+       0xf50800e7,
+       0xf8025621,
+/* 0x0ca1: idle_recv */
+/* 0x0ca3: idle */
+       0xf400f800,
+       0x17f10031,
+       0x14b605d4,
+       0x0011cf06,
+       0xf10110b6,
+       0xb605d407,
+       0x01d00604,
+/* 0x0cbf: idle_loop */
+       0xf004bd00,
+       0x32f45817,
+/* 0x0cc5: idle_proc */
+/* 0x0cc5: idle_proc_exec */
+       0xb910f902,
+       0x21f5021e,
+       0x10fc033f,
+       0xf40911f4,
+       0x0ef40231,
+/* 0x0cd9: idle_proc_next */
+       0x5810b6ef,
+       0xf4061fb8,
+       0x02f4e61b,
+       0x0028f4dd,
+       0x00bb0ef4,
        0x00000000,
        0x00000000,
        0x00000000,
index c2bb616..f2420a3 100644 (file)
@@ -98,8 +98,7 @@ host_send:
 // $r0  - zero
 host_recv:
        // message from intr handler == HOST->PWR comms pending
-       mov $r1 (PROC_KERN & 0x0000ffff)
-       sethi $r1 (PROC_KERN & 0xffff0000)
+       imm32($r1, PROC_KERN)
        cmp b32 $r14 $r1
        bra e #host_send
 
index ad35fa5..c20a3bd 100644 (file)
@@ -51,8 +51,7 @@ time_next: .b32 0
 // $r0  - zero
 rd32:
        nv_iowr(NV_PPWR_MMIO_ADDR, $r14)
-       mov $r13 NV_PPWR_MMIO_CTRL_OP_RD
-       sethi $r13 NV_PPWR_MMIO_CTRL_TRIGGER
+       imm32($r13, NV_PPWR_MMIO_CTRL_OP_RD | NV_PPWR_MMIO_CTRL_TRIGGER)
        nv_iowr(NV_PPWR_MMIO_CTRL, $r13)
        rd32_wait:
                nv_iord($r13, NV_PPWR_MMIO_CTRL)
@@ -70,9 +69,7 @@ rd32:
 wr32:
        nv_iowr(NV_PPWR_MMIO_ADDR, $r14)
        nv_iowr(NV_PPWR_MMIO_DATA, $r13)
-       mov $r13 NV_PPWR_MMIO_CTRL_OP_WR
-       or $r13 NV_PPWR_MMIO_CTRL_MASK_B32_0
-       sethi $r13 NV_PPWR_MMIO_CTRL_TRIGGER
+       imm32($r13, NV_PPWR_MMIO_CTRL_OP_WR | NV_PPWR_MMIO_CTRL_MASK_B32_0 | NV_PPWR_MMIO_CTRL_TRIGGER)
 
 #ifdef NVKM_FALCON_MMIO_TRAP
        push $r13
@@ -215,8 +212,7 @@ intr:
                bra z #intr_subintr_skip_fifo
                        nv_iord($r12, NV_PPWR_FIFO_INTR)
                        push $r12
-                       mov $r14 (PROC_HOST & 0x0000ffff)
-                       sethi $r14 (PROC_HOST & 0xffff0000)
+                       imm32($r14, PROC_HOST)
                        mov $r13 KMSG_FIFO
                        call(send)
                        pop $r12
@@ -256,7 +252,7 @@ ticks_from_ns:
 
        /* try not losing precision (multiply then divide) */
        imm32($r13, HW_TICKS_PER_US)
-       call #mulu32_32_64
+       call(mulu32_32_64)
 
        /* use an immeditate, it's ok because HW_TICKS_PER_US < 16 bits */
        div $r12 $r12 1000
@@ -268,7 +264,7 @@ ticks_from_ns:
        /* let's divide then multiply, too bad for the precision! */
        div $r14 $r14 1000
        imm32($r13, HW_TICKS_PER_US)
-       call #mulu32_32_64
+       call(mulu32_32_64)
 
        /* this cannot overflow as long as HW_TICKS_PER_US < 1000 */
 
@@ -290,7 +286,7 @@ ticks_from_us:
 
        /* simply multiply $us by HW_TICKS_PER_US */
        imm32($r13, HW_TICKS_PER_US)
-       call #mulu32_32_64
+       call(mulu32_32_64)
        mov b32 $r14 $r12
 
        /* check if there wasn't any overflow */
@@ -511,14 +507,12 @@ init:
 #ifdef NVKM_FALCON_MMIO_UAS
        // somehow allows the magic "access mmio via D[]" stuff that's
        // used by the nv_rd32/nv_wr32 macros to work
-       mov $r1 0x0010
-       sethi $r1 NV_PPWR_UAS_CONFIG_ENABLE
+       imm32($r1, 0x10 | NV_PPWR_UAS_CONFIG_ENABLE)
        nv_iowrs(NV_PPWR_UAS_CONFIG, $r1)
 #endif
 
        // route all interrupts except user0/1 and pause to fuc
-       mov $r1 0x00e0
-       sethi $r1 0x00000000
+       imm32($r1, 0xe0)
        nv_iowr(NV_PPWR_INTR_ROUTE, $r1)
 
        // enable watchdog and subintr intrs
@@ -529,8 +523,8 @@ init:
        nv_iowr(NV_PPWR_INTR_EN_SET, $r1)
 
        // enable interrupts globally
-       mov $r1 #intr
-       sethi $r1 0x00000000
+       imm32($r1, #intr)
+       and $r1 0xffff
        mov $iv0 $r1
        bset $flags ie0
 
index 96fc984..3737bd2 100644 (file)
 */     .b32 0 /*
 */     .skip 64
 
-#if NV_PPWR_CHIPSET < GK208
+#if NVKM_PPWR_CHIPSET < GK208
 #define imm32(reg,val) /*
 */     movw reg  ((val) & 0x0000ffff) /*
 */     sethi reg ((val) & 0xffff0000)
 #endif
 
 #define st(size, addr, reg) /*
-*/     movw $r0 addr /*
+*/     imm32($r0, addr) /*
 */     st size D[$r0] reg /*
 */     clear b32 $r0
 
 #define ld(size, reg, addr) /*
-*/     movw $r0 addr /*
+*/     imm32($r0, addr)  /*
 */     ld size reg D[$r0] /*
 */     clear b32 $r0
 
index 0c3a71b..9e3f4e6 100644 (file)
@@ -48,8 +48,7 @@ test_recv:
        nv_iord($r1, NV_PPWR_DSCRATCH(2))
        add b32 $r1 1
        nv_iowr(NV_PPWR_DSCRATCH(2), $r1)
-       mov $r14 -0x2700 /* 0xd900, envyas grrr! */
-       sethi $r14 0x134f0000
+       imm32($r14, 0x134fd900)
        call(timer)
        ret
 
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/Kbuild
new file mode 100644 (file)
index 0000000..b02b868
--- /dev/null
@@ -0,0 +1,3 @@
+nvkm-y += nvkm/subdev/secboot/base.o
+nvkm-y += nvkm/subdev/secboot/gm200.o
+nvkm-y += nvkm/subdev/secboot/gm20b.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/base.c
new file mode 100644 (file)
index 0000000..520facf
--- /dev/null
@@ -0,0 +1,288 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "priv.h"
+#include <subdev/timer.h>
+
+static const char *
+managed_falcons_names[] = {
+       [NVKM_SECBOOT_FALCON_PMU] = "PMU",
+       [NVKM_SECBOOT_FALCON_RESERVED] = "<reserved>",
+       [NVKM_SECBOOT_FALCON_FECS] = "FECS",
+       [NVKM_SECBOOT_FALCON_GPCCS] = "GPCCS",
+       [NVKM_SECBOOT_FALCON_END] = "<invalid>",
+};
+
+/*
+ * Helper falcon functions
+ */
+
+static int
+falcon_clear_halt_interrupt(struct nvkm_device *device, u32 base)
+{
+       int ret;
+
+       /* clear halt interrupt */
+       nvkm_mask(device, base + 0x004, 0x10, 0x10);
+       /* wait until halt interrupt is cleared */
+       ret = nvkm_wait_msec(device, 10, base + 0x008, 0x10, 0x0);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int
+falcon_wait_idle(struct nvkm_device *device, u32 base)
+{
+       int ret;
+
+       ret = nvkm_wait_msec(device, 10, base + 0x04c, 0xffff, 0x0);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int
+nvkm_secboot_falcon_enable(struct nvkm_secboot *sb)
+{
+       struct nvkm_device *device = sb->subdev.device;
+       int ret;
+
+       /* enable engine */
+       nvkm_mask(device, 0x200, sb->enable_mask, sb->enable_mask);
+       nvkm_rd32(device, 0x200);
+       ret = nvkm_wait_msec(device, 10, sb->base + 0x10c, 0x6, 0x0);
+       if (ret < 0) {
+               nvkm_mask(device, 0x200, sb->enable_mask, 0x0);
+               nvkm_error(&sb->subdev, "Falcon mem scrubbing timeout\n");
+               return ret;
+       }
+
+       ret = falcon_wait_idle(device, sb->base);
+       if (ret)
+               return ret;
+
+       /* enable IRQs */
+       nvkm_wr32(device, sb->base + 0x010, 0xff);
+       nvkm_mask(device, 0x640, sb->irq_mask, sb->irq_mask);
+       nvkm_mask(device, 0x644, sb->irq_mask, sb->irq_mask);
+
+       return 0;
+}
+
+static int
+nvkm_secboot_falcon_disable(struct nvkm_secboot *sb)
+{
+       struct nvkm_device *device = sb->subdev.device;
+
+       /* disable IRQs and wait for any previous code to complete */
+       nvkm_mask(device, 0x644, sb->irq_mask, 0x0);
+       nvkm_mask(device, 0x640, sb->irq_mask, 0x0);
+       nvkm_wr32(device, sb->base + 0x014, 0xff);
+
+       falcon_wait_idle(device, sb->base);
+
+       /* disable engine */
+       nvkm_mask(device, 0x200, sb->enable_mask, 0x0);
+
+       return 0;
+}
+
+int
+nvkm_secboot_falcon_reset(struct nvkm_secboot *sb)
+{
+       int ret;
+
+       ret = nvkm_secboot_falcon_disable(sb);
+       if (ret)
+               return ret;
+
+       ret = nvkm_secboot_falcon_enable(sb);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
+/**
+ * nvkm_secboot_falcon_run - run the falcon that will perform secure boot
+ *
+ * This function is to be called after all chip-specific preparations have
+ * been completed. It will start the falcon to perform secure boot, wait for
+ * it to halt, and report if an error occurred.
+ */
+int
+nvkm_secboot_falcon_run(struct nvkm_secboot *sb)
+{
+       struct nvkm_device *device = sb->subdev.device;
+       int ret;
+
+       /* Start falcon */
+       nvkm_wr32(device, sb->base + 0x100, 0x2);
+
+       /* Wait for falcon halt */
+       ret = nvkm_wait_msec(device, 100, sb->base + 0x100, 0x10, 0x10);
+       if (ret < 0)
+               return ret;
+
+       /* If mailbox register contains an error code, then ACR has failed */
+       ret = nvkm_rd32(device, sb->base + 0x040);
+       if (ret) {
+               nvkm_error(&sb->subdev, "ACR boot failed, ret 0x%08x", ret);
+               falcon_clear_halt_interrupt(device, sb->base);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+
+/**
+ * nvkm_secboot_reset() - reset specified falcon
+ */
+int
+nvkm_secboot_reset(struct nvkm_secboot *sb, u32 falcon)
+{
+       /* Unmanaged falcon? */
+       if (!(BIT(falcon) & sb->func->managed_falcons)) {
+               nvkm_error(&sb->subdev, "cannot reset unmanaged falcon!\n");
+               return -EINVAL;
+       }
+
+       return sb->func->reset(sb, falcon);
+}
+
+/**
+ * nvkm_secboot_start() - start specified falcon
+ */
+int
+nvkm_secboot_start(struct nvkm_secboot *sb, u32 falcon)
+{
+       /* Unmanaged falcon? */
+       if (!(BIT(falcon) & sb->func->managed_falcons)) {
+               nvkm_error(&sb->subdev, "cannot start unmanaged falcon!\n");
+               return -EINVAL;
+       }
+
+       return sb->func->start(sb, falcon);
+}
+
+/**
+ * nvkm_secboot_is_managed() - check whether a given falcon is securely-managed
+ */
+bool
+nvkm_secboot_is_managed(struct nvkm_secboot *secboot,
+                       enum nvkm_secboot_falcon fid)
+{
+       if (!secboot)
+               return false;
+
+       return secboot->func->managed_falcons & BIT(fid);
+}
+
+static int
+nvkm_secboot_oneinit(struct nvkm_subdev *subdev)
+{
+       struct nvkm_secboot *sb = nvkm_secboot(subdev);
+       int ret = 0;
+
+       /* Call chip-specific init function */
+       if (sb->func->init)
+               ret = sb->func->init(sb);
+       if (ret) {
+               nvkm_error(subdev, "Secure Boot initialization failed: %d\n",
+                          ret);
+               return ret;
+       }
+
+       /*
+        * Build all blobs - the same blobs can be used to perform secure boot
+        * multiple times
+        */
+       if (sb->func->prepare_blobs)
+               ret = sb->func->prepare_blobs(sb);
+
+       return ret;
+}
+
+static int
+nvkm_secboot_fini(struct nvkm_subdev *subdev, bool suspend)
+{
+       struct nvkm_secboot *sb = nvkm_secboot(subdev);
+       int ret = 0;
+
+       if (sb->func->fini)
+               ret = sb->func->fini(sb, suspend);
+
+       return ret;
+}
+
+static void *
+nvkm_secboot_dtor(struct nvkm_subdev *subdev)
+{
+       struct nvkm_secboot *sb = nvkm_secboot(subdev);
+       void *ret = NULL;
+
+       if (sb->func->dtor)
+               ret = sb->func->dtor(sb);
+
+       return ret;
+}
+
+static const struct nvkm_subdev_func
+nvkm_secboot = {
+       .oneinit = nvkm_secboot_oneinit,
+       .fini = nvkm_secboot_fini,
+       .dtor = nvkm_secboot_dtor,
+};
+
+int
+nvkm_secboot_ctor(const struct nvkm_secboot_func *func,
+                 struct nvkm_device *device, int index,
+                 struct nvkm_secboot *sb)
+{
+       unsigned long fid;
+
+       nvkm_subdev_ctor(&nvkm_secboot, device, index, 0, &sb->subdev);
+       sb->func = func;
+
+       /* setup the performing falcon's base address and masks */
+       switch (func->boot_falcon) {
+       case NVKM_SECBOOT_FALCON_PMU:
+               sb->base = 0x10a000;
+               sb->irq_mask = 0x1000000;
+               sb->enable_mask = 0x2000;
+               break;
+       default:
+               nvkm_error(&sb->subdev, "invalid secure boot falcon\n");
+               return -EINVAL;
+       };
+
+       nvkm_debug(&sb->subdev, "securely managed falcons:\n");
+       for_each_set_bit(fid, &sb->func->managed_falcons,
+                        NVKM_SECBOOT_FALCON_END)
+               nvkm_debug(&sb->subdev, "- %s\n", managed_falcons_names[fid]);
+
+       return 0;
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm200.c b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm200.c
new file mode 100644 (file)
index 0000000..cc100dc
--- /dev/null
@@ -0,0 +1,1489 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Secure boot is the process by which NVIDIA-signed firmware is loaded into
+ * some of the falcons of a GPU. For production devices this is the only way
+ * for the firmware to access useful (but sensitive) registers.
+ *
+ * A Falcon microprocessor supporting advanced security modes can run in one of
+ * three modes:
+ *
+ * - Non-secure (NS). In this mode, functionality is similar to Falcon
+ *   architectures before security modes were introduced (pre-Maxwell), but
+ *   capability is restricted. In particular, certain registers may be
+ *   inaccessible for reads and/or writes, and physical memory access may be
+ *   disabled (on certain Falcon instances). This is the only possible mode that
+ *   can be used if you don't have microcode cryptographically signed by NVIDIA.
+ *
+ * - Heavy Secure (HS). In this mode, the microprocessor is a black box - it's
+ *   not possible to read or write any Falcon internal state or Falcon registers
+ *   from outside the Falcon (for example, from the host system). The only way
+ *   to enable this mode is by loading microcode that has been signed by NVIDIA.
+ *   (The loading process involves tagging the IMEM block as secure, writing the
+ *   signature into a Falcon register, and starting execution. The hardware will
+ *   validate the signature, and if valid, grant HS privileges.)
+ *
+ * - Light Secure (LS). In this mode, the microprocessor has more privileges
+ *   than NS but fewer than HS. Some of the microprocessor state is visible to
+ *   host software to ease debugging. The only way to enable this mode is by HS
+ *   microcode enabling LS mode. Some privileges available to HS mode are not
+ *   available here. LS mode is introduced in GM20x.
+ *
+ * Secure boot consists in temporarily switching a HS-capable falcon (typically
+ * PMU) into HS mode in order to validate the LS firmwares of managed falcons,
+ * load them, and switch managed falcons into LS mode. Once secure boot
+ * completes, no falcon remains in HS mode.
+ *
+ * Secure boot requires a write-protected memory region (WPR) which can only be
+ * written by the secure falcon. On dGPU, the driver sets up the WPR region in
+ * video memory. On Tegra, it is set up by the bootloader and its location and
+ * size written into memory controller registers.
+ *
+ * The secure boot process takes place as follows:
+ *
+ * 1) A LS blob is constructed that contains all the LS firmwares we want to
+ *    load, along with their signatures and bootloaders.
+ *
+ * 2) A HS blob (also called ACR) is created that contains the signed HS
+ *    firmware in charge of loading the LS firmwares into their respective
+ *    falcons.
+ *
+ * 3) The HS blob is loaded (via its own bootloader) and executed on the
+ *    HS-capable falcon. It authenticates itself, switches the secure falcon to
+ *    HS mode and setup the WPR region around the LS blob (dGPU) or copies the
+ *    LS blob into the WPR region (Tegra).
+ *
+ * 4) The LS blob is now secure from all external tampering. The HS falcon
+ *    checks the signatures of the LS firmwares and, if valid, switches the
+ *    managed falcons to LS mode and makes them ready to run the LS firmware.
+ *
+ * 5) The managed falcons remain in LS mode and can be started.
+ *
+ */
+
+#include "priv.h"
+
+#include <core/gpuobj.h>
+#include <core/firmware.h>
+#include <subdev/fb.h>
+
+enum {
+       FALCON_DMAIDX_UCODE             = 0,
+       FALCON_DMAIDX_VIRT              = 1,
+       FALCON_DMAIDX_PHYS_VID          = 2,
+       FALCON_DMAIDX_PHYS_SYS_COH      = 3,
+       FALCON_DMAIDX_PHYS_SYS_NCOH     = 4,
+};
+
+/**
+ * struct fw_bin_header - header of firmware files
+ * @bin_magic:         always 0x3b1d14f0
+ * @bin_ver:           version of the bin format
+ * @bin_size:          entire image size including this header
+ * @header_offset:     offset of the firmware/bootloader header in the file
+ * @data_offset:       offset of the firmware/bootloader payload in the file
+ * @data_size:         size of the payload
+ *
+ * This header is located at the beginning of the HS firmware and HS bootloader
+ * files, to describe where the headers and data can be found.
+ */
+struct fw_bin_header {
+       u32 bin_magic;
+       u32 bin_ver;
+       u32 bin_size;
+       u32 header_offset;
+       u32 data_offset;
+       u32 data_size;
+};
+
+/**
+ * struct fw_bl_desc - firmware bootloader descriptor
+ * @start_tag:         starting tag of bootloader
+ * @desc_dmem_load_off:        DMEM offset of flcn_bl_dmem_desc
+ * @code_off:          offset of code section
+ * @code_size:         size of code section
+ * @data_off:          offset of data section
+ * @data_size:         size of data section
+ *
+ * This structure is embedded in bootloader firmware files at to describe the
+ * IMEM and DMEM layout expected by the bootloader.
+ */
+struct fw_bl_desc {
+       u32 start_tag;
+       u32 dmem_load_off;
+       u32 code_off;
+       u32 code_size;
+       u32 data_off;
+       u32 data_size;
+};
+
+
+/*
+ *
+ * LS blob structures
+ *
+ */
+
+/**
+ * struct lsf_ucode_desc - LS falcon signatures
+ * @prd_keys:          signature to use when the GPU is in production mode
+ * @dgb_keys:          signature to use when the GPU is in debug mode
+ * @b_prd_present:     whether the production key is present
+ * @b_dgb_present:     whether the debug key is present
+ * @falcon_id:         ID of the falcon the ucode applies to
+ *
+ * Directly loaded from a signature file.
+ */
+struct lsf_ucode_desc {
+       u8  prd_keys[2][16];
+       u8  dbg_keys[2][16];
+       u32 b_prd_present;
+       u32 b_dbg_present;
+       u32 falcon_id;
+};
+
+/**
+ * struct lsf_lsb_header - LS firmware header
+ * @signature:         signature to verify the firmware against
+ * @ucode_off:         offset of the ucode blob in the WPR region. The ucode
+ *                      blob contains the bootloader, code and data of the
+ *                      LS falcon
+ * @ucode_size:                size of the ucode blob, including bootloader
+ * @data_size:         size of the ucode blob data
+ * @bl_code_size:      size of the bootloader code
+ * @bl_imem_off:       offset in imem of the bootloader
+ * @bl_data_off:       offset of the bootloader data in WPR region
+ * @bl_data_size:      size of the bootloader data
+ * @app_code_off:      offset of the app code relative to ucode_off
+ * @app_code_size:     size of the app code
+ * @app_data_off:      offset of the app data relative to ucode_off
+ * @app_data_size:     size of the app data
+ * @flags:             flags for the secure bootloader
+ *
+ * This structure is written into the WPR region for each managed falcon. Each
+ * instance is referenced by the lsb_offset member of the corresponding
+ * lsf_wpr_header.
+ */
+struct lsf_lsb_header {
+       struct lsf_ucode_desc signature;
+       u32 ucode_off;
+       u32 ucode_size;
+       u32 data_size;
+       u32 bl_code_size;
+       u32 bl_imem_off;
+       u32 bl_data_off;
+       u32 bl_data_size;
+       u32 app_code_off;
+       u32 app_code_size;
+       u32 app_data_off;
+       u32 app_data_size;
+       u32 flags;
+#define LSF_FLAG_LOAD_CODE_AT_0                1
+#define LSF_FLAG_DMACTL_REQ_CTX                4
+#define LSF_FLAG_FORCE_PRIV_LOAD       8
+};
+
+/**
+ * struct lsf_wpr_header - LS blob WPR Header
+ * @falcon_id:         LS falcon ID
+ * @lsb_offset:                offset of the lsb_lsf_header in the WPR region
+ * @bootstrap_owner:   secure falcon reponsible for bootstrapping the LS falcon
+ * @lazy_bootstrap:    skip bootstrapping by ACR
+ * @status:            bootstrapping status
+ *
+ * An array of these is written at the beginning of the WPR region, one for
+ * each managed falcon. The array is terminated by an instance which falcon_id
+ * is LSF_FALCON_ID_INVALID.
+ */
+struct lsf_wpr_header {
+       u32  falcon_id;
+       u32  lsb_offset;
+       u32  bootstrap_owner;
+       u32  lazy_bootstrap;
+       u32  status;
+#define LSF_IMAGE_STATUS_NONE                          0
+#define LSF_IMAGE_STATUS_COPY                          1
+#define LSF_IMAGE_STATUS_VALIDATION_CODE_FAILED                2
+#define LSF_IMAGE_STATUS_VALIDATION_DATA_FAILED                3
+#define LSF_IMAGE_STATUS_VALIDATION_DONE               4
+#define LSF_IMAGE_STATUS_VALIDATION_SKIPPED            5
+#define LSF_IMAGE_STATUS_BOOTSTRAP_READY               6
+};
+
+
+/**
+ * struct ls_ucode_img_desc - descriptor of firmware image
+ * @descriptor_size:           size of this descriptor
+ * @image_size:                        size of the whole image
+ * @bootloader_start_offset:   start offset of the bootloader in ucode image
+ * @bootloader_size:           size of the bootloader
+ * @bootloader_imem_offset:    start off set of the bootloader in IMEM
+ * @bootloader_entry_point:    entry point of the bootloader in IMEM
+ * @app_start_offset:          start offset of the LS firmware
+ * @app_size:                  size of the LS firmware's code and data
+ * @app_imem_offset:           offset of the app in IMEM
+ * @app_imem_entry:            entry point of the app in IMEM
+ * @app_dmem_offset:           offset of the data in DMEM
+ * @app_resident_code_offset:  offset of app code from app_start_offset
+ * @app_resident_code_size:    size of the code
+ * @app_resident_data_offset:  offset of data from app_start_offset
+ * @app_resident_data_size:    size of data
+ *
+ * A firmware image contains the code, data, and bootloader of a given LS
+ * falcon in a single blob. This structure describes where everything is.
+ *
+ * This can be generated from a (bootloader, code, data) set if they have
+ * been loaded separately, or come directly from a file.
+ */
+struct ls_ucode_img_desc {
+       u32 descriptor_size;
+       u32 image_size;
+       u32 tools_version;
+       u32 app_version;
+       char date[64];
+       u32 bootloader_start_offset;
+       u32 bootloader_size;
+       u32 bootloader_imem_offset;
+       u32 bootloader_entry_point;
+       u32 app_start_offset;
+       u32 app_size;
+       u32 app_imem_offset;
+       u32 app_imem_entry;
+       u32 app_dmem_offset;
+       u32 app_resident_code_offset;
+       u32 app_resident_code_size;
+       u32 app_resident_data_offset;
+       u32 app_resident_data_size;
+       u32 nb_overlays;
+       struct {u32 start; u32 size; } load_ovl[64];
+       u32 compressed;
+};
+
+/**
+ * struct ls_ucode_img - temporary storage for loaded LS firmwares
+ * @node:              to link within lsf_ucode_mgr
+ * @falcon_id:         ID of the falcon this LS firmware is for
+ * @ucode_desc:                loaded or generated map of ucode_data
+ * @ucode_header:      header of the firmware
+ * @ucode_data:                firmware payload (code and data)
+ * @ucode_size:                size in bytes of data in ucode_data
+ * @wpr_header:                WPR header to be written to the LS blob
+ * @lsb_header:                LSB header to be written to the LS blob
+ *
+ * Preparing the WPR LS blob requires information about all the LS firmwares
+ * (size, etc) to be known. This structure contains all the data of one LS
+ * firmware.
+ */
+struct ls_ucode_img {
+       struct list_head node;
+       enum nvkm_secboot_falcon falcon_id;
+
+       struct ls_ucode_img_desc ucode_desc;
+       u32 *ucode_header;
+       u8 *ucode_data;
+       u32 ucode_size;
+
+       struct lsf_wpr_header wpr_header;
+       struct lsf_lsb_header lsb_header;
+};
+
+/**
+ * struct ls_ucode_mgr - manager for all LS falcon firmwares
+ * @count:     number of managed LS falcons
+ * @wpr_size:  size of the required WPR region in bytes
+ * @img_list:  linked list of lsf_ucode_img
+ */
+struct ls_ucode_mgr {
+       u16 count;
+       u32 wpr_size;
+       struct list_head img_list;
+};
+
+
+/*
+ *
+ * HS blob structures
+ *
+ */
+
+/**
+ * struct hsf_fw_header - HS firmware descriptor
+ * @sig_dbg_offset:    offset of the debug signature
+ * @sig_dbg_size:      size of the debug signature
+ * @sig_prod_offset:   offset of the production signature
+ * @sig_prod_size:     size of the production signature
+ * @patch_loc:         offset of the offset (sic) of where the signature is
+ * @patch_sig:         offset of the offset (sic) to add to sig_*_offset
+ * @hdr_offset:                offset of the load header (see struct hs_load_header)
+ * @hdr_size:          size of above header
+ *
+ * This structure is embedded in the HS firmware image at
+ * hs_bin_hdr.header_offset.
+ */
+struct hsf_fw_header {
+       u32 sig_dbg_offset;
+       u32 sig_dbg_size;
+       u32 sig_prod_offset;
+       u32 sig_prod_size;
+       u32 patch_loc;
+       u32 patch_sig;
+       u32 hdr_offset;
+       u32 hdr_size;
+};
+
+/**
+ * struct hsf_load_header - HS firmware load header
+ */
+struct hsf_load_header {
+       u32 non_sec_code_off;
+       u32 non_sec_code_size;
+       u32 data_dma_base;
+       u32 data_size;
+       u32 num_apps;
+       struct {
+               u32 sec_code_off;
+               u32 sec_code_size;
+       } app[0];
+};
+
+/**
+ * Convenience function to duplicate a firmware file in memory and check that
+ * it has the required minimum size.
+ */
+static void *
+gm200_secboot_load_firmware(struct nvkm_subdev *subdev, const char *name,
+                   size_t min_size)
+{
+       const struct firmware *fw;
+       void *blob;
+       int ret;
+
+       ret = nvkm_firmware_get(subdev->device, name, &fw);
+       if (ret)
+               return ERR_PTR(ret);
+       if (fw->size < min_size) {
+               nvkm_error(subdev, "%s is smaller than expected size %zu\n",
+                          name, min_size);
+               nvkm_firmware_put(fw);
+               return ERR_PTR(-EINVAL);
+       }
+       blob = kmemdup(fw->data, fw->size, GFP_KERNEL);
+       nvkm_firmware_put(fw);
+       if (!blob)
+               return ERR_PTR(-ENOMEM);
+
+       return blob;
+}
+
+
+/*
+ * Low-secure blob creation
+ */
+
+#define BL_DESC_BLK_SIZE 256
+/**
+ * Build a ucode image and descriptor from provided bootloader, code and data.
+ *
+ * @bl:                bootloader image, including 16-bytes descriptor
+ * @code:      LS firmware code segment
+ * @data:      LS firmware data segment
+ * @desc:      ucode descriptor to be written
+ *
+ * Return: allocated ucode image with corresponding descriptor information. desc
+ *         is also updated to contain the right offsets within returned image.
+ */
+static void *
+ls_ucode_img_build(const struct firmware *bl, const struct firmware *code,
+                  const struct firmware *data, struct ls_ucode_img_desc *desc)
+{
+       struct fw_bin_header *bin_hdr = (void *)bl->data;
+       struct fw_bl_desc *bl_desc = (void *)bl->data + bin_hdr->header_offset;
+       void *bl_data = (void *)bl->data + bin_hdr->data_offset;
+       u32 pos = 0;
+       void *image;
+
+       desc->bootloader_start_offset = pos;
+       desc->bootloader_size = ALIGN(bl_desc->code_size, sizeof(u32));
+       desc->bootloader_imem_offset = bl_desc->start_tag * 256;
+       desc->bootloader_entry_point = bl_desc->start_tag * 256;
+
+       pos = ALIGN(pos + desc->bootloader_size, BL_DESC_BLK_SIZE);
+       desc->app_start_offset = pos;
+       desc->app_size = ALIGN(code->size, BL_DESC_BLK_SIZE) +
+                        ALIGN(data->size, BL_DESC_BLK_SIZE);
+       desc->app_imem_offset = 0;
+       desc->app_imem_entry = 0;
+       desc->app_dmem_offset = 0;
+       desc->app_resident_code_offset = 0;
+       desc->app_resident_code_size = ALIGN(code->size, BL_DESC_BLK_SIZE);
+
+       pos = ALIGN(pos + desc->app_resident_code_size, BL_DESC_BLK_SIZE);
+       desc->app_resident_data_offset = pos - desc->app_start_offset;
+       desc->app_resident_data_size = ALIGN(data->size, BL_DESC_BLK_SIZE);
+
+       desc->image_size = ALIGN(bl_desc->code_size, BL_DESC_BLK_SIZE) +
+                          desc->app_size;
+
+       image = kzalloc(desc->image_size, GFP_KERNEL);
+       if (!image)
+               return ERR_PTR(-ENOMEM);
+
+       memcpy(image + desc->bootloader_start_offset, bl_data,
+              bl_desc->code_size);
+       memcpy(image + desc->app_start_offset, code->data, code->size);
+       memcpy(image + desc->app_start_offset + desc->app_resident_data_offset,
+              data->data, data->size);
+
+       return image;
+}
+
+/**
+ * ls_ucode_img_load_generic() - load and prepare a LS ucode image
+ *
+ * Load the LS microcode, bootloader and signature and pack them into a single
+ * blob. Also generate the corresponding ucode descriptor.
+ */
+static int
+ls_ucode_img_load_generic(struct nvkm_subdev *subdev,
+                         struct ls_ucode_img *img, const char *falcon_name,
+                         const u32 falcon_id)
+{
+       const struct firmware *bl, *code, *data;
+       struct lsf_ucode_desc *lsf_desc;
+       char f[64];
+       int ret;
+
+       img->ucode_header = NULL;
+
+       snprintf(f, sizeof(f), "gr/%s_bl", falcon_name);
+       ret = nvkm_firmware_get(subdev->device, f, &bl);
+       if (ret)
+               goto error;
+
+       snprintf(f, sizeof(f), "gr/%s_inst", falcon_name);
+       ret = nvkm_firmware_get(subdev->device, f, &code);
+       if (ret)
+               goto free_bl;
+
+       snprintf(f, sizeof(f), "gr/%s_data", falcon_name);
+       ret = nvkm_firmware_get(subdev->device, f, &data);
+       if (ret)
+               goto free_inst;
+
+       img->ucode_data = ls_ucode_img_build(bl, code, data,
+                                            &img->ucode_desc);
+       if (IS_ERR(img->ucode_data)) {
+               ret = PTR_ERR(img->ucode_data);
+               goto free_data;
+       }
+       img->ucode_size = img->ucode_desc.image_size;
+
+       snprintf(f, sizeof(f), "gr/%s_sig", falcon_name);
+       lsf_desc = gm200_secboot_load_firmware(subdev, f, sizeof(*lsf_desc));
+       if (IS_ERR(lsf_desc)) {
+               ret = PTR_ERR(lsf_desc);
+               goto free_image;
+       }
+       /* not needed? the signature should already have the right value */
+       lsf_desc->falcon_id = falcon_id;
+       memcpy(&img->lsb_header.signature, lsf_desc, sizeof(*lsf_desc));
+       img->falcon_id = lsf_desc->falcon_id;
+       kfree(lsf_desc);
+
+       /* success path - only free requested firmware files */
+       goto free_data;
+
+free_image:
+       kfree(img->ucode_data);
+free_data:
+       nvkm_firmware_put(data);
+free_inst:
+       nvkm_firmware_put(code);
+free_bl:
+       nvkm_firmware_put(bl);
+error:
+       return ret;
+}
+
+typedef int (*lsf_load_func)(struct nvkm_subdev *, struct ls_ucode_img *);
+
+static int
+ls_ucode_img_load_fecs(struct nvkm_subdev *subdev, struct ls_ucode_img *img)
+{
+       return ls_ucode_img_load_generic(subdev, img, "fecs",
+                                        NVKM_SECBOOT_FALCON_FECS);
+}
+
+static int
+ls_ucode_img_load_gpccs(struct nvkm_subdev *subdev, struct ls_ucode_img *img)
+{
+       return ls_ucode_img_load_generic(subdev, img, "gpccs",
+                                        NVKM_SECBOOT_FALCON_GPCCS);
+}
+
+/**
+ * ls_ucode_img_load() - create a lsf_ucode_img and load it
+ */
+static struct ls_ucode_img *
+ls_ucode_img_load(struct nvkm_subdev *subdev, lsf_load_func load_func)
+{
+       struct ls_ucode_img *img;
+       int ret;
+
+       img = kzalloc(sizeof(*img), GFP_KERNEL);
+       if (!img)
+               return ERR_PTR(-ENOMEM);
+
+       ret = load_func(subdev, img);
+       if (ret) {
+               kfree(img);
+               return ERR_PTR(ret);
+       }
+
+       return img;
+}
+
+static const lsf_load_func lsf_load_funcs[] = {
+       [NVKM_SECBOOT_FALCON_END] = NULL, /* reserve enough space */
+       [NVKM_SECBOOT_FALCON_FECS] = ls_ucode_img_load_fecs,
+       [NVKM_SECBOOT_FALCON_GPCCS] = ls_ucode_img_load_gpccs,
+};
+
+/**
+ * ls_ucode_img_populate_bl_desc() - populate a DMEM BL descriptor for LS image
+ * @img:       ucode image to generate against
+ * @desc:      descriptor to populate
+ * @sb:                secure boot state to use for base addresses
+ *
+ * Populate the DMEM BL descriptor with the information contained in a
+ * ls_ucode_desc.
+ *
+ */
+static void
+ls_ucode_img_populate_bl_desc(struct ls_ucode_img *img, u64 wpr_addr,
+                             struct gm200_flcn_bl_desc *desc)
+{
+       struct ls_ucode_img_desc *pdesc = &img->ucode_desc;
+       u64 addr_base;
+
+       addr_base = wpr_addr + img->lsb_header.ucode_off +
+                   pdesc->app_start_offset;
+
+       memset(desc, 0, sizeof(*desc));
+       desc->ctx_dma = FALCON_DMAIDX_UCODE;
+       desc->code_dma_base.lo = lower_32_bits(
+               (addr_base + pdesc->app_resident_code_offset));
+       desc->code_dma_base.hi = upper_32_bits(
+               (addr_base + pdesc->app_resident_code_offset));
+       desc->non_sec_code_size = pdesc->app_resident_code_size;
+       desc->data_dma_base.lo = lower_32_bits(
+               (addr_base + pdesc->app_resident_data_offset));
+       desc->data_dma_base.hi = upper_32_bits(
+               (addr_base + pdesc->app_resident_data_offset));
+       desc->data_size = pdesc->app_resident_data_size;
+       desc->code_entry_point = pdesc->app_imem_entry;
+}
+
+#define LSF_LSB_HEADER_ALIGN 256
+#define LSF_BL_DATA_ALIGN 256
+#define LSF_BL_DATA_SIZE_ALIGN 256
+#define LSF_BL_CODE_SIZE_ALIGN 256
+#define LSF_UCODE_DATA_ALIGN 4096
+
+/**
+ * ls_ucode_img_fill_headers - fill the WPR and LSB headers of an image
+ * @gsb:       secure boot device used
+ * @img:       image to generate for
+ * @offset:    offset in the WPR region where this image starts
+ *
+ * Allocate space in the WPR area from offset and write the WPR and LSB headers
+ * accordingly.
+ *
+ * Return: offset at the end of this image.
+ */
+static u32
+ls_ucode_img_fill_headers(struct gm200_secboot *gsb, struct ls_ucode_img *img,
+                         u32 offset)
+{
+       struct lsf_wpr_header *whdr = &img->wpr_header;
+       struct lsf_lsb_header *lhdr = &img->lsb_header;
+       struct ls_ucode_img_desc *desc = &img->ucode_desc;
+
+       if (img->ucode_header) {
+               nvkm_fatal(&gsb->base.subdev,
+                           "images withough loader are not supported yet!\n");
+               return offset;
+       }
+
+       /* Fill WPR header */
+       whdr->falcon_id = img->falcon_id;
+       whdr->bootstrap_owner = gsb->base.func->boot_falcon;
+       whdr->status = LSF_IMAGE_STATUS_COPY;
+
+       /* Align, save off, and include an LSB header size */
+       offset = ALIGN(offset, LSF_LSB_HEADER_ALIGN);
+       whdr->lsb_offset = offset;
+       offset += sizeof(struct lsf_lsb_header);
+
+       /*
+        * Align, save off, and include the original (static) ucode
+        * image size
+        */
+       offset = ALIGN(offset, LSF_UCODE_DATA_ALIGN);
+       lhdr->ucode_off = offset;
+       offset += img->ucode_size;
+
+       /*
+        * For falcons that use a boot loader (BL), we append a loader
+        * desc structure on the end of the ucode image and consider
+        * this the boot loader data. The host will then copy the loader
+        * desc args to this space within the WPR region (before locking
+        * down) and the HS bin will then copy them to DMEM 0 for the
+        * loader.
+        */
+       lhdr->bl_code_size = ALIGN(desc->bootloader_size,
+                                  LSF_BL_CODE_SIZE_ALIGN);
+       lhdr->ucode_size = ALIGN(desc->app_resident_data_offset,
+                                LSF_BL_CODE_SIZE_ALIGN) + lhdr->bl_code_size;
+       lhdr->data_size = ALIGN(desc->app_size, LSF_BL_CODE_SIZE_ALIGN) +
+                               lhdr->bl_code_size - lhdr->ucode_size;
+       /*
+        * Though the BL is located at 0th offset of the image, the VA
+        * is different to make sure that it doesn't collide the actual
+        * OS VA range
+        */
+       lhdr->bl_imem_off = desc->bootloader_imem_offset;
+       lhdr->app_code_off = desc->app_start_offset +
+                            desc->app_resident_code_offset;
+       lhdr->app_code_size = desc->app_resident_code_size;
+       lhdr->app_data_off = desc->app_start_offset +
+                            desc->app_resident_data_offset;
+       lhdr->app_data_size = desc->app_resident_data_size;
+
+       lhdr->flags = 0;
+       if (img->falcon_id == gsb->base.func->boot_falcon)
+               lhdr->flags = LSF_FLAG_DMACTL_REQ_CTX;
+
+       /* GPCCS will be loaded using PRI */
+       if (img->falcon_id == NVKM_SECBOOT_FALCON_GPCCS)
+               lhdr->flags |= LSF_FLAG_FORCE_PRIV_LOAD;
+
+       /* Align (size bloat) and save off BL descriptor size */
+       lhdr->bl_data_size = ALIGN(sizeof(struct gm200_flcn_bl_desc),
+                                  LSF_BL_DATA_SIZE_ALIGN);
+       /*
+        * Align, save off, and include the additional BL data
+        */
+       offset = ALIGN(offset, LSF_BL_DATA_ALIGN);
+       lhdr->bl_data_off = offset;
+       offset += lhdr->bl_data_size;
+
+       return offset;
+}
+
+static void
+ls_ucode_mgr_init(struct ls_ucode_mgr *mgr)
+{
+       memset(mgr, 0, sizeof(*mgr));
+       INIT_LIST_HEAD(&mgr->img_list);
+}
+
+static void
+ls_ucode_mgr_cleanup(struct ls_ucode_mgr *mgr)
+{
+       struct ls_ucode_img *img, *t;
+
+       list_for_each_entry_safe(img, t, &mgr->img_list, node) {
+               kfree(img->ucode_data);
+               kfree(img->ucode_header);
+               kfree(img);
+       }
+}
+
+static void
+ls_ucode_mgr_add_img(struct ls_ucode_mgr *mgr, struct ls_ucode_img *img)
+{
+       mgr->count++;
+       list_add_tail(&img->node, &mgr->img_list);
+}
+
+/**
+ * ls_ucode_mgr_fill_headers - fill WPR and LSB headers of all managed images
+ */
+static void
+ls_ucode_mgr_fill_headers(struct gm200_secboot *gsb, struct ls_ucode_mgr *mgr)
+{
+       struct ls_ucode_img *img;
+       u32 offset;
+
+       /*
+        * Start with an array of WPR headers at the base of the WPR.
+        * The expectation here is that the secure falcon will do a single DMA
+        * read of this array and cache it internally so it's ok to pack these.
+        * Also, we add 1 to the falcon count to indicate the end of the array.
+        */
+       offset = sizeof(struct lsf_wpr_header) * (mgr->count + 1);
+
+       /*
+        * Walk the managed falcons, accounting for the LSB structs
+        * as well as the ucode images.
+        */
+       list_for_each_entry(img, &mgr->img_list, node) {
+               offset = ls_ucode_img_fill_headers(gsb, img, offset);
+       }
+
+       mgr->wpr_size = offset;
+}
+
+/**
+ * ls_ucode_mgr_write_wpr - write the WPR blob contents
+ */
+static int
+ls_ucode_mgr_write_wpr(struct gm200_secboot *gsb, struct ls_ucode_mgr *mgr,
+                      struct nvkm_gpuobj *wpr_blob)
+{
+       struct ls_ucode_img *img;
+       u32 pos = 0;
+
+       nvkm_kmap(wpr_blob);
+
+       list_for_each_entry(img, &mgr->img_list, node) {
+               nvkm_gpuobj_memcpy_to(wpr_blob, pos, &img->wpr_header,
+                                     sizeof(img->wpr_header));
+
+               nvkm_gpuobj_memcpy_to(wpr_blob, img->wpr_header.lsb_offset,
+                                    &img->lsb_header, sizeof(img->lsb_header));
+
+               /* Generate and write BL descriptor */
+               if (!img->ucode_header) {
+                       u8 desc[gsb->func->bl_desc_size];
+                       struct gm200_flcn_bl_desc gdesc;
+
+                       ls_ucode_img_populate_bl_desc(img, gsb->wpr_addr,
+                                                     &gdesc);
+                       gsb->func->fixup_bl_desc(&gdesc, &desc);
+                       nvkm_gpuobj_memcpy_to(wpr_blob,
+                                             img->lsb_header.bl_data_off,
+                                             &desc, gsb->func->bl_desc_size);
+               }
+
+               /* Copy ucode */
+               nvkm_gpuobj_memcpy_to(wpr_blob, img->lsb_header.ucode_off,
+                                     img->ucode_data, img->ucode_size);
+
+               pos += sizeof(img->wpr_header);
+       }
+
+       nvkm_wo32(wpr_blob, pos, NVKM_SECBOOT_FALCON_INVALID);
+
+       nvkm_done(wpr_blob);
+
+       return 0;
+}
+
+/* Both size and address of WPR need to be 128K-aligned */
+#define WPR_ALIGNMENT  0x20000
+/**
+ * gm200_secboot_prepare_ls_blob() - prepare the LS blob
+ *
+ * For each securely managed falcon, load the FW, signatures and bootloaders and
+ * prepare a ucode blob. Then, compute the offsets in the WPR region for each
+ * blob, and finally write the headers and ucode blobs into a GPU object that
+ * will be copied into the WPR region by the HS firmware.
+ */
+static int
+gm200_secboot_prepare_ls_blob(struct gm200_secboot *gsb)
+{
+       struct nvkm_secboot *sb = &gsb->base;
+       struct nvkm_device *device = sb->subdev.device;
+       struct ls_ucode_mgr mgr;
+       int falcon_id;
+       int ret;
+
+       ls_ucode_mgr_init(&mgr);
+
+       /* Load all LS blobs */
+       for_each_set_bit(falcon_id, &gsb->base.func->managed_falcons,
+                        NVKM_SECBOOT_FALCON_END) {
+               struct ls_ucode_img *img;
+
+               img = ls_ucode_img_load(&sb->subdev, lsf_load_funcs[falcon_id]);
+
+               if (IS_ERR(img)) {
+                       ret = PTR_ERR(img);
+                       goto cleanup;
+               }
+               ls_ucode_mgr_add_img(&mgr, img);
+       }
+
+       /*
+        * Fill the WPR and LSF headers with the right offsets and compute
+        * required WPR size
+        */
+       ls_ucode_mgr_fill_headers(gsb, &mgr);
+       mgr.wpr_size = ALIGN(mgr.wpr_size, WPR_ALIGNMENT);
+
+       /* Allocate GPU object that will contain the WPR region */
+       ret = nvkm_gpuobj_new(device, mgr.wpr_size, WPR_ALIGNMENT, false, NULL,
+                             &gsb->ls_blob);
+       if (ret)
+               goto cleanup;
+
+       nvkm_debug(&sb->subdev, "%d managed LS falcons, WPR size is %d bytes\n",
+                   mgr.count, mgr.wpr_size);
+
+       /* If WPR address and size are not fixed, set them to fit the LS blob */
+       if (!gsb->wpr_size) {
+               gsb->wpr_addr = gsb->ls_blob->addr;
+               gsb->wpr_size = gsb->ls_blob->size;
+       }
+
+       /* Write LS blob */
+       ret = ls_ucode_mgr_write_wpr(gsb, &mgr, gsb->ls_blob);
+
+cleanup:
+       ls_ucode_mgr_cleanup(&mgr);
+
+       return ret;
+}
+
+/*
+ * High-secure blob creation
+ */
+
+/**
+ * gm200_secboot_hsf_patch_signature() - patch HS blob with correct signature
+ */
+static void
+gm200_secboot_hsf_patch_signature(struct gm200_secboot *gsb, void *acr_image)
+{
+       struct nvkm_secboot *sb = &gsb->base;
+       struct fw_bin_header *hsbin_hdr = acr_image;
+       struct hsf_fw_header *fw_hdr = acr_image + hsbin_hdr->header_offset;
+       void *hs_data = acr_image + hsbin_hdr->data_offset;
+       void *sig;
+       u32 sig_size;
+
+       /* Falcon in debug or production mode? */
+       if ((nvkm_rd32(sb->subdev.device, sb->base + 0xc08) >> 20) & 0x1) {
+               sig = acr_image + fw_hdr->sig_dbg_offset;
+               sig_size = fw_hdr->sig_dbg_size;
+       } else {
+               sig = acr_image + fw_hdr->sig_prod_offset;
+               sig_size = fw_hdr->sig_prod_size;
+       }
+
+       /* Patch signature */
+       memcpy(hs_data + fw_hdr->patch_loc, sig + fw_hdr->patch_sig, sig_size);
+}
+
+/**
+ * gm200_secboot_populate_hsf_bl_desc() - populate BL descriptor for HS image
+ */
+static void
+gm200_secboot_populate_hsf_bl_desc(void *acr_image,
+                                  struct gm200_flcn_bl_desc *bl_desc)
+{
+       struct fw_bin_header *hsbin_hdr = acr_image;
+       struct hsf_fw_header *fw_hdr = acr_image + hsbin_hdr->header_offset;
+       struct hsf_load_header *load_hdr = acr_image + fw_hdr->hdr_offset;
+
+       /*
+        * Descriptor for the bootloader that will load the ACR image into
+        * IMEM/DMEM memory.
+        */
+       fw_hdr = acr_image + hsbin_hdr->header_offset;
+       load_hdr = acr_image + fw_hdr->hdr_offset;
+       memset(bl_desc, 0, sizeof(*bl_desc));
+       bl_desc->ctx_dma = FALCON_DMAIDX_VIRT;
+       bl_desc->non_sec_code_off = load_hdr->non_sec_code_off;
+       bl_desc->non_sec_code_size = load_hdr->non_sec_code_size;
+       bl_desc->sec_code_off = load_hdr->app[0].sec_code_off;
+       bl_desc->sec_code_size = load_hdr->app[0].sec_code_size;
+       bl_desc->code_entry_point = 0;
+       /*
+        * We need to set code_dma_base to the virtual address of the acr_blob,
+        * and add this address to data_dma_base before writing it into DMEM
+        */
+       bl_desc->code_dma_base.lo = 0;
+       bl_desc->data_dma_base.lo = load_hdr->data_dma_base;
+       bl_desc->data_size = load_hdr->data_size;
+}
+
+/**
+ * gm200_secboot_prepare_hs_blob - load and prepare a HS blob and BL descriptor
+ *
+ * @gsb secure boot instance to prepare for
+ * @fw name of the HS firmware to load
+ * @blob pointer to gpuobj that will be allocated to receive the HS FW payload
+ * @bl_desc pointer to the BL descriptor to write for this firmware
+ * @patch whether we should patch the HS descriptor (only for HS loaders)
+ */
+static int
+gm200_secboot_prepare_hs_blob(struct gm200_secboot *gsb, const char *fw,
+                             struct nvkm_gpuobj **blob,
+                             struct gm200_flcn_bl_desc *bl_desc, bool patch)
+{
+       struct nvkm_subdev *subdev = &gsb->base.subdev;
+       void *acr_image;
+       struct fw_bin_header *hsbin_hdr;
+       struct hsf_fw_header *fw_hdr;
+       void *acr_data;
+       struct hsf_load_header *load_hdr;
+       struct hsflcn_acr_desc *desc;
+       int ret;
+
+       acr_image = gm200_secboot_load_firmware(subdev, fw, 0);
+       if (IS_ERR(acr_image))
+               return PTR_ERR(acr_image);
+       hsbin_hdr = acr_image;
+
+       /* Patch signature */
+       gm200_secboot_hsf_patch_signature(gsb, acr_image);
+
+       acr_data = acr_image + hsbin_hdr->data_offset;
+
+       /* Patch descriptor? */
+       if (patch) {
+               fw_hdr = acr_image + hsbin_hdr->header_offset;
+               load_hdr = acr_image + fw_hdr->hdr_offset;
+               desc = acr_data + load_hdr->data_dma_base;
+               gsb->func->fixup_hs_desc(gsb, desc);
+       }
+
+       /* Generate HS BL descriptor */
+       gm200_secboot_populate_hsf_bl_desc(acr_image, bl_desc);
+
+       /* Create ACR blob and copy HS data to it */
+       ret = nvkm_gpuobj_new(subdev->device, ALIGN(hsbin_hdr->data_size, 256),
+                             0x1000, false, NULL, blob);
+       if (ret)
+               goto cleanup;
+
+       nvkm_kmap(*blob);
+       nvkm_gpuobj_memcpy_to(*blob, 0, acr_data, hsbin_hdr->data_size);
+       nvkm_done(*blob);
+
+cleanup:
+       kfree(acr_image);
+
+       return ret;
+}
+
+/*
+ * High-secure bootloader blob creation
+ */
+
+static int
+gm200_secboot_prepare_hsbl_blob(struct gm200_secboot *gsb)
+{
+       struct nvkm_subdev *subdev = &gsb->base.subdev;
+
+       gsb->hsbl_blob = gm200_secboot_load_firmware(subdev, "acr/bl", 0);
+       if (IS_ERR(gsb->hsbl_blob)) {
+               int ret = PTR_ERR(gsb->hsbl_blob);
+
+               gsb->hsbl_blob = NULL;
+               return ret;
+       }
+
+       return 0;
+}
+
+/**
+ * gm20x_secboot_prepare_blobs - load blobs common to all GM20X GPUs.
+ *
+ * This includes the LS blob, HS ucode loading blob, and HS bootloader.
+ *
+ * The HS ucode unload blob is only used on dGPU.
+ */
+int
+gm20x_secboot_prepare_blobs(struct gm200_secboot *gsb)
+{
+       int ret;
+
+       /* Load and prepare the managed falcon's firmwares */
+       ret = gm200_secboot_prepare_ls_blob(gsb);
+       if (ret)
+               return ret;
+
+       /* Load the HS firmware that will load the LS firmwares */
+       ret = gm200_secboot_prepare_hs_blob(gsb, "acr/ucode_load",
+                                           &gsb->acr_load_blob,
+                                           &gsb->acr_load_bl_desc, true);
+       if (ret)
+               return ret;
+
+       /* Load the HS firmware bootloader */
+       ret = gm200_secboot_prepare_hsbl_blob(gsb);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
+static int
+gm200_secboot_prepare_blobs(struct nvkm_secboot *sb)
+{
+       struct gm200_secboot *gsb = gm200_secboot(sb);
+       int ret;
+
+       ret = gm20x_secboot_prepare_blobs(gsb);
+       if (ret)
+               return ret;
+
+       /* dGPU only: load the HS firmware that unprotects the WPR region */
+       ret = gm200_secboot_prepare_hs_blob(gsb, "acr/ucode_unload",
+                                           &gsb->acr_unload_blob,
+                                           &gsb->acr_unload_bl_desc, false);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
+
+
+/*
+ * Secure Boot Execution
+ */
+
+/**
+ * gm200_secboot_load_hs_bl() - load HS bootloader into DMEM and IMEM
+ */
+static void
+gm200_secboot_load_hs_bl(struct gm200_secboot *gsb, void *data, u32 data_size)
+{
+       struct nvkm_device *device = gsb->base.subdev.device;
+       struct fw_bin_header *hdr = gsb->hsbl_blob;
+       struct fw_bl_desc *hsbl_desc = gsb->hsbl_blob + hdr->header_offset;
+       void *blob_data = gsb->hsbl_blob + hdr->data_offset;
+       void *hsbl_code = blob_data + hsbl_desc->code_off;
+       void *hsbl_data = blob_data + hsbl_desc->data_off;
+       u32 code_size = ALIGN(hsbl_desc->code_size, 256);
+       const u32 base = gsb->base.base;
+       u32 blk;
+       u32 tag;
+       int i;
+
+       /*
+        * Copy HS bootloader data
+        */
+       nvkm_wr32(device, base + 0x1c0, (0x00000000 | (0x1 << 24)));
+       for (i = 0; i < hsbl_desc->data_size / 4; i++)
+               nvkm_wr32(device, base + 0x1c4, ((u32 *)hsbl_data)[i]);
+
+       /*
+        * Copy HS bootloader interface structure where the HS descriptor
+        * expects it to be
+        */
+       nvkm_wr32(device, base + 0x1c0,
+                 (hsbl_desc->dmem_load_off | (0x1 << 24)));
+       for (i = 0; i < data_size / 4; i++)
+               nvkm_wr32(device, base + 0x1c4, ((u32 *)data)[i]);
+
+       /* Copy HS bootloader code to end of IMEM */
+       blk = (nvkm_rd32(device, base + 0x108) & 0x1ff) - (code_size >> 8);
+       tag = hsbl_desc->start_tag;
+       nvkm_wr32(device, base + 0x180, ((blk & 0xff) << 8) | (0x1 << 24));
+       for (i = 0; i < code_size / 4; i++) {
+               /* write new tag every 256B */
+               if ((i & 0x3f) == 0) {
+                       nvkm_wr32(device, base + 0x188, tag & 0xffff);
+                       tag++;
+               }
+               nvkm_wr32(device, base + 0x184, ((u32 *)hsbl_code)[i]);
+       }
+       nvkm_wr32(device, base + 0x188, 0);
+}
+
+/**
+ * gm200_secboot_setup_falcon() - set up the secure falcon for secure boot
+ */
+static int
+gm200_secboot_setup_falcon(struct gm200_secboot *gsb)
+{
+       struct nvkm_device *device = gsb->base.subdev.device;
+       struct fw_bin_header *hdr = gsb->hsbl_blob;
+       struct fw_bl_desc *hsbl_desc = gsb->hsbl_blob + hdr->header_offset;
+       /* virtual start address for boot vector */
+       u32 virt_addr = hsbl_desc->start_tag << 8;
+       const u32 base = gsb->base.base;
+       const u32 reg_base = base + 0xe00;
+       u32 inst_loc;
+       int ret;
+
+       ret = nvkm_secboot_falcon_reset(&gsb->base);
+       if (ret)
+               return ret;
+
+       /* setup apertures - virtual */
+       nvkm_wr32(device, reg_base + 4 * (FALCON_DMAIDX_UCODE), 0x4);
+       nvkm_wr32(device, reg_base + 4 * (FALCON_DMAIDX_VIRT), 0x0);
+       /* setup apertures - physical */
+       nvkm_wr32(device, reg_base + 4 * (FALCON_DMAIDX_PHYS_VID), 0x4);
+       nvkm_wr32(device, reg_base + 4 * (FALCON_DMAIDX_PHYS_SYS_COH),
+                 0x4 | 0x1);
+       nvkm_wr32(device, reg_base + 4 * (FALCON_DMAIDX_PHYS_SYS_NCOH),
+                 0x4 | 0x2);
+
+       /* Set context */
+       if (nvkm_memory_target(gsb->inst->memory) == NVKM_MEM_TARGET_VRAM)
+               inst_loc = 0x0; /* FB */
+       else
+               inst_loc = 0x3; /* Non-coherent sysmem */
+
+       nvkm_mask(device, base + 0x048, 0x1, 0x1);
+       nvkm_wr32(device, base + 0x480,
+                 ((gsb->inst->addr >> 12) & 0xfffffff) |
+                 (inst_loc << 28) | (1 << 30));
+
+       /* Set boot vector to code's starting virtual address */
+       nvkm_wr32(device, base + 0x104, virt_addr);
+
+       return 0;
+}
+
+/**
+ * gm200_secboot_run_hs_blob() - run the given high-secure blob
+ */
+static int
+gm200_secboot_run_hs_blob(struct gm200_secboot *gsb, struct nvkm_gpuobj *blob,
+                         struct gm200_flcn_bl_desc *desc)
+{
+       struct nvkm_vma vma;
+       u64 vma_addr;
+       const u32 bl_desc_size = gsb->func->bl_desc_size;
+       u8 bl_desc[bl_desc_size];
+       int ret;
+
+       /* Map the HS firmware so the HS bootloader can see it */
+       ret = nvkm_gpuobj_map(blob, gsb->vm, NV_MEM_ACCESS_RW, &vma);
+       if (ret)
+               return ret;
+
+       /* Add the mapping address to the DMA bases */
+       vma_addr = flcn64_to_u64(desc->code_dma_base) + vma.offset;
+       desc->code_dma_base.lo = lower_32_bits(vma_addr);
+       desc->code_dma_base.hi = upper_32_bits(vma_addr);
+       vma_addr = flcn64_to_u64(desc->data_dma_base) + vma.offset;
+       desc->data_dma_base.lo = lower_32_bits(vma_addr);
+       desc->data_dma_base.hi = upper_32_bits(vma_addr);
+
+       /* Fixup the BL header */
+       gsb->func->fixup_bl_desc(desc, &bl_desc);
+
+       /* Reset the falcon and make it ready to run the HS bootloader */
+       ret = gm200_secboot_setup_falcon(gsb);
+       if (ret)
+               goto done;
+
+       /* Load the HS bootloader into the falcon's IMEM/DMEM */
+       gm200_secboot_load_hs_bl(gsb, &bl_desc, bl_desc_size);
+
+       /* Start the HS bootloader */
+       ret = nvkm_secboot_falcon_run(&gsb->base);
+       if (ret)
+               goto done;
+
+done:
+       /* Restore the original DMA addresses */
+       vma_addr = flcn64_to_u64(desc->code_dma_base) - vma.offset;
+       desc->code_dma_base.lo = lower_32_bits(vma_addr);
+       desc->code_dma_base.hi = upper_32_bits(vma_addr);
+       vma_addr = flcn64_to_u64(desc->data_dma_base) - vma.offset;
+       desc->data_dma_base.lo = lower_32_bits(vma_addr);
+       desc->data_dma_base.hi = upper_32_bits(vma_addr);
+
+       /* We don't need the ACR firmware anymore */
+       nvkm_gpuobj_unmap(&vma);
+
+       return ret;
+}
+
+/*
+ * gm200_secboot_reset() - execute secure boot from the prepared state
+ *
+ * Load the HS bootloader and ask the falcon to run it. This will in turn
+ * load the HS firmware and run it, so once the falcon stops all the managed
+ * falcons should have their LS firmware loaded and be ready to run.
+ */
+int
+gm200_secboot_reset(struct nvkm_secboot *sb, enum nvkm_secboot_falcon falcon)
+{
+       struct gm200_secboot *gsb = gm200_secboot(sb);
+       int ret;
+
+       /*
+        * Dummy GM200 implementation: perform secure boot each time we are
+        * called on FECS. Since only FECS and GPCCS are managed and started
+        * together, this ought to be safe.
+        *
+        * Once we have proper PMU firmware and support, this will be changed
+        * to a proper call to the PMU method.
+        */
+       if (falcon != NVKM_SECBOOT_FALCON_FECS)
+               goto end;
+
+       /* If WPR is set and we have an unload blob, run it to unlock WPR */
+       if (gsb->acr_unload_blob &&
+           gsb->falcon_state[NVKM_SECBOOT_FALCON_FECS] != NON_SECURE) {
+               ret = gm200_secboot_run_hs_blob(gsb, gsb->acr_unload_blob,
+                                               &gsb->acr_unload_bl_desc);
+               if (ret)
+                       return ret;
+       }
+
+       /* Reload all managed falcons */
+       ret = gm200_secboot_run_hs_blob(gsb, gsb->acr_load_blob,
+                                       &gsb->acr_load_bl_desc);
+       if (ret)
+               return ret;
+
+end:
+       gsb->falcon_state[falcon] = RESET;
+       return 0;
+}
+
+int
+gm200_secboot_start(struct nvkm_secboot *sb, enum nvkm_secboot_falcon falcon)
+{
+       struct gm200_secboot *gsb = gm200_secboot(sb);
+       int base;
+
+       switch (falcon) {
+       case NVKM_SECBOOT_FALCON_FECS:
+               base = 0x409000;
+               break;
+       case NVKM_SECBOOT_FALCON_GPCCS:
+               base = 0x41a000;
+               break;
+       default:
+               nvkm_error(&sb->subdev, "cannot start unhandled falcon!\n");
+               return -EINVAL;
+       }
+
+       nvkm_wr32(sb->subdev.device, base + 0x130, 0x00000002);
+       gsb->falcon_state[falcon] = RUNNING;
+
+       return 0;
+}
+
+
+
+int
+gm200_secboot_init(struct nvkm_secboot *sb)
+{
+       struct gm200_secboot *gsb = gm200_secboot(sb);
+       struct nvkm_device *device = sb->subdev.device;
+       struct nvkm_vm *vm;
+       const u64 vm_area_len = 600 * 1024;
+       int ret;
+
+       /* Allocate instance block and VM */
+       ret = nvkm_gpuobj_new(device, 0x1000, 0, true, NULL, &gsb->inst);
+       if (ret)
+               return ret;
+
+       ret = nvkm_gpuobj_new(device, 0x8000, 0, true, NULL, &gsb->pgd);
+       if (ret)
+               return ret;
+
+       ret = nvkm_vm_new(device, 0, vm_area_len, 0, NULL, &vm);
+       if (ret)
+               return ret;
+
+       atomic_inc(&vm->engref[NVKM_SUBDEV_PMU]);
+
+       ret = nvkm_vm_ref(vm, &gsb->vm, gsb->pgd);
+       nvkm_vm_ref(NULL, &vm, NULL);
+       if (ret)
+               return ret;
+
+       nvkm_kmap(gsb->inst);
+       nvkm_wo32(gsb->inst, 0x200, lower_32_bits(gsb->pgd->addr));
+       nvkm_wo32(gsb->inst, 0x204, upper_32_bits(gsb->pgd->addr));
+       nvkm_wo32(gsb->inst, 0x208, lower_32_bits(vm_area_len - 1));
+       nvkm_wo32(gsb->inst, 0x20c, upper_32_bits(vm_area_len - 1));
+       nvkm_done(gsb->inst);
+
+       return 0;
+}
+
+int
+gm200_secboot_fini(struct nvkm_secboot *sb, bool suspend)
+{
+       struct gm200_secboot *gsb = gm200_secboot(sb);
+       int ret = 0;
+       int i;
+
+       /* Run the unload blob to unprotect the WPR region */
+       if (gsb->acr_unload_blob &&
+           gsb->falcon_state[NVKM_SECBOOT_FALCON_FECS] != NON_SECURE)
+               ret = gm200_secboot_run_hs_blob(gsb, gsb->acr_unload_blob,
+                                               &gsb->acr_unload_bl_desc);
+
+       for (i = 0; i < NVKM_SECBOOT_FALCON_END; i++)
+               gsb->falcon_state[i] = NON_SECURE;
+
+       return ret;
+}
+
+void *
+gm200_secboot_dtor(struct nvkm_secboot *sb)
+{
+       struct gm200_secboot *gsb = gm200_secboot(sb);
+
+       nvkm_gpuobj_del(&gsb->acr_unload_blob);
+
+       kfree(gsb->hsbl_blob);
+       nvkm_gpuobj_del(&gsb->acr_load_blob);
+       nvkm_gpuobj_del(&gsb->ls_blob);
+
+       nvkm_vm_ref(NULL, &gsb->vm, gsb->pgd);
+       nvkm_gpuobj_del(&gsb->pgd);
+       nvkm_gpuobj_del(&gsb->inst);
+
+       return gsb;
+}
+
+
+static const struct nvkm_secboot_func
+gm200_secboot = {
+       .dtor = gm200_secboot_dtor,
+       .init = gm200_secboot_init,
+       .fini = gm200_secboot_fini,
+       .prepare_blobs = gm200_secboot_prepare_blobs,
+       .reset = gm200_secboot_reset,
+       .start = gm200_secboot_start,
+       .managed_falcons = BIT(NVKM_SECBOOT_FALCON_FECS) |
+                          BIT(NVKM_SECBOOT_FALCON_GPCCS),
+       .boot_falcon = NVKM_SECBOOT_FALCON_PMU,
+};
+
+/**
+ * gm200_fixup_bl_desc - just copy the BL descriptor
+ *
+ * Use the GM200 descriptor format by default.
+ */
+static void
+gm200_secboot_fixup_bl_desc(const struct gm200_flcn_bl_desc *desc, void *ret)
+{
+       memcpy(ret, desc, sizeof(*desc));
+}
+
+static void
+gm200_secboot_fixup_hs_desc(struct gm200_secboot *gsb,
+                           struct hsflcn_acr_desc *desc)
+{
+       desc->ucode_blob_base = gsb->ls_blob->addr;
+       desc->ucode_blob_size = gsb->ls_blob->size;
+
+       desc->wpr_offset = 0;
+
+       /* WPR region information for the HS binary to set up */
+       desc->wpr_region_id = 1;
+       desc->regions.no_regions = 1;
+       desc->regions.region_props[0].region_id = 1;
+       desc->regions.region_props[0].start_addr = gsb->wpr_addr >> 8;
+       desc->regions.region_props[0].end_addr =
+               (gsb->wpr_addr + gsb->wpr_size) >> 8;
+}
+
+static const struct gm200_secboot_func
+gm200_secboot_func = {
+       .bl_desc_size = sizeof(struct gm200_flcn_bl_desc),
+       .fixup_bl_desc = gm200_secboot_fixup_bl_desc,
+       .fixup_hs_desc = gm200_secboot_fixup_hs_desc,
+};
+
+int
+gm200_secboot_new(struct nvkm_device *device, int index,
+                 struct nvkm_secboot **psb)
+{
+       int ret;
+       struct gm200_secboot *gsb;
+
+       gsb = kzalloc(sizeof(*gsb), GFP_KERNEL);
+       if (!gsb) {
+               psb = NULL;
+               return -ENOMEM;
+       }
+       *psb = &gsb->base;
+
+       ret = nvkm_secboot_ctor(&gm200_secboot, device, index, &gsb->base);
+       if (ret)
+               return ret;
+
+       gsb->func = &gm200_secboot_func;
+
+       return 0;
+}
+
+MODULE_FIRMWARE("nvidia/gm200/acr/bl.bin");
+MODULE_FIRMWARE("nvidia/gm200/acr/ucode_load.bin");
+MODULE_FIRMWARE("nvidia/gm200/acr/ucode_unload.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/fecs_bl.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/fecs_inst.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/fecs_data.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/fecs_sig.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/gpccs_bl.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/gpccs_inst.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/gpccs_data.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/gpccs_sig.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/sw_ctx.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/sw_nonctx.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/sw_bundle_init.bin");
+MODULE_FIRMWARE("nvidia/gm200/gr/sw_method_init.bin");
+
+MODULE_FIRMWARE("nvidia/gm204/acr/bl.bin");
+MODULE_FIRMWARE("nvidia/gm204/acr/ucode_load.bin");
+MODULE_FIRMWARE("nvidia/gm204/acr/ucode_unload.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/fecs_bl.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/fecs_inst.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/fecs_data.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/fecs_sig.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/gpccs_bl.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/gpccs_inst.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/gpccs_data.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/gpccs_sig.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/sw_ctx.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/sw_nonctx.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/sw_bundle_init.bin");
+MODULE_FIRMWARE("nvidia/gm204/gr/sw_method_init.bin");
+
+MODULE_FIRMWARE("nvidia/gm206/acr/bl.bin");
+MODULE_FIRMWARE("nvidia/gm206/acr/ucode_load.bin");
+MODULE_FIRMWARE("nvidia/gm206/acr/ucode_unload.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/fecs_bl.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/fecs_inst.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/fecs_data.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/fecs_sig.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/gpccs_bl.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/gpccs_inst.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/gpccs_data.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/gpccs_sig.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/sw_ctx.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/sw_nonctx.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/sw_bundle_init.bin");
+MODULE_FIRMWARE("nvidia/gm206/gr/sw_method_init.bin");
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm20b.c b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm20b.c
new file mode 100644 (file)
index 0000000..6843204
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "priv.h"
+
+#include <core/gpuobj.h>
+
+/*
+ * The BL header format used by GM20B's firmware is slightly different
+ * from the one of GM200. Fix the differences here.
+ */
+struct gm20b_flcn_bl_desc {
+       u32 reserved[4];
+       u32 signature[4];
+       u32 ctx_dma;
+       u32 code_dma_base;
+       u32 non_sec_code_off;
+       u32 non_sec_code_size;
+       u32 sec_code_off;
+       u32 sec_code_size;
+       u32 code_entry_point;
+       u32 data_dma_base;
+       u32 data_size;
+};
+
+/**
+ * gm20b_secboot_fixup_bl_desc - adapt BL descriptor to format used by GM20B FW
+ *
+ * There is only a slight format difference (DMA addresses being 32-bits and
+ * 256B-aligned) to address.
+ */
+static void
+gm20b_secboot_fixup_bl_desc(const struct gm200_flcn_bl_desc *desc, void *ret)
+{
+       struct gm20b_flcn_bl_desc *gdesc = ret;
+       u64 addr;
+
+       memcpy(gdesc->reserved, desc->reserved, sizeof(gdesc->reserved));
+       memcpy(gdesc->signature, desc->signature, sizeof(gdesc->signature));
+       gdesc->ctx_dma = desc->ctx_dma;
+       addr = desc->code_dma_base.hi;
+       addr <<= 32;
+       addr |= desc->code_dma_base.lo;
+       gdesc->code_dma_base = lower_32_bits(addr >> 8);
+       gdesc->non_sec_code_off = desc->non_sec_code_off;
+       gdesc->non_sec_code_size = desc->non_sec_code_size;
+       gdesc->sec_code_off = desc->sec_code_off;
+       gdesc->sec_code_size = desc->sec_code_size;
+       gdesc->code_entry_point = desc->code_entry_point;
+       addr = desc->data_dma_base.hi;
+       addr <<= 32;
+       addr |= desc->data_dma_base.lo;
+       gdesc->data_dma_base = lower_32_bits(addr >> 8);
+       gdesc->data_size = desc->data_size;
+}
+
+static void
+gm20b_secboot_fixup_hs_desc(struct gm200_secboot *gsb,
+                           struct hsflcn_acr_desc *desc)
+{
+       desc->ucode_blob_base = gsb->ls_blob->addr;
+       desc->ucode_blob_size = gsb->ls_blob->size;
+
+       desc->wpr_offset = 0;
+}
+
+static const struct gm200_secboot_func
+gm20b_secboot_func = {
+       .bl_desc_size = sizeof(struct gm20b_flcn_bl_desc),
+       .fixup_bl_desc = gm20b_secboot_fixup_bl_desc,
+       .fixup_hs_desc = gm20b_secboot_fixup_hs_desc,
+};
+
+
+#ifdef CONFIG_ARCH_TEGRA
+#define TEGRA_MC_BASE                          0x70019000
+#define MC_SECURITY_CARVEOUT2_CFG0             0xc58
+#define MC_SECURITY_CARVEOUT2_BOM_0            0xc5c
+#define MC_SECURITY_CARVEOUT2_BOM_HI_0         0xc60
+#define MC_SECURITY_CARVEOUT2_SIZE_128K                0xc64
+#define TEGRA_MC_SECURITY_CARVEOUT_CFG_LOCKED  (1 << 1)
+/**
+ * sb_tegra_read_wpr() - read the WPR registers on Tegra
+ *
+ * On dGPU, we can manage the WPR region ourselves, but on Tegra the WPR region
+ * is reserved from system memory by the bootloader and irreversibly locked.
+ * This function reads the address and size of the pre-configured WPR region.
+ */
+static int
+gm20b_tegra_read_wpr(struct gm200_secboot *gsb)
+{
+       struct nvkm_secboot *sb = &gsb->base;
+       void __iomem *mc;
+       u32 cfg;
+
+       mc = ioremap(TEGRA_MC_BASE, 0xd00);
+       if (!mc) {
+               nvkm_error(&sb->subdev, "Cannot map Tegra MC registers\n");
+               return PTR_ERR(mc);
+       }
+       gsb->wpr_addr = ioread32_native(mc + MC_SECURITY_CARVEOUT2_BOM_0) |
+             ((u64)ioread32_native(mc + MC_SECURITY_CARVEOUT2_BOM_HI_0) << 32);
+       gsb->wpr_size = ioread32_native(mc + MC_SECURITY_CARVEOUT2_SIZE_128K)
+               << 17;
+       cfg = ioread32_native(mc + MC_SECURITY_CARVEOUT2_CFG0);
+       iounmap(mc);
+
+       /* Check that WPR settings are valid */
+       if (gsb->wpr_size == 0) {
+               nvkm_error(&sb->subdev, "WPR region is empty\n");
+               return -EINVAL;
+       }
+
+       if (!(cfg & TEGRA_MC_SECURITY_CARVEOUT_CFG_LOCKED)) {
+               nvkm_error(&sb->subdev, "WPR region not locked\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+#else
+static int
+gm20b_tegra_read_wpr(struct gm200_secboot *gsb)
+{
+       nvkm_error(&gsb->base.subdev, "Tegra support not compiled in\n");
+       return -EINVAL;
+}
+#endif
+
+static int
+gm20b_secboot_prepare_blobs(struct nvkm_secboot *sb)
+{
+       struct gm200_secboot *gsb = gm200_secboot(sb);
+       int acr_size;
+       int ret;
+
+       ret = gm20x_secboot_prepare_blobs(gsb);
+       if (ret)
+               return ret;
+
+       acr_size = gsb->acr_load_blob->size;
+       /*
+        * On Tegra the WPR region is set by the bootloader. It is illegal for
+        * the HS blob to be larger than this region.
+        */
+       if (acr_size > gsb->wpr_size) {
+               nvkm_error(&sb->subdev, "WPR region too small for FW blob!\n");
+               nvkm_error(&sb->subdev, "required: %dB\n", acr_size);
+               nvkm_error(&sb->subdev, "WPR size: %dB\n", gsb->wpr_size);
+               return -ENOSPC;
+       }
+
+       return 0;
+}
+
+static int
+gm20b_secboot_init(struct nvkm_secboot *sb)
+{
+       struct gm200_secboot *gsb = gm200_secboot(sb);
+       int ret;
+
+       ret = gm20b_tegra_read_wpr(gsb);
+       if (ret)
+               return ret;
+
+       return gm200_secboot_init(sb);
+}
+
+static const struct nvkm_secboot_func
+gm20b_secboot = {
+       .dtor = gm200_secboot_dtor,
+       .init = gm20b_secboot_init,
+       .prepare_blobs = gm20b_secboot_prepare_blobs,
+       .reset = gm200_secboot_reset,
+       .start = gm200_secboot_start,
+       .managed_falcons = BIT(NVKM_SECBOOT_FALCON_FECS),
+       .boot_falcon = NVKM_SECBOOT_FALCON_PMU,
+};
+
+int
+gm20b_secboot_new(struct nvkm_device *device, int index,
+                 struct nvkm_secboot **psb)
+{
+       int ret;
+       struct gm200_secboot *gsb;
+
+       gsb = kzalloc(sizeof(*gsb), GFP_KERNEL);
+       if (!gsb) {
+               psb = NULL;
+               return -ENOMEM;
+       }
+       *psb = &gsb->base;
+
+       ret = nvkm_secboot_ctor(&gm20b_secboot, device, index, &gsb->base);
+       if (ret)
+               return ret;
+
+       gsb->func = &gm20b_secboot_func;
+
+       return 0;
+}
+
+MODULE_FIRMWARE("nvidia/gm20b/acr/bl.bin");
+MODULE_FIRMWARE("nvidia/gm20b/acr/ucode_load.bin");
+MODULE_FIRMWARE("nvidia/gm20b/gr/fecs_bl.bin");
+MODULE_FIRMWARE("nvidia/gm20b/gr/fecs_inst.bin");
+MODULE_FIRMWARE("nvidia/gm20b/gr/fecs_data.bin");
+MODULE_FIRMWARE("nvidia/gm20b/gr/fecs_sig.bin");
+MODULE_FIRMWARE("nvidia/gm20b/gr/gpccs_inst.bin");
+MODULE_FIRMWARE("nvidia/gm20b/gr/gpccs_data.bin");
+MODULE_FIRMWARE("nvidia/gm20b/gr/sw_ctx.bin");
+MODULE_FIRMWARE("nvidia/gm20b/gr/sw_nonctx.bin");
+MODULE_FIRMWARE("nvidia/gm20b/gr/sw_bundle_init.bin");
+MODULE_FIRMWARE("nvidia/gm20b/gr/sw_method_init.bin");
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/secboot/priv.h
new file mode 100644 (file)
index 0000000..f2b09de
--- /dev/null
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __NVKM_SECBOOT_PRIV_H__
+#define __NVKM_SECBOOT_PRIV_H__
+
+#include <subdev/secboot.h>
+#include <subdev/mmu.h>
+
+struct nvkm_secboot_func {
+       int (*init)(struct nvkm_secboot *);
+       int (*fini)(struct nvkm_secboot *, bool suspend);
+       void *(*dtor)(struct nvkm_secboot *);
+       int (*prepare_blobs)(struct nvkm_secboot *);
+       int (*reset)(struct nvkm_secboot *, enum nvkm_secboot_falcon);
+       int (*start)(struct nvkm_secboot *, enum nvkm_secboot_falcon);
+
+       /* ID of the falcon that will perform secure boot */
+       enum nvkm_secboot_falcon boot_falcon;
+       /* Bit-mask of IDs of managed falcons */
+       unsigned long managed_falcons;
+};
+
+int nvkm_secboot_ctor(const struct nvkm_secboot_func *, struct nvkm_device *,
+                     int index, struct nvkm_secboot *);
+int nvkm_secboot_falcon_reset(struct nvkm_secboot *);
+int nvkm_secboot_falcon_run(struct nvkm_secboot *);
+
+struct flcn_u64 {
+       u32 lo;
+       u32 hi;
+};
+static inline u64 flcn64_to_u64(const struct flcn_u64 f)
+{
+       return ((u64)f.hi) << 32 | f.lo;
+}
+
+/**
+ * struct gm200_flcn_bl_desc - DMEM bootloader descriptor
+ * @signature:         16B signature for secure code. 0s if no secure code
+ * @ctx_dma:           DMA context to be used by BL while loading code/data
+ * @code_dma_base:     256B-aligned Physical FB Address where code is located
+ *                     (falcon's $xcbase register)
+ * @non_sec_code_off:  offset from code_dma_base where the non-secure code is
+ *                      located. The offset must be multiple of 256 to help perf
+ * @non_sec_code_size: the size of the nonSecure code part.
+ * @sec_code_off:      offset from code_dma_base where the secure code is
+ *                      located. The offset must be multiple of 256 to help perf
+ * @sec_code_size:     offset from code_dma_base where the secure code is
+ *                      located. The offset must be multiple of 256 to help perf
+ * @code_entry_point:  code entry point which will be invoked by BL after
+ *                      code is loaded.
+ * @data_dma_base:     256B aligned Physical FB Address where data is located.
+ *                     (falcon's $xdbase register)
+ * @data_size:         size of data block. Should be multiple of 256B
+ *
+ * Structure used by the bootloader to load the rest of the code. This has
+ * to be filled by host and copied into DMEM at offset provided in the
+ * hsflcn_bl_desc.bl_desc_dmem_load_off.
+ */
+struct gm200_flcn_bl_desc {
+       u32 reserved[4];
+       u32 signature[4];
+       u32 ctx_dma;
+       struct flcn_u64 code_dma_base;
+       u32 non_sec_code_off;
+       u32 non_sec_code_size;
+       u32 sec_code_off;
+       u32 sec_code_size;
+       u32 code_entry_point;
+       struct flcn_u64 data_dma_base;
+       u32 data_size;
+};
+
+/**
+ * struct hsflcn_acr_desc - data section of the HS firmware
+ *
+ * This header is to be copied at the beginning of DMEM by the HS bootloader.
+ *
+ * @signature:         signature of ACR ucode
+ * @wpr_region_id:     region ID holding the WPR header and its details
+ * @wpr_offset:                offset from the WPR region holding the wpr header
+ * @regions:           region descriptors
+ * @nonwpr_ucode_blob_size:    size of LS blob
+ * @nonwpr_ucode_blob_start:   FB location of LS blob is
+ */
+struct hsflcn_acr_desc {
+       union {
+               u8 reserved_dmem[0x200];
+               u32 signatures[4];
+       } ucode_reserved_space;
+       u32 wpr_region_id;
+       u32 wpr_offset;
+       u32 mmu_mem_range;
+#define FLCN_ACR_MAX_REGIONS 2
+       struct {
+               u32 no_regions;
+               struct {
+                       u32 start_addr;
+                       u32 end_addr;
+                       u32 region_id;
+                       u32 read_mask;
+                       u32 write_mask;
+                       u32 client_mask;
+               } region_props[FLCN_ACR_MAX_REGIONS];
+       } regions;
+       u32 ucode_blob_size;
+       u64 ucode_blob_base __aligned(8);
+       struct {
+               u32 vpr_enabled;
+               u32 vpr_start;
+               u32 vpr_end;
+               u32 hdcp_policies;
+       } vpr_desc;
+};
+
+/**
+ * Contains the whole secure boot state, allowing it to be performed as needed
+ * @wpr_addr:          physical address of the WPR region
+ * @wpr_size:          size in bytes of the WPR region
+ * @ls_blob:           LS blob of all the LS firmwares, signatures, bootloaders
+ * @ls_blob_size:      size of the LS blob
+ * @ls_blob_nb_regions:        number of LS firmwares that will be loaded
+ * @acr_blob:          HS blob
+ * @acr_blob_vma:      mapping of the HS blob into the secure falcon's VM
+ * @acr_bl_desc:       bootloader descriptor of the HS blob
+ * @hsbl_blob:         HS blob bootloader
+ * @inst:              instance block for HS falcon
+ * @pgd:               page directory for the HS falcon
+ * @vm:                        address space used by the HS falcon
+ * @bl_desc_size:      size of the BL descriptor used by this chip.
+ * @fixup_bl_desc:     hook that generates the proper BL descriptor format from
+ *                     the generic GM200 format into a data array of size
+ *                     bl_desc_size
+ */
+struct gm200_secboot {
+       struct nvkm_secboot base;
+       const struct gm200_secboot_func *func;
+
+       /*
+        * Address and size of the WPR region. On dGPU this will be the
+        * address of the LS blob. On Tegra this is a fixed region set by the
+        * bootloader
+        */
+       u64 wpr_addr;
+       u32 wpr_size;
+
+       /*
+        * HS FW - lock WPR region (dGPU only) and load LS FWs
+        * on Tegra the HS FW copies the LS blob into the fixed WPR instead
+        */
+       struct nvkm_gpuobj *acr_load_blob;
+       struct gm200_flcn_bl_desc acr_load_bl_desc;
+
+       /* HS FW - unlock WPR region (dGPU only) */
+       struct nvkm_gpuobj *acr_unload_blob;
+       struct gm200_flcn_bl_desc acr_unload_bl_desc;
+
+       /* HS bootloader */
+       void *hsbl_blob;
+
+       /* LS FWs, to be loaded by the HS ACR */
+       struct nvkm_gpuobj *ls_blob;
+
+       /* Instance block & address space used for HS FW execution */
+       struct nvkm_gpuobj *inst;
+       struct nvkm_gpuobj *pgd;
+       struct nvkm_vm *vm;
+
+       /* To keep track of the state of all managed falcons */
+       enum {
+               /* In non-secure state, no firmware loaded, no privileges*/
+               NON_SECURE = 0,
+               /* In low-secure mode and ready to be started */
+               RESET,
+               /* In low-secure mode and running */
+               RUNNING,
+       } falcon_state[NVKM_SECBOOT_FALCON_END];
+
+};
+#define gm200_secboot(sb) container_of(sb, struct gm200_secboot, base)
+
+struct gm200_secboot_func {
+       /*
+        * Size of the bootloader descriptor for this chip. A block of this
+        * size is allocated before booting a falcon and the fixup_bl_desc
+        * callback is called on it
+        */
+       u32 bl_desc_size;
+       void (*fixup_bl_desc)(const struct gm200_flcn_bl_desc *, void *);
+
+       /*
+        * Chip-specific modifications of the HS descriptor can be done here.
+        * On dGPU this is used to fill the information about the WPR region
+        * we want the HS FW to set up.
+        */
+       void (*fixup_hs_desc)(struct gm200_secboot *, struct hsflcn_acr_desc *);
+};
+
+int gm200_secboot_init(struct nvkm_secboot *);
+void *gm200_secboot_dtor(struct nvkm_secboot *);
+int gm200_secboot_reset(struct nvkm_secboot *, u32);
+int gm200_secboot_start(struct nvkm_secboot *, u32);
+
+int gm20x_secboot_prepare_blobs(struct gm200_secboot *);
+
+#endif
index b035c6e..c340762 100644 (file)
@@ -3,3 +3,4 @@ nvkm-y += nvkm/subdev/volt/gpio.o
 nvkm-y += nvkm/subdev/volt/nv40.o
 nvkm-y += nvkm/subdev/volt/gk104.o
 nvkm-y += nvkm/subdev/volt/gk20a.o
+nvkm-y += nvkm/subdev/volt/gm20b.o
index fd56c64..d554455 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
 
 #include <core/tegra.h>
 
-struct cvb_coef {
-       int c0;
-       int c1;
-       int c2;
-       int c3;
-       int c4;
-       int c5;
-};
-
-struct gk20a_volt {
-       struct nvkm_volt base;
-       struct regulator *vdd;
-};
+#include "gk20a.h"
 
-const struct cvb_coef gk20a_cvb_coef[] = {
+static const struct cvb_coef gk20a_cvb_coef[] = {
        /* MHz,        c0,     c1,   c2,    c3,     c4,   c5 */
        /*  72 */ { 1209886, -36468,  515,   417, -13123,  203},
        /* 108 */ { 1130804, -27659,  296,   298, -10834,  221},
@@ -89,7 +77,7 @@ gk20a_volt_get_cvb_t_voltage(int speedo, int temp, int s_scale, int t_scale,
        return mv;
 }
 
-static int
+int
 gk20a_volt_calc_voltage(const struct cvb_coef *coef, int speedo)
 {
        int mv;
@@ -100,7 +88,7 @@ gk20a_volt_calc_voltage(const struct cvb_coef *coef, int speedo)
        return mv * 1000;
 }
 
-static int
+int
 gk20a_volt_vid_get(struct nvkm_volt *base)
 {
        struct gk20a_volt *volt = gk20a_volt(base);
@@ -115,7 +103,7 @@ gk20a_volt_vid_get(struct nvkm_volt *base)
        return -EINVAL;
 }
 
-static int
+int
 gk20a_volt_vid_set(struct nvkm_volt *base, u8 vid)
 {
        struct gk20a_volt *volt = gk20a_volt(base);
@@ -125,7 +113,7 @@ gk20a_volt_vid_set(struct nvkm_volt *base, u8 vid)
        return regulator_set_voltage(volt->vdd, volt->base.vid[vid].uv, 1200000);
 }
 
-static int
+int
 gk20a_volt_set_id(struct nvkm_volt *base, u8 id, int condition)
 {
        struct gk20a_volt *volt = gk20a_volt(base);
@@ -155,30 +143,25 @@ gk20a_volt = {
 };
 
 int
-gk20a_volt_new(struct nvkm_device *device, int index, struct nvkm_volt **pvolt)
+_gk20a_volt_ctor(struct nvkm_device *device, int index,
+                const struct cvb_coef *coefs, int nb_coefs,
+                struct gk20a_volt *volt)
 {
        struct nvkm_device_tegra *tdev = device->func->tegra(device);
-       struct gk20a_volt *volt;
        int i, uv;
 
-       if (!(volt = kzalloc(sizeof(*volt), GFP_KERNEL)))
-               return -ENOMEM;
-
        nvkm_volt_ctor(&gk20a_volt, device, index, &volt->base);
-       *pvolt = &volt->base;
 
        uv = regulator_get_voltage(tdev->vdd);
-       nvkm_info(&volt->base.subdev, "The default voltage is %duV\n", uv);
+       nvkm_debug(&volt->base.subdev, "the default voltage is %duV\n", uv);
 
        volt->vdd = tdev->vdd;
 
-       volt->base.vid_nr = ARRAY_SIZE(gk20a_cvb_coef);
-       nvkm_debug(&volt->base.subdev, "%s - vid_nr = %d\n", __func__,
-                  volt->base.vid_nr);
+       volt->base.vid_nr = nb_coefs;
        for (i = 0; i < volt->base.vid_nr; i++) {
                volt->base.vid[i].vid = i;
                volt->base.vid[i].uv =
-                       gk20a_volt_calc_voltage(&gk20a_cvb_coef[i],
+                       gk20a_volt_calc_voltage(&coefs[i],
                                                tdev->gpu_speedo);
                nvkm_debug(&volt->base.subdev, "%2d: vid=%d, uv=%d\n", i,
                           volt->base.vid[i].vid, volt->base.vid[i].uv);
@@ -186,3 +169,17 @@ gk20a_volt_new(struct nvkm_device *device, int index, struct nvkm_volt **pvolt)
 
        return 0;
 }
+
+int
+gk20a_volt_new(struct nvkm_device *device, int index, struct nvkm_volt **pvolt)
+{
+       struct gk20a_volt *volt;
+
+       volt = kzalloc(sizeof(*volt), GFP_KERNEL);
+       if (!volt)
+               return -ENOMEM;
+       *pvolt = &volt->base;
+
+       return _gk20a_volt_ctor(device, index, gk20a_cvb_coef,
+                               ARRAY_SIZE(gk20a_cvb_coef), volt);
+}
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.h b/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.h
new file mode 100644 (file)
index 0000000..0fa3b50
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __GK20A_VOLT_H__
+#define __GK20A_VOLT_H__
+
+struct cvb_coef {
+       int c0;
+       int c1;
+       int c2;
+       int c3;
+       int c4;
+       int c5;
+};
+
+struct gk20a_volt {
+       struct nvkm_volt base;
+       struct regulator *vdd;
+};
+
+int _gk20a_volt_ctor(struct nvkm_device *device, int index,
+                    const struct cvb_coef *coefs, int nb_coefs,
+                    struct gk20a_volt *volt);
+
+int gk20a_volt_calc_voltage(const struct cvb_coef *coef, int speedo);
+int gk20a_volt_vid_get(struct nvkm_volt *volt);
+int gk20a_volt_vid_set(struct nvkm_volt *volt, u8 vid);
+int gk20a_volt_set_id(struct nvkm_volt *volt, u8 id, int condition);
+
+#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gm20b.c b/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gm20b.c
new file mode 100644 (file)
index 0000000..49b5ecb
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "priv.h"
+#include "gk20a.h"
+
+#include <core/tegra.h>
+
+const struct cvb_coef gm20b_cvb_coef[] = {
+       /* KHz,             c0,      c1,   c2 */
+       /*  76800 */ { 1786666,  -85625, 1632 },
+       /* 153600 */ { 1846729,  -87525, 1632 },
+       /* 230400 */ { 1910480,  -89425, 1632 },
+       /* 307200 */ { 1977920,  -91325, 1632 },
+       /* 384000 */ { 2049049,  -93215, 1632 },
+       /* 460800 */ { 2122872,  -95095, 1632 },
+       /* 537600 */ { 2201331,  -96985, 1632 },
+       /* 614400 */ { 2283479,  -98885, 1632 },
+       /* 691200 */ { 2369315, -100785, 1632 },
+       /* 768000 */ { 2458841, -102685, 1632 },
+       /* 844800 */ { 2550821, -104555, 1632 },
+       /* 921600 */ { 2647676, -106455, 1632 },
+};
+
+int
+gm20b_volt_new(struct nvkm_device *device, int index, struct nvkm_volt **pvolt)
+{
+       struct gk20a_volt *volt;
+
+       volt = kzalloc(sizeof(*volt), GFP_KERNEL);
+       if (!volt)
+               return -ENOMEM;
+       *pvolt = &volt->base;
+
+       return _gk20a_volt_ctor(device, index, gm20b_cvb_coef,
+                               ARRAY_SIZE(gm20b_cvb_coef), volt);
+}
index 336ad4d..73241c4 100644 (file)
@@ -2,7 +2,6 @@ config DRM_OMAP
        tristate "OMAP DRM"
        depends on DRM
        depends on ARCH_OMAP2PLUS || ARCH_MULTIPLATFORM
-       select OMAP2_DSS
        select DRM_KMS_HELPER
        select DRM_KMS_FB_HELPER
        select FB_SYS_FILLRECT
index fe4c222..48b7b75 100644 (file)
@@ -6,7 +6,7 @@
 obj-y += dss/
 obj-y += displays/
 
-ccflags-y := -Iinclude/drm -Werror
+ccflags-y := -Iinclude/drm
 omapdrm-y := omap_drv.o \
        omap_irq.o \
        omap_debugfs.o \
index d811e6d..747f26a 100644 (file)
@@ -236,46 +236,6 @@ static struct omap_dss_driver dvic_driver = {
        .detect         = dvic_detect,
 };
 
-static int dvic_probe_pdata(struct platform_device *pdev)
-{
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-       struct connector_dvi_platform_data *pdata;
-       struct omap_dss_device *in, *dssdev;
-       int i2c_bus_num;
-
-       pdata = dev_get_platdata(&pdev->dev);
-       i2c_bus_num = pdata->i2c_bus_num;
-
-       if (i2c_bus_num != -1) {
-               struct i2c_adapter *adapter;
-
-               adapter = i2c_get_adapter(i2c_bus_num);
-               if (!adapter) {
-                       dev_err(&pdev->dev,
-                                       "Failed to get I2C adapter, bus %d\n",
-                                       i2c_bus_num);
-                       return -EPROBE_DEFER;
-               }
-
-               ddata->i2c_adapter = adapter;
-       }
-
-       in = omap_dss_find_output(pdata->source);
-       if (in == NULL) {
-               i2c_put_adapter(ddata->i2c_adapter);
-
-               dev_err(&pdev->dev, "Failed to find video source\n");
-               return -EPROBE_DEFER;
-       }
-
-       ddata->in = in;
-
-       dssdev = &ddata->dssdev;
-       dssdev->name = pdata->name;
-
-       return 0;
-}
-
 static int dvic_probe_of(struct platform_device *pdev)
 {
        struct panel_drv_data *ddata = platform_get_drvdata(pdev);
@@ -319,17 +279,12 @@ static int dvic_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, ddata);
 
-       if (dev_get_platdata(&pdev->dev)) {
-               r = dvic_probe_pdata(pdev);
-               if (r)
-                       return r;
-       } else if (pdev->dev.of_node) {
-               r = dvic_probe_of(pdev);
-               if (r)
-                       return r;
-       } else {
+       if (!pdev->dev.of_node)
                return -ENODEV;
-       }
+
+       r = dvic_probe_of(pdev);
+       if (r)
+               return r;
 
        ddata->timings = dvic_default_timings;
 
index 6ee4129..225fd8d 100644 (file)
@@ -206,30 +206,6 @@ static struct omap_dss_driver hdmic_driver = {
        .set_hdmi_infoframe     = hdmic_set_infoframe,
 };
 
-static int hdmic_probe_pdata(struct platform_device *pdev)
-{
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-       struct connector_hdmi_platform_data *pdata;
-       struct omap_dss_device *in, *dssdev;
-
-       pdata = dev_get_platdata(&pdev->dev);
-
-       ddata->hpd_gpio = -ENODEV;
-
-       in = omap_dss_find_output(pdata->source);
-       if (in == NULL) {
-               dev_err(&pdev->dev, "Failed to find video source\n");
-               return -EPROBE_DEFER;
-       }
-
-       ddata->in = in;
-
-       dssdev = &ddata->dssdev;
-       dssdev->name = pdata->name;
-
-       return 0;
-}
-
 static int hdmic_probe_of(struct platform_device *pdev)
 {
        struct panel_drv_data *ddata = platform_get_drvdata(pdev);
@@ -268,17 +244,12 @@ static int hdmic_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, ddata);
        ddata->dev = &pdev->dev;
 
-       if (dev_get_platdata(&pdev->dev)) {
-               r = hdmic_probe_pdata(pdev);
-               if (r)
-                       return r;
-       } else if (pdev->dev.of_node) {
-               r = hdmic_probe_of(pdev);
-               if (r)
-                       return r;
-       } else {
+       if (!pdev->dev.of_node)
                return -ENODEV;
-       }
+
+       r = hdmic_probe_of(pdev);
+       if (r)
+               return r;
 
        if (gpio_is_valid(ddata->hpd_gpio)) {
                r = devm_gpio_request_one(&pdev->dev, ddata->hpd_gpio,
index d9048b3..2fd5602 100644 (file)
@@ -166,32 +166,6 @@ static const struct omapdss_dvi_ops tfp410_dvi_ops = {
        .get_timings    = tfp410_get_timings,
 };
 
-static int tfp410_probe_pdata(struct platform_device *pdev)
-{
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-       struct encoder_tfp410_platform_data *pdata;
-       struct omap_dss_device *dssdev, *in;
-
-       pdata = dev_get_platdata(&pdev->dev);
-
-       ddata->pd_gpio = pdata->power_down_gpio;
-
-       ddata->data_lines = pdata->data_lines;
-
-       in = omap_dss_find_output(pdata->source);
-       if (in == NULL) {
-               dev_err(&pdev->dev, "Failed to find video source\n");
-               return -ENODEV;
-       }
-
-       ddata->in = in;
-
-       dssdev = &ddata->dssdev;
-       dssdev->name = pdata->name;
-
-       return 0;
-}
-
 static int tfp410_probe_of(struct platform_device *pdev)
 {
        struct panel_drv_data *ddata = platform_get_drvdata(pdev);
@@ -231,17 +205,12 @@ static int tfp410_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, ddata);
 
-       if (dev_get_platdata(&pdev->dev)) {
-               r = tfp410_probe_pdata(pdev);
-               if (r)
-                       return r;
-       } else if (pdev->dev.of_node) {
-               r = tfp410_probe_of(pdev);
-               if (r)
-                       return r;
-       } else {
+       if (!pdev->dev.of_node)
                return -ENODEV;
-       }
+
+       r = tfp410_probe_of(pdev);
+       if (r)
+               return r;
 
        if (gpio_is_valid(ddata->pd_gpio)) {
                r = devm_gpio_request_one(&pdev->dev, ddata->pd_gpio,
index 990af6b..916a899 100644 (file)
@@ -13,9 +13,8 @@
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/slab.h>
-#include <linux/gpio.h>
 #include <linux/platform_device.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/consumer.h>
 
 #include <video/omapdss.h>
 #include <video/omap-panel-data.h>
@@ -24,9 +23,9 @@ struct panel_drv_data {
        struct omap_dss_device dssdev;
        struct omap_dss_device *in;
 
-       int ct_cp_hpd_gpio;
-       int ls_oe_gpio;
-       int hpd_gpio;
+       struct gpio_desc *ct_cp_hpd_gpio;
+       struct gpio_desc *ls_oe_gpio;
+       struct gpio_desc *hpd_gpio;
 
        struct omap_video_timings timings;
 };
@@ -47,7 +46,7 @@ static int tpd_connect(struct omap_dss_device *dssdev,
        dst->src = dssdev;
        dssdev->dst = dst;
 
-       gpio_set_value_cansleep(ddata->ct_cp_hpd_gpio, 1);
+       gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 1);
        /* DC-DC converter needs at max 300us to get to 90% of 5V */
        udelay(300);
 
@@ -65,7 +64,7 @@ static void tpd_disconnect(struct omap_dss_device *dssdev,
        if (dst != dssdev->dst)
                return;
 
-       gpio_set_value_cansleep(ddata->ct_cp_hpd_gpio, 0);
+       gpiod_set_value_cansleep(ddata->ct_cp_hpd_gpio, 0);
 
        dst->src = NULL;
        dssdev->dst = NULL;
@@ -145,16 +144,14 @@ static int tpd_read_edid(struct omap_dss_device *dssdev,
        struct omap_dss_device *in = ddata->in;
        int r;
 
-       if (!gpio_get_value_cansleep(ddata->hpd_gpio))
+       if (!gpiod_get_value_cansleep(ddata->hpd_gpio))
                return -ENODEV;
 
-       if (gpio_is_valid(ddata->ls_oe_gpio))
-               gpio_set_value_cansleep(ddata->ls_oe_gpio, 1);
+       gpiod_set_value_cansleep(ddata->ls_oe_gpio, 1);
 
        r = in->ops.hdmi->read_edid(in, edid, len);
 
-       if (gpio_is_valid(ddata->ls_oe_gpio))
-               gpio_set_value_cansleep(ddata->ls_oe_gpio, 0);
+       gpiod_set_value_cansleep(ddata->ls_oe_gpio, 0);
 
        return r;
 }
@@ -163,7 +160,7 @@ static bool tpd_detect(struct omap_dss_device *dssdev)
 {
        struct panel_drv_data *ddata = to_panel_data(dssdev);
 
-       return gpio_get_value_cansleep(ddata->hpd_gpio);
+       return gpiod_get_value_cansleep(ddata->hpd_gpio);
 }
 
 static int tpd_set_infoframe(struct omap_dss_device *dssdev,
@@ -201,63 +198,11 @@ static const struct omapdss_hdmi_ops tpd_hdmi_ops = {
        .set_hdmi_mode          = tpd_set_hdmi_mode,
 };
 
-static int tpd_probe_pdata(struct platform_device *pdev)
-{
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-       struct encoder_tpd12s015_platform_data *pdata;
-       struct omap_dss_device *dssdev, *in;
-
-       pdata = dev_get_platdata(&pdev->dev);
-
-       ddata->ct_cp_hpd_gpio = pdata->ct_cp_hpd_gpio;
-       ddata->ls_oe_gpio = pdata->ls_oe_gpio;
-       ddata->hpd_gpio = pdata->hpd_gpio;
-
-       in = omap_dss_find_output(pdata->source);
-       if (in == NULL) {
-               dev_err(&pdev->dev, "Failed to find video source\n");
-               return -ENODEV;
-       }
-
-       ddata->in = in;
-
-       dssdev = &ddata->dssdev;
-       dssdev->name = pdata->name;
-
-       return 0;
-}
-
 static int tpd_probe_of(struct platform_device *pdev)
 {
        struct panel_drv_data *ddata = platform_get_drvdata(pdev);
        struct device_node *node = pdev->dev.of_node;
        struct omap_dss_device *in;
-       int gpio;
-
-       /* CT CP HPD GPIO */
-       gpio = of_get_gpio(node, 0);
-       if (!gpio_is_valid(gpio)) {
-               dev_err(&pdev->dev, "failed to parse CT CP HPD gpio\n");
-               return gpio;
-       }
-       ddata->ct_cp_hpd_gpio = gpio;
-
-       /* LS OE GPIO */
-       gpio = of_get_gpio(node, 1);
-       if (gpio_is_valid(gpio) || gpio == -ENOENT) {
-               ddata->ls_oe_gpio = gpio;
-       } else {
-               dev_err(&pdev->dev, "failed to parse LS OE gpio\n");
-               return gpio;
-       }
-
-       /* HPD GPIO */
-       gpio = of_get_gpio(node, 2);
-       if (!gpio_is_valid(gpio)) {
-               dev_err(&pdev->dev, "failed to parse HPD gpio\n");
-               return gpio;
-       }
-       ddata->hpd_gpio = gpio;
 
        in = omapdss_of_find_source_for_first_ep(node);
        if (IS_ERR(in)) {
@@ -275,6 +220,7 @@ static int tpd_probe(struct platform_device *pdev)
        struct omap_dss_device *in, *dssdev;
        struct panel_drv_data *ddata;
        int r;
+       struct gpio_desc *gpio;
 
        ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
        if (!ddata)
@@ -282,35 +228,35 @@ static int tpd_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, ddata);
 
-       if (dev_get_platdata(&pdev->dev)) {
-               r = tpd_probe_pdata(pdev);
-               if (r)
-                       return r;
-       } else if (pdev->dev.of_node) {
-               r = tpd_probe_of(pdev);
-               if (r)
-                       return r;
-       } else {
+       if (!pdev->dev.of_node)
                return -ENODEV;
-       }
 
-       r = devm_gpio_request_one(&pdev->dev, ddata->ct_cp_hpd_gpio,
-                       GPIOF_OUT_INIT_LOW, "hdmi_ct_cp_hpd");
+       r = tpd_probe_of(pdev);
        if (r)
+               return r;
+
+
+       gpio = devm_gpiod_get_index_optional(&pdev->dev, NULL, 0,
+                GPIOD_OUT_LOW);
+       if (IS_ERR(gpio))
                goto err_gpio;
 
-       if (gpio_is_valid(ddata->ls_oe_gpio)) {
-               r = devm_gpio_request_one(&pdev->dev, ddata->ls_oe_gpio,
-                               GPIOF_OUT_INIT_LOW, "hdmi_ls_oe");
-               if (r)
-                       goto err_gpio;
-       }
+       ddata->ct_cp_hpd_gpio = gpio;
 
-       r = devm_gpio_request_one(&pdev->dev, ddata->hpd_gpio,
-                       GPIOF_DIR_IN, "hdmi_hpd");
-       if (r)
+       gpio = devm_gpiod_get_index_optional(&pdev->dev, NULL, 1,
+                GPIOD_OUT_LOW);
+       if (IS_ERR(gpio))
+               goto err_gpio;
+
+       ddata->ls_oe_gpio = gpio;
+
+       gpio = devm_gpiod_get_index(&pdev->dev, NULL, 2,
+               GPIOD_IN);
+       if (IS_ERR(gpio))
                goto err_gpio;
 
+       ddata->hpd_gpio = gpio;
+
        dssdev = &ddata->dssdev;
        dssdev->ops.hdmi = &tpd_hdmi_ops;
        dssdev->dev = &pdev->dev;
index 3414c26..36485c2 100644 (file)
@@ -1127,40 +1127,6 @@ static struct omap_dss_driver dsicm_ops = {
        .memory_read    = dsicm_memory_read,
 };
 
-static int dsicm_probe_pdata(struct platform_device *pdev)
-{
-       const struct panel_dsicm_platform_data *pdata;
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-       struct omap_dss_device *dssdev, *in;
-
-       pdata = dev_get_platdata(&pdev->dev);
-
-       in = omap_dss_find_output(pdata->source);
-       if (in == NULL) {
-               dev_err(&pdev->dev, "failed to find video source\n");
-               return -EPROBE_DEFER;
-       }
-       ddata->in = in;
-
-       ddata->reset_gpio = pdata->reset_gpio;
-
-       if (pdata->use_ext_te)
-               ddata->ext_te_gpio = pdata->ext_te_gpio;
-       else
-               ddata->ext_te_gpio = -1;
-
-       ddata->ulps_timeout = pdata->ulps_timeout;
-
-       ddata->use_dsi_backlight = pdata->use_dsi_backlight;
-
-       ddata->pin_config = pdata->pin_config;
-
-       dssdev = &ddata->dssdev;
-       dssdev->name = pdata->name;
-
-       return 0;
-}
-
 static int dsicm_probe_of(struct platform_device *pdev)
 {
        struct device_node *node = pdev->dev.of_node;
@@ -1214,17 +1180,12 @@ static int dsicm_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, ddata);
        ddata->pdev = pdev;
 
-       if (dev_get_platdata(dev)) {
-               r = dsicm_probe_pdata(pdev);
-               if (r)
-                       return r;
-       } else if (pdev->dev.of_node) {
-               r = dsicm_probe_of(pdev);
-               if (r)
-                       return r;
-       } else {
+       if (!pdev->dev.of_node)
                return -ENODEV;
-       }
+
+       r = dsicm_probe_of(pdev);
+       if (r)
+               return r;
 
        ddata->timings.x_res = 864;
        ddata->timings.y_res = 480;
index 18eb60e..458f77b 100644 (file)
@@ -240,44 +240,6 @@ static struct omap_dss_driver lb035q02_ops = {
        .get_resolution = omapdss_default_get_resolution,
 };
 
-static int lb035q02_probe_pdata(struct spi_device *spi)
-{
-       const struct panel_lb035q02_platform_data *pdata;
-       struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
-       struct omap_dss_device *dssdev, *in;
-       int r;
-
-       pdata = dev_get_platdata(&spi->dev);
-
-       in = omap_dss_find_output(pdata->source);
-       if (in == NULL) {
-               dev_err(&spi->dev, "failed to find video source '%s'\n",
-                               pdata->source);
-               return -EPROBE_DEFER;
-       }
-
-       ddata->in = in;
-
-       ddata->data_lines = pdata->data_lines;
-
-       dssdev = &ddata->dssdev;
-       dssdev->name = pdata->name;
-
-       r = devm_gpio_request_one(&spi->dev, pdata->enable_gpio,
-                                       GPIOF_OUT_INIT_LOW, "panel enable");
-       if (r)
-               goto err_gpio;
-
-       ddata->enable_gpio = gpio_to_desc(pdata->enable_gpio);
-
-       ddata->backlight_gpio = pdata->backlight_gpio;
-
-       return 0;
-err_gpio:
-       omap_dss_put_device(ddata->in);
-       return r;
-}
-
 static int lb035q02_probe_of(struct spi_device *spi)
 {
        struct device_node *node = spi->dev.of_node;
@@ -320,17 +282,12 @@ static int lb035q02_panel_spi_probe(struct spi_device *spi)
 
        ddata->spi = spi;
 
-       if (dev_get_platdata(&spi->dev)) {
-               r = lb035q02_probe_pdata(spi);
-               if (r)
-                       return r;
-       } else if (spi->dev.of_node) {
-               r = lb035q02_probe_of(spi);
-               if (r)
-                       return r;
-       } else {
+       if (!spi->dev.of_node)
                return -ENODEV;
-       }
+
+       r = lb035q02_probe_of(spi);
+       if (r)
+               return r;
 
        if (gpio_is_valid(ddata->backlight_gpio)) {
                r = devm_gpio_request_one(&spi->dev, ddata->backlight_gpio,
index 8a928c9..780cb26 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/of_gpio.h>
 
 #include <video/omapdss.h>
-#include <video/omap-panel-data.h>
 
 struct panel_drv_data {
        struct omap_dss_device  dssdev;
@@ -232,34 +231,6 @@ static struct omap_dss_driver nec_8048_ops = {
        .get_resolution = omapdss_default_get_resolution,
 };
 
-
-static int nec_8048_probe_pdata(struct spi_device *spi)
-{
-       const struct panel_nec_nl8048hl11_platform_data *pdata;
-       struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
-       struct omap_dss_device *dssdev, *in;
-
-       pdata = dev_get_platdata(&spi->dev);
-
-       ddata->qvga_gpio = pdata->qvga_gpio;
-       ddata->res_gpio = pdata->res_gpio;
-
-       in = omap_dss_find_output(pdata->source);
-       if (in == NULL) {
-               dev_err(&spi->dev, "failed to find video source '%s'\n",
-                               pdata->source);
-               return -EPROBE_DEFER;
-       }
-       ddata->in = in;
-
-       ddata->data_lines = pdata->data_lines;
-
-       dssdev = &ddata->dssdev;
-       dssdev->name = pdata->name;
-
-       return 0;
-}
-
 static int nec_8048_probe_of(struct spi_device *spi)
 {
        struct device_node *node = spi->dev.of_node;
@@ -315,17 +286,12 @@ static int nec_8048_probe(struct spi_device *spi)
 
        ddata->spi = spi;
 
-       if (dev_get_platdata(&spi->dev)) {
-               r = nec_8048_probe_pdata(spi);
-               if (r)
-                       return r;
-       } else if (spi->dev.of_node) {
-               r = nec_8048_probe_of(spi);
-               if (r)
-                       return r;
-       } else {
+       if (!spi->dev.of_node)
                return -ENODEV;
-       }
+
+       r = nec_8048_probe_of(spi);
+       if (r)
+               return r;
 
        if (gpio_is_valid(ddata->qvga_gpio)) {
                r = devm_gpio_request_one(&spi->dev, ddata->qvga_gpio,
index abfd1f6..529a017 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/slab.h>
 #include <linux/regulator/consumer.h>
 #include <video/omapdss.h>
-#include <video/omap-panel-data.h>
 
 struct panel_drv_data {
        struct omap_dss_device dssdev;
@@ -197,73 +196,6 @@ static struct omap_dss_driver sharp_ls_ops = {
        .get_resolution = omapdss_default_get_resolution,
 };
 
-static int sharp_ls_get_gpio(struct device *dev, int gpio, unsigned long flags,
-                 char *desc, struct gpio_desc **gpiod)
-{
-       struct gpio_desc *gd;
-       int r;
-
-       *gpiod = NULL;
-
-       r = devm_gpio_request_one(dev, gpio, flags, desc);
-       if (r)
-               return r == -ENOENT ? 0 : r;
-
-       gd = gpio_to_desc(gpio);
-       if (IS_ERR(gd))
-               return PTR_ERR(gd) == -ENOENT ? 0 : PTR_ERR(gd);
-
-       *gpiod = gd;
-       return 0;
-}
-
-static int sharp_ls_probe_pdata(struct platform_device *pdev)
-{
-       const struct panel_sharp_ls037v7dw01_platform_data *pdata;
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
-       struct omap_dss_device *dssdev, *in;
-       int r;
-
-       pdata = dev_get_platdata(&pdev->dev);
-
-       in = omap_dss_find_output(pdata->source);
-       if (in == NULL) {
-               dev_err(&pdev->dev, "failed to find video source '%s'\n",
-                               pdata->source);
-               return -EPROBE_DEFER;
-       }
-
-       ddata->in = in;
-
-       ddata->data_lines = pdata->data_lines;
-
-       dssdev = &ddata->dssdev;
-       dssdev->name = pdata->name;
-
-       r = sharp_ls_get_gpio(&pdev->dev, pdata->mo_gpio, GPIOF_OUT_INIT_LOW,
-               "lcd MO", &ddata->mo_gpio);
-       if (r)
-               return r;
-       r = sharp_ls_get_gpio(&pdev->dev, pdata->lr_gpio, GPIOF_OUT_INIT_HIGH,
-               "lcd LR", &ddata->lr_gpio);
-       if (r)
-               return r;
-       r = sharp_ls_get_gpio(&pdev->dev, pdata->ud_gpio, GPIOF_OUT_INIT_HIGH,
-               "lcd UD", &ddata->ud_gpio);
-       if (r)
-               return r;
-       r = sharp_ls_get_gpio(&pdev->dev, pdata->resb_gpio, GPIOF_OUT_INIT_LOW,
-               "lcd RESB", &ddata->resb_gpio);
-       if (r)
-               return r;
-       r = sharp_ls_get_gpio(&pdev->dev, pdata->ini_gpio, GPIOF_OUT_INIT_LOW,
-               "lcd INI", &ddata->ini_gpio);
-       if (r)
-               return r;
-
-       return 0;
-}
-
 static  int sharp_ls_get_gpio_of(struct device *dev, int index, int val,
        const char *desc, struct gpio_desc **gpiod)
 {
@@ -340,17 +272,12 @@ static int sharp_ls_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, ddata);
 
-       if (dev_get_platdata(&pdev->dev)) {
-               r = sharp_ls_probe_pdata(pdev);
-               if (r)
-                       return r;
-       } else if (pdev->dev.of_node) {
-               r = sharp_ls_probe_of(pdev);
-               if (r)
-                       return r;
-       } else {
+       if (!pdev->dev.of_node)
                return -ENODEV;
-       }
+
+       r = sharp_ls_probe_of(pdev);
+       if (r)
+               return r;
 
        ddata->videomode = sharp_ls_timings;
 
index 4d657f3..bd8d850 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/spi/spi.h>
 #include <linux/gpio.h>
 #include <video/omapdss.h>
-#include <video/omap-panel-data.h>
 
 struct panel_drv_data {
        struct omap_dss_device dssdev;
@@ -365,31 +364,6 @@ static struct omap_dss_driver td028ttec1_ops = {
        .check_timings  = td028ttec1_panel_check_timings,
 };
 
-static int td028ttec1_panel_probe_pdata(struct spi_device *spi)
-{
-       const struct panel_tpo_td028ttec1_platform_data *pdata;
-       struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
-       struct omap_dss_device *dssdev, *in;
-
-       pdata = dev_get_platdata(&spi->dev);
-
-       in = omap_dss_find_output(pdata->source);
-       if (in == NULL) {
-               dev_err(&spi->dev, "failed to find video source '%s'\n",
-                               pdata->source);
-               return -EPROBE_DEFER;
-       }
-
-       ddata->in = in;
-
-       ddata->data_lines = pdata->data_lines;
-
-       dssdev = &ddata->dssdev;
-       dssdev->name = pdata->name;
-
-       return 0;
-}
-
 static int td028ttec1_probe_of(struct spi_device *spi)
 {
        struct device_node *node = spi->dev.of_node;
@@ -432,17 +406,12 @@ static int td028ttec1_panel_probe(struct spi_device *spi)
 
        ddata->spi_dev = spi;
 
-       if (dev_get_platdata(&spi->dev)) {
-               r = td028ttec1_panel_probe_pdata(spi);
-               if (r)
-                       return r;
-       } else if (spi->dev.of_node) {
-               r = td028ttec1_probe_of(spi);
-               if (r)
-                       return r;
-       } else {
+       if (!spi->dev.of_node)
                return -ENODEV;
-       }
+
+       r = td028ttec1_probe_of(spi);
+       if (r)
+               return r;
 
        ddata->videomode = td028ttec1_panel_timings;
 
index 68e3b68..03e2beb 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/of_gpio.h>
 
 #include <video/omapdss.h>
-#include <video/omap-panel-data.h>
 
 #define TPO_R02_MODE(x)                ((x) & 7)
 #define TPO_R02_MODE_800x480   7
@@ -464,33 +463,6 @@ static struct omap_dss_driver tpo_td043_ops = {
        .get_resolution = omapdss_default_get_resolution,
 };
 
-
-static int tpo_td043_probe_pdata(struct spi_device *spi)
-{
-       const struct panel_tpo_td043mtea1_platform_data *pdata;
-       struct panel_drv_data *ddata = dev_get_drvdata(&spi->dev);
-       struct omap_dss_device *dssdev, *in;
-
-       pdata = dev_get_platdata(&spi->dev);
-
-       ddata->nreset_gpio = pdata->nreset_gpio;
-
-       in = omap_dss_find_output(pdata->source);
-       if (in == NULL) {
-               dev_err(&spi->dev, "failed to find video source '%s'\n",
-                               pdata->source);
-               return -EPROBE_DEFER;
-       }
-       ddata->in = in;
-
-       ddata->data_lines = pdata->data_lines;
-
-       dssdev = &ddata->dssdev;
-       dssdev->name = pdata->name;
-
-       return 0;
-}
-
 static int tpo_td043_probe_of(struct spi_device *spi)
 {
        struct device_node *node = spi->dev.of_node;
@@ -541,17 +513,12 @@ static int tpo_td043_probe(struct spi_device *spi)
 
        ddata->spi = spi;
 
-       if (dev_get_platdata(&spi->dev)) {
-               r = tpo_td043_probe_pdata(spi);
-               if (r)
-                       return r;
-       } else if (spi->dev.of_node) {
-               r = tpo_td043_probe_of(spi);
-               if (r)
-                       return r;
-       } else {
+       if (!spi->dev.of_node)
                return -ENODEV;
-       }
+
+       r = tpo_td043_probe_of(spi);
+       if (r)
+               return r;
 
        ddata->mode = TPO_R02_MODE_800x480;
        memcpy(ddata->gamma, tpo_td043_def_gamma, sizeof(ddata->gamma));
index b5136d3..b651ec9 100644 (file)
@@ -3,9 +3,6 @@ obj-$(CONFIG_OMAP2_DSS) += omapdss.o
 # Core DSS files
 omapdss-y := core.o dss.o dss_features.o dispc.o dispc_coefs.o display.o \
        output.o dss-of.o pll.o video-pll.o
-# DSS compat layer files
-omapdss-y += manager.o manager-sysfs.o overlay.o overlay-sysfs.o apply.o \
-       dispc-compat.o display-sysfs.o
 omapdss-$(CONFIG_OMAP2_DSS_DPI) += dpi.o
 omapdss-$(CONFIG_OMAP2_DSS_RFBI) += rfbi.o
 omapdss-$(CONFIG_OMAP2_DSS_VENC) += venc.o
diff --git a/drivers/gpu/drm/omapdrm/dss/apply.c b/drivers/gpu/drm/omapdrm/dss/apply.c
deleted file mode 100644 (file)
index 663ccc3..0000000
+++ /dev/null
@@ -1,1702 +0,0 @@
-/*
- * Copyright (C) 2011 Texas Instruments
- * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define DSS_SUBSYS_NAME "APPLY"
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/jiffies.h>
-
-#include <video/omapdss.h>
-
-#include "dss.h"
-#include "dss_features.h"
-#include "dispc-compat.h"
-
-/*
- * We have 4 levels of cache for the dispc settings. First two are in SW and
- * the latter two in HW.
- *
- *       set_info()
- *          v
- * +--------------------+
- * |     user_info      |
- * +--------------------+
- *          v
- *        apply()
- *          v
- * +--------------------+
- * |       info         |
- * +--------------------+
- *          v
- *      write_regs()
- *          v
- * +--------------------+
- * |  shadow registers  |
- * +--------------------+
- *          v
- * VFP or lcd/digit_enable
- *          v
- * +--------------------+
- * |      registers     |
- * +--------------------+
- */
-
-struct ovl_priv_data {
-
-       bool user_info_dirty;
-       struct omap_overlay_info user_info;
-
-       bool info_dirty;
-       struct omap_overlay_info info;
-
-       bool shadow_info_dirty;
-
-       bool extra_info_dirty;
-       bool shadow_extra_info_dirty;
-
-       bool enabled;
-       u32 fifo_low, fifo_high;
-
-       /*
-        * True if overlay is to be enabled. Used to check and calculate configs
-        * for the overlay before it is enabled in the HW.
-        */
-       bool enabling;
-};
-
-struct mgr_priv_data {
-
-       bool user_info_dirty;
-       struct omap_overlay_manager_info user_info;
-
-       bool info_dirty;
-       struct omap_overlay_manager_info info;
-
-       bool shadow_info_dirty;
-
-       /* If true, GO bit is up and shadow registers cannot be written.
-        * Never true for manual update displays */
-       bool busy;
-
-       /* If true, dispc output is enabled */
-       bool updating;
-
-       /* If true, a display is enabled using this manager */
-       bool enabled;
-
-       bool extra_info_dirty;
-       bool shadow_extra_info_dirty;
-
-       struct omap_video_timings timings;
-       struct dss_lcd_mgr_config lcd_config;
-
-       void (*framedone_handler)(void *);
-       void *framedone_handler_data;
-};
-
-static struct {
-       struct ovl_priv_data ovl_priv_data_array[MAX_DSS_OVERLAYS];
-       struct mgr_priv_data mgr_priv_data_array[MAX_DSS_MANAGERS];
-
-       bool irq_enabled;
-} dss_data;
-
-/* protects dss_data */
-static spinlock_t data_lock;
-/* lock for blocking functions */
-static DEFINE_MUTEX(apply_lock);
-static DECLARE_COMPLETION(extra_updated_completion);
-
-static void dss_register_vsync_isr(void);
-
-static struct ovl_priv_data *get_ovl_priv(struct omap_overlay *ovl)
-{
-       return &dss_data.ovl_priv_data_array[ovl->id];
-}
-
-static struct mgr_priv_data *get_mgr_priv(struct omap_overlay_manager *mgr)
-{
-       return &dss_data.mgr_priv_data_array[mgr->id];
-}
-
-static void apply_init_priv(void)
-{
-       const int num_ovls = dss_feat_get_num_ovls();
-       struct mgr_priv_data *mp;
-       int i;
-
-       spin_lock_init(&data_lock);
-
-       for (i = 0; i < num_ovls; ++i) {
-               struct ovl_priv_data *op;
-
-               op = &dss_data.ovl_priv_data_array[i];
-
-               op->info.color_mode = OMAP_DSS_COLOR_RGB16;
-               op->info.rotation_type = OMAP_DSS_ROT_DMA;
-
-               op->info.global_alpha = 255;
-
-               switch (i) {
-               case 0:
-                       op->info.zorder = 0;
-                       break;
-               case 1:
-                       op->info.zorder =
-                               dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 3 : 0;
-                       break;
-               case 2:
-                       op->info.zorder =
-                               dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 2 : 0;
-                       break;
-               case 3:
-                       op->info.zorder =
-                               dss_has_feature(FEAT_ALPHA_FREE_ZORDER) ? 1 : 0;
-                       break;
-               }
-
-               op->user_info = op->info;
-       }
-
-       /*
-        * Initialize some of the lcd_config fields for TV manager, this lets
-        * us prevent checking if the manager is LCD or TV at some places
-        */
-       mp = &dss_data.mgr_priv_data_array[OMAP_DSS_CHANNEL_DIGIT];
-
-       mp->lcd_config.video_port_width = 24;
-       mp->lcd_config.clock_info.lck_div = 1;
-       mp->lcd_config.clock_info.pck_div = 1;
-}
-
-/*
- * A LCD manager's stallmode decides whether it is in manual or auto update. TV
- * manager is always auto update, stallmode field for TV manager is false by
- * default
- */
-static bool ovl_manual_update(struct omap_overlay *ovl)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(ovl->manager);
-
-       return mp->lcd_config.stallmode;
-}
-
-static bool mgr_manual_update(struct omap_overlay_manager *mgr)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-
-       return mp->lcd_config.stallmode;
-}
-
-static int dss_check_settings_low(struct omap_overlay_manager *mgr,
-               bool applying)
-{
-       struct omap_overlay_info *oi;
-       struct omap_overlay_manager_info *mi;
-       struct omap_overlay *ovl;
-       struct omap_overlay_info *ois[MAX_DSS_OVERLAYS];
-       struct ovl_priv_data *op;
-       struct mgr_priv_data *mp;
-
-       mp = get_mgr_priv(mgr);
-
-       if (!mp->enabled)
-               return 0;
-
-       if (applying && mp->user_info_dirty)
-               mi = &mp->user_info;
-       else
-               mi = &mp->info;
-
-       /* collect the infos to be tested into the array */
-       list_for_each_entry(ovl, &mgr->overlays, list) {
-               op = get_ovl_priv(ovl);
-
-               if (!op->enabled && !op->enabling)
-                       oi = NULL;
-               else if (applying && op->user_info_dirty)
-                       oi = &op->user_info;
-               else
-                       oi = &op->info;
-
-               ois[ovl->id] = oi;
-       }
-
-       return dss_mgr_check(mgr, mi, &mp->timings, &mp->lcd_config, ois);
-}
-
-/*
- * check manager and overlay settings using overlay_info from data->info
- */
-static int dss_check_settings(struct omap_overlay_manager *mgr)
-{
-       return dss_check_settings_low(mgr, false);
-}
-
-/*
- * check manager and overlay settings using overlay_info from ovl->info if
- * dirty and from data->info otherwise
- */
-static int dss_check_settings_apply(struct omap_overlay_manager *mgr)
-{
-       return dss_check_settings_low(mgr, true);
-}
-
-static bool need_isr(void)
-{
-       const int num_mgrs = dss_feat_get_num_mgrs();
-       int i;
-
-       for (i = 0; i < num_mgrs; ++i) {
-               struct omap_overlay_manager *mgr;
-               struct mgr_priv_data *mp;
-               struct omap_overlay *ovl;
-
-               mgr = omap_dss_get_overlay_manager(i);
-               mp = get_mgr_priv(mgr);
-
-               if (!mp->enabled)
-                       continue;
-
-               if (mgr_manual_update(mgr)) {
-                       /* to catch FRAMEDONE */
-                       if (mp->updating)
-                               return true;
-               } else {
-                       /* to catch GO bit going down */
-                       if (mp->busy)
-                               return true;
-
-                       /* to write new values to registers */
-                       if (mp->info_dirty)
-                               return true;
-
-                       /* to set GO bit */
-                       if (mp->shadow_info_dirty)
-                               return true;
-
-                       /*
-                        * NOTE: we don't check extra_info flags for disabled
-                        * managers, once the manager is enabled, the extra_info
-                        * related manager changes will be taken in by HW.
-                        */
-
-                       /* to write new values to registers */
-                       if (mp->extra_info_dirty)
-                               return true;
-
-                       /* to set GO bit */
-                       if (mp->shadow_extra_info_dirty)
-                               return true;
-
-                       list_for_each_entry(ovl, &mgr->overlays, list) {
-                               struct ovl_priv_data *op;
-
-                               op = get_ovl_priv(ovl);
-
-                               /*
-                                * NOTE: we check extra_info flags even for
-                                * disabled overlays, as extra_infos need to be
-                                * always written.
-                                */
-
-                               /* to write new values to registers */
-                               if (op->extra_info_dirty)
-                                       return true;
-
-                               /* to set GO bit */
-                               if (op->shadow_extra_info_dirty)
-                                       return true;
-
-                               if (!op->enabled)
-                                       continue;
-
-                               /* to write new values to registers */
-                               if (op->info_dirty)
-                                       return true;
-
-                               /* to set GO bit */
-                               if (op->shadow_info_dirty)
-                                       return true;
-                       }
-               }
-       }
-
-       return false;
-}
-
-static bool need_go(struct omap_overlay_manager *mgr)
-{
-       struct omap_overlay *ovl;
-       struct mgr_priv_data *mp;
-       struct ovl_priv_data *op;
-
-       mp = get_mgr_priv(mgr);
-
-       if (mp->shadow_info_dirty || mp->shadow_extra_info_dirty)
-               return true;
-
-       list_for_each_entry(ovl, &mgr->overlays, list) {
-               op = get_ovl_priv(ovl);
-               if (op->shadow_info_dirty || op->shadow_extra_info_dirty)
-                       return true;
-       }
-
-       return false;
-}
-
-/* returns true if an extra_info field is currently being updated */
-static bool extra_info_update_ongoing(void)
-{
-       const int num_mgrs = dss_feat_get_num_mgrs();
-       int i;
-
-       for (i = 0; i < num_mgrs; ++i) {
-               struct omap_overlay_manager *mgr;
-               struct omap_overlay *ovl;
-               struct mgr_priv_data *mp;
-
-               mgr = omap_dss_get_overlay_manager(i);
-               mp = get_mgr_priv(mgr);
-
-               if (!mp->enabled)
-                       continue;
-
-               if (!mp->updating)
-                       continue;
-
-               if (mp->extra_info_dirty || mp->shadow_extra_info_dirty)
-                       return true;
-
-               list_for_each_entry(ovl, &mgr->overlays, list) {
-                       struct ovl_priv_data *op = get_ovl_priv(ovl);
-
-                       if (op->extra_info_dirty || op->shadow_extra_info_dirty)
-                               return true;
-               }
-       }
-
-       return false;
-}
-
-/* wait until no extra_info updates are pending */
-static void wait_pending_extra_info_updates(void)
-{
-       bool updating;
-       unsigned long flags;
-       unsigned long t;
-       int r;
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       updating = extra_info_update_ongoing();
-
-       if (!updating) {
-               spin_unlock_irqrestore(&data_lock, flags);
-               return;
-       }
-
-       init_completion(&extra_updated_completion);
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       t = msecs_to_jiffies(500);
-       r = wait_for_completion_timeout(&extra_updated_completion, t);
-       if (r == 0)
-               DSSWARN("timeout in wait_pending_extra_info_updates\n");
-}
-
-static struct omap_dss_device *dss_mgr_get_device(struct omap_overlay_manager *mgr)
-{
-       struct omap_dss_device *dssdev;
-
-       dssdev = mgr->output;
-       if (dssdev == NULL)
-               return NULL;
-
-       while (dssdev->dst)
-               dssdev = dssdev->dst;
-
-       if (dssdev->driver)
-               return dssdev;
-       else
-               return NULL;
-}
-
-static struct omap_dss_device *dss_ovl_get_device(struct omap_overlay *ovl)
-{
-       return ovl->manager ? dss_mgr_get_device(ovl->manager) : NULL;
-}
-
-static int dss_mgr_wait_for_vsync(struct omap_overlay_manager *mgr)
-{
-       unsigned long timeout = msecs_to_jiffies(500);
-       u32 irq;
-       int r;
-
-       if (mgr->output == NULL)
-               return -ENODEV;
-
-       r = dispc_runtime_get();
-       if (r)
-               return r;
-
-       switch (mgr->output->id) {
-       case OMAP_DSS_OUTPUT_VENC:
-               irq = DISPC_IRQ_EVSYNC_ODD;
-               break;
-       case OMAP_DSS_OUTPUT_HDMI:
-               irq = DISPC_IRQ_EVSYNC_EVEN;
-               break;
-       default:
-               irq = dispc_mgr_get_vsync_irq(mgr->id);
-               break;
-       }
-
-       r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout);
-
-       dispc_runtime_put();
-
-       return r;
-}
-
-static int dss_mgr_wait_for_go(struct omap_overlay_manager *mgr)
-{
-       unsigned long timeout = msecs_to_jiffies(500);
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-       u32 irq;
-       unsigned long flags;
-       int r;
-       int i;
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       if (mgr_manual_update(mgr)) {
-               spin_unlock_irqrestore(&data_lock, flags);
-               return 0;
-       }
-
-       if (!mp->enabled) {
-               spin_unlock_irqrestore(&data_lock, flags);
-               return 0;
-       }
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       r = dispc_runtime_get();
-       if (r)
-               return r;
-
-       irq = dispc_mgr_get_vsync_irq(mgr->id);
-
-       i = 0;
-       while (1) {
-               bool shadow_dirty, dirty;
-
-               spin_lock_irqsave(&data_lock, flags);
-               dirty = mp->info_dirty;
-               shadow_dirty = mp->shadow_info_dirty;
-               spin_unlock_irqrestore(&data_lock, flags);
-
-               if (!dirty && !shadow_dirty) {
-                       r = 0;
-                       break;
-               }
-
-               /* 4 iterations is the worst case:
-                * 1 - initial iteration, dirty = true (between VFP and VSYNC)
-                * 2 - first VSYNC, dirty = true
-                * 3 - dirty = false, shadow_dirty = true
-                * 4 - shadow_dirty = false */
-               if (i++ == 3) {
-                       DSSERR("mgr(%d)->wait_for_go() not finishing\n",
-                                       mgr->id);
-                       r = 0;
-                       break;
-               }
-
-               r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout);
-               if (r == -ERESTARTSYS)
-                       break;
-
-               if (r) {
-                       DSSERR("mgr(%d)->wait_for_go() timeout\n", mgr->id);
-                       break;
-               }
-       }
-
-       dispc_runtime_put();
-
-       return r;
-}
-
-static int dss_mgr_wait_for_go_ovl(struct omap_overlay *ovl)
-{
-       unsigned long timeout = msecs_to_jiffies(500);
-       struct ovl_priv_data *op;
-       struct mgr_priv_data *mp;
-       u32 irq;
-       unsigned long flags;
-       int r;
-       int i;
-
-       if (!ovl->manager)
-               return 0;
-
-       mp = get_mgr_priv(ovl->manager);
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       if (ovl_manual_update(ovl)) {
-               spin_unlock_irqrestore(&data_lock, flags);
-               return 0;
-       }
-
-       if (!mp->enabled) {
-               spin_unlock_irqrestore(&data_lock, flags);
-               return 0;
-       }
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       r = dispc_runtime_get();
-       if (r)
-               return r;
-
-       irq = dispc_mgr_get_vsync_irq(ovl->manager->id);
-
-       op = get_ovl_priv(ovl);
-       i = 0;
-       while (1) {
-               bool shadow_dirty, dirty;
-
-               spin_lock_irqsave(&data_lock, flags);
-               dirty = op->info_dirty;
-               shadow_dirty = op->shadow_info_dirty;
-               spin_unlock_irqrestore(&data_lock, flags);
-
-               if (!dirty && !shadow_dirty) {
-                       r = 0;
-                       break;
-               }
-
-               /* 4 iterations is the worst case:
-                * 1 - initial iteration, dirty = true (between VFP and VSYNC)
-                * 2 - first VSYNC, dirty = true
-                * 3 - dirty = false, shadow_dirty = true
-                * 4 - shadow_dirty = false */
-               if (i++ == 3) {
-                       DSSERR("ovl(%d)->wait_for_go() not finishing\n",
-                                       ovl->id);
-                       r = 0;
-                       break;
-               }
-
-               r = omap_dispc_wait_for_irq_interruptible_timeout(irq, timeout);
-               if (r == -ERESTARTSYS)
-                       break;
-
-               if (r) {
-                       DSSERR("ovl(%d)->wait_for_go() timeout\n", ovl->id);
-                       break;
-               }
-       }
-
-       dispc_runtime_put();
-
-       return r;
-}
-
-static void dss_ovl_write_regs(struct omap_overlay *ovl)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-       struct omap_overlay_info *oi;
-       bool replication;
-       struct mgr_priv_data *mp;
-       int r;
-
-       DSSDBG("writing ovl %d regs\n", ovl->id);
-
-       if (!op->enabled || !op->info_dirty)
-               return;
-
-       oi = &op->info;
-
-       mp = get_mgr_priv(ovl->manager);
-
-       replication = dss_ovl_use_replication(mp->lcd_config, oi->color_mode);
-
-       r = dispc_ovl_setup(ovl->id, oi, replication, &mp->timings, false);
-       if (r) {
-               /*
-                * We can't do much here, as this function can be called from
-                * vsync interrupt.
-                */
-               DSSERR("dispc_ovl_setup failed for ovl %d\n", ovl->id);
-
-               /* This will leave fifo configurations in a nonoptimal state */
-               op->enabled = false;
-               dispc_ovl_enable(ovl->id, false);
-               return;
-       }
-
-       op->info_dirty = false;
-       if (mp->updating)
-               op->shadow_info_dirty = true;
-}
-
-static void dss_ovl_write_regs_extra(struct omap_overlay *ovl)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-       struct mgr_priv_data *mp;
-
-       DSSDBG("writing ovl %d regs extra\n", ovl->id);
-
-       if (!op->extra_info_dirty)
-               return;
-
-       /* note: write also when op->enabled == false, so that the ovl gets
-        * disabled */
-
-       dispc_ovl_enable(ovl->id, op->enabled);
-       dispc_ovl_set_fifo_threshold(ovl->id, op->fifo_low, op->fifo_high);
-
-       mp = get_mgr_priv(ovl->manager);
-
-       op->extra_info_dirty = false;
-       if (mp->updating)
-               op->shadow_extra_info_dirty = true;
-}
-
-static void dss_mgr_write_regs(struct omap_overlay_manager *mgr)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-       struct omap_overlay *ovl;
-
-       DSSDBG("writing mgr %d regs\n", mgr->id);
-
-       if (!mp->enabled)
-               return;
-
-       WARN_ON(mp->busy);
-
-       /* Commit overlay settings */
-       list_for_each_entry(ovl, &mgr->overlays, list) {
-               dss_ovl_write_regs(ovl);
-               dss_ovl_write_regs_extra(ovl);
-       }
-
-       if (mp->info_dirty) {
-               dispc_mgr_setup(mgr->id, &mp->info);
-
-               mp->info_dirty = false;
-               if (mp->updating)
-                       mp->shadow_info_dirty = true;
-       }
-}
-
-static void dss_mgr_write_regs_extra(struct omap_overlay_manager *mgr)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-
-       DSSDBG("writing mgr %d regs extra\n", mgr->id);
-
-       if (!mp->extra_info_dirty)
-               return;
-
-       dispc_mgr_set_timings(mgr->id, &mp->timings);
-
-       /* lcd_config parameters */
-       if (dss_mgr_is_lcd(mgr->id))
-               dispc_mgr_set_lcd_config(mgr->id, &mp->lcd_config);
-
-       mp->extra_info_dirty = false;
-       if (mp->updating)
-               mp->shadow_extra_info_dirty = true;
-}
-
-static void dss_write_regs(void)
-{
-       const int num_mgrs = omap_dss_get_num_overlay_managers();
-       int i;
-
-       for (i = 0; i < num_mgrs; ++i) {
-               struct omap_overlay_manager *mgr;
-               struct mgr_priv_data *mp;
-               int r;
-
-               mgr = omap_dss_get_overlay_manager(i);
-               mp = get_mgr_priv(mgr);
-
-               if (!mp->enabled || mgr_manual_update(mgr) || mp->busy)
-                       continue;
-
-               r = dss_check_settings(mgr);
-               if (r) {
-                       DSSERR("cannot write registers for manager %s: "
-                                       "illegal configuration\n", mgr->name);
-                       continue;
-               }
-
-               dss_mgr_write_regs(mgr);
-               dss_mgr_write_regs_extra(mgr);
-       }
-}
-
-static void dss_set_go_bits(void)
-{
-       const int num_mgrs = omap_dss_get_num_overlay_managers();
-       int i;
-
-       for (i = 0; i < num_mgrs; ++i) {
-               struct omap_overlay_manager *mgr;
-               struct mgr_priv_data *mp;
-
-               mgr = omap_dss_get_overlay_manager(i);
-               mp = get_mgr_priv(mgr);
-
-               if (!mp->enabled || mgr_manual_update(mgr) || mp->busy)
-                       continue;
-
-               if (!need_go(mgr))
-                       continue;
-
-               mp->busy = true;
-
-               if (!dss_data.irq_enabled && need_isr())
-                       dss_register_vsync_isr();
-
-               dispc_mgr_go(mgr->id);
-       }
-
-}
-
-static void mgr_clear_shadow_dirty(struct omap_overlay_manager *mgr)
-{
-       struct omap_overlay *ovl;
-       struct mgr_priv_data *mp;
-       struct ovl_priv_data *op;
-
-       mp = get_mgr_priv(mgr);
-       mp->shadow_info_dirty = false;
-       mp->shadow_extra_info_dirty = false;
-
-       list_for_each_entry(ovl, &mgr->overlays, list) {
-               op = get_ovl_priv(ovl);
-               op->shadow_info_dirty = false;
-               op->shadow_extra_info_dirty = false;
-       }
-}
-
-static int dss_mgr_connect_compat(struct omap_overlay_manager *mgr,
-               struct omap_dss_device *dst)
-{
-       return mgr->set_output(mgr, dst);
-}
-
-static void dss_mgr_disconnect_compat(struct omap_overlay_manager *mgr,
-               struct omap_dss_device *dst)
-{
-       mgr->unset_output(mgr);
-}
-
-static void dss_mgr_start_update_compat(struct omap_overlay_manager *mgr)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-       unsigned long flags;
-       int r;
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       WARN_ON(mp->updating);
-
-       r = dss_check_settings(mgr);
-       if (r) {
-               DSSERR("cannot start manual update: illegal configuration\n");
-               spin_unlock_irqrestore(&data_lock, flags);
-               return;
-       }
-
-       dss_mgr_write_regs(mgr);
-       dss_mgr_write_regs_extra(mgr);
-
-       mp->updating = true;
-
-       if (!dss_data.irq_enabled && need_isr())
-               dss_register_vsync_isr();
-
-       dispc_mgr_enable_sync(mgr->id);
-
-       spin_unlock_irqrestore(&data_lock, flags);
-}
-
-static void dss_apply_irq_handler(void *data, u32 mask);
-
-static void dss_register_vsync_isr(void)
-{
-       const int num_mgrs = dss_feat_get_num_mgrs();
-       u32 mask;
-       int r, i;
-
-       mask = 0;
-       for (i = 0; i < num_mgrs; ++i)
-               mask |= dispc_mgr_get_vsync_irq(i);
-
-       for (i = 0; i < num_mgrs; ++i)
-               mask |= dispc_mgr_get_framedone_irq(i);
-
-       r = omap_dispc_register_isr(dss_apply_irq_handler, NULL, mask);
-       WARN_ON(r);
-
-       dss_data.irq_enabled = true;
-}
-
-static void dss_unregister_vsync_isr(void)
-{
-       const int num_mgrs = dss_feat_get_num_mgrs();
-       u32 mask;
-       int r, i;
-
-       mask = 0;
-       for (i = 0; i < num_mgrs; ++i)
-               mask |= dispc_mgr_get_vsync_irq(i);
-
-       for (i = 0; i < num_mgrs; ++i)
-               mask |= dispc_mgr_get_framedone_irq(i);
-
-       r = omap_dispc_unregister_isr(dss_apply_irq_handler, NULL, mask);
-       WARN_ON(r);
-
-       dss_data.irq_enabled = false;
-}
-
-static void dss_apply_irq_handler(void *data, u32 mask)
-{
-       const int num_mgrs = dss_feat_get_num_mgrs();
-       int i;
-       bool extra_updating;
-
-       spin_lock(&data_lock);
-
-       /* clear busy, updating flags, shadow_dirty flags */
-       for (i = 0; i < num_mgrs; i++) {
-               struct omap_overlay_manager *mgr;
-               struct mgr_priv_data *mp;
-
-               mgr = omap_dss_get_overlay_manager(i);
-               mp = get_mgr_priv(mgr);
-
-               if (!mp->enabled)
-                       continue;
-
-               mp->updating = dispc_mgr_is_enabled(i);
-
-               if (!mgr_manual_update(mgr)) {
-                       bool was_busy = mp->busy;
-                       mp->busy = dispc_mgr_go_busy(i);
-
-                       if (was_busy && !mp->busy)
-                               mgr_clear_shadow_dirty(mgr);
-               }
-       }
-
-       dss_write_regs();
-       dss_set_go_bits();
-
-       extra_updating = extra_info_update_ongoing();
-       if (!extra_updating)
-               complete_all(&extra_updated_completion);
-
-       /* call framedone handlers for manual update displays */
-       for (i = 0; i < num_mgrs; i++) {
-               struct omap_overlay_manager *mgr;
-               struct mgr_priv_data *mp;
-
-               mgr = omap_dss_get_overlay_manager(i);
-               mp = get_mgr_priv(mgr);
-
-               if (!mgr_manual_update(mgr) || !mp->framedone_handler)
-                       continue;
-
-               if (mask & dispc_mgr_get_framedone_irq(i))
-                       mp->framedone_handler(mp->framedone_handler_data);
-       }
-
-       if (!need_isr())
-               dss_unregister_vsync_isr();
-
-       spin_unlock(&data_lock);
-}
-
-static void omap_dss_mgr_apply_ovl(struct omap_overlay *ovl)
-{
-       struct ovl_priv_data *op;
-
-       op = get_ovl_priv(ovl);
-
-       if (!op->user_info_dirty)
-               return;
-
-       op->user_info_dirty = false;
-       op->info_dirty = true;
-       op->info = op->user_info;
-}
-
-static void omap_dss_mgr_apply_mgr(struct omap_overlay_manager *mgr)
-{
-       struct mgr_priv_data *mp;
-
-       mp = get_mgr_priv(mgr);
-
-       if (!mp->user_info_dirty)
-               return;
-
-       mp->user_info_dirty = false;
-       mp->info_dirty = true;
-       mp->info = mp->user_info;
-}
-
-static int omap_dss_mgr_apply(struct omap_overlay_manager *mgr)
-{
-       unsigned long flags;
-       struct omap_overlay *ovl;
-       int r;
-
-       DSSDBG("omap_dss_mgr_apply(%s)\n", mgr->name);
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       r = dss_check_settings_apply(mgr);
-       if (r) {
-               spin_unlock_irqrestore(&data_lock, flags);
-               DSSERR("failed to apply settings: illegal configuration.\n");
-               return r;
-       }
-
-       /* Configure overlays */
-       list_for_each_entry(ovl, &mgr->overlays, list)
-               omap_dss_mgr_apply_ovl(ovl);
-
-       /* Configure manager */
-       omap_dss_mgr_apply_mgr(mgr);
-
-       dss_write_regs();
-       dss_set_go_bits();
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       return 0;
-}
-
-static void dss_apply_ovl_enable(struct omap_overlay *ovl, bool enable)
-{
-       struct ovl_priv_data *op;
-
-       op = get_ovl_priv(ovl);
-
-       if (op->enabled == enable)
-               return;
-
-       op->enabled = enable;
-       op->extra_info_dirty = true;
-}
-
-static void dss_apply_ovl_fifo_thresholds(struct omap_overlay *ovl,
-               u32 fifo_low, u32 fifo_high)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-
-       if (op->fifo_low == fifo_low && op->fifo_high == fifo_high)
-               return;
-
-       op->fifo_low = fifo_low;
-       op->fifo_high = fifo_high;
-       op->extra_info_dirty = true;
-}
-
-static void dss_ovl_setup_fifo(struct omap_overlay *ovl)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-       u32 fifo_low, fifo_high;
-       bool use_fifo_merge = false;
-
-       if (!op->enabled && !op->enabling)
-               return;
-
-       dispc_ovl_compute_fifo_thresholds(ovl->id, &fifo_low, &fifo_high,
-                       use_fifo_merge, ovl_manual_update(ovl));
-
-       dss_apply_ovl_fifo_thresholds(ovl, fifo_low, fifo_high);
-}
-
-static void dss_mgr_setup_fifos(struct omap_overlay_manager *mgr)
-{
-       struct omap_overlay *ovl;
-       struct mgr_priv_data *mp;
-
-       mp = get_mgr_priv(mgr);
-
-       if (!mp->enabled)
-               return;
-
-       list_for_each_entry(ovl, &mgr->overlays, list)
-               dss_ovl_setup_fifo(ovl);
-}
-
-static void dss_setup_fifos(void)
-{
-       const int num_mgrs = omap_dss_get_num_overlay_managers();
-       struct omap_overlay_manager *mgr;
-       int i;
-
-       for (i = 0; i < num_mgrs; ++i) {
-               mgr = omap_dss_get_overlay_manager(i);
-               dss_mgr_setup_fifos(mgr);
-       }
-}
-
-static int dss_mgr_enable_compat(struct omap_overlay_manager *mgr)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-       unsigned long flags;
-       int r;
-
-       mutex_lock(&apply_lock);
-
-       if (mp->enabled)
-               goto out;
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       mp->enabled = true;
-
-       r = dss_check_settings(mgr);
-       if (r) {
-               DSSERR("failed to enable manager %d: check_settings failed\n",
-                               mgr->id);
-               goto err;
-       }
-
-       dss_setup_fifos();
-
-       dss_write_regs();
-       dss_set_go_bits();
-
-       if (!mgr_manual_update(mgr))
-               mp->updating = true;
-
-       if (!dss_data.irq_enabled && need_isr())
-               dss_register_vsync_isr();
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       if (!mgr_manual_update(mgr))
-               dispc_mgr_enable_sync(mgr->id);
-
-out:
-       mutex_unlock(&apply_lock);
-
-       return 0;
-
-err:
-       mp->enabled = false;
-       spin_unlock_irqrestore(&data_lock, flags);
-       mutex_unlock(&apply_lock);
-       return r;
-}
-
-static void dss_mgr_disable_compat(struct omap_overlay_manager *mgr)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-       unsigned long flags;
-
-       mutex_lock(&apply_lock);
-
-       if (!mp->enabled)
-               goto out;
-
-       wait_pending_extra_info_updates();
-
-       if (!mgr_manual_update(mgr))
-               dispc_mgr_disable_sync(mgr->id);
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       mp->updating = false;
-       mp->enabled = false;
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-out:
-       mutex_unlock(&apply_lock);
-}
-
-static int dss_mgr_set_info(struct omap_overlay_manager *mgr,
-               struct omap_overlay_manager_info *info)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-       unsigned long flags;
-       int r;
-
-       r = dss_mgr_simple_check(mgr, info);
-       if (r)
-               return r;
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       mp->user_info = *info;
-       mp->user_info_dirty = true;
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       return 0;
-}
-
-static void dss_mgr_get_info(struct omap_overlay_manager *mgr,
-               struct omap_overlay_manager_info *info)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-       unsigned long flags;
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       *info = mp->user_info;
-
-       spin_unlock_irqrestore(&data_lock, flags);
-}
-
-static int dss_mgr_set_output(struct omap_overlay_manager *mgr,
-               struct omap_dss_device *output)
-{
-       int r;
-
-       mutex_lock(&apply_lock);
-
-       if (mgr->output) {
-               DSSERR("manager %s is already connected to an output\n",
-                       mgr->name);
-               r = -EINVAL;
-               goto err;
-       }
-
-       if ((mgr->supported_outputs & output->id) == 0) {
-               DSSERR("output does not support manager %s\n",
-                       mgr->name);
-               r = -EINVAL;
-               goto err;
-       }
-
-       output->manager = mgr;
-       mgr->output = output;
-
-       mutex_unlock(&apply_lock);
-
-       return 0;
-err:
-       mutex_unlock(&apply_lock);
-       return r;
-}
-
-static int dss_mgr_unset_output(struct omap_overlay_manager *mgr)
-{
-       int r;
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-       unsigned long flags;
-
-       mutex_lock(&apply_lock);
-
-       if (!mgr->output) {
-               DSSERR("failed to unset output, output not set\n");
-               r = -EINVAL;
-               goto err;
-       }
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       if (mp->enabled) {
-               DSSERR("output can't be unset when manager is enabled\n");
-               r = -EINVAL;
-               goto err1;
-       }
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       mgr->output->manager = NULL;
-       mgr->output = NULL;
-
-       mutex_unlock(&apply_lock);
-
-       return 0;
-err1:
-       spin_unlock_irqrestore(&data_lock, flags);
-err:
-       mutex_unlock(&apply_lock);
-
-       return r;
-}
-
-static void dss_apply_mgr_timings(struct omap_overlay_manager *mgr,
-               const struct omap_video_timings *timings)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-
-       mp->timings = *timings;
-       mp->extra_info_dirty = true;
-}
-
-static void dss_mgr_set_timings_compat(struct omap_overlay_manager *mgr,
-               const struct omap_video_timings *timings)
-{
-       unsigned long flags;
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       if (mp->updating) {
-               DSSERR("cannot set timings for %s: manager needs to be disabled\n",
-                       mgr->name);
-               goto out;
-       }
-
-       dss_apply_mgr_timings(mgr, timings);
-out:
-       spin_unlock_irqrestore(&data_lock, flags);
-}
-
-static void dss_apply_mgr_lcd_config(struct omap_overlay_manager *mgr,
-               const struct dss_lcd_mgr_config *config)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-
-       mp->lcd_config = *config;
-       mp->extra_info_dirty = true;
-}
-
-static void dss_mgr_set_lcd_config_compat(struct omap_overlay_manager *mgr,
-               const struct dss_lcd_mgr_config *config)
-{
-       unsigned long flags;
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       if (mp->enabled) {
-               DSSERR("cannot apply lcd config for %s: manager needs to be disabled\n",
-                       mgr->name);
-               goto out;
-       }
-
-       dss_apply_mgr_lcd_config(mgr, config);
-out:
-       spin_unlock_irqrestore(&data_lock, flags);
-}
-
-static int dss_ovl_set_info(struct omap_overlay *ovl,
-               struct omap_overlay_info *info)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-       unsigned long flags;
-       int r;
-
-       r = dss_ovl_simple_check(ovl, info);
-       if (r)
-               return r;
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       op->user_info = *info;
-       op->user_info_dirty = true;
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       return 0;
-}
-
-static void dss_ovl_get_info(struct omap_overlay *ovl,
-               struct omap_overlay_info *info)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-       unsigned long flags;
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       *info = op->user_info;
-
-       spin_unlock_irqrestore(&data_lock, flags);
-}
-
-static int dss_ovl_set_manager(struct omap_overlay *ovl,
-               struct omap_overlay_manager *mgr)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-       unsigned long flags;
-       int r;
-
-       if (!mgr)
-               return -EINVAL;
-
-       mutex_lock(&apply_lock);
-
-       if (ovl->manager) {
-               DSSERR("overlay '%s' already has a manager '%s'\n",
-                               ovl->name, ovl->manager->name);
-               r = -EINVAL;
-               goto err;
-       }
-
-       r = dispc_runtime_get();
-       if (r)
-               goto err;
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       if (op->enabled) {
-               spin_unlock_irqrestore(&data_lock, flags);
-               DSSERR("overlay has to be disabled to change the manager\n");
-               r = -EINVAL;
-               goto err1;
-       }
-
-       dispc_ovl_set_channel_out(ovl->id, mgr->id);
-
-       ovl->manager = mgr;
-       list_add_tail(&ovl->list, &mgr->overlays);
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       dispc_runtime_put();
-
-       mutex_unlock(&apply_lock);
-
-       return 0;
-
-err1:
-       dispc_runtime_put();
-err:
-       mutex_unlock(&apply_lock);
-       return r;
-}
-
-static int dss_ovl_unset_manager(struct omap_overlay *ovl)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-       unsigned long flags;
-       int r;
-
-       mutex_lock(&apply_lock);
-
-       if (!ovl->manager) {
-               DSSERR("failed to detach overlay: manager not set\n");
-               r = -EINVAL;
-               goto err;
-       }
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       if (op->enabled) {
-               spin_unlock_irqrestore(&data_lock, flags);
-               DSSERR("overlay has to be disabled to unset the manager\n");
-               r = -EINVAL;
-               goto err;
-       }
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       /* wait for pending extra_info updates to ensure the ovl is disabled */
-       wait_pending_extra_info_updates();
-
-       /*
-        * For a manual update display, there is no guarantee that the overlay
-        * is really disabled in HW, we may need an extra update from this
-        * manager before the configurations can go in. Return an error if the
-        * overlay needed an update from the manager.
-        *
-        * TODO: Instead of returning an error, try to do a dummy manager update
-        * here to disable the overlay in hardware. Use the *GATED fields in
-        * the DISPC_CONFIG registers to do a dummy update.
-        */
-       spin_lock_irqsave(&data_lock, flags);
-
-       if (ovl_manual_update(ovl) && op->extra_info_dirty) {
-               spin_unlock_irqrestore(&data_lock, flags);
-               DSSERR("need an update to change the manager\n");
-               r = -EINVAL;
-               goto err;
-       }
-
-       ovl->manager = NULL;
-       list_del(&ovl->list);
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       mutex_unlock(&apply_lock);
-
-       return 0;
-err:
-       mutex_unlock(&apply_lock);
-       return r;
-}
-
-static bool dss_ovl_is_enabled(struct omap_overlay *ovl)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-       unsigned long flags;
-       bool e;
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       e = op->enabled;
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       return e;
-}
-
-static int dss_ovl_enable(struct omap_overlay *ovl)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-       unsigned long flags;
-       int r;
-
-       mutex_lock(&apply_lock);
-
-       if (op->enabled) {
-               r = 0;
-               goto err1;
-       }
-
-       if (ovl->manager == NULL || ovl->manager->output == NULL) {
-               r = -EINVAL;
-               goto err1;
-       }
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       op->enabling = true;
-
-       r = dss_check_settings(ovl->manager);
-       if (r) {
-               DSSERR("failed to enable overlay %d: check_settings failed\n",
-                               ovl->id);
-               goto err2;
-       }
-
-       dss_setup_fifos();
-
-       op->enabling = false;
-       dss_apply_ovl_enable(ovl, true);
-
-       dss_write_regs();
-       dss_set_go_bits();
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       mutex_unlock(&apply_lock);
-
-       return 0;
-err2:
-       op->enabling = false;
-       spin_unlock_irqrestore(&data_lock, flags);
-err1:
-       mutex_unlock(&apply_lock);
-       return r;
-}
-
-static int dss_ovl_disable(struct omap_overlay *ovl)
-{
-       struct ovl_priv_data *op = get_ovl_priv(ovl);
-       unsigned long flags;
-       int r;
-
-       mutex_lock(&apply_lock);
-
-       if (!op->enabled) {
-               r = 0;
-               goto err;
-       }
-
-       if (ovl->manager == NULL || ovl->manager->output == NULL) {
-               r = -EINVAL;
-               goto err;
-       }
-
-       spin_lock_irqsave(&data_lock, flags);
-
-       dss_apply_ovl_enable(ovl, false);
-       dss_write_regs();
-       dss_set_go_bits();
-
-       spin_unlock_irqrestore(&data_lock, flags);
-
-       mutex_unlock(&apply_lock);
-
-       return 0;
-
-err:
-       mutex_unlock(&apply_lock);
-       return r;
-}
-
-static int dss_mgr_register_framedone_handler_compat(struct omap_overlay_manager *mgr,
-               void (*handler)(void *), void *data)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-
-       if (mp->framedone_handler)
-               return -EBUSY;
-
-       mp->framedone_handler = handler;
-       mp->framedone_handler_data = data;
-
-       return 0;
-}
-
-static void dss_mgr_unregister_framedone_handler_compat(struct omap_overlay_manager *mgr,
-               void (*handler)(void *), void *data)
-{
-       struct mgr_priv_data *mp = get_mgr_priv(mgr);
-
-       WARN_ON(mp->framedone_handler != handler ||
-                       mp->framedone_handler_data != data);
-
-       mp->framedone_handler = NULL;
-       mp->framedone_handler_data = NULL;
-}
-
-static const struct dss_mgr_ops apply_mgr_ops = {
-       .connect = dss_mgr_connect_compat,
-       .disconnect = dss_mgr_disconnect_compat,
-       .start_update = dss_mgr_start_update_compat,
-       .enable = dss_mgr_enable_compat,
-       .disable = dss_mgr_disable_compat,
-       .set_timings = dss_mgr_set_timings_compat,
-       .set_lcd_config = dss_mgr_set_lcd_config_compat,
-       .register_framedone_handler = dss_mgr_register_framedone_handler_compat,
-       .unregister_framedone_handler = dss_mgr_unregister_framedone_handler_compat,
-};
-
-static int compat_refcnt;
-static DEFINE_MUTEX(compat_init_lock);
-
-int omapdss_compat_init(void)
-{
-       struct platform_device *pdev = dss_get_core_pdev();
-       int i, r;
-
-       mutex_lock(&compat_init_lock);
-
-       if (compat_refcnt++ > 0)
-               goto out;
-
-       apply_init_priv();
-
-       dss_init_overlay_managers_sysfs(pdev);
-       dss_init_overlays(pdev);
-
-       for (i = 0; i < omap_dss_get_num_overlay_managers(); i++) {
-               struct omap_overlay_manager *mgr;
-
-               mgr = omap_dss_get_overlay_manager(i);
-
-               mgr->set_output = &dss_mgr_set_output;
-               mgr->unset_output = &dss_mgr_unset_output;
-               mgr->apply = &omap_dss_mgr_apply;
-               mgr->set_manager_info = &dss_mgr_set_info;
-               mgr->get_manager_info = &dss_mgr_get_info;
-               mgr->wait_for_go = &dss_mgr_wait_for_go;
-               mgr->wait_for_vsync = &dss_mgr_wait_for_vsync;
-               mgr->get_device = &dss_mgr_get_device;
-       }
-
-       for (i = 0; i < omap_dss_get_num_overlays(); i++) {
-               struct omap_overlay *ovl = omap_dss_get_overlay(i);
-
-               ovl->is_enabled = &dss_ovl_is_enabled;
-               ovl->enable = &dss_ovl_enable;
-               ovl->disable = &dss_ovl_disable;
-               ovl->set_manager = &dss_ovl_set_manager;
-               ovl->unset_manager = &dss_ovl_unset_manager;
-               ovl->set_overlay_info = &dss_ovl_set_info;
-               ovl->get_overlay_info = &dss_ovl_get_info;
-               ovl->wait_for_go = &dss_mgr_wait_for_go_ovl;
-               ovl->get_device = &dss_ovl_get_device;
-       }
-
-       r = dss_install_mgr_ops(&apply_mgr_ops);
-       if (r)
-               goto err_mgr_ops;
-
-       r = display_init_sysfs(pdev);
-       if (r)
-               goto err_disp_sysfs;
-
-       dispc_runtime_get();
-
-       r = dss_dispc_initialize_irq();
-       if (r)
-               goto err_init_irq;
-
-       dispc_runtime_put();
-
-out:
-       mutex_unlock(&compat_init_lock);
-
-       return 0;
-
-err_init_irq:
-       dispc_runtime_put();
-       display_uninit_sysfs(pdev);
-
-err_disp_sysfs:
-       dss_uninstall_mgr_ops();
-
-err_mgr_ops:
-       dss_uninit_overlay_managers_sysfs(pdev);
-       dss_uninit_overlays(pdev);
-
-       compat_refcnt--;
-
-       mutex_unlock(&compat_init_lock);
-
-       return r;
-}
-EXPORT_SYMBOL(omapdss_compat_init);
-
-void omapdss_compat_uninit(void)
-{
-       struct platform_device *pdev = dss_get_core_pdev();
-
-       mutex_lock(&compat_init_lock);
-
-       if (--compat_refcnt > 0)
-               goto out;
-
-       dss_dispc_uninitialize_irq();
-
-       display_uninit_sysfs(pdev);
-
-       dss_uninstall_mgr_ops();
-
-       dss_uninit_overlay_managers_sysfs(pdev);
-       dss_uninit_overlays(pdev);
-out:
-       mutex_unlock(&compat_init_lock);
-}
-EXPORT_SYMBOL(omapdss_compat_uninit);
index 54eeb50..7e4e5be 100644 (file)
@@ -165,32 +165,20 @@ int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *))
 #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
 
 /* PLATFORM DEVICE */
-static int omap_dss_pm_notif(struct notifier_block *b, unsigned long v, void *d)
+
+static void dss_disable_all_devices(void)
 {
-       DSSDBG("pm notif %lu\n", v);
-
-       switch (v) {
-       case PM_SUSPEND_PREPARE:
-       case PM_HIBERNATION_PREPARE:
-       case PM_RESTORE_PREPARE:
-               DSSDBG("suspending displays\n");
-               return dss_suspend_all_devices();
-
-       case PM_POST_SUSPEND:
-       case PM_POST_HIBERNATION:
-       case PM_POST_RESTORE:
-               DSSDBG("resuming displays\n");
-               return dss_resume_all_devices();
-
-       default:
-               return 0;
+       struct omap_dss_device *dssdev = NULL;
+
+       for_each_dss_dev(dssdev) {
+               if (!dssdev->driver)
+                       continue;
+
+               if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
+                       dssdev->driver->disable(dssdev);
        }
 }
 
-static struct notifier_block omap_dss_pm_notif_block = {
-       .notifier_call = omap_dss_pm_notif,
-};
-
 static int __init omap_dss_probe(struct platform_device *pdev)
 {
        struct omap_dss_board_info *pdata = pdev->dev.platform_data;
@@ -211,8 +199,6 @@ static int __init omap_dss_probe(struct platform_device *pdev)
        else if (pdata->default_device)
                core.default_display_name = pdata->default_device->name;
 
-       register_pm_notifier(&omap_dss_pm_notif_block);
-
        return 0;
 
 err_debugfs:
@@ -222,8 +208,6 @@ err_debugfs:
 
 static int omap_dss_remove(struct platform_device *pdev)
 {
-       unregister_pm_notifier(&omap_dss_pm_notif_block);
-
        dss_uninitialize_debugfs();
 
        return 0;
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc-compat.c b/drivers/gpu/drm/omapdrm/dss/dispc-compat.c
deleted file mode 100644 (file)
index 0918b3b..0000000
+++ /dev/null
@@ -1,667 +0,0 @@
-/*
- * Copyright (C) 2012 Texas Instruments
- * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define DSS_SUBSYS_NAME "APPLY"
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/jiffies.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/seq_file.h>
-
-#include <video/omapdss.h>
-
-#include "dss.h"
-#include "dss_features.h"
-#include "dispc-compat.h"
-
-#define DISPC_IRQ_MASK_ERROR            (DISPC_IRQ_GFX_FIFO_UNDERFLOW | \
-                                        DISPC_IRQ_OCP_ERR | \
-                                        DISPC_IRQ_VID1_FIFO_UNDERFLOW | \
-                                        DISPC_IRQ_VID2_FIFO_UNDERFLOW | \
-                                        DISPC_IRQ_SYNC_LOST | \
-                                        DISPC_IRQ_SYNC_LOST_DIGIT)
-
-#define DISPC_MAX_NR_ISRS              8
-
-struct omap_dispc_isr_data {
-       omap_dispc_isr_t        isr;
-       void                    *arg;
-       u32                     mask;
-};
-
-struct dispc_irq_stats {
-       unsigned long last_reset;
-       unsigned irq_count;
-       unsigned irqs[32];
-};
-
-static struct {
-       spinlock_t irq_lock;
-       u32 irq_error_mask;
-       struct omap_dispc_isr_data registered_isr[DISPC_MAX_NR_ISRS];
-       u32 error_irqs;
-       struct work_struct error_work;
-
-#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-       spinlock_t irq_stats_lock;
-       struct dispc_irq_stats irq_stats;
-#endif
-} dispc_compat;
-
-
-#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-static void dispc_dump_irqs(struct seq_file *s)
-{
-       unsigned long flags;
-       struct dispc_irq_stats stats;
-
-       spin_lock_irqsave(&dispc_compat.irq_stats_lock, flags);
-
-       stats = dispc_compat.irq_stats;
-       memset(&dispc_compat.irq_stats, 0, sizeof(dispc_compat.irq_stats));
-       dispc_compat.irq_stats.last_reset = jiffies;
-
-       spin_unlock_irqrestore(&dispc_compat.irq_stats_lock, flags);
-
-       seq_printf(s, "period %u ms\n",
-                       jiffies_to_msecs(jiffies - stats.last_reset));
-
-       seq_printf(s, "irqs %d\n", stats.irq_count);
-#define PIS(x) \
-       seq_printf(s, "%-20s %10d\n", #x, stats.irqs[ffs(DISPC_IRQ_##x)-1]);
-
-       PIS(FRAMEDONE);
-       PIS(VSYNC);
-       PIS(EVSYNC_EVEN);
-       PIS(EVSYNC_ODD);
-       PIS(ACBIAS_COUNT_STAT);
-       PIS(PROG_LINE_NUM);
-       PIS(GFX_FIFO_UNDERFLOW);
-       PIS(GFX_END_WIN);
-       PIS(PAL_GAMMA_MASK);
-       PIS(OCP_ERR);
-       PIS(VID1_FIFO_UNDERFLOW);
-       PIS(VID1_END_WIN);
-       PIS(VID2_FIFO_UNDERFLOW);
-       PIS(VID2_END_WIN);
-       if (dss_feat_get_num_ovls() > 3) {
-               PIS(VID3_FIFO_UNDERFLOW);
-               PIS(VID3_END_WIN);
-       }
-       PIS(SYNC_LOST);
-       PIS(SYNC_LOST_DIGIT);
-       PIS(WAKEUP);
-       if (dss_has_feature(FEAT_MGR_LCD2)) {
-               PIS(FRAMEDONE2);
-               PIS(VSYNC2);
-               PIS(ACBIAS_COUNT_STAT2);
-               PIS(SYNC_LOST2);
-       }
-       if (dss_has_feature(FEAT_MGR_LCD3)) {
-               PIS(FRAMEDONE3);
-               PIS(VSYNC3);
-               PIS(ACBIAS_COUNT_STAT3);
-               PIS(SYNC_LOST3);
-       }
-#undef PIS
-}
-#endif
-
-/* dispc.irq_lock has to be locked by the caller */
-static void _omap_dispc_set_irqs(void)
-{
-       u32 mask;
-       int i;
-       struct omap_dispc_isr_data *isr_data;
-
-       mask = dispc_compat.irq_error_mask;
-
-       for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
-               isr_data = &dispc_compat.registered_isr[i];
-
-               if (isr_data->isr == NULL)
-                       continue;
-
-               mask |= isr_data->mask;
-       }
-
-       dispc_write_irqenable(mask);
-}
-
-int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask)
-{
-       int i;
-       int ret;
-       unsigned long flags;
-       struct omap_dispc_isr_data *isr_data;
-
-       if (isr == NULL)
-               return -EINVAL;
-
-       spin_lock_irqsave(&dispc_compat.irq_lock, flags);
-
-       /* check for duplicate entry */
-       for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
-               isr_data = &dispc_compat.registered_isr[i];
-               if (isr_data->isr == isr && isr_data->arg == arg &&
-                               isr_data->mask == mask) {
-                       ret = -EINVAL;
-                       goto err;
-               }
-       }
-
-       isr_data = NULL;
-       ret = -EBUSY;
-
-       for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
-               isr_data = &dispc_compat.registered_isr[i];
-
-               if (isr_data->isr != NULL)
-                       continue;
-
-               isr_data->isr = isr;
-               isr_data->arg = arg;
-               isr_data->mask = mask;
-               ret = 0;
-
-               break;
-       }
-
-       if (ret)
-               goto err;
-
-       _omap_dispc_set_irqs();
-
-       spin_unlock_irqrestore(&dispc_compat.irq_lock, flags);
-
-       return 0;
-err:
-       spin_unlock_irqrestore(&dispc_compat.irq_lock, flags);
-
-       return ret;
-}
-EXPORT_SYMBOL(omap_dispc_register_isr);
-
-int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask)
-{
-       int i;
-       unsigned long flags;
-       int ret = -EINVAL;
-       struct omap_dispc_isr_data *isr_data;
-
-       spin_lock_irqsave(&dispc_compat.irq_lock, flags);
-
-       for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
-               isr_data = &dispc_compat.registered_isr[i];
-               if (isr_data->isr != isr || isr_data->arg != arg ||
-                               isr_data->mask != mask)
-                       continue;
-
-               /* found the correct isr */
-
-               isr_data->isr = NULL;
-               isr_data->arg = NULL;
-               isr_data->mask = 0;
-
-               ret = 0;
-               break;
-       }
-
-       if (ret == 0)
-               _omap_dispc_set_irqs();
-
-       spin_unlock_irqrestore(&dispc_compat.irq_lock, flags);
-
-       return ret;
-}
-EXPORT_SYMBOL(omap_dispc_unregister_isr);
-
-static void print_irq_status(u32 status)
-{
-       if ((status & dispc_compat.irq_error_mask) == 0)
-               return;
-
-#define PIS(x) (status & DISPC_IRQ_##x) ? (#x " ") : ""
-
-       pr_debug("DISPC IRQ: 0x%x: %s%s%s%s%s%s%s%s%s\n",
-               status,
-               PIS(OCP_ERR),
-               PIS(GFX_FIFO_UNDERFLOW),
-               PIS(VID1_FIFO_UNDERFLOW),
-               PIS(VID2_FIFO_UNDERFLOW),
-               dss_feat_get_num_ovls() > 3 ? PIS(VID3_FIFO_UNDERFLOW) : "",
-               PIS(SYNC_LOST),
-               PIS(SYNC_LOST_DIGIT),
-               dss_has_feature(FEAT_MGR_LCD2) ? PIS(SYNC_LOST2) : "",
-               dss_has_feature(FEAT_MGR_LCD3) ? PIS(SYNC_LOST3) : "");
-#undef PIS
-}
-
-/* Called from dss.c. Note that we don't touch clocks here,
- * but we presume they are on because we got an IRQ. However,
- * an irq handler may turn the clocks off, so we may not have
- * clock later in the function. */
-static irqreturn_t omap_dispc_irq_handler(int irq, void *arg)
-{
-       int i;
-       u32 irqstatus, irqenable;
-       u32 handledirqs = 0;
-       u32 unhandled_errors;
-       struct omap_dispc_isr_data *isr_data;
-       struct omap_dispc_isr_data registered_isr[DISPC_MAX_NR_ISRS];
-
-       spin_lock(&dispc_compat.irq_lock);
-
-       irqstatus = dispc_read_irqstatus();
-       irqenable = dispc_read_irqenable();
-
-       /* IRQ is not for us */
-       if (!(irqstatus & irqenable)) {
-               spin_unlock(&dispc_compat.irq_lock);
-               return IRQ_NONE;
-       }
-
-#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-       spin_lock(&dispc_compat.irq_stats_lock);
-       dispc_compat.irq_stats.irq_count++;
-       dss_collect_irq_stats(irqstatus, dispc_compat.irq_stats.irqs);
-       spin_unlock(&dispc_compat.irq_stats_lock);
-#endif
-
-       print_irq_status(irqstatus);
-
-       /* Ack the interrupt. Do it here before clocks are possibly turned
-        * off */
-       dispc_clear_irqstatus(irqstatus);
-       /* flush posted write */
-       dispc_read_irqstatus();
-
-       /* make a copy and unlock, so that isrs can unregister
-        * themselves */
-       memcpy(registered_isr, dispc_compat.registered_isr,
-                       sizeof(registered_isr));
-
-       spin_unlock(&dispc_compat.irq_lock);
-
-       for (i = 0; i < DISPC_MAX_NR_ISRS; i++) {
-               isr_data = &registered_isr[i];
-
-               if (!isr_data->isr)
-                       continue;
-
-               if (isr_data->mask & irqstatus) {
-                       isr_data->isr(isr_data->arg, irqstatus);
-                       handledirqs |= isr_data->mask;
-               }
-       }
-
-       spin_lock(&dispc_compat.irq_lock);
-
-       unhandled_errors = irqstatus & ~handledirqs & dispc_compat.irq_error_mask;
-
-       if (unhandled_errors) {
-               dispc_compat.error_irqs |= unhandled_errors;
-
-               dispc_compat.irq_error_mask &= ~unhandled_errors;
-               _omap_dispc_set_irqs();
-
-               schedule_work(&dispc_compat.error_work);
-       }
-
-       spin_unlock(&dispc_compat.irq_lock);
-
-       return IRQ_HANDLED;
-}
-
-static void dispc_error_worker(struct work_struct *work)
-{
-       int i;
-       u32 errors;
-       unsigned long flags;
-       static const unsigned fifo_underflow_bits[] = {
-               DISPC_IRQ_GFX_FIFO_UNDERFLOW,
-               DISPC_IRQ_VID1_FIFO_UNDERFLOW,
-               DISPC_IRQ_VID2_FIFO_UNDERFLOW,
-               DISPC_IRQ_VID3_FIFO_UNDERFLOW,
-       };
-
-       spin_lock_irqsave(&dispc_compat.irq_lock, flags);
-       errors = dispc_compat.error_irqs;
-       dispc_compat.error_irqs = 0;
-       spin_unlock_irqrestore(&dispc_compat.irq_lock, flags);
-
-       dispc_runtime_get();
-
-       for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
-               struct omap_overlay *ovl;
-               unsigned bit;
-
-               ovl = omap_dss_get_overlay(i);
-               bit = fifo_underflow_bits[i];
-
-               if (bit & errors) {
-                       DSSERR("FIFO UNDERFLOW on %s, disabling the overlay\n",
-                                       ovl->name);
-                       ovl->disable(ovl);
-                       msleep(50);
-               }
-       }
-
-       for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
-               struct omap_overlay_manager *mgr;
-               unsigned bit;
-
-               mgr = omap_dss_get_overlay_manager(i);
-               bit = dispc_mgr_get_sync_lost_irq(i);
-
-               if (bit & errors) {
-                       int j;
-
-                       DSSERR("SYNC_LOST on channel %s, restarting the output "
-                                       "with video overlays disabled\n",
-                                       mgr->name);
-
-                       dss_mgr_disable(mgr);
-
-                       for (j = 0; j < omap_dss_get_num_overlays(); ++j) {
-                               struct omap_overlay *ovl;
-                               ovl = omap_dss_get_overlay(j);
-
-                               if (ovl->id != OMAP_DSS_GFX &&
-                                               ovl->manager == mgr)
-                                       ovl->disable(ovl);
-                       }
-
-                       dss_mgr_enable(mgr);
-               }
-       }
-
-       if (errors & DISPC_IRQ_OCP_ERR) {
-               DSSERR("OCP_ERR\n");
-               for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
-                       struct omap_overlay_manager *mgr;
-
-                       mgr = omap_dss_get_overlay_manager(i);
-                       dss_mgr_disable(mgr);
-               }
-       }
-
-       spin_lock_irqsave(&dispc_compat.irq_lock, flags);
-       dispc_compat.irq_error_mask |= errors;
-       _omap_dispc_set_irqs();
-       spin_unlock_irqrestore(&dispc_compat.irq_lock, flags);
-
-       dispc_runtime_put();
-}
-
-int dss_dispc_initialize_irq(void)
-{
-       int r;
-
-#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
-       spin_lock_init(&dispc_compat.irq_stats_lock);
-       dispc_compat.irq_stats.last_reset = jiffies;
-       dss_debugfs_create_file("dispc_irq", dispc_dump_irqs);
-#endif
-
-       spin_lock_init(&dispc_compat.irq_lock);
-
-       memset(dispc_compat.registered_isr, 0,
-                       sizeof(dispc_compat.registered_isr));
-
-       dispc_compat.irq_error_mask = DISPC_IRQ_MASK_ERROR;
-       if (dss_has_feature(FEAT_MGR_LCD2))
-               dispc_compat.irq_error_mask |= DISPC_IRQ_SYNC_LOST2;
-       if (dss_has_feature(FEAT_MGR_LCD3))
-               dispc_compat.irq_error_mask |= DISPC_IRQ_SYNC_LOST3;
-       if (dss_feat_get_num_ovls() > 3)
-               dispc_compat.irq_error_mask |= DISPC_IRQ_VID3_FIFO_UNDERFLOW;
-
-       /*
-        * there's SYNC_LOST_DIGIT waiting after enabling the DSS,
-        * so clear it
-        */
-       dispc_clear_irqstatus(dispc_read_irqstatus());
-
-       INIT_WORK(&dispc_compat.error_work, dispc_error_worker);
-
-       _omap_dispc_set_irqs();
-
-       r = dispc_request_irq(omap_dispc_irq_handler, &dispc_compat);
-       if (r) {
-               DSSERR("dispc_request_irq failed\n");
-               return r;
-       }
-
-       return 0;
-}
-
-void dss_dispc_uninitialize_irq(void)
-{
-       dispc_free_irq(&dispc_compat);
-}
-
-static void dispc_mgr_disable_isr(void *data, u32 mask)
-{
-       struct completion *compl = data;
-       complete(compl);
-}
-
-static void dispc_mgr_enable_lcd_out(enum omap_channel channel)
-{
-       dispc_mgr_enable(channel, true);
-}
-
-static void dispc_mgr_disable_lcd_out(enum omap_channel channel)
-{
-       DECLARE_COMPLETION_ONSTACK(framedone_compl);
-       int r;
-       u32 irq;
-
-       if (!dispc_mgr_is_enabled(channel))
-               return;
-
-       /*
-        * When we disable LCD output, we need to wait for FRAMEDONE to know
-        * that DISPC has finished with the LCD output.
-        */
-
-       irq = dispc_mgr_get_framedone_irq(channel);
-
-       r = omap_dispc_register_isr(dispc_mgr_disable_isr, &framedone_compl,
-                       irq);
-       if (r)
-               DSSERR("failed to register FRAMEDONE isr\n");
-
-       dispc_mgr_enable(channel, false);
-
-       /* if we couldn't register for framedone, just sleep and exit */
-       if (r) {
-               msleep(100);
-               return;
-       }
-
-       if (!wait_for_completion_timeout(&framedone_compl,
-                               msecs_to_jiffies(100)))
-               DSSERR("timeout waiting for FRAME DONE\n");
-
-       r = omap_dispc_unregister_isr(dispc_mgr_disable_isr, &framedone_compl,
-                       irq);
-       if (r)
-               DSSERR("failed to unregister FRAMEDONE isr\n");
-}
-
-static void dispc_digit_out_enable_isr(void *data, u32 mask)
-{
-       struct completion *compl = data;
-
-       /* ignore any sync lost interrupts */
-       if (mask & (DISPC_IRQ_EVSYNC_EVEN | DISPC_IRQ_EVSYNC_ODD))
-               complete(compl);
-}
-
-static void dispc_mgr_enable_digit_out(void)
-{
-       DECLARE_COMPLETION_ONSTACK(vsync_compl);
-       int r;
-       u32 irq_mask;
-
-       if (dispc_mgr_is_enabled(OMAP_DSS_CHANNEL_DIGIT))
-               return;
-
-       /*
-        * Digit output produces some sync lost interrupts during the first
-        * frame when enabling. Those need to be ignored, so we register for the
-        * sync lost irq to prevent the error handler from triggering.
-        */
-
-       irq_mask = dispc_mgr_get_vsync_irq(OMAP_DSS_CHANNEL_DIGIT) |
-               dispc_mgr_get_sync_lost_irq(OMAP_DSS_CHANNEL_DIGIT);
-
-       r = omap_dispc_register_isr(dispc_digit_out_enable_isr, &vsync_compl,
-                       irq_mask);
-       if (r) {
-               DSSERR("failed to register %x isr\n", irq_mask);
-               return;
-       }
-
-       dispc_mgr_enable(OMAP_DSS_CHANNEL_DIGIT, true);
-
-       /* wait for the first evsync */
-       if (!wait_for_completion_timeout(&vsync_compl, msecs_to_jiffies(100)))
-               DSSERR("timeout waiting for digit out to start\n");
-
-       r = omap_dispc_unregister_isr(dispc_digit_out_enable_isr, &vsync_compl,
-                       irq_mask);
-       if (r)
-               DSSERR("failed to unregister %x isr\n", irq_mask);
-}
-
-static void dispc_mgr_disable_digit_out(void)
-{
-       DECLARE_COMPLETION_ONSTACK(framedone_compl);
-       int r, i;
-       u32 irq_mask;
-       int num_irqs;
-
-       if (!dispc_mgr_is_enabled(OMAP_DSS_CHANNEL_DIGIT))
-               return;
-
-       /*
-        * When we disable the digit output, we need to wait for FRAMEDONE to
-        * know that DISPC has finished with the output.
-        */
-
-       irq_mask = dispc_mgr_get_framedone_irq(OMAP_DSS_CHANNEL_DIGIT);
-       num_irqs = 1;
-
-       if (!irq_mask) {
-               /*
-                * omap 2/3 don't have framedone irq for TV, so we need to use
-                * vsyncs for this.
-                */
-
-               irq_mask = dispc_mgr_get_vsync_irq(OMAP_DSS_CHANNEL_DIGIT);
-               /*
-                * We need to wait for both even and odd vsyncs. Note that this
-                * is not totally reliable, as we could get a vsync interrupt
-                * before we disable the output, which leads to timeout in the
-                * wait_for_completion.
-                */
-               num_irqs = 2;
-       }
-
-       r = omap_dispc_register_isr(dispc_mgr_disable_isr, &framedone_compl,
-                       irq_mask);
-       if (r)
-               DSSERR("failed to register %x isr\n", irq_mask);
-
-       dispc_mgr_enable(OMAP_DSS_CHANNEL_DIGIT, false);
-
-       /* if we couldn't register the irq, just sleep and exit */
-       if (r) {
-               msleep(100);
-               return;
-       }
-
-       for (i = 0; i < num_irqs; ++i) {
-               if (!wait_for_completion_timeout(&framedone_compl,
-                                       msecs_to_jiffies(100)))
-                       DSSERR("timeout waiting for digit out to stop\n");
-       }
-
-       r = omap_dispc_unregister_isr(dispc_mgr_disable_isr, &framedone_compl,
-                       irq_mask);
-       if (r)
-               DSSERR("failed to unregister %x isr\n", irq_mask);
-}
-
-void dispc_mgr_enable_sync(enum omap_channel channel)
-{
-       if (dss_mgr_is_lcd(channel))
-               dispc_mgr_enable_lcd_out(channel);
-       else if (channel == OMAP_DSS_CHANNEL_DIGIT)
-               dispc_mgr_enable_digit_out();
-       else
-               WARN_ON(1);
-}
-
-void dispc_mgr_disable_sync(enum omap_channel channel)
-{
-       if (dss_mgr_is_lcd(channel))
-               dispc_mgr_disable_lcd_out(channel);
-       else if (channel == OMAP_DSS_CHANNEL_DIGIT)
-               dispc_mgr_disable_digit_out();
-       else
-               WARN_ON(1);
-}
-
-static inline void dispc_irq_wait_handler(void *data, u32 mask)
-{
-       complete((struct completion *)data);
-}
-
-int omap_dispc_wait_for_irq_interruptible_timeout(u32 irqmask,
-               unsigned long timeout)
-{
-
-       int r;
-       DECLARE_COMPLETION_ONSTACK(completion);
-
-       r = omap_dispc_register_isr(dispc_irq_wait_handler, &completion,
-                       irqmask);
-
-       if (r)
-               return r;
-
-       timeout = wait_for_completion_interruptible_timeout(&completion,
-                       timeout);
-
-       omap_dispc_unregister_isr(dispc_irq_wait_handler, &completion, irqmask);
-
-       if (timeout == 0)
-               return -ETIMEDOUT;
-
-       if (timeout == -ERESTARTSYS)
-               return -ERESTARTSYS;
-
-       return 0;
-}
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc-compat.h b/drivers/gpu/drm/omapdrm/dss/dispc-compat.h
deleted file mode 100644 (file)
index 14a69b3..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2012 Texas Instruments
- * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __OMAP2_DSS_DISPC_COMPAT_H
-#define __OMAP2_DSS_DISPC_COMPAT_H
-
-void dispc_mgr_enable_sync(enum omap_channel channel);
-void dispc_mgr_disable_sync(enum omap_channel channel);
-
-int omap_dispc_wait_for_irq_interruptible_timeout(u32 irqmask,
-               unsigned long timeout);
-
-int dss_dispc_initialize_irq(void);
-void dss_dispc_uninitialize_irq(void);
-
-#endif
index 6b50476..f83608b 100644 (file)
@@ -104,6 +104,15 @@ struct dispc_features {
        bool supports_sync_align:1;
 
        bool has_writeback:1;
+
+       bool supports_double_pixel:1;
+
+       /*
+        * Field order for VENC is different than HDMI. We should handle this in
+        * some intelligent manner, but as the SoCs have either HDMI or VENC,
+        * never both, we can just use this flag for now.
+        */
+       bool reverse_ilace_field_order:1;
 };
 
 #define DISPC_MAX_NR_FIFOS 5
@@ -2552,47 +2561,6 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk,
        return 0;
 }
 
-int dispc_ovl_check(enum omap_plane plane, enum omap_channel channel,
-               const struct omap_overlay_info *oi,
-               const struct omap_video_timings *timings,
-               int *x_predecim, int *y_predecim)
-{
-       enum omap_overlay_caps caps = dss_feat_get_overlay_caps(plane);
-       bool five_taps = true;
-       bool fieldmode = false;
-       u16 in_height = oi->height;
-       u16 in_width = oi->width;
-       bool ilace = timings->interlace;
-       u16 out_width, out_height;
-       int pos_x = oi->pos_x;
-       unsigned long pclk = dispc_mgr_pclk_rate(channel);
-       unsigned long lclk = dispc_mgr_lclk_rate(channel);
-
-       out_width = oi->out_width == 0 ? oi->width : oi->out_width;
-       out_height = oi->out_height == 0 ? oi->height : oi->out_height;
-
-       if (ilace && oi->height == out_height)
-               fieldmode = true;
-
-       if (ilace) {
-               if (fieldmode)
-                       in_height /= 2;
-               out_height /= 2;
-
-               DSSDBG("adjusting for ilace: height %d, out_height %d\n",
-                               in_height, out_height);
-       }
-
-       if (!dss_feat_color_mode_supported(plane, oi->color_mode))
-               return -EINVAL;
-
-       return dispc_ovl_calc_scaling(pclk, lclk, caps, timings, in_width,
-                       in_height, out_width, out_height, oi->color_mode,
-                       &five_taps, x_predecim, y_predecim, pos_x,
-                       oi->rotation_type, false);
-}
-EXPORT_SYMBOL(dispc_ovl_check);
-
 static int dispc_ovl_setup_common(enum omap_plane plane,
                enum omap_overlay_caps caps, u32 paddr, u32 p_uv_addr,
                u16 screen_width, int pos_x, int pos_y, u16 width, u16 height,
@@ -2747,6 +2715,9 @@ static int dispc_ovl_setup_common(enum omap_plane plane,
 
        dispc_ovl_configure_burst_type(plane, rotation_type);
 
+       if (dispc.feat->reverse_ilace_field_order)
+               swap(offset0, offset1);
+
        dispc_ovl_set_ba0(plane, paddr + offset0);
        dispc_ovl_set_ba1(plane, paddr + offset1);
 
@@ -2898,6 +2869,12 @@ bool dispc_ovl_enabled(enum omap_plane plane)
 }
 EXPORT_SYMBOL(dispc_ovl_enabled);
 
+enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel)
+{
+       return dss_feat_get_supported_outputs(channel);
+}
+EXPORT_SYMBOL(dispc_mgr_get_supported_outputs);
+
 void dispc_mgr_enable(enum omap_channel channel, bool enable)
 {
        mgr_fld_write(channel, DISPC_MGR_FLD_ENABLE, enable);
@@ -3287,6 +3264,10 @@ void dispc_mgr_set_timings(enum omap_channel channel,
        } else {
                if (t.interlace)
                        t.y_res /= 2;
+
+               if (dispc.feat->supports_double_pixel)
+                       REG_FLD_MOD(DISPC_CONTROL, t.double_pixel ? 1 : 0,
+                               19, 17);
        }
 
        dispc_mgr_set_size(channel, t.x_res, t.y_res);
@@ -3951,6 +3932,8 @@ static const struct dispc_features omap44xx_dispc_feats = {
        .set_max_preload        =       true,
        .supports_sync_align    =       true,
        .has_writeback          =       true,
+       .supports_double_pixel  =       true,
+       .reverse_ilace_field_order =    true,
 };
 
 static const struct dispc_features omap54xx_dispc_feats = {
@@ -3974,6 +3957,8 @@ static const struct dispc_features omap54xx_dispc_feats = {
        .set_max_preload        =       true,
        .supports_sync_align    =       true,
        .has_writeback          =       true,
+       .supports_double_pixel  =       true,
+       .reverse_ilace_field_order =    true,
 };
 
 static int dispc_init_features(struct platform_device *pdev)
@@ -4129,8 +4114,6 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
 
        dispc_runtime_put();
 
-       dss_init_overlay_managers();
-
        dss_debugfs_create_file("dispc", dispc_dump_regs);
 
        return 0;
@@ -4144,8 +4127,6 @@ static void dispc_unbind(struct device *dev, struct device *master,
                               void *data)
 {
        pm_runtime_disable(dev);
-
-       dss_uninit_overlay_managers();
 }
 
 static const struct component_ops dispc_component_ops = {
diff --git a/drivers/gpu/drm/omapdrm/dss/display-sysfs.c b/drivers/gpu/drm/omapdrm/dss/display-sysfs.c
deleted file mode 100644 (file)
index 6ad0991..0000000
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Copyright (C) 2009 Nokia Corporation
- * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
- *
- * Some code and ideas taken from drivers/video/omap/ driver
- * by Imre Deak.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define DSS_SUBSYS_NAME "DISPLAY"
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/sysfs.h>
-
-#include <video/omapdss.h>
-#include "dss.h"
-
-static ssize_t display_name_show(struct omap_dss_device *dssdev, char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, "%s\n",
-                       dssdev->name ?
-                       dssdev->name : "");
-}
-
-static ssize_t display_enabled_show(struct omap_dss_device *dssdev, char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, "%d\n",
-                       omapdss_device_is_enabled(dssdev));
-}
-
-static ssize_t display_enabled_store(struct omap_dss_device *dssdev,
-               const char *buf, size_t size)
-{
-       int r;
-       bool enable;
-
-       r = strtobool(buf, &enable);
-       if (r)
-               return r;
-
-       if (enable == omapdss_device_is_enabled(dssdev))
-               return size;
-
-       if (omapdss_device_is_connected(dssdev) == false)
-               return -ENODEV;
-
-       if (enable) {
-               r = dssdev->driver->enable(dssdev);
-               if (r)
-                       return r;
-       } else {
-               dssdev->driver->disable(dssdev);
-       }
-
-       return size;
-}
-
-static ssize_t display_tear_show(struct omap_dss_device *dssdev, char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, "%d\n",
-                       dssdev->driver->get_te ?
-                       dssdev->driver->get_te(dssdev) : 0);
-}
-
-static ssize_t display_tear_store(struct omap_dss_device *dssdev,
-       const char *buf, size_t size)
-{
-       int r;
-       bool te;
-
-       if (!dssdev->driver->enable_te || !dssdev->driver->get_te)
-               return -ENOENT;
-
-       r = strtobool(buf, &te);
-       if (r)
-               return r;
-
-       r = dssdev->driver->enable_te(dssdev, te);
-       if (r)
-               return r;
-
-       return size;
-}
-
-static ssize_t display_timings_show(struct omap_dss_device *dssdev, char *buf)
-{
-       struct omap_video_timings t;
-
-       if (!dssdev->driver->get_timings)
-               return -ENOENT;
-
-       dssdev->driver->get_timings(dssdev, &t);
-
-       return snprintf(buf, PAGE_SIZE, "%u,%u/%u/%u/%u,%u/%u/%u/%u\n",
-                       t.pixelclock,
-                       t.x_res, t.hfp, t.hbp, t.hsw,
-                       t.y_res, t.vfp, t.vbp, t.vsw);
-}
-
-static ssize_t display_timings_store(struct omap_dss_device *dssdev,
-       const char *buf, size_t size)
-{
-       struct omap_video_timings t = dssdev->panel.timings;
-       int r, found;
-
-       if (!dssdev->driver->set_timings || !dssdev->driver->check_timings)
-               return -ENOENT;
-
-       found = 0;
-#ifdef CONFIG_OMAP2_DSS_VENC
-       if (strncmp("pal", buf, 3) == 0) {
-               t = omap_dss_pal_timings;
-               found = 1;
-       } else if (strncmp("ntsc", buf, 4) == 0) {
-               t = omap_dss_ntsc_timings;
-               found = 1;
-       }
-#endif
-       if (!found && sscanf(buf, "%u,%hu/%hu/%hu/%hu,%hu/%hu/%hu/%hu",
-                               &t.pixelclock,
-                               &t.x_res, &t.hfp, &t.hbp, &t.hsw,
-                               &t.y_res, &t.vfp, &t.vbp, &t.vsw) != 9)
-               return -EINVAL;
-
-       r = dssdev->driver->check_timings(dssdev, &t);
-       if (r)
-               return r;
-
-       dssdev->driver->disable(dssdev);
-       dssdev->driver->set_timings(dssdev, &t);
-       r = dssdev->driver->enable(dssdev);
-       if (r)
-               return r;
-
-       return size;
-}
-
-static ssize_t display_rotate_show(struct omap_dss_device *dssdev, char *buf)
-{
-       int rotate;
-       if (!dssdev->driver->get_rotate)
-               return -ENOENT;
-       rotate = dssdev->driver->get_rotate(dssdev);
-       return snprintf(buf, PAGE_SIZE, "%u\n", rotate);
-}
-
-static ssize_t display_rotate_store(struct omap_dss_device *dssdev,
-       const char *buf, size_t size)
-{
-       int rot, r;
-
-       if (!dssdev->driver->set_rotate || !dssdev->driver->get_rotate)
-               return -ENOENT;
-
-       r = kstrtoint(buf, 0, &rot);
-       if (r)
-               return r;
-
-       r = dssdev->driver->set_rotate(dssdev, rot);
-       if (r)
-               return r;
-
-       return size;
-}
-
-static ssize_t display_mirror_show(struct omap_dss_device *dssdev, char *buf)
-{
-       int mirror;
-       if (!dssdev->driver->get_mirror)
-               return -ENOENT;
-       mirror = dssdev->driver->get_mirror(dssdev);
-       return snprintf(buf, PAGE_SIZE, "%u\n", mirror);
-}
-
-static ssize_t display_mirror_store(struct omap_dss_device *dssdev,
-       const char *buf, size_t size)
-{
-       int r;
-       bool mirror;
-
-       if (!dssdev->driver->set_mirror || !dssdev->driver->get_mirror)
-               return -ENOENT;
-
-       r = strtobool(buf, &mirror);
-       if (r)
-               return r;
-
-       r = dssdev->driver->set_mirror(dssdev, mirror);
-       if (r)
-               return r;
-
-       return size;
-}
-
-static ssize_t display_wss_show(struct omap_dss_device *dssdev, char *buf)
-{
-       unsigned int wss;
-
-       if (!dssdev->driver->get_wss)
-               return -ENOENT;
-
-       wss = dssdev->driver->get_wss(dssdev);
-
-       return snprintf(buf, PAGE_SIZE, "0x%05x\n", wss);
-}
-
-static ssize_t display_wss_store(struct omap_dss_device *dssdev,
-       const char *buf, size_t size)
-{
-       u32 wss;
-       int r;
-
-       if (!dssdev->driver->get_wss || !dssdev->driver->set_wss)
-               return -ENOENT;
-
-       r = kstrtou32(buf, 0, &wss);
-       if (r)
-               return r;
-
-       if (wss > 0xfffff)
-               return -EINVAL;
-
-       r = dssdev->driver->set_wss(dssdev, wss);
-       if (r)
-               return r;
-
-       return size;
-}
-
-struct display_attribute {
-       struct attribute attr;
-       ssize_t (*show)(struct omap_dss_device *, char *);
-       ssize_t (*store)(struct omap_dss_device *, const char *, size_t);
-};
-
-#define DISPLAY_ATTR(_name, _mode, _show, _store) \
-       struct display_attribute display_attr_##_name = \
-       __ATTR(_name, _mode, _show, _store)
-
-static DISPLAY_ATTR(name, S_IRUGO, display_name_show, NULL);
-static DISPLAY_ATTR(display_name, S_IRUGO, display_name_show, NULL);
-static DISPLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
-               display_enabled_show, display_enabled_store);
-static DISPLAY_ATTR(tear_elim, S_IRUGO|S_IWUSR,
-               display_tear_show, display_tear_store);
-static DISPLAY_ATTR(timings, S_IRUGO|S_IWUSR,
-               display_timings_show, display_timings_store);
-static DISPLAY_ATTR(rotate, S_IRUGO|S_IWUSR,
-               display_rotate_show, display_rotate_store);
-static DISPLAY_ATTR(mirror, S_IRUGO|S_IWUSR,
-               display_mirror_show, display_mirror_store);
-static DISPLAY_ATTR(wss, S_IRUGO|S_IWUSR,
-               display_wss_show, display_wss_store);
-
-static struct attribute *display_sysfs_attrs[] = {
-       &display_attr_name.attr,
-       &display_attr_display_name.attr,
-       &display_attr_enabled.attr,
-       &display_attr_tear_elim.attr,
-       &display_attr_timings.attr,
-       &display_attr_rotate.attr,
-       &display_attr_mirror.attr,
-       &display_attr_wss.attr,
-       NULL
-};
-
-static ssize_t display_attr_show(struct kobject *kobj, struct attribute *attr,
-               char *buf)
-{
-       struct omap_dss_device *dssdev;
-       struct display_attribute *display_attr;
-
-       dssdev = container_of(kobj, struct omap_dss_device, kobj);
-       display_attr = container_of(attr, struct display_attribute, attr);
-
-       if (!display_attr->show)
-               return -ENOENT;
-
-       return display_attr->show(dssdev, buf);
-}
-
-static ssize_t display_attr_store(struct kobject *kobj, struct attribute *attr,
-               const char *buf, size_t size)
-{
-       struct omap_dss_device *dssdev;
-       struct display_attribute *display_attr;
-
-       dssdev = container_of(kobj, struct omap_dss_device, kobj);
-       display_attr = container_of(attr, struct display_attribute, attr);
-
-       if (!display_attr->store)
-               return -ENOENT;
-
-       return display_attr->store(dssdev, buf, size);
-}
-
-static const struct sysfs_ops display_sysfs_ops = {
-       .show = display_attr_show,
-       .store = display_attr_store,
-};
-
-static struct kobj_type display_ktype = {
-       .sysfs_ops = &display_sysfs_ops,
-       .default_attrs = display_sysfs_attrs,
-};
-
-int display_init_sysfs(struct platform_device *pdev)
-{
-       struct omap_dss_device *dssdev = NULL;
-       int r;
-
-       for_each_dss_dev(dssdev) {
-               r = kobject_init_and_add(&dssdev->kobj, &display_ktype,
-                       &pdev->dev.kobj, "%s", dssdev->alias);
-               if (r) {
-                       DSSERR("failed to create sysfs files\n");
-                       omap_dss_put_device(dssdev);
-                       goto err;
-               }
-       }
-
-       return 0;
-
-err:
-       display_uninit_sysfs(pdev);
-
-       return r;
-}
-
-void display_uninit_sysfs(struct platform_device *pdev)
-{
-       struct omap_dss_device *dssdev = NULL;
-
-       for_each_dss_dev(dssdev) {
-               if (kobject_name(&dssdev->kobj) == NULL)
-                       continue;
-
-               kobject_del(&dssdev->kobj);
-               kobject_put(&dssdev->kobj);
-
-               memset(&dssdev->kobj, 0, sizeof(dssdev->kobj));
-       }
-}
index ef5b902..9f3dd09 100644 (file)
@@ -78,55 +78,6 @@ void omapdss_default_get_timings(struct omap_dss_device *dssdev,
 }
 EXPORT_SYMBOL(omapdss_default_get_timings);
 
-int dss_suspend_all_devices(void)
-{
-       struct omap_dss_device *dssdev = NULL;
-
-       for_each_dss_dev(dssdev) {
-               if (!dssdev->driver)
-                       continue;
-
-               if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) {
-                       dssdev->driver->disable(dssdev);
-                       dssdev->activate_after_resume = true;
-               } else {
-                       dssdev->activate_after_resume = false;
-               }
-       }
-
-       return 0;
-}
-
-int dss_resume_all_devices(void)
-{
-       struct omap_dss_device *dssdev = NULL;
-
-       for_each_dss_dev(dssdev) {
-               if (!dssdev->driver)
-                       continue;
-
-               if (dssdev->activate_after_resume) {
-                       dssdev->driver->enable(dssdev);
-                       dssdev->activate_after_resume = false;
-               }
-       }
-
-       return 0;
-}
-
-void dss_disable_all_devices(void)
-{
-       struct omap_dss_device *dssdev = NULL;
-
-       for_each_dss_dev(dssdev) {
-               if (!dssdev->driver)
-                       continue;
-
-               if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
-                       dssdev->driver->disable(dssdev);
-       }
-}
-
 static LIST_HEAD(panel_list);
 static DEFINE_MUTEX(panel_list_mutex);
 static int disp_num_counter;
index 7953e6a..97ea602 100644 (file)
@@ -334,7 +334,7 @@ static int dpi_set_dispc_clk(struct dpi_data *dpi, unsigned long pck_req,
 static int dpi_set_mode(struct dpi_data *dpi)
 {
        struct omap_dss_device *out = &dpi->output;
-       struct omap_overlay_manager *mgr = out->manager;
+       enum omap_channel channel = out->dispc_channel;
        struct omap_video_timings *t = &dpi->timings;
        int lck_div = 0, pck_div = 0;
        unsigned long fck = 0;
@@ -342,7 +342,7 @@ static int dpi_set_mode(struct dpi_data *dpi)
        int r = 0;
 
        if (dpi->pll)
-               r = dpi_set_dsi_clk(dpi, mgr->id, t->pixelclock, &fck,
+               r = dpi_set_dsi_clk(dpi, channel, t->pixelclock, &fck,
                                &lck_div, &pck_div);
        else
                r = dpi_set_dispc_clk(dpi, t->pixelclock, &fck,
@@ -359,7 +359,7 @@ static int dpi_set_mode(struct dpi_data *dpi)
                t->pixelclock = pck;
        }
 
-       dss_mgr_set_timings(mgr, t);
+       dss_mgr_set_timings(channel, t);
 
        return 0;
 }
@@ -367,7 +367,7 @@ static int dpi_set_mode(struct dpi_data *dpi)
 static void dpi_config_lcd_manager(struct dpi_data *dpi)
 {
        struct omap_dss_device *out = &dpi->output;
-       struct omap_overlay_manager *mgr = out->manager;
+       enum omap_channel channel = out->dispc_channel;
 
        dpi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
 
@@ -378,13 +378,14 @@ static void dpi_config_lcd_manager(struct dpi_data *dpi)
 
        dpi->mgr_config.lcden_sig_polarity = 0;
 
-       dss_mgr_set_lcd_config(mgr, &dpi->mgr_config);
+       dss_mgr_set_lcd_config(channel, &dpi->mgr_config);
 }
 
 static int dpi_display_enable(struct omap_dss_device *dssdev)
 {
        struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
        struct omap_dss_device *out = &dpi->output;
+       enum omap_channel channel = out->dispc_channel;
        int r;
 
        mutex_lock(&dpi->lock);
@@ -395,7 +396,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
                goto err_no_reg;
        }
 
-       if (out->manager == NULL) {
+       if (!out->dispc_channel_connected) {
                DSSERR("failed to enable display: no output/manager\n");
                r = -ENODEV;
                goto err_no_out_mgr;
@@ -411,7 +412,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
        if (r)
                goto err_get_dispc;
 
-       r = dss_dpi_select_source(out->port_num, out->manager->id);
+       r = dss_dpi_select_source(out->port_num, channel);
        if (r)
                goto err_src_sel;
 
@@ -429,7 +430,7 @@ static int dpi_display_enable(struct omap_dss_device *dssdev)
 
        mdelay(2);
 
-       r = dss_mgr_enable(out->manager);
+       r = dss_mgr_enable(channel);
        if (r)
                goto err_mgr_enable;
 
@@ -457,14 +458,14 @@ err_no_reg:
 static void dpi_display_disable(struct omap_dss_device *dssdev)
 {
        struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
-       struct omap_overlay_manager *mgr = dpi->output.manager;
+       enum omap_channel channel = dpi->output.dispc_channel;
 
        mutex_lock(&dpi->lock);
 
-       dss_mgr_disable(mgr);
+       dss_mgr_disable(channel);
 
        if (dpi->pll) {
-               dss_select_lcd_clk_source(mgr->id, OMAP_DSS_CLK_SRC_FCK);
+               dss_select_lcd_clk_source(channel, OMAP_DSS_CLK_SRC_FCK);
                dss_pll_disable(dpi->pll);
        }
 
@@ -506,14 +507,17 @@ static int dpi_check_timings(struct omap_dss_device *dssdev,
                        struct omap_video_timings *timings)
 {
        struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
-       struct omap_overlay_manager *mgr = dpi->output.manager;
+       enum omap_channel channel = dpi->output.dispc_channel;
        int lck_div, pck_div;
        unsigned long fck;
        unsigned long pck;
        struct dpi_clk_calc_ctx ctx;
        bool ok;
 
-       if (mgr && !dispc_mgr_timings_ok(mgr->id, timings))
+       if (timings->x_res % 8 != 0)
+               return -EINVAL;
+
+       if (!dispc_mgr_timings_ok(channel, timings))
                return -EINVAL;
 
        if (timings->pixelclock == 0)
@@ -660,7 +664,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
        struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
-       struct omap_overlay_manager *mgr;
+       enum omap_channel channel = dpi->output.dispc_channel;
        int r;
 
        r = dpi_init_regulator(dpi);
@@ -669,11 +673,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,
 
        dpi_init_pll(dpi);
 
-       mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
-       if (!mgr)
-               return -ENODEV;
-
-       r = dss_mgr_connect(mgr, dssdev);
+       r = dss_mgr_connect(channel, dssdev);
        if (r)
                return r;
 
@@ -681,7 +681,7 @@ static int dpi_connect(struct omap_dss_device *dssdev,
        if (r) {
                DSSERR("failed to connect output to new device: %s\n",
                                dst->name);
-               dss_mgr_disconnect(mgr, dssdev);
+               dss_mgr_disconnect(channel, dssdev);
                return r;
        }
 
@@ -691,6 +691,9 @@ static int dpi_connect(struct omap_dss_device *dssdev,
 static void dpi_disconnect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
+       struct dpi_data *dpi = dpi_get_data_from_dssdev(dssdev);
+       enum omap_channel channel = dpi->output.dispc_channel;
+
        WARN_ON(dst != dssdev->dst);
 
        if (dst != dssdev->dst)
@@ -698,8 +701,7 @@ static void dpi_disconnect(struct omap_dss_device *dssdev,
 
        omapdss_output_unset_device(dssdev);
 
-       if (dssdev->manager)
-               dss_mgr_disconnect(dssdev->manager, dssdev);
+       dss_mgr_disconnect(channel, dssdev);
 }
 
 static const struct omapdss_dpi_ops dpi_ops = {
index 43be4b2..8730646 100644 (file)
@@ -214,9 +214,9 @@ struct dsi_reg { u16 module; u16 idx; };
 typedef void (*omap_dsi_isr_t) (void *arg, u32 mask);
 
 static int dsi_display_init_dispc(struct platform_device *dsidev,
-       struct omap_overlay_manager *mgr);
+       enum omap_channel channel);
 static void dsi_display_uninit_dispc(struct platform_device *dsidev,
-       struct omap_overlay_manager *mgr);
+       enum omap_channel channel);
 
 static int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel);
 
@@ -3826,19 +3826,19 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
 {
        struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
        struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-       struct omap_overlay_manager *mgr = dsi->output.manager;
+       enum omap_channel dispc_channel = dssdev->dispc_channel;
        int bpp = dsi_get_pixel_size(dsi->pix_fmt);
        struct omap_dss_device *out = &dsi->output;
        u8 data_type;
        u16 word_count;
        int r;
 
-       if (out->manager == NULL) {
+       if (!out->dispc_channel_connected) {
                DSSERR("failed to enable display: no output/manager\n");
                return -ENODEV;
        }
 
-       r = dsi_display_init_dispc(dsidev, mgr);
+       r = dsi_display_init_dispc(dsidev, dispc_channel);
        if (r)
                goto err_init_dispc;
 
@@ -3876,7 +3876,7 @@ static int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel)
                dsi_if_enable(dsidev, true);
        }
 
-       r = dss_mgr_enable(mgr);
+       r = dss_mgr_enable(dispc_channel);
        if (r)
                goto err_mgr_enable;
 
@@ -3888,7 +3888,7 @@ err_mgr_enable:
                dsi_vc_enable(dsidev, channel, false);
        }
 err_pix_fmt:
-       dsi_display_uninit_dispc(dsidev, mgr);
+       dsi_display_uninit_dispc(dsidev, dispc_channel);
 err_init_dispc:
        return r;
 }
@@ -3897,7 +3897,7 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
 {
        struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
        struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-       struct omap_overlay_manager *mgr = dsi->output.manager;
+       enum omap_channel dispc_channel = dssdev->dispc_channel;
 
        if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) {
                dsi_if_enable(dsidev, false);
@@ -3910,15 +3910,15 @@ static void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel
                dsi_if_enable(dsidev, true);
        }
 
-       dss_mgr_disable(mgr);
+       dss_mgr_disable(dispc_channel);
 
-       dsi_display_uninit_dispc(dsidev, mgr);
+       dsi_display_uninit_dispc(dsidev, dispc_channel);
 }
 
 static void dsi_update_screen_dispc(struct platform_device *dsidev)
 {
        struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-       struct omap_overlay_manager *mgr = dsi->output.manager;
+       enum omap_channel dispc_channel = dsi->output.dispc_channel;
        unsigned bytespp;
        unsigned bytespl;
        unsigned bytespf;
@@ -3980,9 +3980,9 @@ static void dsi_update_screen_dispc(struct platform_device *dsidev)
                msecs_to_jiffies(250));
        BUG_ON(r == 0);
 
-       dss_mgr_set_timings(mgr, &dsi->timings);
+       dss_mgr_set_timings(dispc_channel, &dsi->timings);
 
-       dss_mgr_start_update(mgr);
+       dss_mgr_start_update(dispc_channel);
 
        if (dsi->te_enabled) {
                /* disable LP_RX_TO, so that we can receive TE.  Time to wait
@@ -4105,17 +4105,17 @@ static int dsi_configure_dispc_clocks(struct platform_device *dsidev)
 }
 
 static int dsi_display_init_dispc(struct platform_device *dsidev,
-               struct omap_overlay_manager *mgr)
+               enum omap_channel channel)
 {
        struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
        int r;
 
-       dss_select_lcd_clk_source(mgr->id, dsi->module_id == 0 ?
+       dss_select_lcd_clk_source(channel, dsi->module_id == 0 ?
                        OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC :
                        OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC);
 
        if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) {
-               r = dss_mgr_register_framedone_handler(mgr,
+               r = dss_mgr_register_framedone_handler(channel,
                                dsi_framedone_irq_callback, dsidev);
                if (r) {
                        DSSERR("can't register FRAMEDONE handler\n");
@@ -4140,7 +4140,7 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
        dsi->timings.de_level = OMAPDSS_SIG_ACTIVE_HIGH;
        dsi->timings.sync_pclk_edge = OMAPDSS_DRIVE_SIG_FALLING_EDGE;
 
-       dss_mgr_set_timings(mgr, &dsi->timings);
+       dss_mgr_set_timings(channel, &dsi->timings);
 
        r = dsi_configure_dispc_clocks(dsidev);
        if (r)
@@ -4151,28 +4151,28 @@ static int dsi_display_init_dispc(struct platform_device *dsidev,
                        dsi_get_pixel_size(dsi->pix_fmt);
        dsi->mgr_config.lcden_sig_polarity = 0;
 
-       dss_mgr_set_lcd_config(mgr, &dsi->mgr_config);
+       dss_mgr_set_lcd_config(channel, &dsi->mgr_config);
 
        return 0;
 err1:
        if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
-               dss_mgr_unregister_framedone_handler(mgr,
+               dss_mgr_unregister_framedone_handler(channel,
                                dsi_framedone_irq_callback, dsidev);
 err:
-       dss_select_lcd_clk_source(mgr->id, OMAP_DSS_CLK_SRC_FCK);
+       dss_select_lcd_clk_source(channel, OMAP_DSS_CLK_SRC_FCK);
        return r;
 }
 
 static void dsi_display_uninit_dispc(struct platform_device *dsidev,
-               struct omap_overlay_manager *mgr)
+               enum omap_channel channel)
 {
        struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
 
        if (dsi->mode == OMAP_DSS_DSI_CMD_MODE)
-               dss_mgr_unregister_framedone_handler(mgr,
+               dss_mgr_unregister_framedone_handler(channel,
                                dsi_framedone_irq_callback, dsidev);
 
-       dss_select_lcd_clk_source(mgr->id, OMAP_DSS_CLK_SRC_FCK);
+       dss_select_lcd_clk_source(channel, OMAP_DSS_CLK_SRC_FCK);
 }
 
 static int dsi_configure_dsi_clocks(struct platform_device *dsidev)
@@ -4983,18 +4983,14 @@ static int dsi_connect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
        struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
-       struct omap_overlay_manager *mgr;
+       enum omap_channel dispc_channel = dssdev->dispc_channel;
        int r;
 
        r = dsi_regulator_init(dsidev);
        if (r)
                return r;
 
-       mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
-       if (!mgr)
-               return -ENODEV;
-
-       r = dss_mgr_connect(mgr, dssdev);
+       r = dss_mgr_connect(dispc_channel, dssdev);
        if (r)
                return r;
 
@@ -5002,7 +4998,7 @@ static int dsi_connect(struct omap_dss_device *dssdev,
        if (r) {
                DSSERR("failed to connect output to new device: %s\n",
                                dssdev->name);
-               dss_mgr_disconnect(mgr, dssdev);
+               dss_mgr_disconnect(dispc_channel, dssdev);
                return r;
        }
 
@@ -5012,6 +5008,8 @@ static int dsi_connect(struct omap_dss_device *dssdev,
 static void dsi_disconnect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
+       enum omap_channel dispc_channel = dssdev->dispc_channel;
+
        WARN_ON(dst != dssdev->dst);
 
        if (dst != dssdev->dst)
@@ -5019,8 +5017,7 @@ static void dsi_disconnect(struct omap_dss_device *dssdev,
 
        omapdss_output_unset_device(dssdev);
 
-       if (dssdev->manager)
-               dss_mgr_disconnect(dssdev->manager, dssdev);
+       dss_mgr_disconnect(dispc_channel, dssdev);
 }
 
 static const struct omapdss_dsi_ops dsi_ops = {
index 9a64532..38e6ab5 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <linux/interrupt.h>
 
+#include "omapdss.h"
+
 #ifdef pr_fmt
 #undef pr_fmt
 #endif
@@ -205,29 +207,6 @@ void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask);
 int dss_set_min_bus_tput(struct device *dev, unsigned long tput);
 int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
 
-/* display */
-int dss_suspend_all_devices(void);
-int dss_resume_all_devices(void);
-void dss_disable_all_devices(void);
-
-int display_init_sysfs(struct platform_device *pdev);
-void display_uninit_sysfs(struct platform_device *pdev);
-
-/* manager */
-int dss_init_overlay_managers(void);
-void dss_uninit_overlay_managers(void);
-int dss_init_overlay_managers_sysfs(struct platform_device *pdev);
-void dss_uninit_overlay_managers_sysfs(struct platform_device *pdev);
-int dss_mgr_simple_check(struct omap_overlay_manager *mgr,
-               const struct omap_overlay_manager_info *info);
-int dss_mgr_check_timings(struct omap_overlay_manager *mgr,
-               const struct omap_video_timings *timings);
-int dss_mgr_check(struct omap_overlay_manager *mgr,
-               struct omap_overlay_manager_info *info,
-               const struct omap_video_timings *mgr_timings,
-               const struct dss_lcd_mgr_config *config,
-               struct omap_overlay_info **overlay_infos);
-
 static inline bool dss_mgr_is_lcd(enum omap_channel id)
 {
        if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 ||
@@ -237,24 +216,6 @@ static inline bool dss_mgr_is_lcd(enum omap_channel id)
                return false;
 }
 
-int dss_manager_kobj_init(struct omap_overlay_manager *mgr,
-               struct platform_device *pdev);
-void dss_manager_kobj_uninit(struct omap_overlay_manager *mgr);
-
-/* overlay */
-void dss_init_overlays(struct platform_device *pdev);
-void dss_uninit_overlays(struct platform_device *pdev);
-void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr);
-int dss_ovl_simple_check(struct omap_overlay *ovl,
-               const struct omap_overlay_info *info);
-int dss_ovl_check(struct omap_overlay *ovl, struct omap_overlay_info *info,
-               const struct omap_video_timings *mgr_timings);
-bool dss_ovl_use_replication(struct dss_lcd_mgr_config config,
-               enum omap_color_mode mode);
-int dss_overlay_kobj_init(struct omap_overlay *ovl,
-               struct platform_device *pdev);
-void dss_overlay_kobj_uninit(struct omap_overlay *ovl);
-
 /* DSS */
 int dss_init_platform_driver(void) __init;
 void dss_uninit_platform_driver(void);
index 7103c65..f892ae1 100644 (file)
@@ -165,9 +165,10 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 {
        int r;
        struct omap_video_timings *p;
-       struct omap_overlay_manager *mgr = hdmi.output.manager;
+       enum omap_channel channel = dssdev->dispc_channel;
        struct hdmi_wp_data *wp = &hdmi.wp;
        struct dss_pll_clock_info hdmi_cinfo = { 0 };
+       unsigned pc;
 
        r = hdmi_power_on_core(dssdev);
        if (r)
@@ -181,7 +182,11 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 
        DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res);
 
-       hdmi_pll_compute(&hdmi.pll, p->pixelclock, &hdmi_cinfo);
+       pc = p->pixelclock;
+       if (p->double_pixel)
+               pc *= 2;
+
+       hdmi_pll_compute(&hdmi.pll, pc, &hdmi_cinfo);
 
        r = dss_pll_enable(&hdmi.pll.pll);
        if (r) {
@@ -212,24 +217,24 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
        dispc_enable_gamma_table(0);
 
        /* tv size */
-       dss_mgr_set_timings(mgr, p);
+       dss_mgr_set_timings(channel, p);
 
-       r = hdmi_wp_video_start(&hdmi.wp);
+       r = dss_mgr_enable(channel);
        if (r)
-               goto err_vid_enable;
+               goto err_mgr_enable;
 
-       r = dss_mgr_enable(mgr);
+       r = hdmi_wp_video_start(&hdmi.wp);
        if (r)
-               goto err_mgr_enable;
+               goto err_vid_enable;
 
        hdmi_wp_set_irqenable(wp,
                HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT);
 
        return 0;
 
-err_mgr_enable:
-       hdmi_wp_video_stop(&hdmi.wp);
 err_vid_enable:
+       dss_mgr_disable(channel);
+err_mgr_enable:
        hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
 err_phy_pwr:
 err_phy_cfg:
@@ -242,14 +247,14 @@ err_pll_enable:
 
 static void hdmi_power_off_full(struct omap_dss_device *dssdev)
 {
-       struct omap_overlay_manager *mgr = hdmi.output.manager;
+       enum omap_channel channel = dssdev->dispc_channel;
 
        hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff);
 
-       dss_mgr_disable(mgr);
-
        hdmi_wp_video_stop(&hdmi.wp);
 
+       dss_mgr_disable(channel);
+
        hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
 
        dss_pll_disable(&hdmi.pll.pll);
@@ -260,9 +265,7 @@ static void hdmi_power_off_full(struct omap_dss_device *dssdev)
 static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
                                        struct omap_video_timings *timings)
 {
-       struct omap_dss_device *out = &hdmi.output;
-
-       if (!dispc_mgr_timings_ok(out->dispc_channel, timings))
+       if (!dispc_mgr_timings_ok(dssdev->dispc_channel, timings))
                return -EINVAL;
 
        return 0;
@@ -343,7 +346,7 @@ static int hdmi_display_enable(struct omap_dss_device *dssdev)
 
        mutex_lock(&hdmi.lock);
 
-       if (out->manager == NULL) {
+       if (!out->dispc_channel_connected) {
                DSSERR("failed to enable display: no output/manager\n");
                r = -ENODEV;
                goto err0;
@@ -433,18 +436,14 @@ static void hdmi_core_disable(struct omap_dss_device *dssdev)
 static int hdmi_connect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
-       struct omap_overlay_manager *mgr;
+       enum omap_channel channel = dssdev->dispc_channel;
        int r;
 
        r = hdmi_init_regulator();
        if (r)
                return r;
 
-       mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
-       if (!mgr)
-               return -ENODEV;
-
-       r = dss_mgr_connect(mgr, dssdev);
+       r = dss_mgr_connect(channel, dssdev);
        if (r)
                return r;
 
@@ -452,7 +451,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
        if (r) {
                DSSERR("failed to connect output to new device: %s\n",
                                dst->name);
-               dss_mgr_disconnect(mgr, dssdev);
+               dss_mgr_disconnect(channel, dssdev);
                return r;
        }
 
@@ -462,6 +461,8 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
 static void hdmi_disconnect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
+       enum omap_channel channel = dssdev->dispc_channel;
+
        WARN_ON(dst != dssdev->dst);
 
        if (dst != dssdev->dst)
@@ -469,8 +470,7 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
 
        omapdss_output_unset_device(dssdev);
 
-       if (dssdev->manager)
-               dss_mgr_disconnect(dssdev->manager, dssdev);
+       dss_mgr_disconnect(channel, dssdev);
 }
 
 static int hdmi_read_edid(struct omap_dss_device *dssdev,
index a955a2c..a43f7b1 100644 (file)
@@ -182,8 +182,9 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 {
        int r;
        struct omap_video_timings *p;
-       struct omap_overlay_manager *mgr = hdmi.output.manager;
+       enum omap_channel channel = dssdev->dispc_channel;
        struct dss_pll_clock_info hdmi_cinfo = { 0 };
+       unsigned pc;
 
        r = hdmi_power_on_core(dssdev);
        if (r)
@@ -193,7 +194,11 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
 
        DSSDBG("hdmi_power_on x_res= %d y_res = %d\n", p->x_res, p->y_res);
 
-       hdmi_pll_compute(&hdmi.pll, p->pixelclock, &hdmi_cinfo);
+       pc = p->pixelclock;
+       if (p->double_pixel)
+               pc *= 2;
+
+       hdmi_pll_compute(&hdmi.pll, pc, &hdmi_cinfo);
 
        /* disable and clear irqs */
        hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff);
@@ -229,24 +234,24 @@ static int hdmi_power_on_full(struct omap_dss_device *dssdev)
        dispc_enable_gamma_table(0);
 
        /* tv size */
-       dss_mgr_set_timings(mgr, p);
+       dss_mgr_set_timings(channel, p);
 
-       r = hdmi_wp_video_start(&hdmi.wp);
+       r = dss_mgr_enable(channel);
        if (r)
-               goto err_vid_enable;
+               goto err_mgr_enable;
 
-       r = dss_mgr_enable(mgr);
+       r = hdmi_wp_video_start(&hdmi.wp);
        if (r)
-               goto err_mgr_enable;
+               goto err_vid_enable;
 
        hdmi_wp_set_irqenable(&hdmi.wp,
                        HDMI_IRQ_LINK_CONNECT | HDMI_IRQ_LINK_DISCONNECT);
 
        return 0;
 
-err_mgr_enable:
-       hdmi_wp_video_stop(&hdmi.wp);
 err_vid_enable:
+       dss_mgr_disable(channel);
+err_mgr_enable:
        hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
 err_phy_pwr:
 err_phy_cfg:
@@ -259,14 +264,14 @@ err_pll_enable:
 
 static void hdmi_power_off_full(struct omap_dss_device *dssdev)
 {
-       struct omap_overlay_manager *mgr = hdmi.output.manager;
+       enum omap_channel channel = dssdev->dispc_channel;
 
        hdmi_wp_clear_irqenable(&hdmi.wp, 0xffffffff);
 
-       dss_mgr_disable(mgr);
-
        hdmi_wp_video_stop(&hdmi.wp);
 
+       dss_mgr_disable(channel);
+
        hdmi_wp_set_phy_pwr(&hdmi.wp, HDMI_PHYPWRCMD_OFF);
 
        dss_pll_disable(&hdmi.pll.pll);
@@ -277,13 +282,7 @@ static void hdmi_power_off_full(struct omap_dss_device *dssdev)
 static int hdmi_display_check_timing(struct omap_dss_device *dssdev,
                                        struct omap_video_timings *timings)
 {
-       struct omap_dss_device *out = &hdmi.output;
-
-       /* TODO: proper interlace support */
-       if (timings->interlace)
-               return -EINVAL;
-
-       if (!dispc_mgr_timings_ok(out->dispc_channel, timings))
+       if (!dispc_mgr_timings_ok(dssdev->dispc_channel, timings))
                return -EINVAL;
 
        return 0;
@@ -373,7 +372,7 @@ static int hdmi_display_enable(struct omap_dss_device *dssdev)
 
        mutex_lock(&hdmi.lock);
 
-       if (out->manager == NULL) {
+       if (!out->dispc_channel_connected) {
                DSSERR("failed to enable display: no output/manager\n");
                r = -ENODEV;
                goto err0;
@@ -463,18 +462,14 @@ static void hdmi_core_disable(struct omap_dss_device *dssdev)
 static int hdmi_connect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
-       struct omap_overlay_manager *mgr;
+       enum omap_channel channel = dssdev->dispc_channel;
        int r;
 
        r = hdmi_init_regulator();
        if (r)
                return r;
 
-       mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
-       if (!mgr)
-               return -ENODEV;
-
-       r = dss_mgr_connect(mgr, dssdev);
+       r = dss_mgr_connect(channel, dssdev);
        if (r)
                return r;
 
@@ -482,7 +477,7 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
        if (r) {
                DSSERR("failed to connect output to new device: %s\n",
                                dst->name);
-               dss_mgr_disconnect(mgr, dssdev);
+               dss_mgr_disconnect(channel, dssdev);
                return r;
        }
 
@@ -492,6 +487,8 @@ static int hdmi_connect(struct omap_dss_device *dssdev,
 static void hdmi_disconnect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
+       enum omap_channel channel = dssdev->dispc_channel;
+
        WARN_ON(dst != dssdev->dst);
 
        if (dst != dssdev->dst)
@@ -499,8 +496,7 @@ static void hdmi_disconnect(struct omap_dss_device *dssdev,
 
        omapdss_output_unset_device(dssdev);
 
-       if (dssdev->manager)
-               dss_mgr_disconnect(dssdev->manager, dssdev);
+       dss_mgr_disconnect(channel, dssdev);
 }
 
 static int hdmi_read_edid(struct omap_dss_device *dssdev,
index 8ea531d..6a39752 100644 (file)
@@ -292,25 +292,36 @@ static void hdmi_core_init(struct hdmi_core_vid_config *video_cfg,
 {
        DSSDBG("hdmi_core_init\n");
 
+       video_cfg->v_fc_config.timings = cfg->timings;
+
        /* video core */
        video_cfg->data_enable_pol = 1; /* It is always 1*/
-       video_cfg->v_fc_config.timings.hsync_level = cfg->timings.hsync_level;
-       video_cfg->v_fc_config.timings.x_res = cfg->timings.x_res;
-       video_cfg->v_fc_config.timings.hsw = cfg->timings.hsw - 1;
-       video_cfg->v_fc_config.timings.hbp = cfg->timings.hbp;
-       video_cfg->v_fc_config.timings.hfp = cfg->timings.hfp;
        video_cfg->hblank = cfg->timings.hfp +
-                               cfg->timings.hbp + cfg->timings.hsw - 1;
-       video_cfg->v_fc_config.timings.vsync_level = cfg->timings.vsync_level;
-       video_cfg->v_fc_config.timings.y_res = cfg->timings.y_res;
-       video_cfg->v_fc_config.timings.vsw = cfg->timings.vsw;
-       video_cfg->v_fc_config.timings.vfp = cfg->timings.vfp;
-       video_cfg->v_fc_config.timings.vbp = cfg->timings.vbp;
-       video_cfg->vblank_osc = 0; /* Always 0 - need to confirm */
+                               cfg->timings.hbp + cfg->timings.hsw;
+       video_cfg->vblank_osc = 0;
        video_cfg->vblank = cfg->timings.vsw +
                                cfg->timings.vfp + cfg->timings.vbp;
        video_cfg->v_fc_config.hdmi_dvi_mode = cfg->hdmi_dvi_mode;
-       video_cfg->v_fc_config.timings.interlace = cfg->timings.interlace;
+
+       if (cfg->timings.interlace) {
+               /* set vblank_osc if vblank is fractional */
+               if (video_cfg->vblank % 2 != 0)
+                       video_cfg->vblank_osc = 1;
+
+               video_cfg->v_fc_config.timings.y_res /= 2;
+               video_cfg->vblank /= 2;
+               video_cfg->v_fc_config.timings.vfp /= 2;
+               video_cfg->v_fc_config.timings.vsw /= 2;
+               video_cfg->v_fc_config.timings.vbp /= 2;
+       }
+
+       if (cfg->timings.double_pixel) {
+               video_cfg->v_fc_config.timings.x_res *= 2;
+               video_cfg->hblank *= 2;
+               video_cfg->v_fc_config.timings.hfp *= 2;
+               video_cfg->v_fc_config.timings.hsw *= 2;
+               video_cfg->v_fc_config.timings.hbp *= 2;
+       }
 }
 
 /* DSS_HDMI_CORE_VIDEO_CONFIG */
@@ -377,6 +388,11 @@ static void hdmi_core_video_config(struct hdmi_core_data *core,
        /* select DVI mode */
        REG_FLD_MOD(base, HDMI_CORE_FC_INVIDCONF,
                        cfg->v_fc_config.hdmi_dvi_mode, 3, 3);
+
+       if (cfg->v_fc_config.timings.double_pixel)
+               REG_FLD_MOD(base, HDMI_CORE_FC_PRCONF, 2, 7, 4);
+       else
+               REG_FLD_MOD(base, HDMI_CORE_FC_PRCONF, 1, 7, 4);
 }
 
 static void hdmi_core_config_video_packetizer(struct hdmi_core_data *core)
index 7c544bc..13442b9 100644 (file)
@@ -165,12 +165,24 @@ void hdmi_wp_video_config_timing(struct hdmi_wp_data *wp,
 {
        u32 timing_h = 0;
        u32 timing_v = 0;
+       unsigned hsw_offset = 1;
 
        DSSDBG("Enter hdmi_wp_video_config_timing\n");
 
+       /*
+        * On OMAP4 and OMAP5 ES1 the HSW field is programmed as is. On OMAP5
+        * ES2+ (including DRA7/AM5 SoCs) HSW field is programmed to hsw-1.
+        * However, we don't support OMAP5 ES1 at all, so we can just check for
+        * OMAP4 here.
+        */
+       if (omapdss_get_version() == OMAPDSS_VER_OMAP4430_ES1 ||
+           omapdss_get_version() == OMAPDSS_VER_OMAP4430_ES2 ||
+           omapdss_get_version() == OMAPDSS_VER_OMAP4)
+               hsw_offset = 0;
+
        timing_h |= FLD_VAL(timings->hbp, 31, 20);
        timing_h |= FLD_VAL(timings->hfp, 19, 8);
-       timing_h |= FLD_VAL(timings->hsw, 7, 0);
+       timing_h |= FLD_VAL(timings->hsw - hsw_offset, 7, 0);
        hdmi_write_reg(wp->base, HDMI_WP_VIDEO_TIMING_H, timing_h);
 
        timing_v |= FLD_VAL(timings->vbp, 31, 20);
@@ -187,8 +199,6 @@ void hdmi_wp_init_vid_fmt_timings(struct hdmi_video_format *video_fmt,
        video_fmt->packing_mode = HDMI_PACK_10b_RGB_YUV444;
        video_fmt->y_res = param->timings.y_res;
        video_fmt->x_res = param->timings.x_res;
-       if (param->timings.interlace)
-               video_fmt->y_res /= 2;
 
        timings->hbp = param->timings.hbp;
        timings->hfp = param->timings.hfp;
@@ -196,9 +206,25 @@ void hdmi_wp_init_vid_fmt_timings(struct hdmi_video_format *video_fmt,
        timings->vbp = param->timings.vbp;
        timings->vfp = param->timings.vfp;
        timings->vsw = param->timings.vsw;
+
        timings->vsync_level = param->timings.vsync_level;
        timings->hsync_level = param->timings.hsync_level;
        timings->interlace = param->timings.interlace;
+       timings->double_pixel = param->timings.double_pixel;
+
+       if (param->timings.interlace) {
+               video_fmt->y_res /= 2;
+               timings->vbp /= 2;
+               timings->vfp /= 2;
+               timings->vsw /= 2;
+       }
+
+       if (param->timings.double_pixel) {
+               video_fmt->x_res *= 2;
+               timings->hfp *= 2;
+               timings->hsw *= 2;
+               timings->hbp *= 2;
+       }
 }
 
 void hdmi_wp_audio_config_format(struct hdmi_wp_data *wp,
diff --git a/drivers/gpu/drm/omapdrm/dss/manager-sysfs.c b/drivers/gpu/drm/omapdrm/dss/manager-sysfs.c
deleted file mode 100644 (file)
index a7414fb..0000000
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * Copyright (C) 2009 Nokia Corporation
- * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
- *
- * Some code and ideas taken from drivers/video/omap/ driver
- * by Imre Deak.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define DSS_SUBSYS_NAME "MANAGER"
-
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/jiffies.h>
-
-#include <video/omapdss.h>
-
-#include "dss.h"
-#include "dss_features.h"
-
-static ssize_t manager_name_show(struct omap_overlay_manager *mgr, char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, "%s\n", mgr->name);
-}
-
-static ssize_t manager_display_show(struct omap_overlay_manager *mgr, char *buf)
-{
-       struct omap_dss_device *dssdev = mgr->get_device(mgr);
-
-       return snprintf(buf, PAGE_SIZE, "%s\n", dssdev ?
-                       dssdev->name : "<none>");
-}
-
-static int manager_display_match(struct omap_dss_device *dssdev, void *data)
-{
-       const char *str = data;
-
-       return sysfs_streq(dssdev->name, str);
-}
-
-static ssize_t manager_display_store(struct omap_overlay_manager *mgr,
-               const char *buf, size_t size)
-{
-       int r = 0;
-       size_t len = size;
-       struct omap_dss_device *dssdev = NULL;
-       struct omap_dss_device *old_dssdev;
-
-       if (buf[size-1] == '\n')
-               --len;
-
-       if (len > 0)
-               dssdev = omap_dss_find_device((void *)buf,
-                       manager_display_match);
-
-       if (len > 0 && dssdev == NULL)
-               return -EINVAL;
-
-       if (dssdev) {
-               DSSDBG("display %s found\n", dssdev->name);
-
-               if (omapdss_device_is_connected(dssdev)) {
-                       DSSERR("new display is already connected\n");
-                       r = -EINVAL;
-                       goto put_device;
-               }
-
-               if (omapdss_device_is_enabled(dssdev)) {
-                       DSSERR("new display is not disabled\n");
-                       r = -EINVAL;
-                       goto put_device;
-               }
-       }
-
-       old_dssdev = mgr->get_device(mgr);
-       if (old_dssdev) {
-               if (omapdss_device_is_enabled(old_dssdev)) {
-                       DSSERR("old display is not disabled\n");
-                       r = -EINVAL;
-                       goto put_device;
-               }
-
-               old_dssdev->driver->disconnect(old_dssdev);
-       }
-
-       if (dssdev) {
-               r = dssdev->driver->connect(dssdev);
-               if (r) {
-                       DSSERR("failed to connect new device\n");
-                       goto put_device;
-               }
-
-               old_dssdev = mgr->get_device(mgr);
-               if (old_dssdev != dssdev) {
-                       DSSERR("failed to connect device to this manager\n");
-                       dssdev->driver->disconnect(dssdev);
-                       goto put_device;
-               }
-
-               r = mgr->apply(mgr);
-               if (r) {
-                       DSSERR("failed to apply dispc config\n");
-                       goto put_device;
-               }
-       }
-
-put_device:
-       if (dssdev)
-               omap_dss_put_device(dssdev);
-
-       return r ? r : size;
-}
-
-static ssize_t manager_default_color_show(struct omap_overlay_manager *mgr,
-                                         char *buf)
-{
-       struct omap_overlay_manager_info info;
-
-       mgr->get_manager_info(mgr, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%#x\n", info.default_color);
-}
-
-static ssize_t manager_default_color_store(struct omap_overlay_manager *mgr,
-                                          const char *buf, size_t size)
-{
-       struct omap_overlay_manager_info info;
-       u32 color;
-       int r;
-
-       r = kstrtouint(buf, 0, &color);
-       if (r)
-               return r;
-
-       mgr->get_manager_info(mgr, &info);
-
-       info.default_color = color;
-
-       r = mgr->set_manager_info(mgr, &info);
-       if (r)
-               return r;
-
-       r = mgr->apply(mgr);
-       if (r)
-               return r;
-
-       return size;
-}
-
-static const char *trans_key_type_str[] = {
-       "gfx-destination",
-       "video-source",
-};
-
-static ssize_t manager_trans_key_type_show(struct omap_overlay_manager *mgr,
-                                          char *buf)
-{
-       enum omap_dss_trans_key_type key_type;
-       struct omap_overlay_manager_info info;
-
-       mgr->get_manager_info(mgr, &info);
-
-       key_type = info.trans_key_type;
-       BUG_ON(key_type >= ARRAY_SIZE(trans_key_type_str));
-
-       return snprintf(buf, PAGE_SIZE, "%s\n", trans_key_type_str[key_type]);
-}
-
-static ssize_t manager_trans_key_type_store(struct omap_overlay_manager *mgr,
-                                           const char *buf, size_t size)
-{
-       enum omap_dss_trans_key_type key_type;
-       struct omap_overlay_manager_info info;
-       int r;
-
-       for (key_type = OMAP_DSS_COLOR_KEY_GFX_DST;
-                       key_type < ARRAY_SIZE(trans_key_type_str); key_type++) {
-               if (sysfs_streq(buf, trans_key_type_str[key_type]))
-                       break;
-       }
-
-       if (key_type == ARRAY_SIZE(trans_key_type_str))
-               return -EINVAL;
-
-       mgr->get_manager_info(mgr, &info);
-
-       info.trans_key_type = key_type;
-
-       r = mgr->set_manager_info(mgr, &info);
-       if (r)
-               return r;
-
-       r = mgr->apply(mgr);
-       if (r)
-               return r;
-
-       return size;
-}
-
-static ssize_t manager_trans_key_value_show(struct omap_overlay_manager *mgr,
-                                           char *buf)
-{
-       struct omap_overlay_manager_info info;
-
-       mgr->get_manager_info(mgr, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%#x\n", info.trans_key);
-}
-
-static ssize_t manager_trans_key_value_store(struct omap_overlay_manager *mgr,
-                                            const char *buf, size_t size)
-{
-       struct omap_overlay_manager_info info;
-       u32 key_value;
-       int r;
-
-       r = kstrtouint(buf, 0, &key_value);
-       if (r)
-               return r;
-
-       mgr->get_manager_info(mgr, &info);
-
-       info.trans_key = key_value;
-
-       r = mgr->set_manager_info(mgr, &info);
-       if (r)
-               return r;
-
-       r = mgr->apply(mgr);
-       if (r)
-               return r;
-
-       return size;
-}
-
-static ssize_t manager_trans_key_enabled_show(struct omap_overlay_manager *mgr,
-                                             char *buf)
-{
-       struct omap_overlay_manager_info info;
-
-       mgr->get_manager_info(mgr, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%d\n", info.trans_enabled);
-}
-
-static ssize_t manager_trans_key_enabled_store(struct omap_overlay_manager *mgr,
-                                              const char *buf, size_t size)
-{
-       struct omap_overlay_manager_info info;
-       bool enable;
-       int r;
-
-       r = strtobool(buf, &enable);
-       if (r)
-               return r;
-
-       mgr->get_manager_info(mgr, &info);
-
-       info.trans_enabled = enable;
-
-       r = mgr->set_manager_info(mgr, &info);
-       if (r)
-               return r;
-
-       r = mgr->apply(mgr);
-       if (r)
-               return r;
-
-       return size;
-}
-
-static ssize_t manager_alpha_blending_enabled_show(
-               struct omap_overlay_manager *mgr, char *buf)
-{
-       struct omap_overlay_manager_info info;
-
-       if(!dss_has_feature(FEAT_ALPHA_FIXED_ZORDER))
-               return -ENODEV;
-
-       mgr->get_manager_info(mgr, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%d\n",
-               info.partial_alpha_enabled);
-}
-
-static ssize_t manager_alpha_blending_enabled_store(
-               struct omap_overlay_manager *mgr,
-               const char *buf, size_t size)
-{
-       struct omap_overlay_manager_info info;
-       bool enable;
-       int r;
-
-       if(!dss_has_feature(FEAT_ALPHA_FIXED_ZORDER))
-               return -ENODEV;
-
-       r = strtobool(buf, &enable);
-       if (r)
-               return r;
-
-       mgr->get_manager_info(mgr, &info);
-
-       info.partial_alpha_enabled = enable;
-
-       r = mgr->set_manager_info(mgr, &info);
-       if (r)
-               return r;
-
-       r = mgr->apply(mgr);
-       if (r)
-               return r;
-
-       return size;
-}
-
-static ssize_t manager_cpr_enable_show(struct omap_overlay_manager *mgr,
-               char *buf)
-{
-       struct omap_overlay_manager_info info;
-
-       mgr->get_manager_info(mgr, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%d\n", info.cpr_enable);
-}
-
-static ssize_t manager_cpr_enable_store(struct omap_overlay_manager *mgr,
-               const char *buf, size_t size)
-{
-       struct omap_overlay_manager_info info;
-       int r;
-       bool enable;
-
-       if (!dss_has_feature(FEAT_CPR))
-               return -ENODEV;
-
-       r = strtobool(buf, &enable);
-       if (r)
-               return r;
-
-       mgr->get_manager_info(mgr, &info);
-
-       if (info.cpr_enable == enable)
-               return size;
-
-       info.cpr_enable = enable;
-
-       r = mgr->set_manager_info(mgr, &info);
-       if (r)
-               return r;
-
-       r = mgr->apply(mgr);
-       if (r)
-               return r;
-
-       return size;
-}
-
-static ssize_t manager_cpr_coef_show(struct omap_overlay_manager *mgr,
-               char *buf)
-{
-       struct omap_overlay_manager_info info;
-
-       mgr->get_manager_info(mgr, &info);
-
-       return snprintf(buf, PAGE_SIZE,
-                       "%d %d %d %d %d %d %d %d %d\n",
-                       info.cpr_coefs.rr,
-                       info.cpr_coefs.rg,
-                       info.cpr_coefs.rb,
-                       info.cpr_coefs.gr,
-                       info.cpr_coefs.gg,
-                       info.cpr_coefs.gb,
-                       info.cpr_coefs.br,
-                       info.cpr_coefs.bg,
-                       info.cpr_coefs.bb);
-}
-
-static ssize_t manager_cpr_coef_store(struct omap_overlay_manager *mgr,
-               const char *buf, size_t size)
-{
-       struct omap_overlay_manager_info info;
-       struct omap_dss_cpr_coefs coefs;
-       int r, i;
-       s16 *arr;
-
-       if (!dss_has_feature(FEAT_CPR))
-               return -ENODEV;
-
-       if (sscanf(buf, "%hd %hd %hd %hd %hd %hd %hd %hd %hd",
-                               &coefs.rr, &coefs.rg, &coefs.rb,
-                               &coefs.gr, &coefs.gg, &coefs.gb,
-                               &coefs.br, &coefs.bg, &coefs.bb) != 9)
-               return -EINVAL;
-
-       arr = (s16[]){ coefs.rr, coefs.rg, coefs.rb,
-               coefs.gr, coefs.gg, coefs.gb,
-               coefs.br, coefs.bg, coefs.bb };
-
-       for (i = 0; i < 9; ++i) {
-               if (arr[i] < -512 || arr[i] > 511)
-                       return -EINVAL;
-       }
-
-       mgr->get_manager_info(mgr, &info);
-
-       info.cpr_coefs = coefs;
-
-       r = mgr->set_manager_info(mgr, &info);
-       if (r)
-               return r;
-
-       r = mgr->apply(mgr);
-       if (r)
-               return r;
-
-       return size;
-}
-
-struct manager_attribute {
-       struct attribute attr;
-       ssize_t (*show)(struct omap_overlay_manager *, char *);
-       ssize_t (*store)(struct omap_overlay_manager *, const char *, size_t);
-};
-
-#define MANAGER_ATTR(_name, _mode, _show, _store) \
-       struct manager_attribute manager_attr_##_name = \
-       __ATTR(_name, _mode, _show, _store)
-
-static MANAGER_ATTR(name, S_IRUGO, manager_name_show, NULL);
-static MANAGER_ATTR(display, S_IRUGO|S_IWUSR,
-               manager_display_show, manager_display_store);
-static MANAGER_ATTR(default_color, S_IRUGO|S_IWUSR,
-               manager_default_color_show, manager_default_color_store);
-static MANAGER_ATTR(trans_key_type, S_IRUGO|S_IWUSR,
-               manager_trans_key_type_show, manager_trans_key_type_store);
-static MANAGER_ATTR(trans_key_value, S_IRUGO|S_IWUSR,
-               manager_trans_key_value_show, manager_trans_key_value_store);
-static MANAGER_ATTR(trans_key_enabled, S_IRUGO|S_IWUSR,
-               manager_trans_key_enabled_show,
-               manager_trans_key_enabled_store);
-static MANAGER_ATTR(alpha_blending_enabled, S_IRUGO|S_IWUSR,
-               manager_alpha_blending_enabled_show,
-               manager_alpha_blending_enabled_store);
-static MANAGER_ATTR(cpr_enable, S_IRUGO|S_IWUSR,
-               manager_cpr_enable_show,
-               manager_cpr_enable_store);
-static MANAGER_ATTR(cpr_coef, S_IRUGO|S_IWUSR,
-               manager_cpr_coef_show,
-               manager_cpr_coef_store);
-
-
-static struct attribute *manager_sysfs_attrs[] = {
-       &manager_attr_name.attr,
-       &manager_attr_display.attr,
-       &manager_attr_default_color.attr,
-       &manager_attr_trans_key_type.attr,
-       &manager_attr_trans_key_value.attr,
-       &manager_attr_trans_key_enabled.attr,
-       &manager_attr_alpha_blending_enabled.attr,
-       &manager_attr_cpr_enable.attr,
-       &manager_attr_cpr_coef.attr,
-       NULL
-};
-
-static ssize_t manager_attr_show(struct kobject *kobj, struct attribute *attr,
-               char *buf)
-{
-       struct omap_overlay_manager *manager;
-       struct manager_attribute *manager_attr;
-
-       manager = container_of(kobj, struct omap_overlay_manager, kobj);
-       manager_attr = container_of(attr, struct manager_attribute, attr);
-
-       if (!manager_attr->show)
-               return -ENOENT;
-
-       return manager_attr->show(manager, buf);
-}
-
-static ssize_t manager_attr_store(struct kobject *kobj, struct attribute *attr,
-               const char *buf, size_t size)
-{
-       struct omap_overlay_manager *manager;
-       struct manager_attribute *manager_attr;
-
-       manager = container_of(kobj, struct omap_overlay_manager, kobj);
-       manager_attr = container_of(attr, struct manager_attribute, attr);
-
-       if (!manager_attr->store)
-               return -ENOENT;
-
-       return manager_attr->store(manager, buf, size);
-}
-
-static const struct sysfs_ops manager_sysfs_ops = {
-       .show = manager_attr_show,
-       .store = manager_attr_store,
-};
-
-static struct kobj_type manager_ktype = {
-       .sysfs_ops = &manager_sysfs_ops,
-       .default_attrs = manager_sysfs_attrs,
-};
-
-int dss_manager_kobj_init(struct omap_overlay_manager *mgr,
-               struct platform_device *pdev)
-{
-       return kobject_init_and_add(&mgr->kobj, &manager_ktype,
-                       &pdev->dev.kobj, "manager%d", mgr->id);
-}
-
-void dss_manager_kobj_uninit(struct omap_overlay_manager *mgr)
-{
-       kobject_del(&mgr->kobj);
-       kobject_put(&mgr->kobj);
-
-       memset(&mgr->kobj, 0, sizeof(mgr->kobj));
-}
diff --git a/drivers/gpu/drm/omapdrm/dss/manager.c b/drivers/gpu/drm/omapdrm/dss/manager.c
deleted file mode 100644 (file)
index 08a67f4..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * linux/drivers/video/omap2/dss/manager.c
- *
- * Copyright (C) 2009 Nokia Corporation
- * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
- *
- * Some code and ideas taken from drivers/video/omap/ driver
- * by Imre Deak.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define DSS_SUBSYS_NAME "MANAGER"
-
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/jiffies.h>
-
-#include <video/omapdss.h>
-
-#include "dss.h"
-#include "dss_features.h"
-
-static int num_managers;
-static struct omap_overlay_manager *managers;
-
-int dss_init_overlay_managers(void)
-{
-       int i;
-
-       num_managers = dss_feat_get_num_mgrs();
-
-       managers = kzalloc(sizeof(struct omap_overlay_manager) * num_managers,
-                       GFP_KERNEL);
-
-       BUG_ON(managers == NULL);
-
-       for (i = 0; i < num_managers; ++i) {
-               struct omap_overlay_manager *mgr = &managers[i];
-
-               switch (i) {
-               case 0:
-                       mgr->name = "lcd";
-                       mgr->id = OMAP_DSS_CHANNEL_LCD;
-                       break;
-               case 1:
-                       mgr->name = "tv";
-                       mgr->id = OMAP_DSS_CHANNEL_DIGIT;
-                       break;
-               case 2:
-                       mgr->name = "lcd2";
-                       mgr->id = OMAP_DSS_CHANNEL_LCD2;
-                       break;
-               case 3:
-                       mgr->name = "lcd3";
-                       mgr->id = OMAP_DSS_CHANNEL_LCD3;
-                       break;
-               }
-
-               mgr->caps = 0;
-               mgr->supported_displays =
-                       dss_feat_get_supported_displays(mgr->id);
-               mgr->supported_outputs =
-                       dss_feat_get_supported_outputs(mgr->id);
-
-               INIT_LIST_HEAD(&mgr->overlays);
-       }
-
-       return 0;
-}
-
-int dss_init_overlay_managers_sysfs(struct platform_device *pdev)
-{
-       int i, r;
-
-       for (i = 0; i < num_managers; ++i) {
-               struct omap_overlay_manager *mgr = &managers[i];
-
-               r = dss_manager_kobj_init(mgr, pdev);
-               if (r)
-                       DSSERR("failed to create sysfs file\n");
-       }
-
-       return 0;
-}
-
-void dss_uninit_overlay_managers(void)
-{
-       kfree(managers);
-       managers = NULL;
-       num_managers = 0;
-}
-
-void dss_uninit_overlay_managers_sysfs(struct platform_device *pdev)
-{
-       int i;
-
-       for (i = 0; i < num_managers; ++i) {
-               struct omap_overlay_manager *mgr = &managers[i];
-
-               dss_manager_kobj_uninit(mgr);
-       }
-}
-
-int omap_dss_get_num_overlay_managers(void)
-{
-       return num_managers;
-}
-EXPORT_SYMBOL(omap_dss_get_num_overlay_managers);
-
-struct omap_overlay_manager *omap_dss_get_overlay_manager(int num)
-{
-       if (num >= num_managers)
-               return NULL;
-
-       return &managers[num];
-}
-EXPORT_SYMBOL(omap_dss_get_overlay_manager);
-
-int dss_mgr_simple_check(struct omap_overlay_manager *mgr,
-               const struct omap_overlay_manager_info *info)
-{
-       if (dss_has_feature(FEAT_ALPHA_FIXED_ZORDER)) {
-               /*
-                * OMAP3 supports only graphics source transparency color key
-                * and alpha blending simultaneously. See TRM 15.4.2.4.2.2
-                * Alpha Mode.
-                */
-               if (info->partial_alpha_enabled && info->trans_enabled
-                       && info->trans_key_type != OMAP_DSS_COLOR_KEY_GFX_DST) {
-                       DSSERR("check_manager: illegal transparency key\n");
-                       return -EINVAL;
-               }
-       }
-
-       return 0;
-}
-
-static int dss_mgr_check_zorder(struct omap_overlay_manager *mgr,
-               struct omap_overlay_info **overlay_infos)
-{
-       struct omap_overlay *ovl1, *ovl2;
-       struct omap_overlay_info *info1, *info2;
-
-       list_for_each_entry(ovl1, &mgr->overlays, list) {
-               info1 = overlay_infos[ovl1->id];
-
-               if (info1 == NULL)
-                       continue;
-
-               list_for_each_entry(ovl2, &mgr->overlays, list) {
-                       if (ovl1 == ovl2)
-                               continue;
-
-                       info2 = overlay_infos[ovl2->id];
-
-                       if (info2 == NULL)
-                               continue;
-
-                       if (info1->zorder == info2->zorder) {
-                               DSSERR("overlays %d and %d have the same "
-                                               "zorder %d\n",
-                                       ovl1->id, ovl2->id, info1->zorder);
-                               return -EINVAL;
-                       }
-               }
-       }
-
-       return 0;
-}
-
-int dss_mgr_check_timings(struct omap_overlay_manager *mgr,
-               const struct omap_video_timings *timings)
-{
-       if (!dispc_mgr_timings_ok(mgr->id, timings)) {
-               DSSERR("check_manager: invalid timings\n");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-static int dss_mgr_check_lcd_config(struct omap_overlay_manager *mgr,
-               const struct dss_lcd_mgr_config *config)
-{
-       struct dispc_clock_info cinfo = config->clock_info;
-       int dl = config->video_port_width;
-       bool stallmode = config->stallmode;
-       bool fifohandcheck = config->fifohandcheck;
-
-       if (cinfo.lck_div < 1 || cinfo.lck_div > 255)
-               return -EINVAL;
-
-       if (cinfo.pck_div < 1 || cinfo.pck_div > 255)
-               return -EINVAL;
-
-       if (dl != 12 && dl != 16 && dl != 18 && dl != 24)
-               return -EINVAL;
-
-       /* fifohandcheck should be used only with stallmode */
-       if (!stallmode && fifohandcheck)
-               return -EINVAL;
-
-       /*
-        * io pad mode can be only checked by using dssdev connected to the
-        * manager. Ignore checking these for now, add checks when manager
-        * is capable of holding information related to the connected interface
-        */
-
-       return 0;
-}
-
-int dss_mgr_check(struct omap_overlay_manager *mgr,
-               struct omap_overlay_manager_info *info,
-               const struct omap_video_timings *mgr_timings,
-               const struct dss_lcd_mgr_config *lcd_config,
-               struct omap_overlay_info **overlay_infos)
-{
-       struct omap_overlay *ovl;
-       int r;
-
-       if (dss_has_feature(FEAT_ALPHA_FREE_ZORDER)) {
-               r = dss_mgr_check_zorder(mgr, overlay_infos);
-               if (r)
-                       return r;
-       }
-
-       r = dss_mgr_check_timings(mgr, mgr_timings);
-       if (r)
-               return r;
-
-       r = dss_mgr_check_lcd_config(mgr, lcd_config);
-       if (r)
-               return r;
-
-       list_for_each_entry(ovl, &mgr->overlays, list) {
-               struct omap_overlay_info *oi;
-               int r;
-
-               oi = overlay_infos[ovl->id];
-
-               if (oi == NULL)
-                       continue;
-
-               r = dss_ovl_check(ovl, oi, mgr_timings);
-               if (r)
-                       return r;
-       }
-
-       return 0;
-}
diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h
new file mode 100644 (file)
index 0000000..d7e7c90
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2016 Texas Instruments
+ * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __OMAP_DRM_DSS_H
+#define __OMAP_DRM_DSS_H
+
+#include <video/omapdss.h>
+
+u32 dispc_read_irqstatus(void);
+void dispc_clear_irqstatus(u32 mask);
+u32 dispc_read_irqenable(void);
+void dispc_write_irqenable(u32 mask);
+
+int dispc_request_irq(irq_handler_t handler, void *dev_id);
+void dispc_free_irq(void *dev_id);
+
+int dispc_runtime_get(void);
+void dispc_runtime_put(void);
+
+void dispc_mgr_enable(enum omap_channel channel, bool enable);
+bool dispc_mgr_is_enabled(enum omap_channel channel);
+u32 dispc_mgr_get_vsync_irq(enum omap_channel channel);
+u32 dispc_mgr_get_framedone_irq(enum omap_channel channel);
+u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel);
+bool dispc_mgr_go_busy(enum omap_channel channel);
+void dispc_mgr_go(enum omap_channel channel);
+void dispc_mgr_set_lcd_config(enum omap_channel channel,
+               const struct dss_lcd_mgr_config *config);
+void dispc_mgr_set_timings(enum omap_channel channel,
+               const struct omap_video_timings *timings);
+void dispc_mgr_setup(enum omap_channel channel,
+               const struct omap_overlay_manager_info *info);
+
+int dispc_ovl_enable(enum omap_plane plane, bool enable);
+bool dispc_ovl_enabled(enum omap_plane plane);
+void dispc_ovl_set_channel_out(enum omap_plane plane,
+               enum omap_channel channel);
+int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
+               bool replication, const struct omap_video_timings *mgr_timings,
+               bool mem_to_mem);
+
+enum omap_dss_output_id dispc_mgr_get_supported_outputs(enum omap_channel channel);
+
+struct dss_mgr_ops {
+       int (*connect)(enum omap_channel channel,
+               struct omap_dss_device *dst);
+       void (*disconnect)(enum omap_channel channel,
+               struct omap_dss_device *dst);
+
+       void (*start_update)(enum omap_channel channel);
+       int (*enable)(enum omap_channel channel);
+       void (*disable)(enum omap_channel channel);
+       void (*set_timings)(enum omap_channel channel,
+                       const struct omap_video_timings *timings);
+       void (*set_lcd_config)(enum omap_channel channel,
+                       const struct dss_lcd_mgr_config *config);
+       int (*register_framedone_handler)(enum omap_channel channel,
+                       void (*handler)(void *), void *data);
+       void (*unregister_framedone_handler)(enum omap_channel channel,
+                       void (*handler)(void *), void *data);
+};
+
+int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops);
+void dss_uninstall_mgr_ops(void);
+
+int dss_mgr_connect(enum omap_channel channel,
+               struct omap_dss_device *dst);
+void dss_mgr_disconnect(enum omap_channel channel,
+               struct omap_dss_device *dst);
+void dss_mgr_set_timings(enum omap_channel channel,
+               const struct omap_video_timings *timings);
+void dss_mgr_set_lcd_config(enum omap_channel channel,
+               const struct dss_lcd_mgr_config *config);
+int dss_mgr_enable(enum omap_channel channel);
+void dss_mgr_disable(enum omap_channel channel);
+void dss_mgr_start_update(enum omap_channel channel);
+int dss_mgr_register_framedone_handler(enum omap_channel channel,
+               void (*handler)(void *), void *data);
+void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
+               void (*handler)(void *), void *data);
+
+#endif /* __OMAP_DRM_DSS_H */
index 1607215..829232a 100644 (file)
@@ -169,24 +169,6 @@ struct omap_dss_device *omapdss_find_output_from_display(struct omap_dss_device
 }
 EXPORT_SYMBOL(omapdss_find_output_from_display);
 
-struct omap_overlay_manager *omapdss_find_mgr_from_display(struct omap_dss_device *dssdev)
-{
-       struct omap_dss_device *out;
-       struct omap_overlay_manager *mgr;
-
-       out = omapdss_find_output_from_display(dssdev);
-
-       if (out == NULL)
-               return NULL;
-
-       mgr = out->manager;
-
-       omap_dss_put_device(out);
-
-       return mgr;
-}
-EXPORT_SYMBOL(omapdss_find_mgr_from_display);
-
 static const struct dss_mgr_ops *dss_mgr_ops;
 
 int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops)
@@ -206,62 +188,62 @@ void dss_uninstall_mgr_ops(void)
 }
 EXPORT_SYMBOL(dss_uninstall_mgr_ops);
 
-int dss_mgr_connect(struct omap_overlay_manager *mgr,
+int dss_mgr_connect(enum omap_channel channel,
                struct omap_dss_device *dst)
 {
-       return dss_mgr_ops->connect(mgr, dst);
+       return dss_mgr_ops->connect(channel, dst);
 }
 EXPORT_SYMBOL(dss_mgr_connect);
 
-void dss_mgr_disconnect(struct omap_overlay_manager *mgr,
+void dss_mgr_disconnect(enum omap_channel channel,
                struct omap_dss_device *dst)
 {
-       dss_mgr_ops->disconnect(mgr, dst);
+       dss_mgr_ops->disconnect(channel, dst);
 }
 EXPORT_SYMBOL(dss_mgr_disconnect);
 
-void dss_mgr_set_timings(struct omap_overlay_manager *mgr,
+void dss_mgr_set_timings(enum omap_channel channel,
                const struct omap_video_timings *timings)
 {
-       dss_mgr_ops->set_timings(mgr, timings);
+       dss_mgr_ops->set_timings(channel, timings);
 }
 EXPORT_SYMBOL(dss_mgr_set_timings);
 
-void dss_mgr_set_lcd_config(struct omap_overlay_manager *mgr,
+void dss_mgr_set_lcd_config(enum omap_channel channel,
                const struct dss_lcd_mgr_config *config)
 {
-       dss_mgr_ops->set_lcd_config(mgr, config);
+       dss_mgr_ops->set_lcd_config(channel, config);
 }
 EXPORT_SYMBOL(dss_mgr_set_lcd_config);
 
-int dss_mgr_enable(struct omap_overlay_manager *mgr)
+int dss_mgr_enable(enum omap_channel channel)
 {
-       return dss_mgr_ops->enable(mgr);
+       return dss_mgr_ops->enable(channel);
 }
 EXPORT_SYMBOL(dss_mgr_enable);
 
-void dss_mgr_disable(struct omap_overlay_manager *mgr)
+void dss_mgr_disable(enum omap_channel channel)
 {
-       dss_mgr_ops->disable(mgr);
+       dss_mgr_ops->disable(channel);
 }
 EXPORT_SYMBOL(dss_mgr_disable);
 
-void dss_mgr_start_update(struct omap_overlay_manager *mgr)
+void dss_mgr_start_update(enum omap_channel channel)
 {
-       dss_mgr_ops->start_update(mgr);
+       dss_mgr_ops->start_update(channel);
 }
 EXPORT_SYMBOL(dss_mgr_start_update);
 
-int dss_mgr_register_framedone_handler(struct omap_overlay_manager *mgr,
+int dss_mgr_register_framedone_handler(enum omap_channel channel,
                void (*handler)(void *), void *data)
 {
-       return dss_mgr_ops->register_framedone_handler(mgr, handler, data);
+       return dss_mgr_ops->register_framedone_handler(channel, handler, data);
 }
 EXPORT_SYMBOL(dss_mgr_register_framedone_handler);
 
-void dss_mgr_unregister_framedone_handler(struct omap_overlay_manager *mgr,
+void dss_mgr_unregister_framedone_handler(enum omap_channel channel,
                void (*handler)(void *), void *data)
 {
-       dss_mgr_ops->unregister_framedone_handler(mgr, handler, data);
+       dss_mgr_ops->unregister_framedone_handler(channel, handler, data);
 }
 EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler);
diff --git a/drivers/gpu/drm/omapdrm/dss/overlay-sysfs.c b/drivers/gpu/drm/omapdrm/dss/overlay-sysfs.c
deleted file mode 100644 (file)
index 4cc5dde..0000000
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * Copyright (C) 2009 Nokia Corporation
- * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
- *
- * Some code and ideas taken from drivers/video/omap/ driver
- * by Imre Deak.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define DSS_SUBSYS_NAME "OVERLAY"
-
-#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/sysfs.h>
-#include <linux/kobject.h>
-#include <linux/platform_device.h>
-
-#include <video/omapdss.h>
-
-#include "dss.h"
-#include "dss_features.h"
-
-static ssize_t overlay_name_show(struct omap_overlay *ovl, char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, "%s\n", ovl->name);
-}
-
-static ssize_t overlay_manager_show(struct omap_overlay *ovl, char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, "%s\n",
-                       ovl->manager ? ovl->manager->name : "<none>");
-}
-
-static ssize_t overlay_manager_store(struct omap_overlay *ovl, const char *buf,
-               size_t size)
-{
-       int i, r;
-       struct omap_overlay_manager *mgr = NULL;
-       struct omap_overlay_manager *old_mgr;
-       int len = size;
-
-       if (buf[size-1] == '\n')
-               --len;
-
-       if (len > 0) {
-               for (i = 0; i < omap_dss_get_num_overlay_managers(); ++i) {
-                       mgr = omap_dss_get_overlay_manager(i);
-
-                       if (sysfs_streq(buf, mgr->name))
-                               break;
-
-                       mgr = NULL;
-               }
-       }
-
-       if (len > 0 && mgr == NULL)
-               return -EINVAL;
-
-       if (mgr)
-               DSSDBG("manager %s found\n", mgr->name);
-
-       if (mgr == ovl->manager)
-               return size;
-
-       old_mgr = ovl->manager;
-
-       r = dispc_runtime_get();
-       if (r)
-               return r;
-
-       /* detach old manager */
-       if (old_mgr) {
-               r = ovl->unset_manager(ovl);
-               if (r) {
-                       DSSERR("detach failed\n");
-                       goto err;
-               }
-
-               r = old_mgr->apply(old_mgr);
-               if (r)
-                       goto err;
-       }
-
-       if (mgr) {
-               r = ovl->set_manager(ovl, mgr);
-               if (r) {
-                       DSSERR("Failed to attach overlay\n");
-                       goto err;
-               }
-
-               r = mgr->apply(mgr);
-               if (r)
-                       goto err;
-       }
-
-       dispc_runtime_put();
-
-       return size;
-
-err:
-       dispc_runtime_put();
-       return r;
-}
-
-static ssize_t overlay_input_size_show(struct omap_overlay *ovl, char *buf)
-{
-       struct omap_overlay_info info;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%d,%d\n",
-                       info.width, info.height);
-}
-
-static ssize_t overlay_screen_width_show(struct omap_overlay *ovl, char *buf)
-{
-       struct omap_overlay_info info;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%d\n", info.screen_width);
-}
-
-static ssize_t overlay_position_show(struct omap_overlay *ovl, char *buf)
-{
-       struct omap_overlay_info info;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%d,%d\n",
-                       info.pos_x, info.pos_y);
-}
-
-static ssize_t overlay_position_store(struct omap_overlay *ovl,
-               const char *buf, size_t size)
-{
-       int r;
-       char *last;
-       struct omap_overlay_info info;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       info.pos_x = simple_strtoul(buf, &last, 10);
-       ++last;
-       if (last - buf >= size)
-               return -EINVAL;
-
-       info.pos_y = simple_strtoul(last, &last, 10);
-
-       r = ovl->set_overlay_info(ovl, &info);
-       if (r)
-               return r;
-
-       if (ovl->manager) {
-               r = ovl->manager->apply(ovl->manager);
-               if (r)
-                       return r;
-       }
-
-       return size;
-}
-
-static ssize_t overlay_output_size_show(struct omap_overlay *ovl, char *buf)
-{
-       struct omap_overlay_info info;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%d,%d\n",
-                       info.out_width, info.out_height);
-}
-
-static ssize_t overlay_output_size_store(struct omap_overlay *ovl,
-               const char *buf, size_t size)
-{
-       int r;
-       char *last;
-       struct omap_overlay_info info;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       info.out_width = simple_strtoul(buf, &last, 10);
-       ++last;
-       if (last - buf >= size)
-               return -EINVAL;
-
-       info.out_height = simple_strtoul(last, &last, 10);
-
-       r = ovl->set_overlay_info(ovl, &info);
-       if (r)
-               return r;
-
-       if (ovl->manager) {
-               r = ovl->manager->apply(ovl->manager);
-               if (r)
-                       return r;
-       }
-
-       return size;
-}
-
-static ssize_t overlay_enabled_show(struct omap_overlay *ovl, char *buf)
-{
-       return snprintf(buf, PAGE_SIZE, "%d\n", ovl->is_enabled(ovl));
-}
-
-static ssize_t overlay_enabled_store(struct omap_overlay *ovl, const char *buf,
-               size_t size)
-{
-       int r;
-       bool enable;
-
-       r = strtobool(buf, &enable);
-       if (r)
-               return r;
-
-       if (enable)
-               r = ovl->enable(ovl);
-       else
-               r = ovl->disable(ovl);
-
-       if (r)
-               return r;
-
-       return size;
-}
-
-static ssize_t overlay_global_alpha_show(struct omap_overlay *ovl, char *buf)
-{
-       struct omap_overlay_info info;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%d\n",
-                       info.global_alpha);
-}
-
-static ssize_t overlay_global_alpha_store(struct omap_overlay *ovl,
-               const char *buf, size_t size)
-{
-       int r;
-       u8 alpha;
-       struct omap_overlay_info info;
-
-       if ((ovl->caps & OMAP_DSS_OVL_CAP_GLOBAL_ALPHA) == 0)
-               return -ENODEV;
-
-       r = kstrtou8(buf, 0, &alpha);
-       if (r)
-               return r;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       info.global_alpha = alpha;
-
-       r = ovl->set_overlay_info(ovl, &info);
-       if (r)
-               return r;
-
-       if (ovl->manager) {
-               r = ovl->manager->apply(ovl->manager);
-               if (r)
-                       return r;
-       }
-
-       return size;
-}
-
-static ssize_t overlay_pre_mult_alpha_show(struct omap_overlay *ovl,
-               char *buf)
-{
-       struct omap_overlay_info info;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%d\n",
-                       info.pre_mult_alpha);
-}
-
-static ssize_t overlay_pre_mult_alpha_store(struct omap_overlay *ovl,
-               const char *buf, size_t size)
-{
-       int r;
-       u8 alpha;
-       struct omap_overlay_info info;
-
-       if ((ovl->caps & OMAP_DSS_OVL_CAP_PRE_MULT_ALPHA) == 0)
-               return -ENODEV;
-
-       r = kstrtou8(buf, 0, &alpha);
-       if (r)
-               return r;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       info.pre_mult_alpha = alpha;
-
-       r = ovl->set_overlay_info(ovl, &info);
-       if (r)
-               return r;
-
-       if (ovl->manager) {
-               r = ovl->manager->apply(ovl->manager);
-               if (r)
-                       return r;
-       }
-
-       return size;
-}
-
-static ssize_t overlay_zorder_show(struct omap_overlay *ovl, char *buf)
-{
-       struct omap_overlay_info info;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       return snprintf(buf, PAGE_SIZE, "%d\n", info.zorder);
-}
-
-static ssize_t overlay_zorder_store(struct omap_overlay *ovl,
-               const char *buf, size_t size)
-{
-       int r;
-       u8 zorder;
-       struct omap_overlay_info info;
-
-       if ((ovl->caps & OMAP_DSS_OVL_CAP_ZORDER) == 0)
-               return -ENODEV;
-
-       r = kstrtou8(buf, 0, &zorder);
-       if (r)
-               return r;
-
-       ovl->get_overlay_info(ovl, &info);
-
-       info.zorder = zorder;
-
-       r = ovl->set_overlay_info(ovl, &info);
-       if (r)
-               return r;
-
-       if (ovl->manager) {
-               r = ovl->manager->apply(ovl->manager);
-               if (r)
-                       return r;
-       }
-
-       return size;
-}
-
-struct overlay_attribute {
-       struct attribute attr;
-       ssize_t (*show)(struct omap_overlay *, char *);
-       ssize_t (*store)(struct omap_overlay *, const char *, size_t);
-};
-
-#define OVERLAY_ATTR(_name, _mode, _show, _store) \
-       struct overlay_attribute overlay_attr_##_name = \
-       __ATTR(_name, _mode, _show, _store)
-
-static OVERLAY_ATTR(name, S_IRUGO, overlay_name_show, NULL);
-static OVERLAY_ATTR(manager, S_IRUGO|S_IWUSR,
-               overlay_manager_show, overlay_manager_store);
-static OVERLAY_ATTR(input_size, S_IRUGO, overlay_input_size_show, NULL);
-static OVERLAY_ATTR(screen_width, S_IRUGO, overlay_screen_width_show, NULL);
-static OVERLAY_ATTR(position, S_IRUGO|S_IWUSR,
-               overlay_position_show, overlay_position_store);
-static OVERLAY_ATTR(output_size, S_IRUGO|S_IWUSR,
-               overlay_output_size_show, overlay_output_size_store);
-static OVERLAY_ATTR(enabled, S_IRUGO|S_IWUSR,
-               overlay_enabled_show, overlay_enabled_store);
-static OVERLAY_ATTR(global_alpha, S_IRUGO|S_IWUSR,
-               overlay_global_alpha_show, overlay_global_alpha_store);
-static OVERLAY_ATTR(pre_mult_alpha, S_IRUGO|S_IWUSR,
-               overlay_pre_mult_alpha_show,
-               overlay_pre_mult_alpha_store);
-static OVERLAY_ATTR(zorder, S_IRUGO|S_IWUSR,
-               overlay_zorder_show, overlay_zorder_store);
-
-static struct attribute *overlay_sysfs_attrs[] = {
-       &overlay_attr_name.attr,
-       &overlay_attr_manager.attr,
-       &overlay_attr_input_size.attr,
-       &overlay_attr_screen_width.attr,
-       &overlay_attr_position.attr,
-       &overlay_attr_output_size.attr,
-       &overlay_attr_enabled.attr,
-       &overlay_attr_global_alpha.attr,
-       &overlay_attr_pre_mult_alpha.attr,
-       &overlay_attr_zorder.attr,
-       NULL
-};
-
-static ssize_t overlay_attr_show(struct kobject *kobj, struct attribute *attr,
-               char *buf)
-{
-       struct omap_overlay *overlay;
-       struct overlay_attribute *overlay_attr;
-
-       overlay = container_of(kobj, struct omap_overlay, kobj);
-       overlay_attr = container_of(attr, struct overlay_attribute, attr);
-
-       if (!overlay_attr->show)
-               return -ENOENT;
-
-       return overlay_attr->show(overlay, buf);
-}
-
-static ssize_t overlay_attr_store(struct kobject *kobj, struct attribute *attr,
-               const char *buf, size_t size)
-{
-       struct omap_overlay *overlay;
-       struct overlay_attribute *overlay_attr;
-
-       overlay = container_of(kobj, struct omap_overlay, kobj);
-       overlay_attr = container_of(attr, struct overlay_attribute, attr);
-
-       if (!overlay_attr->store)
-               return -ENOENT;
-
-       return overlay_attr->store(overlay, buf, size);
-}
-
-static const struct sysfs_ops overlay_sysfs_ops = {
-       .show = overlay_attr_show,
-       .store = overlay_attr_store,
-};
-
-static struct kobj_type overlay_ktype = {
-       .sysfs_ops = &overlay_sysfs_ops,
-       .default_attrs = overlay_sysfs_attrs,
-};
-
-int dss_overlay_kobj_init(struct omap_overlay *ovl,
-               struct platform_device *pdev)
-{
-       return kobject_init_and_add(&ovl->kobj, &overlay_ktype,
-                       &pdev->dev.kobj, "overlay%d", ovl->id);
-}
-
-void dss_overlay_kobj_uninit(struct omap_overlay *ovl)
-{
-       kobject_del(&ovl->kobj);
-       kobject_put(&ovl->kobj);
-}
diff --git a/drivers/gpu/drm/omapdrm/dss/overlay.c b/drivers/gpu/drm/omapdrm/dss/overlay.c
deleted file mode 100644 (file)
index 2f7cee9..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * linux/drivers/video/omap2/dss/overlay.c
- *
- * Copyright (C) 2009 Nokia Corporation
- * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
- *
- * Some code and ideas taken from drivers/video/omap/ driver
- * by Imre Deak.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define DSS_SUBSYS_NAME "OVERLAY"
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/err.h>
-#include <linux/sysfs.h>
-#include <linux/platform_device.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-
-#include <video/omapdss.h>
-
-#include "dss.h"
-#include "dss_features.h"
-
-static int num_overlays;
-static struct omap_overlay *overlays;
-
-int omap_dss_get_num_overlays(void)
-{
-       return num_overlays;
-}
-EXPORT_SYMBOL(omap_dss_get_num_overlays);
-
-struct omap_overlay *omap_dss_get_overlay(int num)
-{
-       if (num >= num_overlays)
-               return NULL;
-
-       return &overlays[num];
-}
-EXPORT_SYMBOL(omap_dss_get_overlay);
-
-void dss_init_overlays(struct platform_device *pdev)
-{
-       int i, r;
-
-       num_overlays = dss_feat_get_num_ovls();
-
-       overlays = kzalloc(sizeof(struct omap_overlay) * num_overlays,
-                       GFP_KERNEL);
-
-       BUG_ON(overlays == NULL);
-
-       for (i = 0; i < num_overlays; ++i) {
-               struct omap_overlay *ovl = &overlays[i];
-
-               switch (i) {
-               case 0:
-                       ovl->name = "gfx";
-                       ovl->id = OMAP_DSS_GFX;
-                       break;
-               case 1:
-                       ovl->name = "vid1";
-                       ovl->id = OMAP_DSS_VIDEO1;
-                       break;
-               case 2:
-                       ovl->name = "vid2";
-                       ovl->id = OMAP_DSS_VIDEO2;
-                       break;
-               case 3:
-                       ovl->name = "vid3";
-                       ovl->id = OMAP_DSS_VIDEO3;
-                       break;
-               }
-
-               ovl->caps = dss_feat_get_overlay_caps(ovl->id);
-               ovl->supported_modes =
-                       dss_feat_get_supported_color_modes(ovl->id);
-
-               r = dss_overlay_kobj_init(ovl, pdev);
-               if (r)
-                       DSSERR("failed to create sysfs file\n");
-       }
-}
-
-void dss_uninit_overlays(struct platform_device *pdev)
-{
-       int i;
-
-       for (i = 0; i < num_overlays; ++i) {
-               struct omap_overlay *ovl = &overlays[i];
-               dss_overlay_kobj_uninit(ovl);
-       }
-
-       kfree(overlays);
-       overlays = NULL;
-       num_overlays = 0;
-}
-
-int dss_ovl_simple_check(struct omap_overlay *ovl,
-               const struct omap_overlay_info *info)
-{
-       if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) {
-               if (info->out_width != 0 && info->width != info->out_width) {
-                       DSSERR("check_overlay: overlay %d doesn't support "
-                                       "scaling\n", ovl->id);
-                       return -EINVAL;
-               }
-
-               if (info->out_height != 0 && info->height != info->out_height) {
-                       DSSERR("check_overlay: overlay %d doesn't support "
-                                       "scaling\n", ovl->id);
-                       return -EINVAL;
-               }
-       }
-
-       if ((ovl->supported_modes & info->color_mode) == 0) {
-               DSSERR("check_overlay: overlay %d doesn't support mode %d\n",
-                               ovl->id, info->color_mode);
-               return -EINVAL;
-       }
-
-       if (info->zorder >= omap_dss_get_num_overlays()) {
-               DSSERR("check_overlay: zorder %d too high\n", info->zorder);
-               return -EINVAL;
-       }
-
-       if (dss_feat_rotation_type_supported(info->rotation_type) == 0) {
-               DSSERR("check_overlay: rotation type %d not supported\n",
-                               info->rotation_type);
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-int dss_ovl_check(struct omap_overlay *ovl, struct omap_overlay_info *info,
-               const struct omap_video_timings *mgr_timings)
-{
-       u16 outw, outh;
-       u16 dw, dh;
-
-       dw = mgr_timings->x_res;
-       dh = mgr_timings->y_res;
-
-       if ((ovl->caps & OMAP_DSS_OVL_CAP_SCALE) == 0) {
-               outw = info->width;
-               outh = info->height;
-       } else {
-               if (info->out_width == 0)
-                       outw = info->width;
-               else
-                       outw = info->out_width;
-
-               if (info->out_height == 0)
-                       outh = info->height;
-               else
-                       outh = info->out_height;
-       }
-
-       if (dw < info->pos_x + outw) {
-               DSSERR("overlay %d horizontally not inside the display area "
-                               "(%d + %d >= %d)\n",
-                               ovl->id, info->pos_x, outw, dw);
-               return -EINVAL;
-       }
-
-       if (dh < info->pos_y + outh) {
-               DSSERR("overlay %d vertically not inside the display area "
-                               "(%d + %d >= %d)\n",
-                               ovl->id, info->pos_y, outh, dh);
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
-/*
- * Checks if replication logic should be used. Only use when overlay is in
- * RGB12U or RGB16 mode, and video port width interface is 18bpp or 24bpp
- */
-bool dss_ovl_use_replication(struct dss_lcd_mgr_config config,
-               enum omap_color_mode mode)
-{
-       if (mode != OMAP_DSS_COLOR_RGB12U && mode != OMAP_DSS_COLOR_RGB16)
-               return false;
-
-       return config.video_port_width > 16;
-}
index aea6a1d..3796576 100644 (file)
@@ -880,7 +880,7 @@ static int rfbi_display_enable(struct omap_dss_device *dssdev)
        struct omap_dss_device *out = &rfbi.output;
        int r;
 
-       if (out->manager == NULL) {
+       if (!out->dispc_channel_connected) {
                DSSERR("failed to enable display: no output/manager\n");
                return -ENODEV;
        }
index d747cc6..cd6d3bf 100644 (file)
@@ -114,7 +114,7 @@ static int sdi_calc_clock_div(unsigned long pclk,
 
 static void sdi_config_lcd_manager(struct omap_dss_device *dssdev)
 {
-       struct omap_overlay_manager *mgr = sdi.output.manager;
+       enum omap_channel channel = dssdev->dispc_channel;
 
        sdi.mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
 
@@ -124,19 +124,20 @@ static void sdi_config_lcd_manager(struct omap_dss_device *dssdev)
        sdi.mgr_config.video_port_width = 24;
        sdi.mgr_config.lcden_sig_polarity = 1;
 
-       dss_mgr_set_lcd_config(mgr, &sdi.mgr_config);
+       dss_mgr_set_lcd_config(channel, &sdi.mgr_config);
 }
 
 static int sdi_display_enable(struct omap_dss_device *dssdev)
 {
        struct omap_dss_device *out = &sdi.output;
+       enum omap_channel channel = dssdev->dispc_channel;
        struct omap_video_timings *t = &sdi.timings;
        unsigned long fck;
        struct dispc_clock_info dispc_cinfo;
        unsigned long pck;
        int r;
 
-       if (out->manager == NULL) {
+       if (!out->dispc_channel_connected) {
                DSSERR("failed to enable display: no output/manager\n");
                return -ENODEV;
        }
@@ -169,7 +170,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
        }
 
 
-       dss_mgr_set_timings(out->manager, t);
+       dss_mgr_set_timings(channel, t);
 
        r = dss_set_fck_rate(fck);
        if (r)
@@ -188,7 +189,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
         * need to care about the shadow register mechanism for pck-free. The
         * exact reason for this is unknown.
         */
-       dispc_mgr_set_clock_div(out->manager->id, &sdi.mgr_config.clock_info);
+       dispc_mgr_set_clock_div(channel, &sdi.mgr_config.clock_info);
 
        dss_sdi_init(sdi.datapairs);
        r = dss_sdi_enable();
@@ -196,7 +197,7 @@ static int sdi_display_enable(struct omap_dss_device *dssdev)
                goto err_sdi_enable;
        mdelay(2);
 
-       r = dss_mgr_enable(out->manager);
+       r = dss_mgr_enable(channel);
        if (r)
                goto err_mgr_enable;
 
@@ -216,9 +217,9 @@ err_reg_enable:
 
 static void sdi_display_disable(struct omap_dss_device *dssdev)
 {
-       struct omap_overlay_manager *mgr = sdi.output.manager;
+       enum omap_channel channel = dssdev->dispc_channel;
 
-       dss_mgr_disable(mgr);
+       dss_mgr_disable(channel);
 
        dss_sdi_disable();
 
@@ -242,9 +243,9 @@ static void sdi_get_timings(struct omap_dss_device *dssdev,
 static int sdi_check_timings(struct omap_dss_device *dssdev,
                        struct omap_video_timings *timings)
 {
-       struct omap_overlay_manager *mgr = sdi.output.manager;
+       enum omap_channel channel = dssdev->dispc_channel;
 
-       if (mgr && !dispc_mgr_timings_ok(mgr->id, timings))
+       if (!dispc_mgr_timings_ok(channel, timings))
                return -EINVAL;
 
        if (timings->pixelclock == 0)
@@ -280,18 +281,14 @@ static int sdi_init_regulator(void)
 static int sdi_connect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
-       struct omap_overlay_manager *mgr;
+       enum omap_channel channel = dssdev->dispc_channel;
        int r;
 
        r = sdi_init_regulator();
        if (r)
                return r;
 
-       mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
-       if (!mgr)
-               return -ENODEV;
-
-       r = dss_mgr_connect(mgr, dssdev);
+       r = dss_mgr_connect(channel, dssdev);
        if (r)
                return r;
 
@@ -299,7 +296,7 @@ static int sdi_connect(struct omap_dss_device *dssdev,
        if (r) {
                DSSERR("failed to connect output to new device: %s\n",
                                dst->name);
-               dss_mgr_disconnect(mgr, dssdev);
+               dss_mgr_disconnect(channel, dssdev);
                return r;
        }
 
@@ -309,6 +306,8 @@ static int sdi_connect(struct omap_dss_device *dssdev,
 static void sdi_disconnect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
+       enum omap_channel channel = dssdev->dispc_channel;
+
        WARN_ON(dst != dssdev->dst);
 
        if (dst != dssdev->dst)
@@ -316,8 +315,7 @@ static void sdi_disconnect(struct omap_dss_device *dssdev,
 
        omapdss_output_unset_device(dssdev);
 
-       if (dssdev->manager)
-               dss_mgr_disconnect(dssdev->manager, dssdev);
+       dss_mgr_disconnect(channel, dssdev);
 }
 
 static const struct omapdss_sdi_ops sdi_ops = {
index 08f9def..08a2cc7 100644 (file)
@@ -443,7 +443,7 @@ static const struct venc_config *venc_timings_to_config(
 
 static int venc_power_on(struct omap_dss_device *dssdev)
 {
-       struct omap_overlay_manager *mgr = venc.output.manager;
+       enum omap_channel channel = dssdev->dispc_channel;
        u32 l;
        int r;
 
@@ -469,13 +469,13 @@ static int venc_power_on(struct omap_dss_device *dssdev)
 
        venc_write_reg(VENC_OUTPUT_CONTROL, l);
 
-       dss_mgr_set_timings(mgr, &venc.timings);
+       dss_mgr_set_timings(channel, &venc.timings);
 
        r = regulator_enable(venc.vdda_dac_reg);
        if (r)
                goto err1;
 
-       r = dss_mgr_enable(mgr);
+       r = dss_mgr_enable(channel);
        if (r)
                goto err2;
 
@@ -494,12 +494,12 @@ err0:
 
 static void venc_power_off(struct omap_dss_device *dssdev)
 {
-       struct omap_overlay_manager *mgr = venc.output.manager;
+       enum omap_channel channel = dssdev->dispc_channel;
 
        venc_write_reg(VENC_OUTPUT_CONTROL, 0);
        dss_set_dac_pwrdn_bgz(0);
 
-       dss_mgr_disable(mgr);
+       dss_mgr_disable(channel);
 
        regulator_disable(venc.vdda_dac_reg);
 
@@ -515,7 +515,7 @@ static int venc_display_enable(struct omap_dss_device *dssdev)
 
        mutex_lock(&venc.venc_lock);
 
-       if (out->manager == NULL) {
+       if (!out->dispc_channel_connected) {
                DSSERR("Failed to enable display: no output/manager\n");
                r = -ENODEV;
                goto err0;
@@ -742,18 +742,14 @@ static int venc_get_clocks(struct platform_device *pdev)
 static int venc_connect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
-       struct omap_overlay_manager *mgr;
+       enum omap_channel channel = dssdev->dispc_channel;
        int r;
 
        r = venc_init_regulator();
        if (r)
                return r;
 
-       mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
-       if (!mgr)
-               return -ENODEV;
-
-       r = dss_mgr_connect(mgr, dssdev);
+       r = dss_mgr_connect(channel, dssdev);
        if (r)
                return r;
 
@@ -761,7 +757,7 @@ static int venc_connect(struct omap_dss_device *dssdev,
        if (r) {
                DSSERR("failed to connect output to new device: %s\n",
                                dst->name);
-               dss_mgr_disconnect(mgr, dssdev);
+               dss_mgr_disconnect(channel, dssdev);
                return r;
        }
 
@@ -771,6 +767,8 @@ static int venc_connect(struct omap_dss_device *dssdev,
 static void venc_disconnect(struct omap_dss_device *dssdev,
                struct omap_dss_device *dst)
 {
+       enum omap_channel channel = dssdev->dispc_channel;
+
        WARN_ON(dst != dssdev->dst);
 
        if (dst != dssdev->dst)
@@ -778,8 +776,7 @@ static void venc_disconnect(struct omap_dss_device *dssdev,
 
        omapdss_output_unset_device(dssdev);
 
-       if (dssdev->manager)
-               dss_mgr_disconnect(dssdev->manager, dssdev);
+       dss_mgr_disconnect(channel, dssdev);
 }
 
 static const struct omapdss_atv_ops venc_ops = {
index 83f2a91..ce2d67b 100644 (file)
@@ -63,6 +63,9 @@ void copy_timings_omap_to_drm(struct drm_display_mode *mode,
        if (timings->interlace)
                mode->flags |= DRM_MODE_FLAG_INTERLACE;
 
+       if (timings->double_pixel)
+               mode->flags |= DRM_MODE_FLAG_DBLCLK;
+
        if (timings->hsync_level == OMAPDSS_SIG_ACTIVE_HIGH)
                mode->flags |= DRM_MODE_FLAG_PHSYNC;
        else
@@ -90,6 +93,7 @@ void copy_timings_drm_to_omap(struct omap_video_timings *timings,
        timings->vbp = mode->vtotal - mode->vsync_end;
 
        timings->interlace = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
+       timings->double_pixel = !!(mode->flags & DRM_MODE_FLAG_DBLCLK);
 
        if (mode->flags & DRM_MODE_FLAG_PHSYNC)
                timings->hsync_level = OMAPDSS_SIG_ACTIVE_HIGH;
index d38fcbc..075f2bb 100644 (file)
@@ -34,14 +34,6 @@ struct omap_crtc {
        const char *name;
        enum omap_channel channel;
 
-       /*
-        * Temporary: eventually this will go away, but it is needed
-        * for now to keep the output's happy.  (They only need
-        * mgr->id.)  Eventually this will be replaced w/ something
-        * more common-panel-framework-y
-        */
-       struct omap_overlay_manager *mgr;
-
        struct omap_video_timings timings;
 
        struct omap_drm_irq vblank_irq;
@@ -80,9 +72,13 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
 {
        struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
 
+       /*
+        * Timeout is set to a "sufficiently" high value, which should cover
+        * a single frame refresh even on slower displays.
+        */
        return wait_event_timeout(omap_crtc->pending_wait,
                                  !omap_crtc->pending,
-                                 msecs_to_jiffies(50));
+                                 msecs_to_jiffies(250));
 }
 
 /* -----------------------------------------------------------------------------
@@ -100,31 +96,32 @@ int omap_crtc_wait_pending(struct drm_crtc *crtc)
 
 /* ovl-mgr-id -> crtc */
 static struct omap_crtc *omap_crtcs[8];
+static struct omap_dss_device *omap_crtc_output[8];
 
 /* we can probably ignore these until we support command-mode panels: */
-static int omap_crtc_dss_connect(struct omap_overlay_manager *mgr,
+static int omap_crtc_dss_connect(enum omap_channel channel,
                struct omap_dss_device *dst)
 {
-       if (mgr->output)
+       if (omap_crtc_output[channel])
                return -EINVAL;
 
-       if ((mgr->supported_outputs & dst->id) == 0)
+       if ((dispc_mgr_get_supported_outputs(channel) & dst->id) == 0)
                return -EINVAL;
 
-       dst->manager = mgr;
-       mgr->output = dst;
+       omap_crtc_output[channel] = dst;
+       dst->dispc_channel_connected = true;
 
        return 0;
 }
 
-static void omap_crtc_dss_disconnect(struct omap_overlay_manager *mgr,
+static void omap_crtc_dss_disconnect(enum omap_channel channel,
                struct omap_dss_device *dst)
 {
-       mgr->output->manager = NULL;
-       mgr->output = NULL;
+       omap_crtc_output[channel] = NULL;
+       dst->dispc_channel_connected = false;
 }
 
-static void omap_crtc_dss_start_update(struct omap_overlay_manager *mgr)
+static void omap_crtc_dss_start_update(enum omap_channel channel)
 {
 }
 
@@ -138,6 +135,11 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
        u32 framedone_irq, vsync_irq;
        int ret;
 
+       if (omap_crtc_output[channel]->output_type == OMAP_DISPLAY_TYPE_HDMI) {
+               dispc_mgr_enable(channel, enable);
+               return;
+       }
+
        if (dispc_mgr_is_enabled(channel) == enable)
                return;
 
@@ -186,9 +188,9 @@ static void omap_crtc_set_enabled(struct drm_crtc *crtc, bool enable)
 }
 
 
-static int omap_crtc_dss_enable(struct omap_overlay_manager *mgr)
+static int omap_crtc_dss_enable(enum omap_channel channel)
 {
-       struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
+       struct omap_crtc *omap_crtc = omap_crtcs[channel];
        struct omap_overlay_manager_info info;
 
        memset(&info, 0, sizeof(info));
@@ -205,38 +207,38 @@ static int omap_crtc_dss_enable(struct omap_overlay_manager *mgr)
        return 0;
 }
 
-static void omap_crtc_dss_disable(struct omap_overlay_manager *mgr)
+static void omap_crtc_dss_disable(enum omap_channel channel)
 {
-       struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
+       struct omap_crtc *omap_crtc = omap_crtcs[channel];
 
        omap_crtc_set_enabled(&omap_crtc->base, false);
 }
 
-static void omap_crtc_dss_set_timings(struct omap_overlay_manager *mgr,
+static void omap_crtc_dss_set_timings(enum omap_channel channel,
                const struct omap_video_timings *timings)
 {
-       struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
+       struct omap_crtc *omap_crtc = omap_crtcs[channel];
        DBG("%s", omap_crtc->name);
        omap_crtc->timings = *timings;
 }
 
-static void omap_crtc_dss_set_lcd_config(struct omap_overlay_manager *mgr,
+static void omap_crtc_dss_set_lcd_config(enum omap_channel channel,
                const struct dss_lcd_mgr_config *config)
 {
-       struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
+       struct omap_crtc *omap_crtc = omap_crtcs[channel];
        DBG("%s", omap_crtc->name);
        dispc_mgr_set_lcd_config(omap_crtc->channel, config);
 }
 
 static int omap_crtc_dss_register_framedone(
-               struct omap_overlay_manager *mgr,
+               enum omap_channel channel,
                void (*handler)(void *), void *data)
 {
        return 0;
 }
 
 static void omap_crtc_dss_unregister_framedone(
-               struct omap_overlay_manager *mgr,
+               enum omap_channel channel,
                void (*handler)(void *), void *data)
 {
 }
@@ -330,13 +332,6 @@ static void omap_crtc_destroy(struct drm_crtc *crtc)
        kfree(omap_crtc);
 }
 
-static bool omap_crtc_mode_fixup(struct drm_crtc *crtc,
-               const struct drm_display_mode *mode,
-               struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 static void omap_crtc_enable(struct drm_crtc *crtc)
 {
        struct omap_crtc *omap_crtc = to_omap_crtc(crtc);
@@ -403,24 +398,40 @@ static void omap_crtc_atomic_flush(struct drm_crtc *crtc,
        }
 }
 
+static bool omap_crtc_is_plane_prop(struct drm_device *dev,
+       struct drm_property *property)
+{
+       struct omap_drm_private *priv = dev->dev_private;
+
+       return property == priv->zorder_prop ||
+               property == dev->mode_config.rotation_property;
+}
+
 static int omap_crtc_atomic_set_property(struct drm_crtc *crtc,
                                         struct drm_crtc_state *state,
                                         struct drm_property *property,
                                         uint64_t val)
 {
-       struct drm_plane_state *plane_state;
-       struct drm_plane *plane = crtc->primary;
+       struct drm_device *dev = crtc->dev;
 
-       /*
-        * Delegate property set to the primary plane. Get the plane state and
-        * set the property directly.
-        */
+       if (omap_crtc_is_plane_prop(dev, property)) {
+               struct drm_plane_state *plane_state;
+               struct drm_plane *plane = crtc->primary;
 
-       plane_state = drm_atomic_get_plane_state(state->state, plane);
-       if (!plane_state)
-               return -EINVAL;
+               /*
+                * Delegate property set to the primary plane. Get the plane
+                * state and set the property directly.
+                */
 
-       return drm_atomic_plane_set_property(plane, plane_state, property, val);
+               plane_state = drm_atomic_get_plane_state(state->state, plane);
+               if (IS_ERR(plane_state))
+                       return PTR_ERR(plane_state);
+
+               return drm_atomic_plane_set_property(plane, plane_state,
+                               property, val);
+       }
+
+       return -EINVAL;
 }
 
 static int omap_crtc_atomic_get_property(struct drm_crtc *crtc,
@@ -428,14 +439,20 @@ static int omap_crtc_atomic_get_property(struct drm_crtc *crtc,
                                         struct drm_property *property,
                                         uint64_t *val)
 {
-       /*
-        * Delegate property get to the primary plane. The
-        * drm_atomic_plane_get_property() function isn't exported, but can be
-        * called through drm_object_property_get_value() as that will call
-        * drm_atomic_get_property() for atomic drivers.
-        */
-       return drm_object_property_get_value(&crtc->primary->base, property,
-                                            val);
+       struct drm_device *dev = crtc->dev;
+
+       if (omap_crtc_is_plane_prop(dev, property)) {
+               /*
+                * Delegate property get to the primary plane. The
+                * drm_atomic_plane_get_property() function isn't exported, but
+                * can be called through drm_object_property_get_value() as that
+                * will call drm_atomic_get_property() for atomic drivers.
+                */
+               return drm_object_property_get_value(&crtc->primary->base,
+                               property, val);
+       }
+
+       return -EINVAL;
 }
 
 static const struct drm_crtc_funcs omap_crtc_funcs = {
@@ -451,7 +468,6 @@ static const struct drm_crtc_funcs omap_crtc_funcs = {
 };
 
 static const struct drm_crtc_helper_funcs omap_crtc_helper_funcs = {
-       .mode_fixup = omap_crtc_mode_fixup,
        .mode_set_nofb = omap_crtc_mode_set_nofb,
        .disable = omap_crtc_disable,
        .enable = omap_crtc_enable,
@@ -509,9 +525,6 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
        omap_crtc->error_irq.irq = omap_crtc_error_irq;
        omap_irq_register(dev, &omap_crtc->error_irq);
 
-       /* temporary: */
-       omap_crtc->mgr = omap_dss_get_overlay_manager(channel);
-
        ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL,
                                        &omap_crtc_funcs, NULL);
        if (ret < 0) {
index dfebdc4..9f94576 100644 (file)
@@ -79,6 +79,16 @@ static const uint32_t reg[][4] = {
                        DMM_PAT_DESCR__2, DMM_PAT_DESCR__3},
 };
 
+static u32 dmm_read(struct dmm *dmm, u32 reg)
+{
+       return readl(dmm->base + reg);
+}
+
+static void dmm_write(struct dmm *dmm, u32 val, u32 reg)
+{
+       writel(val, dmm->base + reg);
+}
+
 /* simple allocator to grab next 16 byte aligned memory from txn */
 static void *alloc_dma(struct dmm_txn *txn, size_t sz, dma_addr_t *pa)
 {
@@ -108,7 +118,7 @@ static int wait_status(struct refill_engine *engine, uint32_t wait_mask)
 
        i = DMM_FIXED_RETRY_COUNT;
        while (true) {
-               r = readl(dmm->base + reg[PAT_STATUS][engine->id]);
+               r = dmm_read(dmm, reg[PAT_STATUS][engine->id]);
                err = r & DMM_PATSTATUS_ERR;
                if (err)
                        return -EFAULT;
@@ -140,11 +150,11 @@ static void release_engine(struct refill_engine *engine)
 static irqreturn_t omap_dmm_irq_handler(int irq, void *arg)
 {
        struct dmm *dmm = arg;
-       uint32_t status = readl(dmm->base + DMM_PAT_IRQSTATUS);
+       uint32_t status = dmm_read(dmm, DMM_PAT_IRQSTATUS);
        int i;
 
        /* ack IRQ */
-       writel(status, dmm->base + DMM_PAT_IRQSTATUS);
+       dmm_write(dmm, status, DMM_PAT_IRQSTATUS);
 
        for (i = 0; i < dmm->num_engines; i++) {
                if (status & DMM_IRQSTAT_LST) {
@@ -264,7 +274,7 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait)
        txn->last_pat->next_pa = 0;
 
        /* write to PAT_DESCR to clear out any pending transaction */
-       writel(0x0, dmm->base + reg[PAT_DESCR][engine->id]);
+       dmm_write(dmm, 0x0, reg[PAT_DESCR][engine->id]);
 
        /* wait for engine ready: */
        ret = wait_status(engine, DMM_PATSTATUS_READY);
@@ -280,8 +290,7 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait)
        smp_mb();
 
        /* kick reload */
-       writel(engine->refill_pa,
-               dmm->base + reg[PAT_DESCR][engine->id]);
+       dmm_write(dmm, engine->refill_pa, reg[PAT_DESCR][engine->id]);
 
        if (wait) {
                if (!wait_for_completion_timeout(&engine->compl,
@@ -309,6 +318,21 @@ static int fill(struct tcm_area *area, struct page **pages,
        struct tcm_area slice, area_s;
        struct dmm_txn *txn;
 
+       /*
+        * FIXME
+        *
+        * Asynchronous fill does not work reliably, as the driver does not
+        * handle errors in the async code paths. The fill operation may
+        * silently fail, leading to leaking DMM engines, which may eventually
+        * lead to deadlock if we run out of DMM engines.
+        *
+        * For now, always set 'wait' so that we only use sync fills. Async
+        * fills should be fixed, or alternatively we could decide to only
+        * support sync fills and so the whole async code path could be removed.
+        */
+
+       wait = true;
+
        txn = dmm_txn_init(omap_dmm, area->tcm);
        if (IS_ERR_OR_NULL(txn))
                return -ENOMEM;
@@ -642,7 +666,7 @@ static int omap_dmm_probe(struct platform_device *dev)
 
        omap_dmm->dev = &dev->dev;
 
-       hwinfo = readl(omap_dmm->base + DMM_PAT_HWINFO);
+       hwinfo = dmm_read(omap_dmm, DMM_PAT_HWINFO);
        omap_dmm->num_engines = (hwinfo >> 24) & 0x1F;
        omap_dmm->num_lut = (hwinfo >> 16) & 0x1F;
        omap_dmm->container_width = 256;
@@ -651,7 +675,7 @@ static int omap_dmm_probe(struct platform_device *dev)
        atomic_set(&omap_dmm->engine_counter, omap_dmm->num_engines);
 
        /* read out actual LUT width and height */
-       pat_geom = readl(omap_dmm->base + DMM_PAT_GEOMETRY);
+       pat_geom = dmm_read(omap_dmm, DMM_PAT_GEOMETRY);
        omap_dmm->lut_width = ((pat_geom >> 16) & 0xF) << 5;
        omap_dmm->lut_height = ((pat_geom >> 24) & 0xF) << 5;
 
@@ -661,12 +685,12 @@ static int omap_dmm_probe(struct platform_device *dev)
                omap_dmm->num_lut++;
 
        /* initialize DMM registers */
-       writel(0x88888888, omap_dmm->base + DMM_PAT_VIEW__0);
-       writel(0x88888888, omap_dmm->base + DMM_PAT_VIEW__1);
-       writel(0x80808080, omap_dmm->base + DMM_PAT_VIEW_MAP__0);
-       writel(0x80000000, omap_dmm->base + DMM_PAT_VIEW_MAP_BASE);
-       writel(0x88888888, omap_dmm->base + DMM_TILER_OR__0);
-       writel(0x88888888, omap_dmm->base + DMM_TILER_OR__1);
+       dmm_write(omap_dmm, 0x88888888, DMM_PAT_VIEW__0);
+       dmm_write(omap_dmm, 0x88888888, DMM_PAT_VIEW__1);
+       dmm_write(omap_dmm, 0x80808080, DMM_PAT_VIEW_MAP__0);
+       dmm_write(omap_dmm, 0x80000000, DMM_PAT_VIEW_MAP_BASE);
+       dmm_write(omap_dmm, 0x88888888, DMM_TILER_OR__0);
+       dmm_write(omap_dmm, 0x88888888, DMM_TILER_OR__1);
 
        ret = request_irq(omap_dmm->irq, omap_dmm_irq_handler, IRQF_SHARED,
                                "omap_dmm_irq_handler", omap_dmm);
@@ -684,7 +708,7 @@ static int omap_dmm_probe(struct platform_device *dev)
         * buffers for accelerated pan/scroll) and FILL_DSC<n> which
         * we just generally don't care about.
         */
-       writel(0x7e7e7e7e, omap_dmm->base + DMM_PAT_IRQENABLE_SET);
+       dmm_write(omap_dmm, 0x7e7e7e7e, DMM_PAT_IRQENABLE_SET);
 
        omap_dmm->dummy_page = alloc_page(GFP_KERNEL | __GFP_DMA32);
        if (!omap_dmm->dummy_page) {
index 33370f4..80398a6 100644 (file)
@@ -340,7 +340,7 @@ static int omap_modeset_init(struct drm_device *dev)
                struct drm_connector *connector;
                struct drm_encoder *encoder;
                enum omap_channel channel;
-               struct omap_overlay_manager *mgr;
+               struct omap_dss_device *out;
 
                if (!omapdss_device_is_connected(dssdev))
                        continue;
@@ -387,8 +387,10 @@ static int omap_modeset_init(struct drm_device *dev)
                 * not considered.
                 */
 
-               mgr = omapdss_find_mgr_from_display(dssdev);
-               channel = mgr->id;
+               out = omapdss_find_output_from_display(dssdev);
+               channel = out->dispc_channel;
+               omap_dss_put_device(out);
+
                /*
                 * if this channel hasn't already been taken by a previously
                 * allocated crtc, we create a new crtc for it
@@ -858,12 +860,52 @@ static int pdev_remove(struct platform_device *device)
 }
 
 #ifdef CONFIG_PM_SLEEP
+static int omap_drm_suspend_all_displays(void)
+{
+       struct omap_dss_device *dssdev = NULL;
+
+       for_each_dss_dev(dssdev) {
+               if (!dssdev->driver)
+                       continue;
+
+               if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) {
+                       dssdev->driver->disable(dssdev);
+                       dssdev->activate_after_resume = true;
+               } else {
+                       dssdev->activate_after_resume = false;
+               }
+       }
+
+       return 0;
+}
+
+static int omap_drm_resume_all_displays(void)
+{
+       struct omap_dss_device *dssdev = NULL;
+
+       for_each_dss_dev(dssdev) {
+               if (!dssdev->driver)
+                       continue;
+
+               if (dssdev->activate_after_resume) {
+                       dssdev->driver->enable(dssdev);
+                       dssdev->activate_after_resume = false;
+               }
+       }
+
+       return 0;
+}
+
 static int omap_drm_suspend(struct device *dev)
 {
        struct drm_device *drm_dev = dev_get_drvdata(dev);
 
        drm_kms_helper_poll_disable(drm_dev);
 
+       drm_modeset_lock_all(drm_dev);
+       omap_drm_suspend_all_displays();
+       drm_modeset_unlock_all(drm_dev);
+
        return 0;
 }
 
@@ -871,6 +913,10 @@ static int omap_drm_resume(struct device *dev)
 {
        struct drm_device *drm_dev = dev_get_drvdata(dev);
 
+       drm_modeset_lock_all(drm_dev);
+       omap_drm_resume_all_displays();
+       drm_modeset_unlock_all(drm_dev);
+
        drm_kms_helper_poll_enable(drm_dev);
 
        return omap_gem_resume(dev);
index c23cbe6..0fbe17d 100644 (file)
@@ -31,6 +31,8 @@
 #include <drm/drm_gem.h>
 #include <drm/omap_drm.h>
 
+#include "dss/omapdss.h"
+
 #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
 #define VERB(fmt, ...) if (0) DRM_DEBUG(fmt, ##__VA_ARGS__) /* verbose debug */
 
@@ -188,12 +190,15 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
                struct omap_drm_window *win, struct omap_overlay_info *info);
 struct drm_connector *omap_framebuffer_get_next_connector(
                struct drm_framebuffer *fb, struct drm_connector *from);
+bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb);
 
 void omap_gem_init(struct drm_device *dev);
 void omap_gem_deinit(struct drm_device *dev);
 
 struct drm_gem_object *omap_gem_new(struct drm_device *dev,
                union omap_gem_size gsize, uint32_t flags);
+struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
+               struct sg_table *sgt);
 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
                union omap_gem_size gsize, uint32_t flags, uint32_t *handle);
 void omap_gem_free_object(struct drm_gem_object *obj);
index 61714e9..0bbb9c5 100644 (file)
@@ -139,11 +139,16 @@ static void omap_encoder_enable(struct drm_encoder *encoder)
        struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
        struct omap_dss_device *dssdev = omap_encoder->dssdev;
        struct omap_dss_driver *dssdrv = dssdev->driver;
+       int r;
 
        omap_encoder_update(encoder, omap_crtc_channel(encoder->crtc),
                            omap_crtc_timings(encoder->crtc));
 
-       dssdrv->enable(dssdev);
+       r = dssdrv->enable(dssdev);
+       if (r)
+               dev_err(encoder->dev->dev,
+                       "Failed to enable display '%s': %d\n",
+                       dssdev->name, r);
 }
 
 static int omap_encoder_atomic_check(struct drm_encoder *encoder,
index ad202df..6109623 100644 (file)
@@ -145,6 +145,14 @@ static uint32_t get_linear_addr(struct plane *plane,
        return plane->paddr + offset;
 }
 
+bool omap_framebuffer_supports_rotation(struct drm_framebuffer *fb)
+{
+       struct omap_framebuffer *omap_fb = to_omap_framebuffer(fb);
+       struct plane *plane = &omap_fb->planes[0];
+
+       return omap_gem_flags(plane->bo) & OMAP_BO_TILED;
+}
+
 /* update ovl info for scanout, handles cases of multi-planar fb's, etc.
  */
 void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
@@ -449,6 +457,14 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
                        goto fail;
                }
 
+               if (i > 0 && pitch != mode_cmd->pitches[i - 1]) {
+                       dev_err(dev->dev,
+                               "pitches are not the same between framebuffer planes %d != %d\n",
+                               pitch, mode_cmd->pitches[i - 1]);
+                       ret = -EINVAL;
+                       goto fail;
+               }
+
                plane->bo     = bos[i];
                plane->offset = mode_cmd->offsets[i];
                plane->pitch  = pitch;
index 8495a1a..cc36a8d 100644 (file)
@@ -31,9 +31,9 @@
  */
 
 /* note: we use upper 8 bits of flags for driver-internal flags: */
-#define OMAP_BO_DMA            0x01000000      /* actually is physically contiguous */
-#define OMAP_BO_EXT_SYNC       0x02000000      /* externally allocated sync object */
-#define OMAP_BO_EXT_MEM                0x04000000      /* externally allocated memory */
+#define OMAP_BO_MEM_DMA_API    0x01000000      /* memory allocated with the dma_alloc_* API */
+#define OMAP_BO_MEM_SHMEM      0x02000000      /* memory allocated through shmem backing */
+#define OMAP_BO_MEM_DMABUF     0x08000000      /* memory imported from a dmabuf */
 
 struct omap_gem_object {
        struct drm_gem_object base;
@@ -49,17 +49,25 @@ struct omap_gem_object {
        uint32_t roll;
 
        /**
-        * If buffer is allocated physically contiguous, the OMAP_BO_DMA flag
-        * is set and the paddr is valid.  Also if the buffer is remapped in
-        * TILER and paddr_cnt > 0, then paddr is valid.  But if you are using
-        * the physical address and OMAP_BO_DMA is not set, then you should
-        * be going thru omap_gem_{get,put}_paddr() to ensure the mapping is
-        * not removed from under your feet.
+        * paddr contains the buffer DMA address. It is valid for
         *
-        * Note that OMAP_BO_SCANOUT is a hint from userspace that DMA capable
-        * buffer is requested, but doesn't mean that it is.  Use the
-        * OMAP_BO_DMA flag to determine if the buffer has a DMA capable
-        * physical address.
+        * - buffers allocated through the DMA mapping API (with the
+        *   OMAP_BO_MEM_DMA_API flag set)
+        *
+        * - buffers imported from dmabuf (with the OMAP_BO_MEM_DMABUF flag set)
+        *   if they are physically contiguous (when sgt->orig_nents == 1)
+        *
+        * - buffers mapped through the TILER when paddr_cnt is not zero, in
+        *   which case the DMA address points to the TILER aperture
+        *
+        * Physically contiguous buffers have their DMA address equal to the
+        * physical address as we don't remap those buffers through the TILER.
+        *
+        * Buffers mapped to the TILER have their DMA address pointing to the
+        * TILER aperture. As TILER mappings are refcounted (through paddr_cnt)
+        * the DMA address must be accessed through omap_get_get_paddr() to
+        * ensure that the mapping won't disappear unexpectedly. References must
+        * be released with omap_gem_put_paddr().
         */
        dma_addr_t paddr;
 
@@ -69,6 +77,12 @@ struct omap_gem_object {
        uint32_t paddr_cnt;
 
        /**
+        * If the buffer has been imported from a dmabuf the OMAP_DB_DMABUF flag
+        * is set and the sgt field is valid.
+        */
+       struct sg_table *sgt;
+
+       /**
         * tiler block used when buffer is remapped in DMM/TILER.
         */
        struct tiler_block *block;
@@ -91,17 +105,7 @@ struct omap_gem_object {
         * sync-object allocated on demand (if needed)
         *
         * Per-buffer sync-object for tracking pending and completed hw/dma
-        * read and write operations.  The layout in memory is dictated by
-        * the SGX firmware, which uses this information to stall the command
-        * stream if a surface is not ready yet.
-        *
-        * Note that when buffer is used by SGX, the sync-object needs to be
-        * allocated from a special heap of sync-objects.  This way many sync
-        * objects can be packed in a page, and not waste GPU virtual address
-        * space.  Because of this we have to have a omap_gem_set_sync_object()
-        * API to allow replacement of the syncobj after it has (potentially)
-        * already been allocated.  A bit ugly but I haven't thought of a
-        * better alternative.
+        * read and write operations.
         */
        struct {
                uint32_t write_pending;
@@ -166,16 +170,15 @@ static uint64_t mmap_offset(struct drm_gem_object *obj)
        return drm_vma_node_offset_addr(&obj->vma_node);
 }
 
-/* GEM objects can either be allocated from contiguous memory (in which
- * case obj->filp==NULL), or w/ shmem backing (obj->filp!=NULL).  But non
- * contiguous buffers can be remapped in TILER/DMM if they need to be
- * contiguous... but we don't do this all the time to reduce pressure
- * on TILER/DMM space when we know at allocation time that the buffer
- * will need to be scanned out.
- */
-static inline bool is_shmem(struct drm_gem_object *obj)
+static bool is_contiguous(struct omap_gem_object *omap_obj)
 {
-       return obj->filp != NULL;
+       if (omap_obj->flags & OMAP_BO_MEM_DMA_API)
+               return true;
+
+       if ((omap_obj->flags & OMAP_BO_MEM_DMABUF) && omap_obj->sgt->nents == 1)
+               return true;
+
+       return false;
 }
 
 /* -----------------------------------------------------------------------------
@@ -264,6 +267,19 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
                for (i = 0; i < npages; i++) {
                        addrs[i] = dma_map_page(dev->dev, pages[i],
                                        0, PAGE_SIZE, DMA_BIDIRECTIONAL);
+
+                       if (dma_mapping_error(dev->dev, addrs[i])) {
+                               dev_warn(dev->dev,
+                                       "%s: failed to map page\n", __func__);
+
+                               for (i = i - 1; i >= 0; --i) {
+                                       dma_unmap_page(dev->dev, addrs[i],
+                                               PAGE_SIZE, DMA_BIDIRECTIONAL);
+                               }
+
+                               ret = -ENOMEM;
+                               goto free_addrs;
+                       }
                }
        } else {
                addrs = kzalloc(npages * sizeof(*addrs), GFP_KERNEL);
@@ -278,6 +294,8 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
 
        return 0;
 
+free_addrs:
+       kfree(addrs);
 free_pages:
        drm_gem_put_pages(obj, pages, true, false);
 
@@ -292,7 +310,7 @@ static int get_pages(struct drm_gem_object *obj, struct page ***pages)
        struct omap_gem_object *omap_obj = to_omap_bo(obj);
        int ret = 0;
 
-       if (is_shmem(obj) && !omap_obj->pages) {
+       if ((omap_obj->flags & OMAP_BO_MEM_SHMEM) && !omap_obj->pages) {
                ret = omap_gem_attach_pages(obj);
                if (ret) {
                        dev_err(obj->dev->dev, "could not attach pages\n");
@@ -396,7 +414,7 @@ static int fault_1d(struct drm_gem_object *obj,
                omap_gem_cpu_sync(obj, pgoff);
                pfn = page_to_pfn(omap_obj->pages[pgoff]);
        } else {
-               BUG_ON(!(omap_obj->flags & OMAP_BO_DMA));
+               BUG_ON(!is_contiguous(omap_obj));
                pfn = (omap_obj->paddr >> PAGE_SHIFT) + pgoff;
        }
 
@@ -560,6 +578,11 @@ fail:
        case 0:
        case -ERESTARTSYS:
        case -EINTR:
+       case -EBUSY:
+               /*
+                * EBUSY is ok: this just means that another thread
+                * already did the job.
+                */
                return VM_FAULT_NOPAGE;
        case -ENOMEM:
                return VM_FAULT_OOM;
@@ -728,7 +751,8 @@ fail:
 static inline bool is_cached_coherent(struct drm_gem_object *obj)
 {
        struct omap_gem_object *omap_obj = to_omap_bo(obj);
-       return is_shmem(obj) &&
+
+       return (omap_obj->flags & OMAP_BO_MEM_SHMEM) &&
                ((omap_obj->flags & OMAP_BO_CACHE_MASK) == OMAP_BO_CACHED);
 }
 
@@ -761,9 +785,20 @@ void omap_gem_dma_sync(struct drm_gem_object *obj,
 
                for (i = 0; i < npages; i++) {
                        if (!omap_obj->addrs[i]) {
-                               omap_obj->addrs[i] = dma_map_page(dev->dev, pages[i], 0,
+                               dma_addr_t addr;
+
+                               addr = dma_map_page(dev->dev, pages[i], 0,
                                                PAGE_SIZE, DMA_BIDIRECTIONAL);
+
+                               if (dma_mapping_error(dev->dev, addr)) {
+                                       dev_warn(dev->dev,
+                                               "%s: failed to map page\n",
+                                               __func__);
+                                       break;
+                               }
+
                                dirty = true;
+                               omap_obj->addrs[i] = addr;
                        }
                }
 
@@ -787,7 +822,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
 
        mutex_lock(&obj->dev->struct_mutex);
 
-       if (remap && is_shmem(obj) && priv->has_dmm) {
+       if (!is_contiguous(omap_obj) && remap && priv->has_dmm) {
                if (omap_obj->paddr_cnt == 0) {
                        struct page **pages;
                        uint32_t npages = obj->size >> PAGE_SHIFT;
@@ -834,7 +869,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
                omap_obj->paddr_cnt++;
 
                *paddr = omap_obj->paddr;
-       } else if (omap_obj->flags & OMAP_BO_DMA) {
+       } else if (is_contiguous(omap_obj)) {
                *paddr = omap_obj->paddr;
        } else {
                ret = -EINVAL;
@@ -1138,20 +1173,6 @@ unlock:
        return ret;
 }
 
-/* it is a bit lame to handle updates in this sort of polling way, but
- * in case of PVR, the GPU can directly update read/write complete
- * values, and not really tell us which ones it updated.. this also
- * means that sync_lock is not quite sufficient.  So we'll need to
- * do something a bit better when it comes time to add support for
- * separate 2d hw..
- */
-void omap_gem_op_update(void)
-{
-       spin_lock(&sync_lock);
-       sync_op_update();
-       spin_unlock(&sync_lock);
-}
-
 /* mark the start of read and/or write operation */
 int omap_gem_op_start(struct drm_gem_object *obj, enum omap_gem_op op)
 {
@@ -1219,7 +1240,7 @@ int omap_gem_op_sync(struct drm_gem_object *obj, enum omap_gem_op op)
  * is currently blocked..  fxn() can be called from any context
  *
  * (TODO for now fxn is called back from whichever context calls
- * omap_gem_op_update().. but this could be better defined later
+ * omap_gem_op_finish().. but this could be better defined later
  * if needed)
  *
  * TODO more code in common w/ _sync()..
@@ -1261,50 +1282,10 @@ int omap_gem_op_async(struct drm_gem_object *obj, enum omap_gem_op op,
        return 0;
 }
 
-/* special API so PVR can update the buffer to use a sync-object allocated
- * from it's sync-obj heap.  Only used for a newly allocated (from PVR's
- * perspective) sync-object, so we overwrite the new syncobj w/ values
- * from the already allocated syncobj (if there is one)
- */
-int omap_gem_set_sync_object(struct drm_gem_object *obj, void *syncobj)
-{
-       struct omap_gem_object *omap_obj = to_omap_bo(obj);
-       int ret = 0;
-
-       spin_lock(&sync_lock);
-
-       if ((omap_obj->flags & OMAP_BO_EXT_SYNC) && !syncobj) {
-               /* clearing a previously set syncobj */
-               syncobj = kmemdup(omap_obj->sync, sizeof(*omap_obj->sync),
-                                 GFP_ATOMIC);
-               if (!syncobj) {
-                       ret = -ENOMEM;
-                       goto unlock;
-               }
-               omap_obj->flags &= ~OMAP_BO_EXT_SYNC;
-               omap_obj->sync = syncobj;
-       } else if (syncobj && !(omap_obj->flags & OMAP_BO_EXT_SYNC)) {
-               /* replacing an existing syncobj */
-               if (omap_obj->sync) {
-                       memcpy(syncobj, omap_obj->sync, sizeof(*omap_obj->sync));
-                       kfree(omap_obj->sync);
-               }
-               omap_obj->flags |= OMAP_BO_EXT_SYNC;
-               omap_obj->sync = syncobj;
-       }
-
-unlock:
-       spin_unlock(&sync_lock);
-       return ret;
-}
-
 /* -----------------------------------------------------------------------------
  * Constructor & Destructor
  */
 
-/* don't call directly.. called from GEM core when it is time to actually
- * free the object..
- */
 void omap_gem_free_object(struct drm_gem_object *obj)
 {
        struct drm_device *dev = obj->dev;
@@ -1324,22 +1305,23 @@ void omap_gem_free_object(struct drm_gem_object *obj)
         */
        WARN_ON(omap_obj->paddr_cnt > 0);
 
-       /* don't free externally allocated backing memory */
-       if (!(omap_obj->flags & OMAP_BO_EXT_MEM)) {
-               if (omap_obj->pages)
+       if (omap_obj->pages) {
+               if (omap_obj->flags & OMAP_BO_MEM_DMABUF)
+                       kfree(omap_obj->pages);
+               else
                        omap_gem_detach_pages(obj);
+       }
 
-               if (!is_shmem(obj)) {
-                       dma_free_writecombine(dev->dev, obj->size,
-                                       omap_obj->vaddr, omap_obj->paddr);
-               } else if (omap_obj->vaddr) {
-                       vunmap(omap_obj->vaddr);
-               }
+       if (omap_obj->flags & OMAP_BO_MEM_DMA_API) {
+               dma_free_writecombine(dev->dev, obj->size,
+                               omap_obj->vaddr, omap_obj->paddr);
+       } else if (omap_obj->vaddr) {
+               vunmap(omap_obj->vaddr);
+       } else if (obj->import_attach) {
+               drm_prime_gem_destroy(obj, omap_obj->sgt);
        }
 
-       /* don't free externally allocated syncobj */
-       if (!(omap_obj->flags & OMAP_BO_EXT_SYNC))
-               kfree(omap_obj->sync);
+       kfree(omap_obj->sync);
 
        drm_gem_object_release(obj);
 
@@ -1357,84 +1339,160 @@ struct drm_gem_object *omap_gem_new(struct drm_device *dev,
        size_t size;
        int ret;
 
+       /* Validate the flags and compute the memory and cache flags. */
        if (flags & OMAP_BO_TILED) {
                if (!priv->usergart) {
                        dev_err(dev->dev, "Tiled buffers require DMM\n");
                        return NULL;
                }
 
-               /* tiled buffers are always shmem paged backed.. when they are
-                * scanned out, they are remapped into DMM/TILER
+               /*
+                * Tiled buffers are always shmem paged backed. When they are
+                * scanned out, they are remapped into DMM/TILER.
                 */
                flags &= ~OMAP_BO_SCANOUT;
+               flags |= OMAP_BO_MEM_SHMEM;
 
-               /* currently don't allow cached buffers.. there is some caching
-                * stuff that needs to be handled better
+               /*
+                * Currently don't allow cached buffers. There is some caching
+                * stuff that needs to be handled better.
                 */
                flags &= ~(OMAP_BO_CACHED|OMAP_BO_WC|OMAP_BO_UNCACHED);
                flags |= tiler_get_cpu_cache_flags();
-
-               /* align dimensions to slot boundaries... */
-               tiler_align(gem2fmt(flags),
-                               &gsize.tiled.width, &gsize.tiled.height);
-
-               /* ...and calculate size based on aligned dimensions */
-               size = tiler_size(gem2fmt(flags),
-                               gsize.tiled.width, gsize.tiled.height);
-       } else {
-               size = PAGE_ALIGN(gsize.bytes);
+       } else if ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm) {
+               /*
+                * OMAP_BO_SCANOUT hints that the buffer doesn't need to be
+                * tiled. However, to lower the pressure on memory allocation,
+                * use contiguous memory only if no TILER is available.
+                */
+               flags |= OMAP_BO_MEM_DMA_API;
+       } else if (!(flags & OMAP_BO_MEM_DMABUF)) {
+               /*
+                * All other buffers not backed by dma_buf are shmem-backed.
+                */
+               flags |= OMAP_BO_MEM_SHMEM;
        }
 
+       /* Allocate the initialize the OMAP GEM object. */
        omap_obj = kzalloc(sizeof(*omap_obj), GFP_KERNEL);
        if (!omap_obj)
                return NULL;
 
        obj = &omap_obj->base;
+       omap_obj->flags = flags;
 
-       if ((flags & OMAP_BO_SCANOUT) && !priv->has_dmm) {
-               /* attempt to allocate contiguous memory if we don't
-                * have DMM for remappign discontiguous buffers
+       if (flags & OMAP_BO_TILED) {
+               /*
+                * For tiled buffers align dimensions to slot boundaries and
+                * calculate size based on aligned dimensions.
                 */
-               omap_obj->vaddr =  dma_alloc_writecombine(dev->dev, size,
-                               &omap_obj->paddr, GFP_KERNEL);
-               if (!omap_obj->vaddr) {
-                       kfree(omap_obj);
+               tiler_align(gem2fmt(flags), &gsize.tiled.width,
+                           &gsize.tiled.height);
 
-                       return NULL;
-               }
-
-               flags |= OMAP_BO_DMA;
-       }
+               size = tiler_size(gem2fmt(flags), gsize.tiled.width,
+                                 gsize.tiled.height);
 
-       spin_lock(&priv->list_lock);
-       list_add(&omap_obj->mm_list, &priv->obj_list);
-       spin_unlock(&priv->list_lock);
-
-       omap_obj->flags = flags;
-
-       if (flags & OMAP_BO_TILED) {
                omap_obj->width = gsize.tiled.width;
                omap_obj->height = gsize.tiled.height;
+       } else {
+               size = PAGE_ALIGN(gsize.bytes);
        }
 
-       if (flags & (OMAP_BO_DMA|OMAP_BO_EXT_MEM)) {
+       /* Initialize the GEM object. */
+       if (!(flags & OMAP_BO_MEM_SHMEM)) {
                drm_gem_private_object_init(dev, obj, size);
        } else {
                ret = drm_gem_object_init(dev, obj, size);
                if (ret)
-                       goto fail;
+                       goto err_free;
 
                mapping = file_inode(obj->filp)->i_mapping;
                mapping_set_gfp_mask(mapping, GFP_USER | __GFP_DMA32);
        }
 
+       /* Allocate memory if needed. */
+       if (flags & OMAP_BO_MEM_DMA_API) {
+               omap_obj->vaddr = dma_alloc_writecombine(dev->dev, size,
+                                                        &omap_obj->paddr,
+                                                        GFP_KERNEL);
+               if (!omap_obj->vaddr)
+                       goto err_release;
+       }
+
+       spin_lock(&priv->list_lock);
+       list_add(&omap_obj->mm_list, &priv->obj_list);
+       spin_unlock(&priv->list_lock);
+
        return obj;
 
-fail:
-       omap_gem_free_object(obj);
+err_release:
+       drm_gem_object_release(obj);
+err_free:
+       kfree(omap_obj);
        return NULL;
 }
 
+struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
+                                          struct sg_table *sgt)
+{
+       struct omap_drm_private *priv = dev->dev_private;
+       struct omap_gem_object *omap_obj;
+       struct drm_gem_object *obj;
+       union omap_gem_size gsize;
+
+       /* Without a DMM only physically contiguous buffers can be supported. */
+       if (sgt->orig_nents != 1 && !priv->has_dmm)
+               return ERR_PTR(-EINVAL);
+
+       mutex_lock(&dev->struct_mutex);
+
+       gsize.bytes = PAGE_ALIGN(size);
+       obj = omap_gem_new(dev, gsize, OMAP_BO_MEM_DMABUF | OMAP_BO_WC);
+       if (!obj) {
+               obj = ERR_PTR(-ENOMEM);
+               goto done;
+       }
+
+       omap_obj = to_omap_bo(obj);
+       omap_obj->sgt = sgt;
+
+       if (sgt->orig_nents == 1) {
+               omap_obj->paddr = sg_dma_address(sgt->sgl);
+       } else {
+               /* Create pages list from sgt */
+               struct sg_page_iter iter;
+               struct page **pages;
+               unsigned int npages;
+               unsigned int i = 0;
+
+               npages = DIV_ROUND_UP(size, PAGE_SIZE);
+               pages = kcalloc(npages, sizeof(*pages), GFP_KERNEL);
+               if (!pages) {
+                       omap_gem_free_object(obj);
+                       obj = ERR_PTR(-ENOMEM);
+                       goto done;
+               }
+
+               omap_obj->pages = pages;
+
+               for_each_sg_page(sgt->sgl, &iter, sgt->orig_nents, 0) {
+                       pages[i++] = sg_page_iter_page(&iter);
+                       if (i > npages)
+                               break;
+               }
+
+               if (WARN_ON(i != npages)) {
+                       omap_gem_free_object(obj);
+                       obj = ERR_PTR(-ENOMEM);
+                       goto done;
+               }
+       }
+
+done:
+       mutex_unlock(&dev->struct_mutex);
+       return obj;
+}
+
 /* convenience method to construct a GEM buffer object, and userspace handle */
 int omap_gem_new_handle(struct drm_device *dev, struct drm_file *file,
                union omap_gem_size gsize, uint32_t flags, uint32_t *handle)
index aebae1c..3cf8aab 100644 (file)
 
 #include "omap_drv.h"
 
+/* -----------------------------------------------------------------------------
+ * DMABUF Export
+ */
+
 static struct sg_table *omap_gem_map_dma_buf(
                struct dma_buf_attachment *attachment,
                enum dma_data_direction dir)
@@ -178,15 +182,20 @@ struct dma_buf *omap_gem_prime_export(struct drm_device *dev,
        return dma_buf_export(&exp_info);
 }
 
+/* -----------------------------------------------------------------------------
+ * DMABUF Import
+ */
+
 struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
-               struct dma_buf *buffer)
+                                            struct dma_buf *dma_buf)
 {
+       struct dma_buf_attachment *attach;
        struct drm_gem_object *obj;
+       struct sg_table *sgt;
+       int ret;
 
-       /* is this one of own objects? */
-       if (buffer->ops == &omap_dmabuf_ops) {
-               obj = buffer->priv;
-               /* is it from our device? */
+       if (dma_buf->ops == &omap_dmabuf_ops) {
+               obj = dma_buf->priv;
                if (obj->dev == dev) {
                        /*
                         * Importing dmabuf exported from out own gem increases
@@ -197,9 +206,33 @@ struct drm_gem_object *omap_gem_prime_import(struct drm_device *dev,
                }
        }
 
-       /*
-        * TODO add support for importing buffers from other devices..
-        * for now we don't need this but would be nice to add eventually
-        */
-       return ERR_PTR(-EINVAL);
+       attach = dma_buf_attach(dma_buf, dev->dev);
+       if (IS_ERR(attach))
+               return ERR_CAST(attach);
+
+       get_dma_buf(dma_buf);
+
+       sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
+       if (IS_ERR(sgt)) {
+               ret = PTR_ERR(sgt);
+               goto fail_detach;
+       }
+
+       obj = omap_gem_new_dmabuf(dev, dma_buf->size, sgt);
+       if (IS_ERR(obj)) {
+               ret = PTR_ERR(obj);
+               goto fail_unmap;
+       }
+
+       obj->import_attach = attach;
+
+       return obj;
+
+fail_unmap:
+       dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL);
+fail_detach:
+       dma_buf_detach(dma_buf, attach);
+       dma_buf_put(dma_buf);
+
+       return ERR_PTR(ret);
 }
index d75b197..93ee538 100644 (file)
@@ -177,6 +177,12 @@ static int omap_plane_atomic_check(struct drm_plane *plane,
        if (state->crtc_y + state->crtc_h > crtc_state->adjusted_mode.vdisplay)
                return -EINVAL;
 
+       if (state->fb) {
+               if (state->rotation != BIT(DRM_ROTATE_0) &&
+                   !omap_framebuffer_supports_rotation(state->fb))
+                       return -EINVAL;
+       }
+
        return 0;
 }
 
index f88a631..ceb2048 100644 (file)
@@ -847,6 +847,7 @@ static const struct drm_display_mode innolux_g121x1_l03_mode = {
        .vsync_end = 768 + 38 + 1,
        .vtotal = 768 + 38 + 1 + 0,
        .vrefresh = 60,
+       .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
 };
 
 static const struct panel_desc innolux_g121x1_l03 = {
@@ -982,6 +983,29 @@ static const struct panel_desc lg_lb070wv8 = {
        .bus_format = MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
 };
 
+static const struct drm_display_mode lg_lp120up1_mode = {
+       .clock = 162300,
+       .hdisplay = 1920,
+       .hsync_start = 1920 + 40,
+       .hsync_end = 1920 + 40 + 40,
+       .htotal = 1920 + 40 + 40+ 80,
+       .vdisplay = 1280,
+       .vsync_start = 1280 + 4,
+       .vsync_end = 1280 + 4 + 4,
+       .vtotal = 1280 + 4 + 4 + 12,
+       .vrefresh = 60,
+};
+
+static const struct panel_desc lg_lp120up1 = {
+       .modes = &lg_lp120up1_mode,
+       .num_modes = 1,
+       .bpc = 8,
+       .size = {
+               .width = 267,
+               .height = 183,
+       },
+};
+
 static const struct drm_display_mode lg_lp129qe_mode = {
        .clock = 285250,
        .hdisplay = 2560,
@@ -1016,6 +1040,7 @@ static const struct drm_display_mode nec_nl4827hc19_05b_mode = {
        .vsync_end = 272 + 2 + 4,
        .vtotal = 272 + 2 + 4 + 2,
        .vrefresh = 74,
+       .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
 };
 
 static const struct panel_desc nec_nl4827hc19_05b = {
@@ -1176,6 +1201,42 @@ static const struct panel_desc shelly_sca07010_bfn_lnn = {
        .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
 };
 
+static const struct display_timing urt_umsh_8596md_timing = {
+       .pixelclock = { 33260000, 33260000, 33260000 },
+       .hactive = { 800, 800, 800 },
+       .hfront_porch = { 41, 41, 41 },
+       .hback_porch = { 216 - 128, 216 - 128, 216 - 128 },
+       .hsync_len = { 71, 128, 128 },
+       .vactive = { 480, 480, 480 },
+       .vfront_porch = { 10, 10, 10 },
+       .vback_porch = { 35 - 2, 35 - 2, 35 - 2 },
+       .vsync_len = { 2, 2, 2 },
+       .flags = DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_NEGEDGE |
+               DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW,
+};
+
+static const struct panel_desc urt_umsh_8596md_lvds = {
+       .timings = &urt_umsh_8596md_timing,
+       .num_timings = 1,
+       .bpc = 6,
+       .size = {
+               .width = 152,
+               .height = 91,
+       },
+       .bus_format = MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
+};
+
+static const struct panel_desc urt_umsh_8596md_parallel = {
+       .timings = &urt_umsh_8596md_timing,
+       .num_timings = 1,
+       .bpc = 6,
+       .size = {
+               .width = 152,
+               .height = 91,
+       },
+       .bus_format = MEDIA_BUS_FMT_RGB666_1X18,
+};
+
 static const struct of_device_id platform_of_match[] = {
        {
                .compatible = "ampire,am800480r3tmqwa1h",
@@ -1256,6 +1317,9 @@ static const struct of_device_id platform_of_match[] = {
                .compatible = "lg,lb070wv8",
                .data = &lg_lb070wv8,
        }, {
+               .compatible = "lg,lp120up1",
+               .data = &lg_lp120up1,
+       }, {
                .compatible = "lg,lp129qe",
                .data = &lg_lp129qe,
        }, {
@@ -1280,6 +1344,24 @@ static const struct of_device_id platform_of_match[] = {
                .compatible = "shelly,sca07010-bfn-lnn",
                .data = &shelly_sca07010_bfn_lnn,
        }, {
+               .compatible = "urt,umsh-8596md-t",
+               .data = &urt_umsh_8596md_parallel,
+       }, {
+               .compatible = "urt,umsh-8596md-1t",
+               .data = &urt_umsh_8596md_parallel,
+       }, {
+               .compatible = "urt,umsh-8596md-7t",
+               .data = &urt_umsh_8596md_parallel,
+       }, {
+               .compatible = "urt,umsh-8596md-11t",
+               .data = &urt_umsh_8596md_lvds,
+       }, {
+               .compatible = "urt,umsh-8596md-19t",
+               .data = &urt_umsh_8596md_lvds,
+       }, {
+               .compatible = "urt,umsh-8596md-20t",
+               .data = &urt_umsh_8596md_parallel,
+       }, {
                /* sentinel */
        }
 };
index 2ae8577..7c2e782 100644 (file)
@@ -168,7 +168,8 @@ static int qxl_process_single_command(struct qxl_device *qdev,
                       cmd->command_size))
                return -EFAULT;
 
-       reloc_info = kmalloc(sizeof(struct qxl_reloc_info) * cmd->relocs_num, GFP_KERNEL);
+       reloc_info = kmalloc_array(cmd->relocs_num,
+                                  sizeof(struct qxl_reloc_info), GFP_KERNEL);
        if (!reloc_info)
                return -ENOMEM;
 
index 3d031b5..9f029dd 100644 (file)
@@ -68,5 +68,5 @@ int qxl_gem_prime_mmap(struct drm_gem_object *obj,
                       struct vm_area_struct *area)
 {
        WARN_ONCE(1, "not implemented");
-       return ENOSYS;
+       return -ENOSYS;
 }
index 44ee72e..6af8325 100644 (file)
@@ -315,15 +315,27 @@ int radeon_dp_get_dp_link_config(struct drm_connector *connector,
        unsigned max_lane_num = drm_dp_max_lane_count(dpcd);
        unsigned lane_num, i, max_pix_clock;
 
-       for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) {
-               for (i = 0; i < ARRAY_SIZE(link_rates) && link_rates[i] <= max_link_rate; i++) {
-                       max_pix_clock = (lane_num * link_rates[i] * 8) / bpp;
+       if (radeon_connector_encoder_get_dp_bridge_encoder_id(connector) ==
+           ENCODER_OBJECT_ID_NUTMEG) {
+               for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) {
+                       max_pix_clock = (lane_num * 270000 * 8) / bpp;
                        if (max_pix_clock >= pix_clock) {
                                *dp_lanes = lane_num;
-                               *dp_rate = link_rates[i];
+                               *dp_rate = 270000;
                                return 0;
                        }
                }
+       } else {
+               for (lane_num = 1; lane_num <= max_lane_num; lane_num <<= 1) {
+                       for (i = 0; i < ARRAY_SIZE(link_rates) && link_rates[i] <= max_link_rate; i++) {
+                               max_pix_clock = (lane_num * link_rates[i] * 8) / bpp;
+                               if (max_pix_clock >= pix_clock) {
+                                       *dp_lanes = lane_num;
+                                       *dp_rate = link_rates[i];
+                                       return 0;
+                               }
+                       }
+               }
        }
 
        return -EINVAL;
index 4de23ae..e239633 100644 (file)
@@ -1750,7 +1750,6 @@ int radeon_resume_kms(struct drm_device *dev, bool resume, bool fbcon)
        }
 
        drm_kms_helper_poll_enable(dev);
-       drm_helper_hpd_irq_event(dev);
 
        /* set the power state here in case we are a PX system or headless */
        if ((rdev->pm.pm_method == PM_METHOD_DPM) && rdev->pm.dpm_enabled)
index a4674bf..e29096b 100644 (file)
@@ -403,7 +403,8 @@ static void radeon_flip_work_func(struct work_struct *__work)
        struct drm_crtc *crtc = &radeon_crtc->base;
        unsigned long flags;
        int r;
-       int vpos, hpos, stat, min_udelay;
+       int vpos, hpos, stat, min_udelay = 0;
+       unsigned repcnt = 4;
        struct drm_vblank_crtc *vblank = &crtc->dev->vblank[work->crtc_id];
 
         down_read(&rdev->exclusive_lock);
@@ -454,7 +455,7 @@ static void radeon_flip_work_func(struct work_struct *__work)
         * In practice this won't execute very often unless on very fast
         * machines because the time window for this to happen is very small.
         */
-       for (;;) {
+       while (radeon_crtc->enabled && --repcnt) {
                /* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank
                 * start in hpos, and to the "fudged earlier" vblank start in
                 * vpos.
@@ -470,12 +471,24 @@ static void radeon_flip_work_func(struct work_struct *__work)
                        break;
 
                /* Sleep at least until estimated real start of hw vblank */
-               spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
                min_udelay = (-hpos + 1) * max(vblank->linedur_ns / 1000, 5);
+               if (min_udelay > vblank->framedur_ns / 2000) {
+                       /* Don't wait ridiculously long - something is wrong */
+                       repcnt = 0;
+                       break;
+               }
+               spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
                usleep_range(min_udelay, 2 * min_udelay);
                spin_lock_irqsave(&crtc->dev->event_lock, flags);
        };
 
+       if (!repcnt)
+               DRM_DEBUG_DRIVER("Delay problem on crtc %d: min_udelay %d, "
+                                "framedur %d, linedur %d, stat %d, vpos %d, "
+                                "hpos %d\n", work->crtc_id, min_udelay,
+                                vblank->framedur_ns / 1000,
+                                vblank->linedur_ns / 1000, stat, vpos, hpos);
+
        /* do the flip (mmio) */
        radeon_page_flip(rdev, radeon_crtc->crtc_id, work->base);
 
index cad2555..ccd4ad4 100644 (file)
@@ -322,6 +322,14 @@ static int radeon_pci_probe(struct pci_dev *pdev,
        int ret;
 
        /*
+        * Initialize amdkfd before starting radeon. If it was not loaded yet,
+        * defer radeon probing
+        */
+       ret = radeon_kfd_init();
+       if (ret == -EPROBE_DEFER)
+               return ret;
+
+       /*
         * apple-gmux is needed on dual GPU MacBook Pro
         * to probe the panel if we're the inactive GPU.
         */
@@ -581,8 +589,6 @@ static int __init radeon_init(void)
                return -EINVAL;
        }
 
-       radeon_kfd_init();
-
        /* let modprobe override vga console setting */
        return drm_pci_init(driver, pdriver);
 }
index 9a4d69e..87a9ebb 100644 (file)
@@ -132,35 +132,34 @@ static const struct kfd2kgd_calls kfd2kgd = {
 
 static const struct kgd2kfd_calls *kgd2kfd;
 
-bool radeon_kfd_init(void)
+int radeon_kfd_init(void)
 {
+       int ret;
+
 #if defined(CONFIG_HSA_AMD_MODULE)
-       bool (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);
+       int (*kgd2kfd_init_p)(unsigned, const struct kgd2kfd_calls**);
 
        kgd2kfd_init_p = symbol_request(kgd2kfd_init);
 
        if (kgd2kfd_init_p == NULL)
-               return false;
+               return -ENOENT;
 
-       if (!kgd2kfd_init_p(KFD_INTERFACE_VERSION, &kgd2kfd)) {
+       ret = kgd2kfd_init_p(KFD_INTERFACE_VERSION, &kgd2kfd);
+       if (ret) {
                symbol_put(kgd2kfd_init);
                kgd2kfd = NULL;
-
-               return false;
        }
 
-       return true;
 #elif defined(CONFIG_HSA_AMD)
-       if (!kgd2kfd_init(KFD_INTERFACE_VERSION, &kgd2kfd)) {
+       ret = kgd2kfd_init(KFD_INTERFACE_VERSION, &kgd2kfd);
+       if (ret)
                kgd2kfd = NULL;
 
-               return false;
-       }
-
-       return true;
 #else
-       return false;
+       ret = -ENOENT;
 #endif
+
+       return ret;
 }
 
 void radeon_kfd_fini(void)
index 1103f90..9df1fea 100644 (file)
@@ -33,7 +33,7 @@
 
 struct radeon_device;
 
-bool radeon_kfd_init(void);
+int radeon_kfd_init(void);
 void radeon_kfd_fini(void);
 
 void radeon_kfd_suspend(struct radeon_device *rdev);
index 460c8f2..7a98823 100644 (file)
@@ -276,8 +276,12 @@ static void radeon_pm_set_clocks(struct radeon_device *rdev)
        if (rdev->irq.installed) {
                for (i = 0; i < rdev->num_crtc; i++) {
                        if (rdev->pm.active_crtcs & (1 << i)) {
-                               rdev->pm.req_vblank |= (1 << i);
-                               drm_vblank_get(rdev->ddev, i);
+                               /* This can fail if a modeset is in progress */
+                               if (drm_vblank_get(rdev->ddev, i) == 0)
+                                       rdev->pm.req_vblank |= (1 << i);
+                               else
+                                       DRM_DEBUG_DRIVER("crtc %d no vblank, can glitch\n",
+                                                        i);
                        }
                }
        }
@@ -1078,10 +1082,6 @@ force:
        /* update displays */
        radeon_dpm_display_configuration_changed(rdev);
 
-       rdev->pm.dpm.current_active_crtcs = rdev->pm.dpm.new_active_crtcs;
-       rdev->pm.dpm.current_active_crtc_count = rdev->pm.dpm.new_active_crtc_count;
-       rdev->pm.dpm.single_display = single_display;
-
        /* wait for the rings to drain */
        for (i = 0; i < RADEON_NUM_RINGS; i++) {
                struct radeon_ring *ring = &rdev->ring[i];
@@ -1097,6 +1097,10 @@ force:
 
        radeon_dpm_post_set_power_state(rdev);
 
+       rdev->pm.dpm.current_active_crtcs = rdev->pm.dpm.new_active_crtcs;
+       rdev->pm.dpm.current_active_crtc_count = rdev->pm.dpm.new_active_crtc_count;
+       rdev->pm.dpm.single_display = single_display;
+
        if (rdev->asic->dpm.force_performance_level) {
                if (rdev->pm.dpm.thermal_active) {
                        enum radeon_dpm_forced_level level = rdev->pm.dpm.forced_level;
index c507896..197b157 100644 (file)
@@ -349,8 +349,13 @@ int radeon_sa_bo_new(struct radeon_device *rdev,
                        /* see if we can skip over some allocations */
                } while (radeon_sa_bo_next_hole(sa_manager, fences, tries));
 
+               for (i = 0; i < RADEON_NUM_RINGS; ++i)
+                       radeon_fence_ref(fences[i]);
+
                spin_unlock(&sa_manager->wq.lock);
                r = radeon_fence_wait_any(rdev, fences, false);
+               for (i = 0; i < RADEON_NUM_RINGS; ++i)
+                       radeon_fence_unref(&fences[i]);
                spin_lock(&sa_manager->wq.lock);
                /* if we have nothing to wait for block */
                if (r == -ENOENT) {
index e343074..e06ac54 100644 (file)
@@ -758,7 +758,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm)
                                                       0, PAGE_SIZE,
                                                       PCI_DMA_BIDIRECTIONAL);
                if (pci_dma_mapping_error(rdev->pdev, gtt->ttm.dma_address[i])) {
-                       while (--i) {
+                       while (i--) {
                                pci_unmap_page(rdev->pdev, gtt->ttm.dma_address[i],
                                               PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
                                gtt->ttm.dma_address[i] = 0;
index 96dcd4a..1f10fa0 100644 (file)
@@ -1,6 +1,7 @@
 config DRM_RCAR_DU
        tristate "DRM Support for R-Car Display Unit"
-       depends on DRM && ARM && OF
+       depends on DRM && OF
+       depends on ARM || ARM64
        depends on ARCH_SHMOBILE || COMPILE_TEST
        select DRM_KMS_HELPER
        select DRM_KMS_CMA_HELPER
@@ -14,14 +15,18 @@ config DRM_RCAR_DU
 config DRM_RCAR_HDMI
        bool "R-Car DU HDMI Encoder Support"
        depends on DRM_RCAR_DU
-       depends on OF
        help
          Enable support for external HDMI encoders.
 
 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 for the R-Car Display Unit embedded LVDS encoders
-         (currently only on R8A7790 and R8A7791).
+         Enable support for the R-Car Display Unit embedded LVDS encoders.
+
+config DRM_RCAR_VSP
+       bool "R-Car DU VSP Compositor Support"
+       depends on DRM_RCAR_DU
+       depends on VIDEO_RENESAS_VSP1
+       help
+         Enable support to expose the R-Car VSP Compositor as KMS planes.
index 05de1c4..827711e 100644 (file)
@@ -11,4 +11,6 @@ rcar-du-drm-$(CONFIG_DRM_RCAR_HDMI)   += rcar_du_hdmicon.o \
                                           rcar_du_hdmienc.o
 rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)    += rcar_du_lvdsenc.o
 
+rcar-du-drm-$(CONFIG_DRM_RCAR_VSP)     += rcar_du_vsp.o
+
 obj-$(CONFIG_DRM_RCAR_DU)              += rcar-du-drm.o
index 4ec80ae..d9f06cc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_crtc.c  --  R-Car Display Unit CRTCs
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -28,6 +28,7 @@
 #include "rcar_du_kms.h"
 #include "rcar_du_plane.h"
 #include "rcar_du_regs.h"
+#include "rcar_du_vsp.h"
 
 static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg)
 {
@@ -150,7 +151,7 @@ static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc)
        /* Signal polarities */
        value = ((mode->flags & DRM_MODE_FLAG_PVSYNC) ? 0 : DSMR_VSL)
              | ((mode->flags & DRM_MODE_FLAG_PHSYNC) ? 0 : DSMR_HSL)
-             | DSMR_DIPM_DE | DSMR_CSPM;
+             | DSMR_DIPM_DISP | DSMR_CSPM;
        rcar_du_crtc_write(rcrtc, DSMR, value);
 
        /* Display timings */
@@ -207,6 +208,7 @@ plane_format(struct rcar_du_plane *plane)
 static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc)
 {
        struct rcar_du_plane *planes[RCAR_DU_NUM_HW_PLANES];
+       struct rcar_du_device *rcdu = rcrtc->group->dev;
        unsigned int num_planes = 0;
        unsigned int dptsr_planes;
        unsigned int hwplanes = 0;
@@ -250,6 +252,17 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc)
                }
        }
 
+       /* If VSP+DU integration is enabled the plane assignment is fixed. */
+       if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
+               if (rcdu->info->gen < 3) {
+                       dspr = (rcrtc->index % 2) + 1;
+                       hwplanes = 1 << (rcrtc->index % 2);
+               } else {
+                       dspr = (rcrtc->index % 2) ? 3 : 1;
+                       hwplanes = 1 << ((rcrtc->index % 2) ? 2 : 0);
+               }
+       }
+
        /* Update the planes to display timing and dot clock generator
         * associations.
         *
@@ -272,6 +285,10 @@ static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc)
                        rcar_du_group_restart(rcrtc->group);
        }
 
+       /* Restart the group if plane sources have changed. */
+       if (rcrtc->group->need_restart)
+               rcar_du_group_restart(rcrtc->group);
+
        mutex_unlock(&rcrtc->group->lock);
 
        rcar_du_group_write(rcrtc->group, rcrtc->index % 2 ? DS2PR : DS1PR,
@@ -365,6 +382,10 @@ static void rcar_du_crtc_start(struct rcar_du_crtc *rcrtc)
 
        rcar_du_group_start_stop(rcrtc->group, true);
 
+       /* Enable the VSP compositor. */
+       if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
+               rcar_du_vsp_enable(rcrtc);
+
        /* Turn vertical blanking interrupt reporting back on. */
        drm_crtc_vblank_on(crtc);
 
@@ -398,6 +419,10 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc)
        rcar_du_crtc_wait_page_flip(rcrtc);
        drm_crtc_vblank_off(crtc);
 
+       /* Disable the VSP compositor. */
+       if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
+               rcar_du_vsp_disable(rcrtc);
+
        /* Select switch sync mode. This stops display operation and configures
         * the HSYNC and VSYNC signals as inputs.
         */
@@ -410,6 +435,9 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc)
 
 void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc)
 {
+       if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
+               rcar_du_vsp_disable(rcrtc);
+
        rcar_du_crtc_stop(rcrtc);
        rcar_du_crtc_put(rcrtc);
 }
@@ -418,20 +446,24 @@ void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc)
 {
        unsigned int i;
 
-       if (!rcrtc->enabled)
+       if (!rcrtc->crtc.state->active)
                return;
 
        rcar_du_crtc_get(rcrtc);
        rcar_du_crtc_start(rcrtc);
 
        /* Commit the planes state. */
-       for (i = 0; i < rcrtc->group->num_planes; ++i) {
-               struct rcar_du_plane *plane = &rcrtc->group->planes[i];
+       if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE)) {
+               rcar_du_vsp_enable(rcrtc);
+       } else {
+               for (i = 0; i < rcrtc->group->num_planes; ++i) {
+                       struct rcar_du_plane *plane = &rcrtc->group->planes[i];
 
-               if (plane->plane.state->crtc != &rcrtc->crtc)
-                       continue;
+                       if (plane->plane.state->crtc != &rcrtc->crtc)
+                               continue;
 
-               rcar_du_plane_setup(plane);
+                       rcar_du_plane_setup(plane);
+               }
        }
 
        rcar_du_crtc_update_planes(rcrtc);
@@ -445,37 +477,20 @@ static void rcar_du_crtc_enable(struct drm_crtc *crtc)
 {
        struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
 
-       if (rcrtc->enabled)
-               return;
-
        rcar_du_crtc_get(rcrtc);
        rcar_du_crtc_start(rcrtc);
-
-       rcrtc->enabled = true;
 }
 
 static void rcar_du_crtc_disable(struct drm_crtc *crtc)
 {
        struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
 
-       if (!rcrtc->enabled)
-               return;
-
        rcar_du_crtc_stop(rcrtc);
        rcar_du_crtc_put(rcrtc);
 
-       rcrtc->enabled = false;
        rcrtc->outputs = 0;
 }
 
-static bool rcar_du_crtc_mode_fixup(struct drm_crtc *crtc,
-                                   const struct drm_display_mode *mode,
-                                   struct drm_display_mode *adjusted_mode)
-{
-       /* TODO Fixup modes */
-       return true;
-}
-
 static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
                                      struct drm_crtc_state *old_crtc_state)
 {
@@ -491,6 +506,9 @@ static void rcar_du_crtc_atomic_begin(struct drm_crtc *crtc,
                rcrtc->event = event;
                spin_unlock_irqrestore(&dev->event_lock, flags);
        }
+
+       if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
+               rcar_du_vsp_atomic_begin(rcrtc);
 }
 
 static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc,
@@ -499,10 +517,12 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc,
        struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
 
        rcar_du_crtc_update_planes(rcrtc);
+
+       if (rcar_du_has(rcrtc->group->dev, RCAR_DU_FEATURE_VSP1_SOURCE))
+               rcar_du_vsp_atomic_flush(rcrtc);
 }
 
 static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
-       .mode_fixup = rcar_du_crtc_mode_fixup,
        .disable = rcar_du_crtc_disable,
        .enable = rcar_du_crtc_enable,
        .atomic_begin = rcar_du_crtc_atomic_begin,
@@ -547,13 +567,14 @@ static irqreturn_t rcar_du_crtc_irq(int irq, void *arg)
 int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index)
 {
        static const unsigned int mmio_offsets[] = {
-               DU0_REG_OFFSET, DU1_REG_OFFSET, DU2_REG_OFFSET
+               DU0_REG_OFFSET, DU1_REG_OFFSET, DU2_REG_OFFSET, DU3_REG_OFFSET
        };
 
        struct rcar_du_device *rcdu = rgrp->dev;
        struct platform_device *pdev = to_platform_device(rcdu->dev);
        struct rcar_du_crtc *rcrtc = &rcdu->crtcs[index];
        struct drm_crtc *crtc = &rcrtc->crtc;
+       struct drm_plane *primary;
        unsigned int irqflags;
        struct clk *clk;
        char clk_name[9];
@@ -589,10 +610,13 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index)
        rcrtc->group = rgrp;
        rcrtc->mmio_offset = mmio_offsets[index];
        rcrtc->index = index;
-       rcrtc->enabled = false;
 
-       ret = drm_crtc_init_with_planes(rcdu->ddev, crtc,
-                                       &rgrp->planes[index % 2].plane,
+       if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE))
+               primary = &rcrtc->vsp->planes[0].plane;
+       else
+               primary = &rgrp->planes[index % 2].plane;
+
+       ret = drm_crtc_init_with_planes(rcdu->ddev, crtc, primary,
                                        NULL, &crtc_funcs, NULL);
        if (ret < 0)
                return ret;
index 2bbe3f5..6f08b7e 100644 (file)
@@ -21,6 +21,7 @@
 #include <drm/drm_crtc.h>
 
 struct rcar_du_group;
+struct rcar_du_vsp;
 
 /**
  * struct rcar_du_crtc - the CRTC, representing a DU superposition processor
@@ -33,7 +34,6 @@ struct rcar_du_group;
  * @event: event to post when the pending page flip completes
  * @flip_wait: wait queue used to signal page flip completion
  * @outputs: bitmask of the outputs (enum rcar_du_output) driven by this CRTC
- * @enabled: whether the CRTC is enabled, used to control system resume
  * @group: CRTC group this CRTC belongs to
  */
 struct rcar_du_crtc {
@@ -49,9 +49,9 @@ struct rcar_du_crtc {
        wait_queue_head_t flip_wait;
 
        unsigned int outputs;
-       bool enabled;
 
        struct rcar_du_group *group;
+       struct rcar_du_vsp *vsp;
 };
 
 #define to_rcar_crtc(c)        container_of(c, struct rcar_du_crtc, crtc)
index 0bb2b31..ed6006b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_drv.c  --  R-Car Display Unit DRM driver
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -36,6 +36,7 @@
  */
 
 static const struct rcar_du_device_info rcar_du_r8a7779_info = {
+       .gen = 2,
        .features = 0,
        .num_crtcs = 2,
        .routes = {
@@ -57,6 +58,7 @@ static const struct rcar_du_device_info rcar_du_r8a7779_info = {
 };
 
 static const struct rcar_du_device_info rcar_du_r8a7790_info = {
+       .gen = 2,
        .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
                  | RCAR_DU_FEATURE_EXT_CTRL_REGS,
        .quirks = RCAR_DU_QUIRK_ALIGN_128B | RCAR_DU_QUIRK_LVDS_LANES,
@@ -86,6 +88,7 @@ static const struct rcar_du_device_info rcar_du_r8a7790_info = {
 
 /* M2-W (r8a7791) and M2-N (r8a7793) are identical */
 static const struct rcar_du_device_info rcar_du_r8a7791_info = {
+       .gen = 2,
        .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
                  | RCAR_DU_FEATURE_EXT_CTRL_REGS,
        .num_crtcs = 2,
@@ -108,6 +111,7 @@ static const struct rcar_du_device_info rcar_du_r8a7791_info = {
 };
 
 static const struct rcar_du_device_info rcar_du_r8a7794_info = {
+       .gen = 2,
        .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
                  | RCAR_DU_FEATURE_EXT_CTRL_REGS,
        .num_crtcs = 2,
@@ -129,12 +133,37 @@ static const struct rcar_du_device_info rcar_du_r8a7794_info = {
        .num_lvds = 0,
 };
 
+static const struct rcar_du_device_info rcar_du_r8a7795_info = {
+       .gen = 3,
+       .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK
+                 | RCAR_DU_FEATURE_EXT_CTRL_REGS
+                 | RCAR_DU_FEATURE_VSP1_SOURCE,
+       .num_crtcs = 4,
+       .routes = {
+               /* R8A7795 has one RGB output, one LVDS output and two
+                * (currently unsupported) HDMI outputs.
+                */
+               [RCAR_DU_OUTPUT_DPAD0] = {
+                       .possible_crtcs = BIT(3),
+                       .encoder_type = DRM_MODE_ENCODER_NONE,
+                       .port = 0,
+               },
+               [RCAR_DU_OUTPUT_LVDS0] = {
+                       .possible_crtcs = BIT(0),
+                       .encoder_type = DRM_MODE_ENCODER_LVDS,
+                       .port = 3,
+               },
+       },
+       .num_lvds = 1,
+};
+
 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 },
        { .compatible = "renesas,du-r8a7793", .data = &rcar_du_r8a7791_info },
        { .compatible = "renesas,du-r8a7794", .data = &rcar_du_r8a7794_info },
+       { .compatible = "renesas,du-r8a7795", .data = &rcar_du_r8a7795_info },
        { }
 };
 
@@ -144,82 +173,6 @@ MODULE_DEVICE_TABLE(of, rcar_du_of_table);
  * DRM operations
  */
 
-static int rcar_du_unload(struct drm_device *dev)
-{
-       struct rcar_du_device *rcdu = dev->dev_private;
-
-       if (rcdu->fbdev)
-               drm_fbdev_cma_fini(rcdu->fbdev);
-
-       drm_kms_helper_poll_fini(dev);
-       drm_mode_config_cleanup(dev);
-       drm_vblank_cleanup(dev);
-
-       dev->irq_enabled = 0;
-       dev->dev_private = NULL;
-
-       return 0;
-}
-
-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_device *rcdu;
-       struct resource *mem;
-       int ret;
-
-       if (np == NULL) {
-               dev_err(dev->dev, "no platform data\n");
-               return -ENODEV;
-       }
-
-       rcdu = devm_kzalloc(&pdev->dev, sizeof(*rcdu), GFP_KERNEL);
-       if (rcdu == NULL) {
-               dev_err(dev->dev, "failed to allocate private data\n");
-               return -ENOMEM;
-       }
-
-       init_waitqueue_head(&rcdu->commit.wait);
-
-       rcdu->dev = &pdev->dev;
-       rcdu->info = of_match_device(rcar_du_of_table, rcdu->dev)->data;
-       rcdu->ddev = dev;
-       dev->dev_private = rcdu;
-
-       /* I/O resources */
-       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       rcdu->mmio = devm_ioremap_resource(&pdev->dev, mem);
-       if (IS_ERR(rcdu->mmio))
-               return PTR_ERR(rcdu->mmio);
-
-       /* Initialize vertical blanking interrupts handling. Start with vblank
-        * disabled for all CRTCs.
-        */
-       ret = drm_vblank_init(dev, (1 << rcdu->info->num_crtcs) - 1);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "failed to initialize vblank\n");
-               goto done;
-       }
-
-       /* DRM/KMS objects */
-       ret = rcar_du_modeset_init(rcdu);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "failed to initialize DRM/KMS (%d)\n", ret);
-               goto done;
-       }
-
-       dev->irq_enabled = 1;
-
-       platform_set_drvdata(pdev, rcdu);
-
-done:
-       if (ret)
-               rcar_du_unload(dev);
-
-       return ret;
-}
-
 static void rcar_du_lastclose(struct drm_device *dev)
 {
        struct rcar_du_device *rcdu = dev->dev_private;
@@ -260,10 +213,7 @@ static const struct file_operations rcar_du_fops = {
 static struct drm_driver rcar_du_driver = {
        .driver_features        = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
                                | DRIVER_ATOMIC,
-       .load                   = rcar_du_load,
-       .unload                 = rcar_du_unload,
        .lastclose              = rcar_du_lastclose,
-       .set_busid              = drm_platform_set_busid,
        .get_vblank_counter     = drm_vblank_no_hw_counter,
        .enable_vblank          = rcar_du_enable_vblank,
        .disable_vblank         = rcar_du_disable_vblank,
@@ -323,18 +273,116 @@ static const struct dev_pm_ops rcar_du_pm_ops = {
  * Platform driver
  */
 
-static int rcar_du_probe(struct platform_device *pdev)
+static int rcar_du_remove(struct platform_device *pdev)
 {
-       return drm_platform_init(&rcar_du_driver, pdev);
+       struct rcar_du_device *rcdu = platform_get_drvdata(pdev);
+       struct drm_device *ddev = rcdu->ddev;
+
+       mutex_lock(&ddev->mode_config.mutex);
+       drm_connector_unplug_all(ddev);
+       mutex_unlock(&ddev->mode_config.mutex);
+
+       drm_dev_unregister(ddev);
+
+       if (rcdu->fbdev)
+               drm_fbdev_cma_fini(rcdu->fbdev);
+
+       drm_kms_helper_poll_fini(ddev);
+       drm_mode_config_cleanup(ddev);
+       drm_vblank_cleanup(ddev);
+
+       drm_dev_unref(ddev);
+
+       return 0;
 }
 
-static int rcar_du_remove(struct platform_device *pdev)
+static int rcar_du_probe(struct platform_device *pdev)
 {
-       struct rcar_du_device *rcdu = platform_get_drvdata(pdev);
+       struct device_node *np = pdev->dev.of_node;
+       struct rcar_du_device *rcdu;
+       struct drm_connector *connector;
+       struct drm_device *ddev;
+       struct resource *mem;
+       int ret;
 
-       drm_put_dev(rcdu->ddev);
+       if (np == NULL) {
+               dev_err(&pdev->dev, "no device tree node\n");
+               return -ENODEV;
+       }
+
+       /* Allocate and initialize the DRM and R-Car device structures. */
+       rcdu = devm_kzalloc(&pdev->dev, sizeof(*rcdu), GFP_KERNEL);
+       if (rcdu == NULL)
+               return -ENOMEM;
+
+       init_waitqueue_head(&rcdu->commit.wait);
+
+       rcdu->dev = &pdev->dev;
+       rcdu->info = of_match_device(rcar_du_of_table, rcdu->dev)->data;
+
+       ddev = drm_dev_alloc(&rcar_du_driver, &pdev->dev);
+       if (!ddev)
+               return -ENOMEM;
+
+       drm_dev_set_unique(ddev, dev_name(&pdev->dev));
+
+       rcdu->ddev = ddev;
+       ddev->dev_private = rcdu;
+
+       platform_set_drvdata(pdev, rcdu);
+
+       /* I/O resources */
+       mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       rcdu->mmio = devm_ioremap_resource(&pdev->dev, mem);
+       if (IS_ERR(rcdu->mmio)) {
+               ret = PTR_ERR(rcdu->mmio);
+               goto error;
+       }
+
+       /* Initialize vertical blanking interrupts handling. Start with vblank
+        * disabled for all CRTCs.
+        */
+       ret = drm_vblank_init(ddev, (1 << rcdu->info->num_crtcs) - 1);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "failed to initialize vblank\n");
+               goto error;
+       }
+
+       /* DRM/KMS objects */
+       ret = rcar_du_modeset_init(rcdu);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "failed to initialize DRM/KMS (%d)\n", ret);
+               goto error;
+       }
+
+       ddev->irq_enabled = 1;
+
+       /* Register the DRM device with the core and the connectors with
+        * sysfs.
+        */
+       ret = drm_dev_register(ddev, 0);
+       if (ret)
+               goto error;
+
+       mutex_lock(&ddev->mode_config.mutex);
+       drm_for_each_connector(connector, ddev) {
+               ret = drm_connector_register(connector);
+               if (ret < 0)
+                       break;
+       }
+       mutex_unlock(&ddev->mode_config.mutex);
+
+       if (ret < 0)
+               goto error;
+
+       DRM_INFO("Device %s probed\n", dev_name(&pdev->dev));
 
        return 0;
+
+error:
+       rcar_du_remove(pdev);
+
+       return ret;
 }
 
 static struct platform_driver rcar_du_platform_driver = {
index 9f34fc8..ed35467 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_drv.h  --  R-Car Display Unit DRM driver
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -19,6 +19,7 @@
 
 #include "rcar_du_crtc.h"
 #include "rcar_du_group.h"
+#include "rcar_du_vsp.h"
 
 struct clk;
 struct device;
@@ -29,6 +30,7 @@ struct rcar_du_lvdsenc;
 
 #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0)        /* Per-CRTC IRQ and clock */
 #define RCAR_DU_FEATURE_EXT_CTRL_REGS  (1 << 1)        /* Has extended control registers */
+#define RCAR_DU_FEATURE_VSP1_SOURCE    (1 << 2)        /* Has inputs from VSP1 */
 
 #define RCAR_DU_QUIRK_ALIGN_128B       (1 << 0)        /* Align pitches to 128 bytes */
 #define RCAR_DU_QUIRK_LVDS_LANES       (1 << 1)        /* LVDS lanes 1 and 3 inverted */
@@ -51,6 +53,7 @@ struct rcar_du_output_routing {
 
 /*
  * struct rcar_du_device_info - DU model-specific information
+ * @gen: device generation (2 or 3)
  * @features: device features (RCAR_DU_FEATURE_*)
  * @quirks: device quirks (RCAR_DU_QUIRK_*)
  * @num_crtcs: total number of CRTCs
@@ -58,6 +61,7 @@ struct rcar_du_output_routing {
  * @num_lvds: number of internal LVDS encoders
  */
 struct rcar_du_device_info {
+       unsigned int gen;
        unsigned int features;
        unsigned int quirks;
        unsigned int num_crtcs;
@@ -65,9 +69,10 @@ struct rcar_du_device_info {
        unsigned int num_lvds;
 };
 
-#define RCAR_DU_MAX_CRTCS              3
+#define RCAR_DU_MAX_CRTCS              4
 #define RCAR_DU_MAX_GROUPS             DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
 #define RCAR_DU_MAX_LVDS               2
+#define RCAR_DU_MAX_VSPS               4
 
 struct rcar_du_device {
        struct device *dev;
@@ -82,6 +87,7 @@ struct rcar_du_device {
        unsigned int num_crtcs;
 
        struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
+       struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
 
        struct {
                struct drm_property *alpha;
@@ -90,6 +96,8 @@ struct rcar_du_device {
        } props;
 
        unsigned int dpad0_source;
+       unsigned int vspd1_sink;
+
        struct rcar_du_lvdsenc *lvds[RCAR_DU_MAX_LVDS];
 
        struct {
index c087007..4e939e4 100644 (file)
@@ -89,12 +89,8 @@ static int rcar_du_encoder_atomic_check(struct drm_encoder *encoder,
        /* The flat panel mode is fixed, just copy it to the adjusted mode. */
        drm_mode_copy(adjusted_mode, panel_mode);
 
-       /* The internal LVDS encoder has a clock frequency operating range of
-        * 30MHz to 150MHz. Clamp the clock accordingly.
-        */
        if (renc->lvds)
-               adjusted_mode->clock = clamp(adjusted_mode->clock,
-                                            30000, 150000);
+               rcar_du_lvdsenc_atomic_check(renc->lvds, adjusted_mode);
 
        return 0;
 }
index 8e2ffe0..33b2fc5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_group.c  --  R-Car Display Unit Channels Pair
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -44,29 +44,64 @@ void rcar_du_group_write(struct rcar_du_group *rgrp, u32 reg, u32 data)
        rcar_du_write(rgrp->dev, rgrp->mmio_offset + reg, data);
 }
 
+static void rcar_du_group_setup_pins(struct rcar_du_group *rgrp)
+{
+       u32 defr6 = DEFR6_CODE | DEFR6_ODPM12_DISP;
+
+       if (rgrp->num_crtcs > 1)
+               defr6 |= DEFR6_ODPM22_DISP;
+
+       rcar_du_group_write(rgrp, DEFR6, defr6);
+}
+
 static void rcar_du_group_setup_defr8(struct rcar_du_group *rgrp)
 {
-       u32 defr8 = DEFR8_CODE | DEFR8_DEFE8;
+       struct rcar_du_device *rcdu = rgrp->dev;
+       unsigned int possible_crtcs =
+               rcdu->info->routes[RCAR_DU_OUTPUT_DPAD0].possible_crtcs;
+       u32 defr8 = DEFR8_CODE;
 
-       /* The DEFR8 register for the first group also controls RGB output
-        * routing to DPAD0 for DU instances that support it.
-        */
-       if (rgrp->dev->info->routes[RCAR_DU_OUTPUT_DPAD0].possible_crtcs > 1 &&
-           rgrp->index == 0)
-               defr8 |= DEFR8_DRGBS_DU(rgrp->dev->dpad0_source);
+       if (rcdu->info->gen < 3) {
+               defr8 |= DEFR8_DEFE8;
+
+               /* On Gen2 the DEFR8 register for the first group also controls
+                * RGB output routing to DPAD0 and VSPD1 routing to DU0/1/2 for
+                * DU instances that support it.
+                */
+               if (rgrp->index == 0) {
+                       if (possible_crtcs > 1)
+                               defr8 |= DEFR8_DRGBS_DU(rcdu->dpad0_source);
+                       if (rgrp->dev->vspd1_sink == 2)
+                               defr8 |= DEFR8_VSCS;
+               }
+       } else {
+               /* On Gen3 VSPD routing can't be configured, but DPAD routing
+                * needs to be set despite having a single option available.
+                */
+               u32 crtc = ffs(possible_crtcs) - 1;
+
+               if (crtc / 2 == rgrp->index)
+                       defr8 |= DEFR8_DRGBS_DU(crtc);
+       }
 
        rcar_du_group_write(rgrp, DEFR8, defr8);
 }
 
 static void rcar_du_group_setup(struct rcar_du_group *rgrp)
 {
+       struct rcar_du_device *rcdu = rgrp->dev;
+
        /* Enable extended features */
        rcar_du_group_write(rgrp, DEFR, DEFR_CODE | DEFR_DEFE);
-       rcar_du_group_write(rgrp, DEFR2, DEFR2_CODE | DEFR2_DEFE2G);
-       rcar_du_group_write(rgrp, DEFR3, DEFR3_CODE | DEFR3_DEFE3);
-       rcar_du_group_write(rgrp, DEFR4, DEFR4_CODE);
+       if (rcdu->info->gen < 3) {
+               rcar_du_group_write(rgrp, DEFR2, DEFR2_CODE | DEFR2_DEFE2G);
+               rcar_du_group_write(rgrp, DEFR3, DEFR3_CODE | DEFR3_DEFE3);
+               rcar_du_group_write(rgrp, DEFR4, DEFR4_CODE);
+       }
        rcar_du_group_write(rgrp, DEFR5, DEFR5_CODE | DEFR5_DEFE5);
 
+       rcar_du_group_setup_pins(rgrp);
+
        if (rcar_du_has(rgrp->dev, RCAR_DU_FEATURE_EXT_CTRL_REGS)) {
                rcar_du_group_setup_defr8(rgrp);
 
@@ -82,6 +117,9 @@ static void rcar_du_group_setup(struct rcar_du_group *rgrp)
                                    DIDSR_PDCS_CLK(0, 0));
        }
 
+       if (rcdu->info->gen >= 3)
+               rcar_du_group_write(rgrp, DEFR10, DEFR10_CODE | DEFR10_DEFE10);
+
        /* Use DS1PR and DS2PR to configure planes priorities and connects the
         * superposition 0 to DU0 pins. DU1 pins will be configured dynamically.
         */
@@ -158,21 +196,23 @@ void rcar_du_group_start_stop(struct rcar_du_group *rgrp, bool start)
 
 void rcar_du_group_restart(struct rcar_du_group *rgrp)
 {
+       rgrp->need_restart = false;
+
        __rcar_du_group_start_stop(rgrp, false);
        __rcar_du_group_start_stop(rgrp, true);
 }
 
-static int rcar_du_set_dpad0_routing(struct rcar_du_device *rcdu)
+int rcar_du_set_dpad0_vsp1_routing(struct rcar_du_device *rcdu)
 {
        int ret;
 
        if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_EXT_CTRL_REGS))
                return 0;
 
-       /* RGB output routing to DPAD0 is configured in the DEFR8 register of
-        * the first group. As this function can be called with the DU0 and DU1
-        * CRTCs disabled, we need to enable the first group clock before
-        * accessing the register.
+       /* RGB output routing to DPAD0 and VSP1D routing to DU0/1/2 are
+        * configured in the DEFR8 register of the first group. As this function
+        * can be called with the DU0 and DU1 CRTCs disabled, we need to enable
+        * the first group clock before accessing the register.
         */
        ret = clk_prepare_enable(rcdu->crtcs[0].clock);
        if (ret < 0)
@@ -203,5 +243,5 @@ int rcar_du_group_set_routing(struct rcar_du_group *rgrp)
 
        rcar_du_group_write(rgrp, DORCR, dorcr);
 
-       return rcar_du_set_dpad0_routing(rgrp->dev);
+       return rcar_du_set_dpad0_vsp1_routing(rgrp->dev);
 }
index d7318e1..5e3adc6 100644 (file)
@@ -32,6 +32,7 @@ struct rcar_du_device;
  * @dptsr_planes: bitmask of planes driven by dot-clock and timing generator 1
  * @num_planes: number of planes in the group
  * @planes: planes handled by the group
+ * @need_restart: the group needs to be restarted due to a configuration change
  */
 struct rcar_du_group {
        struct rcar_du_device *dev;
@@ -47,6 +48,7 @@ struct rcar_du_group {
 
        unsigned int num_planes;
        struct rcar_du_plane planes[RCAR_DU_NUM_KMS_PLANES];
+       bool need_restart;
 };
 
 u32 rcar_du_group_read(struct rcar_du_group *rgrp, u32 reg);
@@ -58,4 +60,6 @@ void rcar_du_group_start_stop(struct rcar_du_group *rgrp, bool start);
 void rcar_du_group_restart(struct rcar_du_group *rgrp);
 int rcar_du_group_set_routing(struct rcar_du_group *rgrp);
 
+int rcar_du_set_dpad0_vsp1_routing(struct rcar_du_device *rcdu);
+
 #endif /* __RCAR_DU_GROUP_H__ */
index a37b6e2..6c92714 100644 (file)
@@ -55,12 +55,6 @@ static const struct drm_connector_helper_funcs connector_helper_funcs = {
        .best_encoder = rcar_du_connector_best_encoder,
 };
 
-static void rcar_du_hdmi_connector_destroy(struct drm_connector *connector)
-{
-       drm_connector_unregister(connector);
-       drm_connector_cleanup(connector);
-}
-
 static enum drm_connector_status
 rcar_du_hdmi_connector_detect(struct drm_connector *connector, bool force)
 {
@@ -79,7 +73,7 @@ static const struct drm_connector_funcs connector_funcs = {
        .reset = drm_atomic_helper_connector_reset,
        .detect = rcar_du_hdmi_connector_detect,
        .fill_modes = drm_helper_probe_single_connector_modes,
-       .destroy = rcar_du_hdmi_connector_destroy,
+       .destroy = drm_connector_cleanup,
        .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
@@ -108,9 +102,6 @@ int rcar_du_hdmi_connector_init(struct rcar_du_device *rcdu,
                return ret;
 
        drm_connector_helper_add(connector, &connector_helper_funcs);
-       ret = drm_connector_register(connector);
-       if (ret < 0)
-               return ret;
 
        connector->dpms = DRM_MODE_DPMS_OFF;
        drm_object_property_set_value(&connector->base,
index 2567efc..461662d 100644 (file)
@@ -71,12 +71,9 @@ static int rcar_du_hdmienc_atomic_check(struct drm_encoder *encoder,
        struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
        const struct drm_display_mode *mode = &crtc_state->mode;
 
-       /* The internal LVDS encoder has a clock frequency operating range of
-        * 30MHz to 150MHz. Clamp the clock accordingly.
-        */
        if (hdmienc->renc->lvds)
-               adjusted_mode->clock = clamp(adjusted_mode->clock,
-                                            30000, 150000);
+               rcar_du_lvdsenc_atomic_check(hdmienc->renc->lvds,
+                                            adjusted_mode);
 
        if (sfuncs->mode_fixup == NULL)
                return 0;
@@ -134,12 +131,19 @@ int rcar_du_hdmienc_init(struct rcar_du_device *rcdu,
 
        /* Locate the slave I2C device and driver. */
        i2c_slave = of_find_i2c_device_by_node(np);
-       if (!i2c_slave || !i2c_get_clientdata(i2c_slave))
+       if (!i2c_slave || !i2c_get_clientdata(i2c_slave)) {
+               dev_dbg(rcdu->dev,
+                       "can't get I2C slave for %s, deferring probe\n",
+                       of_node_full_name(np));
                return -EPROBE_DEFER;
+       }
 
        hdmienc->dev = &i2c_slave->dev;
 
        if (hdmienc->dev->driver == NULL) {
+               dev_dbg(rcdu->dev,
+                       "I2C slave %s not probed yet, deferring probe\n",
+                       dev_name(hdmienc->dev));
                ret = -EPROBE_DEFER;
                goto error;
        }
index 43bce69..24725bf 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_kms.c  --  R-Car Display Unit Mode Setting
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -28,6 +28,7 @@
 #include "rcar_du_kms.h"
 #include "rcar_du_lvdsenc.h"
 #include "rcar_du_regs.h"
+#include "rcar_du_vsp.h"
 
 /* -----------------------------------------------------------------------------
  * Format helpers
@@ -89,13 +90,44 @@ static const struct rcar_du_format_info rcar_du_format_infos[] = {
                .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
                .edf = PnDDCR4_EDF_NONE,
        }, {
-               /* In YUV 4:2:2, only NV16 is supported (NV61 isn't) */
                .fourcc = DRM_FORMAT_NV16,
                .bpp = 16,
                .planes = 2,
                .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC,
                .edf = PnDDCR4_EDF_NONE,
        },
+       /* The following formats are not supported on Gen2 and thus have no
+        * associated .pnmr or .edf settings.
+        */
+       {
+               .fourcc = DRM_FORMAT_NV61,
+               .bpp = 16,
+               .planes = 2,
+       }, {
+               .fourcc = DRM_FORMAT_YUV420,
+               .bpp = 12,
+               .planes = 3,
+       }, {
+               .fourcc = DRM_FORMAT_YVU420,
+               .bpp = 12,
+               .planes = 3,
+       }, {
+               .fourcc = DRM_FORMAT_YUV422,
+               .bpp = 16,
+               .planes = 3,
+       }, {
+               .fourcc = DRM_FORMAT_YVU422,
+               .bpp = 16,
+               .planes = 3,
+       }, {
+               .fourcc = DRM_FORMAT_YUV444,
+               .bpp = 24,
+               .planes = 3,
+       }, {
+               .fourcc = DRM_FORMAT_YVU444,
+               .bpp = 24,
+               .planes = 3,
+       },
 };
 
 const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc)
@@ -143,6 +175,7 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
        unsigned int max_pitch;
        unsigned int align;
        unsigned int bpp;
+       unsigned int i;
 
        format = rcar_du_format_info(mode_cmd->pixel_format);
        if (format == NULL) {
@@ -155,7 +188,7 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
         * 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;
+       bpp = format->planes == 1 ? format->bpp / 8 : 1;
        max_pitch =  4096 * bpp;
 
        if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B))
@@ -170,8 +203,8 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
                return ERR_PTR(-EINVAL);
        }
 
-       if (format->planes == 2) {
-               if (mode_cmd->pitches[1] != mode_cmd->pitches[0]) {
+       for (i = 1; i < format->planes; ++i) {
+               if (mode_cmd->pitches[i] != mode_cmd->pitches[0]) {
                        dev_dbg(dev->dev,
                                "luma and chroma pitches do not match\n");
                        return ERR_PTR(-EINVAL);
@@ -192,252 +225,20 @@ static void rcar_du_output_poll_changed(struct drm_device *dev)
  * Atomic Check and Update
  */
 
-/*
- * Atomic hardware plane allocator
- *
- * The hardware plane allocator is solely based on the atomic plane states
- * without keeping any external state to avoid races between .atomic_check()
- * and .atomic_commit().
- *
- * The core idea is to avoid using a free planes bitmask that would need to be
- * shared between check and commit handlers with a collective knowledge based on
- * the allocated hardware plane(s) for each KMS plane. The allocator then loops
- * over all plane states to compute the free planes bitmask, allocates hardware
- * planes based on that bitmask, and stores the result back in the plane states.
- *
- * For this to work we need to access the current state of planes not touched by
- * the atomic update. To ensure that it won't be modified, we need to lock all
- * planes using drm_atomic_get_plane_state(). This effectively serializes atomic
- * updates from .atomic_check() up to completion (when swapping the states if
- * the check step has succeeded) or rollback (when freeing the states if the
- * check step has failed).
- *
- * Allocation is performed in the .atomic_check() handler and applied
- * automatically when the core swaps the old and new states.
- */
-
-static bool rcar_du_plane_needs_realloc(struct rcar_du_plane *plane,
-                                       struct rcar_du_plane_state *state)
-{
-       const struct rcar_du_format_info *cur_format;
-
-       cur_format = to_rcar_plane_state(plane->plane.state)->format;
-
-       /* Lowering the number of planes doesn't strictly require reallocation
-        * as the extra hardware plane will be freed when committing, but doing
-        * so could lead to more fragmentation.
-        */
-       return !cur_format || cur_format->planes != state->format->planes;
-}
-
-static unsigned int rcar_du_plane_hwmask(struct rcar_du_plane_state *state)
-{
-       unsigned int mask;
-
-       if (state->hwindex == -1)
-               return 0;
-
-       mask = 1 << state->hwindex;
-       if (state->format->planes == 2)
-               mask |= 1 << ((state->hwindex + 1) % 8);
-
-       return mask;
-}
-
-static int rcar_du_plane_hwalloc(unsigned int num_planes, unsigned int free)
-{
-       unsigned int i;
-
-       for (i = 0; i < RCAR_DU_NUM_HW_PLANES; ++i) {
-               if (!(free & (1 << i)))
-                       continue;
-
-               if (num_planes == 1 || free & (1 << ((i + 1) % 8)))
-                       break;
-       }
-
-       return i == RCAR_DU_NUM_HW_PLANES ? -EBUSY : i;
-}
-
 static int rcar_du_atomic_check(struct drm_device *dev,
                                struct drm_atomic_state *state)
 {
        struct rcar_du_device *rcdu = dev->dev_private;
-       unsigned int group_freed_planes[RCAR_DU_MAX_GROUPS] = { 0, };
-       unsigned int group_free_planes[RCAR_DU_MAX_GROUPS] = { 0, };
-       bool needs_realloc = false;
-       unsigned int groups = 0;
-       unsigned int i;
        int ret;
 
        ret = drm_atomic_helper_check(dev, state);
        if (ret < 0)
                return ret;
 
-       /* Check if hardware planes need to be reallocated. */
-       for (i = 0; i < dev->mode_config.num_total_plane; ++i) {
-               struct rcar_du_plane_state *plane_state;
-               struct rcar_du_plane *plane;
-               unsigned int index;
-
-               if (!state->planes[i])
-                       continue;
-
-               plane = to_rcar_plane(state->planes[i]);
-               plane_state = to_rcar_plane_state(state->plane_states[i]);
-
-               dev_dbg(rcdu->dev, "%s: checking plane (%u,%u)\n", __func__,
-                       plane->group->index, plane - plane->group->planes);
-
-               /* If the plane is being disabled we don't need to go through
-                * the full reallocation procedure. Just mark the hardware
-                * plane(s) as freed.
-                */
-               if (!plane_state->format) {
-                       dev_dbg(rcdu->dev, "%s: plane is being disabled\n",
-                               __func__);
-                       index = plane - plane->group->planes;
-                       group_freed_planes[plane->group->index] |= 1 << index;
-                       plane_state->hwindex = -1;
-                       continue;
-               }
-
-               /* If the plane needs to be reallocated mark it as such, and
-                * mark the hardware plane(s) as free.
-                */
-               if (rcar_du_plane_needs_realloc(plane, plane_state)) {
-                       dev_dbg(rcdu->dev, "%s: plane needs reallocation\n",
-                               __func__);
-                       groups |= 1 << plane->group->index;
-                       needs_realloc = true;
-
-                       index = plane - plane->group->planes;
-                       group_freed_planes[plane->group->index] |= 1 << index;
-                       plane_state->hwindex = -1;
-               }
-       }
-
-       if (!needs_realloc)
+       if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE))
                return 0;
 
-       /* Grab all plane states for the groups that need reallocation to ensure
-        * locking and avoid racy updates. This serializes the update operation,
-        * but there's not much we can do about it as that's the hardware
-        * design.
-        *
-        * Compute the used planes mask for each group at the same time to avoid
-        * looping over the planes separately later.
-        */
-       while (groups) {
-               unsigned int index = ffs(groups) - 1;
-               struct rcar_du_group *group = &rcdu->groups[index];
-               unsigned int used_planes = 0;
-
-               dev_dbg(rcdu->dev, "%s: finding free planes for group %u\n",
-                       __func__, index);
-
-               for (i = 0; i < group->num_planes; ++i) {
-                       struct rcar_du_plane *plane = &group->planes[i];
-                       struct rcar_du_plane_state *plane_state;
-                       struct drm_plane_state *s;
-
-                       s = drm_atomic_get_plane_state(state, &plane->plane);
-                       if (IS_ERR(s))
-                               return PTR_ERR(s);
-
-                       /* If the plane has been freed in the above loop its
-                        * hardware planes must not be added to the used planes
-                        * bitmask. However, the current state doesn't reflect
-                        * the free state yet, as we've modified the new state
-                        * above. Use the local freed planes list to check for
-                        * that condition instead.
-                        */
-                       if (group_freed_planes[index] & (1 << i)) {
-                               dev_dbg(rcdu->dev,
-                                       "%s: plane (%u,%u) has been freed, skipping\n",
-                                       __func__, plane->group->index,
-                                       plane - plane->group->planes);
-                               continue;
-                       }
-
-                       plane_state = to_rcar_plane_state(plane->plane.state);
-                       used_planes |= rcar_du_plane_hwmask(plane_state);
-
-                       dev_dbg(rcdu->dev,
-                               "%s: plane (%u,%u) uses %u hwplanes (index %d)\n",
-                               __func__, plane->group->index,
-                               plane - plane->group->planes,
-                               plane_state->format ?
-                               plane_state->format->planes : 0,
-                               plane_state->hwindex);
-               }
-
-               group_free_planes[index] = 0xff & ~used_planes;
-               groups &= ~(1 << index);
-
-               dev_dbg(rcdu->dev, "%s: group %u free planes mask 0x%02x\n",
-                       __func__, index, group_free_planes[index]);
-       }
-
-       /* Reallocate hardware planes for each plane that needs it. */
-       for (i = 0; i < dev->mode_config.num_total_plane; ++i) {
-               struct rcar_du_plane_state *plane_state;
-               struct rcar_du_plane *plane;
-               unsigned int crtc_planes;
-               unsigned int free;
-               int idx;
-
-               if (!state->planes[i])
-                       continue;
-
-               plane = to_rcar_plane(state->planes[i]);
-               plane_state = to_rcar_plane_state(state->plane_states[i]);
-
-               dev_dbg(rcdu->dev, "%s: allocating plane (%u,%u)\n", __func__,
-                       plane->group->index, plane - plane->group->planes);
-
-               /* Skip planes that are being disabled or don't need to be
-                * reallocated.
-                */
-               if (!plane_state->format ||
-                   !rcar_du_plane_needs_realloc(plane, plane_state))
-                       continue;
-
-               /* Try to allocate the plane from the free planes currently
-                * associated with the target CRTC to avoid restarting the CRTC
-                * group and thus minimize flicker. If it fails fall back to
-                * allocating from all free planes.
-                */
-               crtc_planes = to_rcar_crtc(plane_state->state.crtc)->index % 2
-                           ? plane->group->dptsr_planes
-                           : ~plane->group->dptsr_planes;
-               free = group_free_planes[plane->group->index];
-
-               idx = rcar_du_plane_hwalloc(plane_state->format->planes,
-                                           free & crtc_planes);
-               if (idx < 0)
-                       idx = rcar_du_plane_hwalloc(plane_state->format->planes,
-                                                   free);
-               if (idx < 0) {
-                       dev_dbg(rcdu->dev, "%s: no available hardware plane\n",
-                               __func__);
-                       return idx;
-               }
-
-               dev_dbg(rcdu->dev, "%s: allocated %u hwplanes (index %u)\n",
-                       __func__, plane_state->format->planes, idx);
-
-               plane_state->hwindex = idx;
-
-               group_free_planes[plane->group->index] &=
-                       ~rcar_du_plane_hwmask(plane_state);
-
-               dev_dbg(rcdu->dev, "%s: group %u free planes mask 0x%02x\n",
-                       __func__, plane->group->index,
-                       group_free_planes[plane->group->index]);
-       }
-
-       return 0;
+       return rcar_du_atomic_check_planes(dev, state);
 }
 
 struct rcar_du_commit {
@@ -456,7 +257,7 @@ static void rcar_du_atomic_complete(struct rcar_du_commit *commit)
        /* Apply the atomic update. */
        drm_atomic_helper_commit_modeset_disables(dev, old_state);
        drm_atomic_helper_commit_modeset_enables(dev, old_state);
-       drm_atomic_helper_commit_planes(dev, old_state, false);
+       drm_atomic_helper_commit_planes(dev, old_state, true);
 
        drm_atomic_helper_wait_for_vblanks(dev, old_state);
 
@@ -775,14 +576,34 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
                rgrp->num_crtcs = min(rcdu->num_crtcs - 2 * i, 2U);
 
                /* If we have more than one CRTCs in this group pre-associate
-                * planes 0-3 with CRTC 0 and planes 4-7 with CRTC 1 to minimize
-                * flicker occurring when the association is changed.
+                * the low-order planes with CRTC 0 and the high-order planes
+                * with CRTC 1 to minimize flicker occurring when the
+                * association is changed.
                 */
-               rgrp->dptsr_planes = rgrp->num_crtcs > 1 ? 0xf0 : 0;
+               rgrp->dptsr_planes = rgrp->num_crtcs > 1
+                                  ? (rcdu->info->gen >= 3 ? 0x04 : 0xf0)
+                                  : 0;
 
-               ret = rcar_du_planes_init(rgrp);
-               if (ret < 0)
-                       return ret;
+               if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
+                       ret = rcar_du_planes_init(rgrp);
+                       if (ret < 0)
+                               return ret;
+               }
+       }
+
+       /* Initialize the compositors. */
+       if (rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) {
+               for (i = 0; i < rcdu->num_crtcs; ++i) {
+                       struct rcar_du_vsp *vsp = &rcdu->vsps[i];
+
+                       vsp->index = i;
+                       vsp->dev = rcdu;
+                       rcdu->crtcs[i].vsp = vsp;
+
+                       ret = rcar_du_vsp_init(vsp);
+                       if (ret < 0)
+                               return ret;
+               }
        }
 
        /* Create the CRTCs. */
index 0c43032..e905f5d 100644 (file)
@@ -62,12 +62,6 @@ static const struct drm_connector_helper_funcs connector_helper_funcs = {
        .best_encoder = rcar_du_connector_best_encoder,
 };
 
-static void rcar_du_lvds_connector_destroy(struct drm_connector *connector)
-{
-       drm_connector_unregister(connector);
-       drm_connector_cleanup(connector);
-}
-
 static enum drm_connector_status
 rcar_du_lvds_connector_detect(struct drm_connector *connector, bool force)
 {
@@ -79,7 +73,7 @@ static const struct drm_connector_funcs connector_funcs = {
        .reset = drm_atomic_helper_connector_reset,
        .detect = rcar_du_lvds_connector_detect,
        .fill_modes = drm_helper_probe_single_connector_modes,
-       .destroy = rcar_du_lvds_connector_destroy,
+       .destroy = drm_connector_cleanup,
        .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
@@ -117,9 +111,6 @@ int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu,
                return ret;
 
        drm_connector_helper_add(connector, &connector_helper_funcs);
-       ret = drm_connector_register(connector);
-       if (ret < 0)
-               return ret;
 
        connector->dpms = DRM_MODE_DPMS_OFF;
        drm_object_property_set_value(&connector->base,
index 85043c5..ef3a503 100644 (file)
@@ -38,35 +38,106 @@ static void rcar_lvds_write(struct rcar_du_lvdsenc *lvds, u32 reg, u32 data)
        iowrite32(data, lvds->mmio + reg);
 }
 
-static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc *lvds,
-                                struct rcar_du_crtc *rcrtc)
+static void rcar_du_lvdsenc_start_gen2(struct rcar_du_lvdsenc *lvds,
+                                      struct rcar_du_crtc *rcrtc)
 {
        const struct drm_display_mode *mode = &rcrtc->crtc.mode;
        unsigned int freq = mode->clock;
        u32 lvdcr0;
-       u32 lvdhcr;
        u32 pllcr;
-       int ret;
-
-       if (lvds->enabled)
-               return 0;
-
-       ret = clk_prepare_enable(lvds->clock);
-       if (ret < 0)
-               return ret;
 
        /* PLL clock configuration */
-       if (freq <= 38000)
+       if (freq < 39000)
                pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_38M;
-       else if (freq <= 60000)
+       else if (freq < 61000)
                pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_60M;
-       else if (freq <= 121000)
+       else if (freq < 121000)
                pllcr = LVDPLLCR_CEEN | LVDPLLCR_COSEL | LVDPLLCR_PLLDLYCNT_121M;
        else
                pllcr = LVDPLLCR_PLLDLYCNT_150M;
 
        rcar_lvds_write(lvds, LVDPLLCR, pllcr);
 
+       /* Select the input, hardcode mode 0, enable LVDS operation and turn
+        * bias circuitry on.
+        */
+       lvdcr0 = LVDCR0_BEN | LVDCR0_LVEN;
+       if (rcrtc->index == 2)
+               lvdcr0 |= LVDCR0_DUSEL;
+       rcar_lvds_write(lvds, LVDCR0, lvdcr0);
+
+       /* Turn all the channels on. */
+       rcar_lvds_write(lvds, LVDCR1,
+                       LVDCR1_CHSTBY_GEN2(3) | LVDCR1_CHSTBY_GEN2(2) |
+                       LVDCR1_CHSTBY_GEN2(1) | LVDCR1_CHSTBY_GEN2(0) |
+                       LVDCR1_CLKSTBY_GEN2);
+
+       /* Turn the PLL on, wait for the startup delay, and turn the output
+        * on.
+        */
+       lvdcr0 |= LVDCR0_PLLON;
+       rcar_lvds_write(lvds, LVDCR0, lvdcr0);
+
+       usleep_range(100, 150);
+
+       lvdcr0 |= LVDCR0_LVRES;
+       rcar_lvds_write(lvds, LVDCR0, lvdcr0);
+}
+
+static void rcar_du_lvdsenc_start_gen3(struct rcar_du_lvdsenc *lvds,
+                                      struct rcar_du_crtc *rcrtc)
+{
+       const struct drm_display_mode *mode = &rcrtc->crtc.mode;
+       unsigned int freq = mode->clock;
+       u32 lvdcr0;
+       u32 pllcr;
+
+       /* PLL clock configuration */
+       if (freq < 42000)
+               pllcr = LVDPLLCR_PLLDIVCNT_42M;
+       else if (freq < 85000)
+               pllcr = LVDPLLCR_PLLDIVCNT_85M;
+       else if (freq < 128000)
+               pllcr = LVDPLLCR_PLLDIVCNT_128M;
+       else
+               pllcr = LVDPLLCR_PLLDIVCNT_148M;
+
+       rcar_lvds_write(lvds, LVDPLLCR, pllcr);
+
+       /* Turn the PLL on, set it to LVDS normal mode, wait for the startup
+        * delay and turn the output on.
+        */
+       lvdcr0 = LVDCR0_PLLON;
+       rcar_lvds_write(lvds, LVDCR0, lvdcr0);
+
+       lvdcr0 |= LVDCR0_PWD;
+       rcar_lvds_write(lvds, LVDCR0, lvdcr0);
+
+       usleep_range(100, 150);
+
+       lvdcr0 |= LVDCR0_LVRES;
+       rcar_lvds_write(lvds, LVDCR0, lvdcr0);
+
+       /* Turn all the channels on. */
+       rcar_lvds_write(lvds, LVDCR1,
+                       LVDCR1_CHSTBY_GEN3(3) | LVDCR1_CHSTBY_GEN3(2) |
+                       LVDCR1_CHSTBY_GEN3(1) | LVDCR1_CHSTBY_GEN3(0) |
+                       LVDCR1_CLKSTBY_GEN3);
+}
+
+static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc *lvds,
+                                struct rcar_du_crtc *rcrtc)
+{
+       u32 lvdhcr;
+       int ret;
+
+       if (lvds->enabled)
+               return 0;
+
+       ret = clk_prepare_enable(lvds->clock);
+       if (ret < 0)
+               return ret;
+
        /* Hardcode the channels and control signals routing for now.
         *
         * HSYNC -> CTRL0
@@ -87,30 +158,14 @@ static int rcar_du_lvdsenc_start(struct rcar_du_lvdsenc *lvds,
 
        rcar_lvds_write(lvds, LVDCHCR, lvdhcr);
 
-       /* Select the input, hardcode mode 0, enable LVDS operation and turn
-        * bias circuitry on.
-        */
-       lvdcr0 = LVDCR0_BEN | LVDCR0_LVEN;
-       if (rcrtc->index == 2)
-               lvdcr0 |= LVDCR0_DUSEL;
-       rcar_lvds_write(lvds, LVDCR0, lvdcr0);
-
-       /* Turn all the channels on. */
-       rcar_lvds_write(lvds, LVDCR1, LVDCR1_CHSTBY(3) | LVDCR1_CHSTBY(2) |
-                       LVDCR1_CHSTBY(1) | LVDCR1_CHSTBY(0) | LVDCR1_CLKSTBY);
-
-       /* Turn the PLL on, wait for the startup delay, and turn the output
-        * on.
-        */
-       lvdcr0 |= LVDCR0_PLLEN;
-       rcar_lvds_write(lvds, LVDCR0, lvdcr0);
-
-       usleep_range(100, 150);
-
-       lvdcr0 |= LVDCR0_LVRES;
-       rcar_lvds_write(lvds, LVDCR0, lvdcr0);
+       /* Perform generation-specific initialization. */
+       if (lvds->dev->info->gen < 3)
+               rcar_du_lvdsenc_start_gen2(lvds, rcrtc);
+       else
+               rcar_du_lvdsenc_start_gen3(lvds, rcrtc);
 
        lvds->enabled = true;
+
        return 0;
 }
 
@@ -140,6 +195,21 @@ int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds, struct drm_crtc *crtc,
                return -EINVAL;
 }
 
+void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
+                                 struct drm_display_mode *mode)
+{
+       struct rcar_du_device *rcdu = lvds->dev;
+
+       /* The internal LVDS encoder has a restricted clock frequency operating
+        * range (30MHz to 150MHz on Gen2, 25.175MHz to 148.5MHz on Gen3). Clamp
+        * the clock accordingly.
+        */
+       if (rcdu->info->gen < 3)
+               mode->clock = clamp(mode->clock, 30000, 150000);
+       else
+               mode->clock = clamp(mode->clock, 25175, 148500);
+}
+
 static int rcar_du_lvdsenc_get_resources(struct rcar_du_lvdsenc *lvds,
                                         struct platform_device *pdev)
 {
index 9a6001c..dfdba74 100644 (file)
@@ -30,6 +30,8 @@ enum rcar_lvds_input {
 int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu);
 int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds,
                           struct drm_crtc *crtc, bool enable);
+void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
+                                 struct drm_display_mode *mode);
 #else
 static inline int rcar_du_lvdsenc_init(struct rcar_du_device *rcdu)
 {
@@ -40,6 +42,10 @@ static inline int rcar_du_lvdsenc_enable(struct rcar_du_lvdsenc *lvds,
 {
        return 0;
 }
+static inline void rcar_du_lvdsenc_atomic_check(struct rcar_du_lvdsenc *lvds,
+                                               struct drm_display_mode *mode)
+{
+}
 #endif
 
 #endif /* __RCAR_DU_LVDSENC_H__ */
index c3ed952..8460ae1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_plane.c  --  R-Car Display Unit Planes
  *
- * Copyright (C) 2013-2014 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -12,6 +12,7 @@
  */
 
 #include <drm/drmP.h>
+#include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_plane_helper.h>
 
 #include "rcar_du_drv.h"
+#include "rcar_du_group.h"
 #include "rcar_du_kms.h"
 #include "rcar_du_plane.h"
 #include "rcar_du_regs.h"
 
-#define RCAR_DU_COLORKEY_NONE          (0 << 24)
-#define RCAR_DU_COLORKEY_SOURCE                (1 << 24)
-#define RCAR_DU_COLORKEY_MASK          (1 << 24)
+/* -----------------------------------------------------------------------------
+ * Atomic hardware plane allocator
+ *
+ * The hardware plane allocator is solely based on the atomic plane states
+ * without keeping any external state to avoid races between .atomic_check()
+ * and .atomic_commit().
+ *
+ * The core idea is to avoid using a free planes bitmask that would need to be
+ * shared between check and commit handlers with a collective knowledge based on
+ * the allocated hardware plane(s) for each KMS plane. The allocator then loops
+ * over all plane states to compute the free planes bitmask, allocates hardware
+ * planes based on that bitmask, and stores the result back in the plane states.
+ *
+ * For this to work we need to access the current state of planes not touched by
+ * the atomic update. To ensure that it won't be modified, we need to lock all
+ * planes using drm_atomic_get_plane_state(). This effectively serializes atomic
+ * updates from .atomic_check() up to completion (when swapping the states if
+ * the check step has succeeded) or rollback (when freeing the states if the
+ * check step has failed).
+ *
+ * Allocation is performed in the .atomic_check() handler and applied
+ * automatically when the core swaps the old and new states.
+ */
+
+static bool rcar_du_plane_needs_realloc(struct rcar_du_plane *plane,
+                                       struct rcar_du_plane_state *new_state)
+{
+       struct rcar_du_plane_state *cur_state;
+
+       cur_state = to_rcar_plane_state(plane->plane.state);
+
+       /* Lowering the number of planes doesn't strictly require reallocation
+        * as the extra hardware plane will be freed when committing, but doing
+        * so could lead to more fragmentation.
+        */
+       if (!cur_state->format ||
+           cur_state->format->planes != new_state->format->planes)
+               return true;
+
+       /* Reallocate hardware planes if the source has changed. */
+       if (cur_state->source != new_state->source)
+               return true;
 
-static u32 rcar_du_plane_read(struct rcar_du_group *rgrp,
-                             unsigned int index, u32 reg)
+       return false;
+}
+
+static unsigned int rcar_du_plane_hwmask(struct rcar_du_plane_state *state)
+{
+       unsigned int mask;
+
+       if (state->hwindex == -1)
+               return 0;
+
+       mask = 1 << state->hwindex;
+       if (state->format->planes == 2)
+               mask |= 1 << ((state->hwindex + 1) % 8);
+
+       return mask;
+}
+
+/*
+ * The R8A7790 DU can source frames directly from the VSP1 devices VSPD0 and
+ * VSPD1. VSPD0 feeds DU0/1 plane 0, and VSPD1 feeds either DU2 plane 0 or
+ * DU0/1 plane 1.
+ *
+ * Allocate the correct fixed plane when sourcing frames from VSPD0 or VSPD1,
+ * and allocate planes in reverse index order otherwise to ensure maximum
+ * availability of planes 0 and 1.
+ *
+ * The caller is responsible for ensuring that the requested source is
+ * compatible with the DU revision.
+ */
+static int rcar_du_plane_hwalloc(struct rcar_du_plane *plane,
+                                struct rcar_du_plane_state *state,
+                                unsigned int free)
 {
-       return rcar_du_read(rgrp->dev,
-                           rgrp->mmio_offset + index * PLANE_OFF + reg);
+       unsigned int num_planes = state->format->planes;
+       int fixed = -1;
+       int i;
+
+       if (state->source == RCAR_DU_PLANE_VSPD0) {
+               /* VSPD0 feeds plane 0 on DU0/1. */
+               if (plane->group->index != 0)
+                       return -EINVAL;
+
+               fixed = 0;
+       } else if (state->source == RCAR_DU_PLANE_VSPD1) {
+               /* VSPD1 feeds plane 1 on DU0/1 or plane 0 on DU2. */
+               fixed = plane->group->index == 0 ? 1 : 0;
+       }
+
+       if (fixed >= 0)
+               return free & (1 << fixed) ? fixed : -EBUSY;
+
+       for (i = RCAR_DU_NUM_HW_PLANES - 1; i >= 0; --i) {
+               if (!(free & (1 << i)))
+                       continue;
+
+               if (num_planes == 1 || free & (1 << ((i + 1) % 8)))
+                       break;
+       }
+
+       return i < 0 ? -EBUSY : i;
 }
 
+int rcar_du_atomic_check_planes(struct drm_device *dev,
+                               struct drm_atomic_state *state)
+{
+       struct rcar_du_device *rcdu = dev->dev_private;
+       unsigned int group_freed_planes[RCAR_DU_MAX_GROUPS] = { 0, };
+       unsigned int group_free_planes[RCAR_DU_MAX_GROUPS] = { 0, };
+       bool needs_realloc = false;
+       unsigned int groups = 0;
+       unsigned int i;
+
+       /* Check if hardware planes need to be reallocated. */
+       for (i = 0; i < dev->mode_config.num_total_plane; ++i) {
+               struct rcar_du_plane_state *plane_state;
+               struct rcar_du_plane *plane;
+               unsigned int index;
+
+               if (!state->planes[i])
+                       continue;
+
+               plane = to_rcar_plane(state->planes[i]);
+               plane_state = to_rcar_plane_state(state->plane_states[i]);
+
+               dev_dbg(rcdu->dev, "%s: checking plane (%u,%tu)\n", __func__,
+                       plane->group->index, plane - plane->group->planes);
+
+               /* If the plane is being disabled we don't need to go through
+                * the full reallocation procedure. Just mark the hardware
+                * plane(s) as freed.
+                */
+               if (!plane_state->format) {
+                       dev_dbg(rcdu->dev, "%s: plane is being disabled\n",
+                               __func__);
+                       index = plane - plane->group->planes;
+                       group_freed_planes[plane->group->index] |= 1 << index;
+                       plane_state->hwindex = -1;
+                       continue;
+               }
+
+               /* If the plane needs to be reallocated mark it as such, and
+                * mark the hardware plane(s) as free.
+                */
+               if (rcar_du_plane_needs_realloc(plane, plane_state)) {
+                       dev_dbg(rcdu->dev, "%s: plane needs reallocation\n",
+                               __func__);
+                       groups |= 1 << plane->group->index;
+                       needs_realloc = true;
+
+                       index = plane - plane->group->planes;
+                       group_freed_planes[plane->group->index] |= 1 << index;
+                       plane_state->hwindex = -1;
+               }
+       }
+
+       if (!needs_realloc)
+               return 0;
+
+       /* Grab all plane states for the groups that need reallocation to ensure
+        * locking and avoid racy updates. This serializes the update operation,
+        * but there's not much we can do about it as that's the hardware
+        * design.
+        *
+        * Compute the used planes mask for each group at the same time to avoid
+        * looping over the planes separately later.
+        */
+       while (groups) {
+               unsigned int index = ffs(groups) - 1;
+               struct rcar_du_group *group = &rcdu->groups[index];
+               unsigned int used_planes = 0;
+
+               dev_dbg(rcdu->dev, "%s: finding free planes for group %u\n",
+                       __func__, index);
+
+               for (i = 0; i < group->num_planes; ++i) {
+                       struct rcar_du_plane *plane = &group->planes[i];
+                       struct rcar_du_plane_state *plane_state;
+                       struct drm_plane_state *s;
+
+                       s = drm_atomic_get_plane_state(state, &plane->plane);
+                       if (IS_ERR(s))
+                               return PTR_ERR(s);
+
+                       /* If the plane has been freed in the above loop its
+                        * hardware planes must not be added to the used planes
+                        * bitmask. However, the current state doesn't reflect
+                        * the free state yet, as we've modified the new state
+                        * above. Use the local freed planes list to check for
+                        * that condition instead.
+                        */
+                       if (group_freed_planes[index] & (1 << i)) {
+                               dev_dbg(rcdu->dev,
+                                       "%s: plane (%u,%tu) has been freed, skipping\n",
+                                       __func__, plane->group->index,
+                                       plane - plane->group->planes);
+                               continue;
+                       }
+
+                       plane_state = to_rcar_plane_state(plane->plane.state);
+                       used_planes |= rcar_du_plane_hwmask(plane_state);
+
+                       dev_dbg(rcdu->dev,
+                               "%s: plane (%u,%tu) uses %u hwplanes (index %d)\n",
+                               __func__, plane->group->index,
+                               plane - plane->group->planes,
+                               plane_state->format ?
+                               plane_state->format->planes : 0,
+                               plane_state->hwindex);
+               }
+
+               group_free_planes[index] = 0xff & ~used_planes;
+               groups &= ~(1 << index);
+
+               dev_dbg(rcdu->dev, "%s: group %u free planes mask 0x%02x\n",
+                       __func__, index, group_free_planes[index]);
+       }
+
+       /* Reallocate hardware planes for each plane that needs it. */
+       for (i = 0; i < dev->mode_config.num_total_plane; ++i) {
+               struct rcar_du_plane_state *plane_state;
+               struct rcar_du_plane *plane;
+               unsigned int crtc_planes;
+               unsigned int free;
+               int idx;
+
+               if (!state->planes[i])
+                       continue;
+
+               plane = to_rcar_plane(state->planes[i]);
+               plane_state = to_rcar_plane_state(state->plane_states[i]);
+
+               dev_dbg(rcdu->dev, "%s: allocating plane (%u,%tu)\n", __func__,
+                       plane->group->index, plane - plane->group->planes);
+
+               /* Skip planes that are being disabled or don't need to be
+                * reallocated.
+                */
+               if (!plane_state->format ||
+                   !rcar_du_plane_needs_realloc(plane, plane_state))
+                       continue;
+
+               /* Try to allocate the plane from the free planes currently
+                * associated with the target CRTC to avoid restarting the CRTC
+                * group and thus minimize flicker. If it fails fall back to
+                * allocating from all free planes.
+                */
+               crtc_planes = to_rcar_crtc(plane_state->state.crtc)->index % 2
+                           ? plane->group->dptsr_planes
+                           : ~plane->group->dptsr_planes;
+               free = group_free_planes[plane->group->index];
+
+               idx = rcar_du_plane_hwalloc(plane, plane_state,
+                                           free & crtc_planes);
+               if (idx < 0)
+                       idx = rcar_du_plane_hwalloc(plane, plane_state,
+                                                   free);
+               if (idx < 0) {
+                       dev_dbg(rcdu->dev, "%s: no available hardware plane\n",
+                               __func__);
+                       return idx;
+               }
+
+               dev_dbg(rcdu->dev, "%s: allocated %u hwplanes (index %u)\n",
+                       __func__, plane_state->format->planes, idx);
+
+               plane_state->hwindex = idx;
+
+               group_free_planes[plane->group->index] &=
+                       ~rcar_du_plane_hwmask(plane_state);
+
+               dev_dbg(rcdu->dev, "%s: group %u free planes mask 0x%02x\n",
+                       __func__, plane->group->index,
+                       group_free_planes[plane->group->index]);
+       }
+
+       return 0;
+}
+
+/* -----------------------------------------------------------------------------
+ * Plane Setup
+ */
+
+#define RCAR_DU_COLORKEY_NONE          (0 << 24)
+#define RCAR_DU_COLORKEY_SOURCE                (1 << 24)
+#define RCAR_DU_COLORKEY_MASK          (1 << 24)
+
 static void rcar_du_plane_write(struct rcar_du_group *rgrp,
                                unsigned int index, u32 reg, u32 data)
 {
@@ -42,34 +322,45 @@ static void rcar_du_plane_write(struct rcar_du_group *rgrp,
                      data);
 }
 
-static void rcar_du_plane_setup_fb(struct rcar_du_plane *plane)
+static void rcar_du_plane_setup_scanout(struct rcar_du_group *rgrp,
+                                       const struct rcar_du_plane_state *state)
 {
-       struct rcar_du_plane_state *state =
-               to_rcar_plane_state(plane->plane.state);
-       struct drm_framebuffer *fb = plane->plane.state->fb;
-       struct rcar_du_group *rgrp = plane->group;
        unsigned int src_x = state->state.src_x >> 16;
        unsigned int src_y = state->state.src_y >> 16;
        unsigned int index = state->hwindex;
-       struct drm_gem_cma_object *gem;
+       unsigned int pitch;
        bool interlaced;
-       u32 mwr;
+       u32 dma[2];
 
        interlaced = state->state.crtc->state->adjusted_mode.flags
                   & DRM_MODE_FLAG_INTERLACE;
 
+       if (state->source == RCAR_DU_PLANE_MEMORY) {
+               struct drm_framebuffer *fb = state->state.fb;
+               struct drm_gem_cma_object *gem;
+               unsigned int i;
+
+               if (state->format->planes == 2)
+                       pitch = fb->pitches[0];
+               else
+                       pitch = fb->pitches[0] * 8 / state->format->bpp;
+
+               for (i = 0; i < state->format->planes; ++i) {
+                       gem = drm_fb_cma_get_gem_obj(fb, i);
+                       dma[i] = gem->paddr + fb->offsets[i];
+               }
+       } else {
+               pitch = state->state.src_w >> 16;
+               dma[0] = 0;
+               dma[1] = 0;
+       }
+
        /* Memory pitch (expressed in pixels). Must be doubled for interlaced
         * operation with 32bpp formats.
         */
-       if (state->format->planes == 2)
-               mwr = fb->pitches[0];
-       else
-               mwr = fb->pitches[0] * 8 / state->format->bpp;
-
-       if (interlaced && state->format->bpp == 32)
-               mwr *= 2;
-
-       rcar_du_plane_write(rgrp, index, PnMWR, mwr);
+       rcar_du_plane_write(rgrp, index, PnMWR,
+                           (interlaced && state->format->bpp == 32) ?
+                           pitch * 2 : pitch);
 
        /* The Y position is expressed in raster line units and must be doubled
         * for 32bpp formats, according to the R8A7790 datasheet. No mention of
@@ -87,30 +378,25 @@ static void rcar_du_plane_setup_fb(struct rcar_du_plane *plane)
        rcar_du_plane_write(rgrp, index, PnSPYR, src_y *
                            (!interlaced && state->format->bpp == 32 ? 2 : 1));
 
-       gem = drm_fb_cma_get_gem_obj(fb, 0);
-       rcar_du_plane_write(rgrp, index, PnDSA0R, gem->paddr + fb->offsets[0]);
+       rcar_du_plane_write(rgrp, index, PnDSA0R, dma[0]);
 
        if (state->format->planes == 2) {
                index = (index + 1) % 8;
 
-               rcar_du_plane_write(rgrp, index, PnMWR, fb->pitches[0]);
+               rcar_du_plane_write(rgrp, index, PnMWR, pitch);
 
                rcar_du_plane_write(rgrp, index, PnSPXR, src_x);
                rcar_du_plane_write(rgrp, index, PnSPYR, src_y *
                                    (state->format->bpp == 16 ? 2 : 1) / 2);
 
-               gem = drm_fb_cma_get_gem_obj(fb, 1);
-               rcar_du_plane_write(rgrp, index, PnDSA0R,
-                                   gem->paddr + fb->offsets[1]);
+               rcar_du_plane_write(rgrp, index, PnDSA0R, dma[1]);
        }
 }
 
-static void rcar_du_plane_setup_mode(struct rcar_du_plane *plane,
-                                    unsigned int index)
+static void rcar_du_plane_setup_mode(struct rcar_du_group *rgrp,
+                                    unsigned int index,
+                                    const struct rcar_du_plane_state *state)
 {
-       struct rcar_du_plane_state *state =
-               to_rcar_plane_state(plane->plane.state);
-       struct rcar_du_group *rgrp = plane->group;
        u32 colorkey;
        u32 pnmr;
 
@@ -168,12 +454,10 @@ static void rcar_du_plane_setup_mode(struct rcar_du_plane *plane,
        }
 }
 
-static void __rcar_du_plane_setup(struct rcar_du_plane *plane,
-                                 unsigned int index)
+static void rcar_du_plane_setup_format_gen2(struct rcar_du_group *rgrp,
+                                           unsigned int index,
+                                           const struct rcar_du_plane_state *state)
 {
-       struct rcar_du_plane_state *state =
-               to_rcar_plane_state(plane->plane.state);
-       struct rcar_du_group *rgrp = plane->group;
        u32 ddcr2 = PnDDCR2_CODE;
        u32 ddcr4;
 
@@ -182,11 +466,8 @@ static void __rcar_du_plane_setup(struct rcar_du_plane *plane,
         * The data format is selected by the DDDF field in PnMR and the EDF
         * field in DDCR4.
         */
-       ddcr4 = rcar_du_plane_read(rgrp, index, PnDDCR4);
-       ddcr4 &= ~PnDDCR4_EDF_MASK;
-       ddcr4 |= state->format->edf | PnDDCR4_CODE;
 
-       rcar_du_plane_setup_mode(plane, index);
+       rcar_du_plane_setup_mode(rgrp, index, state);
 
        if (state->format->planes == 2) {
                if (state->hwindex != index) {
@@ -204,31 +485,72 @@ static void __rcar_du_plane_setup(struct rcar_du_plane *plane,
        }
 
        rcar_du_plane_write(rgrp, index, PnDDCR2, ddcr2);
+
+       ddcr4 = state->format->edf | PnDDCR4_CODE;
+       if (state->source != RCAR_DU_PLANE_MEMORY)
+               ddcr4 |= PnDDCR4_VSPS;
+
        rcar_du_plane_write(rgrp, index, PnDDCR4, ddcr4);
+}
+
+static void rcar_du_plane_setup_format_gen3(struct rcar_du_group *rgrp,
+                                           unsigned int index,
+                                           const struct rcar_du_plane_state *state)
+{
+       rcar_du_plane_write(rgrp, index, PnMR,
+                           PnMR_SPIM_TP_OFF | state->format->pnmr);
+
+       rcar_du_plane_write(rgrp, index, PnDDCR4,
+                           state->format->edf | PnDDCR4_CODE);
+}
+
+static void rcar_du_plane_setup_format(struct rcar_du_group *rgrp,
+                                      unsigned int index,
+                                      const struct rcar_du_plane_state *state)
+{
+       struct rcar_du_device *rcdu = rgrp->dev;
+
+       if (rcdu->info->gen < 3)
+               rcar_du_plane_setup_format_gen2(rgrp, index, state);
+       else
+               rcar_du_plane_setup_format_gen3(rgrp, index, state);
 
        /* Destination position and size */
-       rcar_du_plane_write(rgrp, index, PnDSXR, plane->plane.state->crtc_w);
-       rcar_du_plane_write(rgrp, index, PnDSYR, plane->plane.state->crtc_h);
-       rcar_du_plane_write(rgrp, index, PnDPXR, plane->plane.state->crtc_x);
-       rcar_du_plane_write(rgrp, index, PnDPYR, plane->plane.state->crtc_y);
-
-       /* Wrap-around and blinking, disabled */
-       rcar_du_plane_write(rgrp, index, PnWASPR, 0);
-       rcar_du_plane_write(rgrp, index, PnWAMWR, 4095);
-       rcar_du_plane_write(rgrp, index, PnBTR, 0);
-       rcar_du_plane_write(rgrp, index, PnMLR, 0);
+       rcar_du_plane_write(rgrp, index, PnDSXR, state->state.crtc_w);
+       rcar_du_plane_write(rgrp, index, PnDSYR, state->state.crtc_h);
+       rcar_du_plane_write(rgrp, index, PnDPXR, state->state.crtc_x);
+       rcar_du_plane_write(rgrp, index, PnDPYR, state->state.crtc_y);
+
+       if (rcdu->info->gen < 3) {
+               /* Wrap-around and blinking, disabled */
+               rcar_du_plane_write(rgrp, index, PnWASPR, 0);
+               rcar_du_plane_write(rgrp, index, PnWAMWR, 4095);
+               rcar_du_plane_write(rgrp, index, PnBTR, 0);
+               rcar_du_plane_write(rgrp, index, PnMLR, 0);
+       }
 }
 
-void rcar_du_plane_setup(struct rcar_du_plane *plane)
+void __rcar_du_plane_setup(struct rcar_du_group *rgrp,
+                          const struct rcar_du_plane_state *state)
 {
-       struct rcar_du_plane_state *state =
-               to_rcar_plane_state(plane->plane.state);
+       struct rcar_du_device *rcdu = rgrp->dev;
 
-       __rcar_du_plane_setup(plane, state->hwindex);
+       rcar_du_plane_setup_format(rgrp, state->hwindex, state);
        if (state->format->planes == 2)
-               __rcar_du_plane_setup(plane, (state->hwindex + 1) % 8);
+               rcar_du_plane_setup_format(rgrp, (state->hwindex + 1) % 8,
+                                          state);
 
-       rcar_du_plane_setup_fb(plane);
+       if (rcdu->info->gen < 3)
+               rcar_du_plane_setup_scanout(rgrp, state);
+
+       if (state->source == RCAR_DU_PLANE_VSPD1) {
+               unsigned int vspd1_sink = rgrp->index ? 2 : 0;
+
+               if (rcdu->vspd1_sink != vspd1_sink) {
+                       rcdu->vspd1_sink = vspd1_sink;
+                       rcar_du_set_dpad0_vsp1_routing(rcdu);
+               }
+       }
 }
 
 static int rcar_du_plane_atomic_check(struct drm_plane *plane,
@@ -263,9 +585,27 @@ static void rcar_du_plane_atomic_update(struct drm_plane *plane,
                                        struct drm_plane_state *old_state)
 {
        struct rcar_du_plane *rplane = to_rcar_plane(plane);
+       struct rcar_du_plane_state *old_rstate;
+       struct rcar_du_plane_state *new_rstate;
+
+       if (!plane->state->crtc)
+               return;
+
+       rcar_du_plane_setup(rplane);
+
+       /* Check whether the source has changed from memory to live source or
+        * from live source to memory. The source has been configured by the
+        * VSPS bit in the PnDDCR4 register. Although the datasheet states that
+        * the bit is updated during vertical blanking, it seems that updates
+        * only occur when the DU group is held in reset through the DSYSR.DRES
+        * bit. We thus need to restart the group if the source changes.
+        */
+       old_rstate = to_rcar_plane_state(old_state);
+       new_rstate = to_rcar_plane_state(plane->state);
 
-       if (plane->state->crtc)
-               rcar_du_plane_setup(rplane);
+       if ((old_rstate->source == RCAR_DU_PLANE_MEMORY) !=
+           (new_rstate->source == RCAR_DU_PLANE_MEMORY))
+               rplane->group->need_restart = true;
 }
 
 static const struct drm_plane_helper_funcs rcar_du_plane_helper_funcs = {
@@ -313,6 +653,7 @@ static void rcar_du_plane_reset(struct drm_plane *plane)
                return;
 
        state->hwindex = -1;
+       state->source = RCAR_DU_PLANE_MEMORY;
        state->alpha = 255;
        state->colorkey = RCAR_DU_COLORKEY_NONE;
        state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1;
index 9732bff..b18b7b2 100644 (file)
@@ -28,6 +28,12 @@ struct rcar_du_group;
 #define RCAR_DU_NUM_KMS_PLANES         9
 #define RCAR_DU_NUM_HW_PLANES          8
 
+enum rcar_du_plane_source {
+       RCAR_DU_PLANE_MEMORY,
+       RCAR_DU_PLANE_VSPD0,
+       RCAR_DU_PLANE_VSPD1,
+};
+
 struct rcar_du_plane {
        struct drm_plane plane;
        struct rcar_du_group *group;
@@ -52,6 +58,7 @@ struct rcar_du_plane_state {
 
        const struct rcar_du_format_info *format;
        int hwindex;
+       enum rcar_du_plane_source source;
 
        unsigned int alpha;
        unsigned int colorkey;
@@ -64,8 +71,20 @@ to_rcar_plane_state(struct drm_plane_state *state)
        return container_of(state, struct rcar_du_plane_state, state);
 }
 
+int rcar_du_atomic_check_planes(struct drm_device *dev,
+                               struct drm_atomic_state *state);
+
 int rcar_du_planes_init(struct rcar_du_group *rgrp);
 
-void rcar_du_plane_setup(struct rcar_du_plane *plane);
+void __rcar_du_plane_setup(struct rcar_du_group *rgrp,
+                          const struct rcar_du_plane_state *state);
+
+static inline void rcar_du_plane_setup(struct rcar_du_plane *plane)
+{
+       struct rcar_du_plane_state *state =
+               to_rcar_plane_state(plane->plane.state);
+
+       return __rcar_du_plane_setup(plane->group, state);
+}
 
 #endif /* __RCAR_DU_PLANE_H__ */
index 70fcbc4..d2f6606 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_regs.h  --  R-Car Display Unit Registers Definitions
  *
- * Copyright (C) 2013 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -16,6 +16,7 @@
 #define DU0_REG_OFFSET         0x00000
 #define DU1_REG_OFFSET         0x30000
 #define DU2_REG_OFFSET         0x40000
+#define DU3_REG_OFFSET         0x70000
 
 /* -----------------------------------------------------------------------------
  * Display Control Registers
 
 #define DEFR6                  0x000e8
 #define DEFR6_CODE             (0x7778 << 16)
-#define DEFR6_ODPM22_D2SMR     (0 << 10)
+#define DEFR6_ODPM22_DSMR      (0 << 10)
 #define DEFR6_ODPM22_DISP      (2 << 10)
 #define DEFR6_ODPM22_CDE       (3 << 10)
 #define DEFR6_ODPM22_MASK      (3 << 10)
 #define DIDSR_PDCS_CLK(n, clk) (clk << ((n) * 2))
 #define DIDSR_PDCS_MASK(n)     (3 << ((n) * 2))
 
+#define DEFR10                 0x20038
+#define DEFR10_CODE            (0x7795 << 16)
+#define DEFR10_VSPF1_RGB       (0 << 14)
+#define DEFR10_VSPF1_YC                (1 << 14)
+#define DEFR10_DOCF1_RGB       (0 << 12)
+#define DEFR10_DOCF1_YC                (1 << 12)
+#define DEFR10_YCDF0_YCBCR444  (0 << 11)
+#define DEFR10_YCDF0_YCBCR422  (1 << 11)
+#define DEFR10_VSPF0_RGB       (0 << 10)
+#define DEFR10_VSPF0_YC                (1 << 10)
+#define DEFR10_DOCF0_RGB       (0 << 8)
+#define DEFR10_DOCF0_YC                (1 << 8)
+#define DEFR10_TSEL_H3_TCON1   (0 << 1) /* DEFR102 register only (DU2/DU3) */
+#define DEFR10_DEFE10          (1 << 0)
+
 /* -----------------------------------------------------------------------------
  * Display Timing Generation Registers
  */
 
 #define PnDDCR4                        0x00190
 #define PnDDCR4_CODE           (0x7766 << 16)
+#define PnDDCR4_VSPS           (1 << 13)
 #define PnDDCR4_SDFS_RGB       (0 << 4)
 #define PnDDCR4_SDFS_YC                (5 << 4)
 #define PnDDCR4_SDFS_MASK      (7 << 4)
index e0a5d8f..9d7e5c9 100644 (file)
@@ -31,12 +31,6 @@ static const struct drm_connector_helper_funcs connector_helper_funcs = {
        .best_encoder = rcar_du_connector_best_encoder,
 };
 
-static void rcar_du_vga_connector_destroy(struct drm_connector *connector)
-{
-       drm_connector_unregister(connector);
-       drm_connector_cleanup(connector);
-}
-
 static enum drm_connector_status
 rcar_du_vga_connector_detect(struct drm_connector *connector, bool force)
 {
@@ -48,7 +42,7 @@ static const struct drm_connector_funcs connector_funcs = {
        .reset = drm_atomic_helper_connector_reset,
        .detect = rcar_du_vga_connector_detect,
        .fill_modes = drm_helper_probe_single_connector_modes,
-       .destroy = rcar_du_vga_connector_destroy,
+       .destroy = drm_connector_cleanup,
        .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
@@ -76,9 +70,6 @@ int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
                return ret;
 
        drm_connector_helper_add(connector, &connector_helper_funcs);
-       ret = drm_connector_register(connector);
-       if (ret < 0)
-               return ret;
 
        connector->dpms = DRM_MODE_DPMS_OFF;
        drm_object_property_set_value(&connector->base,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
new file mode 100644 (file)
index 0000000..de7ef04
--- /dev/null
@@ -0,0 +1,384 @@
+/*
+ * rcar_du_vsp.h  --  R-Car Display Unit VSP-Based Compositor
+ *
+ * Copyright (C) 2015 Renesas Electronics 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 <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_plane_helper.h>
+
+#include <linux/of_platform.h>
+#include <linux/videodev2.h>
+
+#include <media/vsp1.h>
+
+#include "rcar_du_drv.h"
+#include "rcar_du_kms.h"
+#include "rcar_du_vsp.h"
+
+void rcar_du_vsp_enable(struct rcar_du_crtc *crtc)
+{
+       const struct drm_display_mode *mode = &crtc->crtc.state->adjusted_mode;
+       struct rcar_du_device *rcdu = crtc->group->dev;
+       struct rcar_du_plane_state state = {
+               .state = {
+                       .crtc = &crtc->crtc,
+                       .crtc_x = 0,
+                       .crtc_y = 0,
+                       .crtc_w = mode->hdisplay,
+                       .crtc_h = mode->vdisplay,
+                       .src_x = 0,
+                       .src_y = 0,
+                       .src_w = mode->hdisplay << 16,
+                       .src_h = mode->vdisplay << 16,
+               },
+               .format = rcar_du_format_info(DRM_FORMAT_ARGB8888),
+               .source = RCAR_DU_PLANE_VSPD1,
+               .alpha = 255,
+               .colorkey = 0,
+               .zpos = 0,
+       };
+
+       if (rcdu->info->gen >= 3)
+               state.hwindex = (crtc->index % 2) ? 2 : 0;
+       else
+               state.hwindex = crtc->index % 2;
+
+       __rcar_du_plane_setup(crtc->group, &state);
+
+       /* Ensure that the plane source configuration takes effect by requesting
+        * a restart of the group. See rcar_du_plane_atomic_update() for a more
+        * detailed explanation.
+        *
+        * TODO: Check whether this is still needed on Gen3.
+        */
+       crtc->group->need_restart = true;
+
+       vsp1_du_setup_lif(crtc->vsp->vsp, mode->hdisplay, mode->vdisplay);
+}
+
+void rcar_du_vsp_disable(struct rcar_du_crtc *crtc)
+{
+       vsp1_du_setup_lif(crtc->vsp->vsp, 0, 0);
+}
+
+void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc)
+{
+       vsp1_du_atomic_begin(crtc->vsp->vsp);
+}
+
+void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc)
+{
+       vsp1_du_atomic_flush(crtc->vsp->vsp);
+}
+
+/* Keep the two tables in sync. */
+static const u32 formats_kms[] = {
+       DRM_FORMAT_RGB332,
+       DRM_FORMAT_ARGB4444,
+       DRM_FORMAT_XRGB4444,
+       DRM_FORMAT_ARGB1555,
+       DRM_FORMAT_XRGB1555,
+       DRM_FORMAT_RGB565,
+       DRM_FORMAT_BGR888,
+       DRM_FORMAT_RGB888,
+       DRM_FORMAT_BGRA8888,
+       DRM_FORMAT_BGRX8888,
+       DRM_FORMAT_ARGB8888,
+       DRM_FORMAT_XRGB8888,
+       DRM_FORMAT_UYVY,
+       DRM_FORMAT_VYUY,
+       DRM_FORMAT_YUYV,
+       DRM_FORMAT_YVYU,
+       DRM_FORMAT_NV12,
+       DRM_FORMAT_NV21,
+       DRM_FORMAT_NV16,
+       DRM_FORMAT_NV61,
+       DRM_FORMAT_YUV420,
+       DRM_FORMAT_YVU420,
+       DRM_FORMAT_YUV422,
+       DRM_FORMAT_YVU422,
+       DRM_FORMAT_YUV444,
+       DRM_FORMAT_YVU444,
+};
+
+static const u32 formats_v4l2[] = {
+       V4L2_PIX_FMT_RGB332,
+       V4L2_PIX_FMT_ARGB444,
+       V4L2_PIX_FMT_XRGB444,
+       V4L2_PIX_FMT_ARGB555,
+       V4L2_PIX_FMT_XRGB555,
+       V4L2_PIX_FMT_RGB565,
+       V4L2_PIX_FMT_RGB24,
+       V4L2_PIX_FMT_BGR24,
+       V4L2_PIX_FMT_ARGB32,
+       V4L2_PIX_FMT_XRGB32,
+       V4L2_PIX_FMT_ABGR32,
+       V4L2_PIX_FMT_XBGR32,
+       V4L2_PIX_FMT_UYVY,
+       V4L2_PIX_FMT_VYUY,
+       V4L2_PIX_FMT_YUYV,
+       V4L2_PIX_FMT_YVYU,
+       V4L2_PIX_FMT_NV12M,
+       V4L2_PIX_FMT_NV21M,
+       V4L2_PIX_FMT_NV16M,
+       V4L2_PIX_FMT_NV61M,
+       V4L2_PIX_FMT_YUV420M,
+       V4L2_PIX_FMT_YVU420M,
+       V4L2_PIX_FMT_YUV422M,
+       V4L2_PIX_FMT_YVU422M,
+       V4L2_PIX_FMT_YUV444M,
+       V4L2_PIX_FMT_YVU444M,
+};
+
+static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
+{
+       struct rcar_du_vsp_plane_state *state =
+               to_rcar_vsp_plane_state(plane->plane.state);
+       struct drm_framebuffer *fb = plane->plane.state->fb;
+       struct v4l2_rect src;
+       struct v4l2_rect dst;
+       dma_addr_t paddr[2] = { 0, };
+       u32 pixelformat = 0;
+       unsigned int i;
+
+       src.left = state->state.src_x >> 16;
+       src.top = state->state.src_y >> 16;
+       src.width = state->state.src_w >> 16;
+       src.height = state->state.src_h >> 16;
+
+       dst.left = state->state.crtc_x;
+       dst.top = state->state.crtc_y;
+       dst.width = state->state.crtc_w;
+       dst.height = state->state.crtc_h;
+
+       for (i = 0; i < state->format->planes; ++i) {
+               struct drm_gem_cma_object *gem;
+
+               gem = drm_fb_cma_get_gem_obj(fb, i);
+               paddr[i] = gem->paddr + fb->offsets[i];
+       }
+
+       for (i = 0; i < ARRAY_SIZE(formats_kms); ++i) {
+               if (formats_kms[i] == state->format->fourcc) {
+                       pixelformat = formats_v4l2[i];
+                       break;
+               }
+       }
+
+       WARN_ON(!pixelformat);
+
+       vsp1_du_atomic_update(plane->vsp->vsp, plane->index, pixelformat,
+                             fb->pitches[0], paddr, &src, &dst);
+}
+
+static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane,
+                                         struct drm_plane_state *state)
+{
+       struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state);
+       struct rcar_du_vsp_plane *rplane = to_rcar_vsp_plane(plane);
+       struct rcar_du_device *rcdu = rplane->vsp->dev;
+
+       if (!state->fb || !state->crtc) {
+               rstate->format = NULL;
+               return 0;
+       }
+
+       if (state->src_w >> 16 != state->crtc_w ||
+           state->src_h >> 16 != state->crtc_h) {
+               dev_dbg(rcdu->dev, "%s: scaling not supported\n", __func__);
+               return -EINVAL;
+       }
+
+       rstate->format = rcar_du_format_info(state->fb->pixel_format);
+       if (rstate->format == NULL) {
+               dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__,
+                       state->fb->pixel_format);
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static void rcar_du_vsp_plane_atomic_update(struct drm_plane *plane,
+                                       struct drm_plane_state *old_state)
+{
+       struct rcar_du_vsp_plane *rplane = to_rcar_vsp_plane(plane);
+
+       if (plane->state->crtc)
+               rcar_du_vsp_plane_setup(rplane);
+       else
+               vsp1_du_atomic_update(rplane->vsp->vsp, rplane->index, 0, 0, 0,
+                                     NULL, NULL);
+}
+
+static const struct drm_plane_helper_funcs rcar_du_vsp_plane_helper_funcs = {
+       .atomic_check = rcar_du_vsp_plane_atomic_check,
+       .atomic_update = rcar_du_vsp_plane_atomic_update,
+};
+
+static struct drm_plane_state *
+rcar_du_vsp_plane_atomic_duplicate_state(struct drm_plane *plane)
+{
+       struct rcar_du_vsp_plane_state *state;
+       struct rcar_du_vsp_plane_state *copy;
+
+       if (WARN_ON(!plane->state))
+               return NULL;
+
+       state = to_rcar_vsp_plane_state(plane->state);
+       copy = kmemdup(state, sizeof(*state), GFP_KERNEL);
+       if (copy == NULL)
+               return NULL;
+
+       __drm_atomic_helper_plane_duplicate_state(plane, &copy->state);
+
+       return &copy->state;
+}
+
+static void rcar_du_vsp_plane_atomic_destroy_state(struct drm_plane *plane,
+                                                  struct drm_plane_state *state)
+{
+       __drm_atomic_helper_plane_destroy_state(plane, state);
+       kfree(to_rcar_vsp_plane_state(state));
+}
+
+static void rcar_du_vsp_plane_reset(struct drm_plane *plane)
+{
+       struct rcar_du_vsp_plane_state *state;
+
+       if (plane->state) {
+               rcar_du_vsp_plane_atomic_destroy_state(plane, plane->state);
+               plane->state = NULL;
+       }
+
+       state = kzalloc(sizeof(*state), GFP_KERNEL);
+       if (state == NULL)
+               return;
+
+       state->alpha = 255;
+
+       plane->state = &state->state;
+       plane->state->plane = plane;
+}
+
+static int rcar_du_vsp_plane_atomic_set_property(struct drm_plane *plane,
+       struct drm_plane_state *state, struct drm_property *property,
+       uint64_t val)
+{
+       struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state);
+       struct rcar_du_device *rcdu = to_rcar_vsp_plane(plane)->vsp->dev;
+
+       if (property == rcdu->props.alpha)
+               rstate->alpha = val;
+       else
+               return -EINVAL;
+
+       return 0;
+}
+
+static int rcar_du_vsp_plane_atomic_get_property(struct drm_plane *plane,
+       const struct drm_plane_state *state, struct drm_property *property,
+       uint64_t *val)
+{
+       const struct rcar_du_vsp_plane_state *rstate =
+               container_of(state, const struct rcar_du_vsp_plane_state, state);
+       struct rcar_du_device *rcdu = to_rcar_vsp_plane(plane)->vsp->dev;
+
+       if (property == rcdu->props.alpha)
+               *val = rstate->alpha;
+       else
+               return -EINVAL;
+
+       return 0;
+}
+
+static const struct drm_plane_funcs rcar_du_vsp_plane_funcs = {
+       .update_plane = drm_atomic_helper_update_plane,
+       .disable_plane = drm_atomic_helper_disable_plane,
+       .reset = rcar_du_vsp_plane_reset,
+       .set_property = drm_atomic_helper_plane_set_property,
+       .destroy = drm_plane_cleanup,
+       .atomic_duplicate_state = rcar_du_vsp_plane_atomic_duplicate_state,
+       .atomic_destroy_state = rcar_du_vsp_plane_atomic_destroy_state,
+       .atomic_set_property = rcar_du_vsp_plane_atomic_set_property,
+       .atomic_get_property = rcar_du_vsp_plane_atomic_get_property,
+};
+
+int rcar_du_vsp_init(struct rcar_du_vsp *vsp)
+{
+       struct rcar_du_device *rcdu = vsp->dev;
+       struct platform_device *pdev;
+       struct device_node *np;
+       unsigned int i;
+       int ret;
+
+       /* Find the VSP device and initialize it. */
+       np = of_parse_phandle(rcdu->dev->of_node, "vsps", vsp->index);
+       if (!np) {
+               dev_err(rcdu->dev, "vsps node not found\n");
+               return -ENXIO;
+       }
+
+       pdev = of_find_device_by_node(np);
+       of_node_put(np);
+       if (!pdev)
+               return -ENXIO;
+
+       vsp->vsp = &pdev->dev;
+
+       ret = vsp1_du_init(vsp->vsp);
+       if (ret < 0)
+               return ret;
+
+        /* The VSP2D (Gen3) has 5 RPFs, but the VSP1D (Gen2) is limited to
+         * 4 RPFs.
+         */
+       vsp->num_planes = rcdu->info->gen >= 3 ? 5 : 4;
+
+       vsp->planes = devm_kcalloc(rcdu->dev, vsp->num_planes,
+                                  sizeof(*vsp->planes), GFP_KERNEL);
+       if (!vsp->planes)
+               return -ENOMEM;
+
+       for (i = 0; i < vsp->num_planes; ++i) {
+               enum drm_plane_type type = i ? DRM_PLANE_TYPE_OVERLAY
+                                        : DRM_PLANE_TYPE_PRIMARY;
+               struct rcar_du_vsp_plane *plane = &vsp->planes[i];
+
+               plane->vsp = vsp;
+               plane->index = i;
+
+               ret = drm_universal_plane_init(rcdu->ddev, &plane->plane,
+                                              1 << vsp->index,
+                                              &rcar_du_vsp_plane_funcs,
+                                              formats_kms,
+                                              ARRAY_SIZE(formats_kms), type,
+                                              NULL);
+               if (ret < 0)
+                       return ret;
+
+               drm_plane_helper_add(&plane->plane,
+                                    &rcar_du_vsp_plane_helper_funcs);
+
+               if (type == DRM_PLANE_TYPE_PRIMARY)
+                       continue;
+
+               drm_object_attach_property(&plane->plane.base,
+                                          rcdu->props.alpha, 255);
+       }
+
+       return 0;
+}
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h
new file mode 100644 (file)
index 0000000..df3bf38
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * rcar_du_vsp.h  --  R-Car Display Unit VSP-Based Compositor
+ *
+ * Copyright (C) 2015 Renesas Electronics 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 __RCAR_DU_VSP_H__
+#define __RCAR_DU_VSP_H__
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+
+struct rcar_du_format_info;
+struct rcar_du_vsp;
+
+struct rcar_du_vsp_plane {
+       struct drm_plane plane;
+       struct rcar_du_vsp *vsp;
+       unsigned int index;
+};
+
+struct rcar_du_vsp {
+       unsigned int index;
+       struct device *vsp;
+       struct rcar_du_device *dev;
+       struct rcar_du_vsp_plane *planes;
+       unsigned int num_planes;
+};
+
+static inline struct rcar_du_vsp_plane *to_rcar_vsp_plane(struct drm_plane *p)
+{
+       return container_of(p, struct rcar_du_vsp_plane, plane);
+}
+
+/**
+ * struct rcar_du_vsp_plane_state - Driver-specific plane state
+ * @state: base DRM plane state
+ * @format: information about the pixel format used by the plane
+ * @alpha: value of the plane alpha property
+ */
+struct rcar_du_vsp_plane_state {
+       struct drm_plane_state state;
+
+       const struct rcar_du_format_info *format;
+
+       unsigned int alpha;
+};
+
+static inline struct rcar_du_vsp_plane_state *
+to_rcar_vsp_plane_state(struct drm_plane_state *state)
+{
+       return container_of(state, struct rcar_du_vsp_plane_state, state);
+}
+
+#ifdef CONFIG_DRM_RCAR_VSP
+int rcar_du_vsp_init(struct rcar_du_vsp *vsp);
+void rcar_du_vsp_enable(struct rcar_du_crtc *crtc);
+void rcar_du_vsp_disable(struct rcar_du_crtc *crtc);
+void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc);
+void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc);
+#else
+static inline int rcar_du_vsp_init(struct rcar_du_vsp *vsp) { return 0; };
+static inline void rcar_du_vsp_enable(struct rcar_du_crtc *crtc) { };
+static inline void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { };
+static inline void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { };
+static inline void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc) { };
+#endif
+
+#endif /* __RCAR_DU_VSP_H__ */
index 77cf928..d7d294b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_lvds_regs.h  --  R-Car LVDS Interface Registers Definitions
  *
- * Copyright (C) 2013 Renesas Electronics Corporation
+ * Copyright (C) 2013-2015 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
 
 #define LVDCR0                         0x0000
 #define LVDCR0_DUSEL                   (1 << 15)
-#define LVDCR0_DMD                     (1 << 12)
+#define LVDCR0_DMD                     (1 << 12)               /* Gen2 only */
 #define LVDCR0_LVMD_MASK               (0xf << 8)
 #define LVDCR0_LVMD_SHIFT              8
-#define LVDCR0_PLLEN                   (1 << 4)
-#define LVDCR0_BEN                     (1 << 2)
-#define LVDCR0_LVEN                    (1 << 1)
+#define LVDCR0_PLLON                   (1 << 4)
+#define LVDCR0_PWD                     (1 << 2)                /* Gen3 only */
+#define LVDCR0_BEN                     (1 << 2)                /* Gen2 only */
+#define LVDCR0_LVEN                    (1 << 1)                /* Gen2 only */
 #define LVDCR0_LVRES                   (1 << 0)
 
 #define LVDCR1                         0x0004
-#define LVDCR1_CKSEL                   (1 << 15)
-#define LVDCR1_CHSTBY(n)               (3 << (2 + (n) * 2))
-#define LVDCR1_CLKSTBY                 (3 << 0)
+#define LVDCR1_CKSEL                   (1 << 15)               /* Gen2 only */
+#define LVDCR1_CHSTBY_GEN2(n)          (3 << (2 + (n) * 2))    /* Gen2 only */
+#define LVDCR1_CHSTBY_GEN3(n)          (1 << (2 + (n) * 2))    /* Gen3 only */
+#define LVDCR1_CLKSTBY_GEN2            (3 << 0)                /* Gen2 only */
+#define LVDCR1_CLKSTBY_GEN3            (1 << 0)                /* Gen3 only */
 
 #define LVDPLLCR                       0x0008
 #define LVDPLLCR_CEEN                  (1 << 14)
 #define LVDPLLCR_FBEN                  (1 << 13)
 #define LVDPLLCR_COSEL                 (1 << 12)
+/* Gen2 */
 #define LVDPLLCR_PLLDLYCNT_150M                (0x1bf << 0)
 #define LVDPLLCR_PLLDLYCNT_121M                (0x22c << 0)
 #define LVDPLLCR_PLLDLYCNT_60M         (0x77b << 0)
 #define LVDPLLCR_PLLDLYCNT_38M         (0x69a << 0)
 #define LVDPLLCR_PLLDLYCNT_MASK                (0x7ff << 0)
+/* Gen3 */
+#define LVDPLLCR_PLLDIVCNT_42M         (0x014cb << 0)
+#define LVDPLLCR_PLLDIVCNT_85M         (0x00a45 << 0)
+#define LVDPLLCR_PLLDIVCNT_128M                (0x006c3 << 0)
+#define LVDPLLCR_PLLDIVCNT_148M                (0x046c1 << 0)
+#define LVDPLLCR_PLLDIVCNT_MASK                (0x7ffff << 0)
 
 #define LVDCTRCR                       0x000c
 #define LVDCTRCR_CTR3SEL_ZERO          (0 << 12)
index 7766206..7975158 100644 (file)
@@ -878,7 +878,7 @@ static void dw_mipi_dsi_encoder_disable(struct drm_encoder *encoder)
 static void dw_mipi_dsi_encoder_commit(struct drm_encoder *encoder)
 {
        struct dw_mipi_dsi *dsi = encoder_to_dsi(encoder);
-       int mux  = rockchip_drm_encoder_get_mux_id(dsi->dev->of_node, encoder);
+       int mux = drm_of_encoder_active_endpoint_id(dsi->dev->of_node, encoder);
        u32 interface_pix_fmt;
        u32 val;
 
index c65ce8c..3d3cf2f 100644 (file)
@@ -204,7 +204,7 @@ static void dw_hdmi_rockchip_encoder_enable(struct drm_encoder *encoder)
        rockchip_drm_crtc_mode_config(encoder->crtc, DRM_MODE_CONNECTOR_HDMIA,
                                      ROCKCHIP_OUT_MODE_AAAA);
 
-       mux = rockchip_drm_encoder_get_mux_id(hdmi->dev->of_node, encoder);
+       mux = drm_of_encoder_active_endpoint_id(hdmi->dev->of_node, encoder);
        if (mux)
                val = HDMI_SEL_VOP_LIT | (HDMI_SEL_VOP_LIT << 16);
        else
index a0d51cc..896da09 100644 (file)
@@ -384,36 +384,6 @@ static const struct dev_pm_ops rockchip_drm_pm_ops = {
                                rockchip_drm_sys_resume)
 };
 
-/*
- * @node: device tree node containing encoder input ports
- * @encoder: drm_encoder
- */
-int rockchip_drm_encoder_get_mux_id(struct device_node *node,
-                                   struct drm_encoder *encoder)
-{
-       struct device_node *ep;
-       struct drm_crtc *crtc = encoder->crtc;
-       struct of_endpoint endpoint;
-       struct device_node *port;
-       int ret;
-
-       if (!node || !crtc)
-               return -EINVAL;
-
-       for_each_endpoint_of_node(node, ep) {
-               port = of_graph_get_remote_port(ep);
-               of_node_put(port);
-               if (port == crtc->port) {
-                       ret = of_graph_parse_endpoint(ep, &endpoint);
-                       of_node_put(ep);
-                       return ret ?: endpoint.id;
-               }
-       }
-
-       return -EINVAL;
-}
-EXPORT_SYMBOL_GPL(rockchip_drm_encoder_get_mux_id);
-
 static int compare_of(struct device *dev, void *data)
 {
        struct device_node *np = data;
index bb8b076..3529f69 100644 (file)
@@ -67,8 +67,6 @@ void rockchip_drm_atomic_work(struct work_struct *work);
 int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
                                 const struct rockchip_crtc_funcs *crtc_funcs);
 void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc);
-int rockchip_drm_encoder_get_mux_id(struct device_node *node,
-                                   struct drm_encoder *encoder);
 int rockchip_drm_crtc_mode_config(struct drm_crtc *crtc, int connector_type,
                                  int out_mode);
 int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
index 27342fd..88643ab 100644 (file)
@@ -359,13 +359,6 @@ static void shmob_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
        scrtc->dpms = mode;
 }
 
-static bool shmob_drm_crtc_mode_fixup(struct drm_crtc *crtc,
-                                     const struct drm_display_mode *mode,
-                                     struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 static void shmob_drm_crtc_mode_prepare(struct drm_crtc *crtc)
 {
        shmob_drm_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
@@ -431,7 +424,6 @@ static int shmob_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
 
 static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
        .dpms = shmob_drm_crtc_dpms,
-       .mode_fixup = shmob_drm_crtc_mode_fixup,
        .prepare = shmob_drm_crtc_mode_prepare,
        .commit = shmob_drm_crtc_mode_commit,
        .mode_set = shmob_drm_crtc_mode_set,
index de11c7c..e04deed 100644 (file)
@@ -51,14 +51,6 @@ static void sti_crtc_disabling(struct drm_crtc *crtc)
        mixer->status = STI_MIXER_DISABLING;
 }
 
-static bool sti_crtc_mode_fixup(struct drm_crtc *crtc,
-                               const struct drm_display_mode *mode,
-                               struct drm_display_mode *adjusted_mode)
-{
-       /* accept the provided drm_display_mode, do not fix it up */
-       return true;
-}
-
 static int
 sti_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode)
 {
@@ -229,7 +221,6 @@ static void sti_crtc_atomic_flush(struct drm_crtc *crtc,
 static const struct drm_crtc_helper_funcs sti_crtc_helper_funcs = {
        .enable = sti_crtc_enable,
        .disable = sti_crtc_disabling,
-       .mode_fixup = sti_crtc_mode_fixup,
        .mode_set = drm_helper_crtc_mode_set,
        .mode_set_nofb = sti_crtc_mode_set_nofb,
        .mode_set_base = drm_helper_crtc_mode_set_base,
index 4802da8..051e5e1 100644 (file)
 #include "tilcdc_drv.h"
 #include "tilcdc_regs.h"
 
+#define TILCDC_VBLANK_SAFETY_THRESHOLD_US 1000
+
 struct tilcdc_crtc {
        struct drm_crtc base;
 
        const struct tilcdc_panel_info *info;
-       uint32_t dirty;
-       dma_addr_t start, end;
        struct drm_pending_vblank_event *event;
        int dpms;
        wait_queue_head_t frame_done_wq;
        bool frame_done;
+       spinlock_t irq_lock;
 
-       /* fb currently set to scanout 0/1: */
-       struct drm_framebuffer *scanout[2];
+       ktime_t last_vblank;
+
+       struct drm_framebuffer *curr_fb;
+       struct drm_framebuffer *next_fb;
 
        /* for deferred fb unref's: */
        struct drm_flip_work unref_work;
 
        /* Only set if an external encoder is connected */
        bool simulate_vesa_sync;
+
+       int sync_lost_count;
+       bool frame_intact;
 };
 #define to_tilcdc_crtc(x) container_of(x, struct tilcdc_crtc, base)
 
@@ -54,79 +60,53 @@ static void unref_worker(struct drm_flip_work *work, void *val)
        mutex_unlock(&dev->mode_config.mutex);
 }
 
-static void set_scanout(struct drm_crtc *crtc, int n)
+static void set_scanout(struct drm_crtc *crtc, struct drm_framebuffer *fb)
 {
-       static const uint32_t base_reg[] = {
-                       LCDC_DMA_FB_BASE_ADDR_0_REG,
-                       LCDC_DMA_FB_BASE_ADDR_1_REG,
-       };
-       static const uint32_t ceil_reg[] = {
-                       LCDC_DMA_FB_CEILING_ADDR_0_REG,
-                       LCDC_DMA_FB_CEILING_ADDR_1_REG,
-       };
-       static const uint32_t stat[] = {
-                       LCDC_END_OF_FRAME0, LCDC_END_OF_FRAME1,
-       };
        struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
        struct drm_device *dev = crtc->dev;
-       struct tilcdc_drm_private *priv = dev->dev_private;
-
-       pm_runtime_get_sync(dev->dev);
-       tilcdc_write(dev, base_reg[n], tilcdc_crtc->start);
-       tilcdc_write(dev, ceil_reg[n], tilcdc_crtc->end);
-       if (tilcdc_crtc->scanout[n]) {
-               drm_flip_work_queue(&tilcdc_crtc->unref_work, tilcdc_crtc->scanout[n]);
-               drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq);
-       }
-       tilcdc_crtc->scanout[n] = crtc->primary->fb;
-       drm_framebuffer_reference(tilcdc_crtc->scanout[n]);
-       tilcdc_crtc->dirty &= ~stat[n];
-       pm_runtime_put_sync(dev->dev);
-}
-
-static void update_scanout(struct drm_crtc *crtc)
-{
-       struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
-       struct drm_device *dev = crtc->dev;
-       struct drm_framebuffer *fb = crtc->primary->fb;
        struct drm_gem_cma_object *gem;
        unsigned int depth, bpp;
+       dma_addr_t start, end;
 
        drm_fb_get_bpp_depth(fb->pixel_format, &depth, &bpp);
        gem = drm_fb_cma_get_gem_obj(fb, 0);
 
-       tilcdc_crtc->start = gem->paddr + fb->offsets[0] +
-                       (crtc->y * fb->pitches[0]) + (crtc->x * bpp/8);
+       start = gem->paddr + fb->offsets[0] +
+               crtc->y * fb->pitches[0] +
+               crtc->x * bpp / 8;
 
-       tilcdc_crtc->end = tilcdc_crtc->start +
-                       (crtc->mode.vdisplay * fb->pitches[0]);
+       end = start + (crtc->mode.vdisplay * fb->pitches[0]);
 
-       if (tilcdc_crtc->dpms == DRM_MODE_DPMS_ON) {
-               /* already enabled, so just mark the frames that need
-                * updating and they will be updated on vblank:
-                */
-               tilcdc_crtc->dirty |= LCDC_END_OF_FRAME0 | LCDC_END_OF_FRAME1;
-               drm_vblank_get(dev, 0);
-       } else {
-               /* not enabled yet, so update registers immediately: */
-               set_scanout(crtc, 0);
-               set_scanout(crtc, 1);
-       }
+       tilcdc_write(dev, LCDC_DMA_FB_BASE_ADDR_0_REG, start);
+       tilcdc_write(dev, LCDC_DMA_FB_CEILING_ADDR_0_REG, end);
+
+       if (tilcdc_crtc->curr_fb)
+               drm_flip_work_queue(&tilcdc_crtc->unref_work,
+                       tilcdc_crtc->curr_fb);
+
+       tilcdc_crtc->curr_fb = fb;
 }
 
-static void start(struct drm_crtc *crtc)
+static void reset(struct drm_crtc *crtc)
 {
        struct drm_device *dev = crtc->dev;
        struct tilcdc_drm_private *priv = dev->dev_private;
 
-       if (priv->rev == 2) {
-               tilcdc_set(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET);
-               msleep(1);
-               tilcdc_clear(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET);
-               msleep(1);
-       }
+       if (priv->rev != 2)
+               return;
+
+       tilcdc_set(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET);
+       usleep_range(250, 1000);
+       tilcdc_clear(dev, LCDC_CLK_RESET_REG, LCDC_CLK_MAIN_RESET);
+}
 
-       tilcdc_set(dev, LCDC_DMA_CTRL_REG, LCDC_DUAL_FRAME_BUFFER_ENABLE);
+static void start(struct drm_crtc *crtc)
+{
+       struct drm_device *dev = crtc->dev;
+
+       reset(crtc);
+
+       tilcdc_clear(dev, LCDC_DMA_CTRL_REG, LCDC_DUAL_FRAME_BUFFER_ENABLE);
        tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_PALETTE_LOAD_MODE(DATA_ONLY));
        tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE);
 }
@@ -138,17 +118,31 @@ static void stop(struct drm_crtc *crtc)
        tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE);
 }
 
-static void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode);
 static void tilcdc_crtc_destroy(struct drm_crtc *crtc)
 {
        struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
 
        tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 
+       of_node_put(crtc->port);
        drm_crtc_cleanup(crtc);
        drm_flip_work_cleanup(&tilcdc_crtc->unref_work);
+}
+
+static int tilcdc_verify_fb(struct drm_crtc *crtc, struct drm_framebuffer *fb)
+{
+       struct drm_device *dev = crtc->dev;
+       unsigned int depth, bpp;
+
+       drm_fb_get_bpp_depth(fb->pixel_format, &depth, &bpp);
+
+       if (fb->pitches[0] != crtc->mode.hdisplay * bpp / 8) {
+               dev_err(dev->dev,
+                       "Invalid pitch: fb and crtc widths must be the same");
+               return -EINVAL;
+       }
 
-       kfree(tilcdc_crtc);
+       return 0;
 }
 
 static int tilcdc_crtc_page_flip(struct drm_crtc *crtc,
@@ -158,20 +152,48 @@ static int tilcdc_crtc_page_flip(struct drm_crtc *crtc,
 {
        struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
        struct drm_device *dev = crtc->dev;
+       int r;
+       unsigned long flags;
+       s64 tdiff;
+       ktime_t next_vblank;
+
+       r = tilcdc_verify_fb(crtc, fb);
+       if (r)
+               return r;
 
        if (tilcdc_crtc->event) {
                dev_err(dev->dev, "already pending page flip!\n");
                return -EBUSY;
        }
 
+       drm_framebuffer_reference(fb);
+
        crtc->primary->fb = fb;
+
+       pm_runtime_get_sync(dev->dev);
+
+       spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags);
+
+       next_vblank = ktime_add_us(tilcdc_crtc->last_vblank,
+               1000000 / crtc->hwmode.vrefresh);
+
+       tdiff = ktime_to_us(ktime_sub(next_vblank, ktime_get()));
+
+       if (tdiff >= TILCDC_VBLANK_SAFETY_THRESHOLD_US)
+               set_scanout(crtc, fb);
+       else
+               tilcdc_crtc->next_fb = fb;
+
        tilcdc_crtc->event = event;
-       update_scanout(crtc);
+
+       spin_unlock_irqrestore(&tilcdc_crtc->irq_lock, flags);
+
+       pm_runtime_put_sync(dev->dev);
 
        return 0;
 }
 
-static void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode)
+void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode)
 {
        struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
        struct drm_device *dev = crtc->dev;
@@ -186,10 +208,8 @@ static void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode)
 
        tilcdc_crtc->dpms = mode;
 
-       pm_runtime_get_sync(dev->dev);
-
        if (mode == DRM_MODE_DPMS_ON) {
-               pm_runtime_forbid(dev->dev);
+               pm_runtime_get_sync(dev->dev);
                start(crtc);
        } else {
                tilcdc_crtc->frame_done = false;
@@ -207,10 +227,23 @@ static void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode)
                        if (ret == 0)
                                dev_err(dev->dev, "timeout waiting for framedone\n");
                }
-               pm_runtime_allow(dev->dev);
-       }
 
-       pm_runtime_put_sync(dev->dev);
+               pm_runtime_put_sync(dev->dev);
+
+               if (tilcdc_crtc->next_fb) {
+                       drm_flip_work_queue(&tilcdc_crtc->unref_work,
+                                           tilcdc_crtc->next_fb);
+                       tilcdc_crtc->next_fb = NULL;
+               }
+
+               if (tilcdc_crtc->curr_fb) {
+                       drm_flip_work_queue(&tilcdc_crtc->unref_work,
+                                           tilcdc_crtc->curr_fb);
+                       tilcdc_crtc->curr_fb = NULL;
+               }
+
+               drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq);
+       }
 }
 
 static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc,
@@ -272,6 +305,10 @@ static int tilcdc_crtc_mode_set(struct drm_crtc *crtc,
        if (WARN_ON(!info))
                return -EINVAL;
 
+       ret = tilcdc_verify_fb(crtc, crtc->primary->fb);
+       if (ret)
+               return ret;
+
        pm_runtime_get_sync(dev->dev);
 
        /* Configure the Burst Size and fifo threshold of DMA: */
@@ -419,8 +456,10 @@ static int tilcdc_crtc_mode_set(struct drm_crtc *crtc,
        else
                tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ORDER);
 
+       drm_framebuffer_reference(crtc->primary->fb);
+
+       set_scanout(crtc, crtc->primary->fb);
 
-       update_scanout(crtc);
        tilcdc_crtc_update_clk(crtc);
 
        pm_runtime_put_sync(dev->dev);
@@ -431,7 +470,21 @@ static int tilcdc_crtc_mode_set(struct drm_crtc *crtc,
 static int tilcdc_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
                struct drm_framebuffer *old_fb)
 {
-       update_scanout(crtc);
+       struct drm_device *dev = crtc->dev;
+       int r;
+
+       r = tilcdc_verify_fb(crtc, crtc->primary->fb);
+       if (r)
+               return r;
+
+       drm_framebuffer_reference(crtc->primary->fb);
+
+       pm_runtime_get_sync(dev->dev);
+
+       set_scanout(crtc, crtc->primary->fb);
+
+       pm_runtime_put_sync(dev->dev);
+
        return 0;
 }
 
@@ -573,7 +626,8 @@ void tilcdc_crtc_update_clk(struct drm_crtc *crtc)
        struct drm_device *dev = crtc->dev;
        struct tilcdc_drm_private *priv = dev->dev_private;
        int dpms = tilcdc_crtc->dpms;
-       unsigned int lcd_clk, div;
+       unsigned long lcd_clk;
+       const unsigned clkdiv = 2; /* using a fixed divider of 2 */
        int ret;
 
        pm_runtime_get_sync(dev->dev);
@@ -581,22 +635,21 @@ void tilcdc_crtc_update_clk(struct drm_crtc *crtc)
        if (dpms == DRM_MODE_DPMS_ON)
                tilcdc_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
 
-       /* in raster mode, minimum divisor is 2: */
-       ret = clk_set_rate(priv->disp_clk, crtc->mode.clock * 1000 * 2);
-       if (ret) {
+       /* mode.clock is in KHz, set_rate wants parameter in Hz */
+       ret = clk_set_rate(priv->clk, crtc->mode.clock * 1000 * clkdiv);
+       if (ret < 0) {
                dev_err(dev->dev, "failed to set display clock rate to: %d\n",
                                crtc->mode.clock);
                goto out;
        }
 
        lcd_clk = clk_get_rate(priv->clk);
-       div = lcd_clk / (crtc->mode.clock * 1000);
 
-       DBG("lcd_clk=%u, mode clock=%d, div=%u", lcd_clk, crtc->mode.clock, div);
-       DBG("fck=%lu, dpll_disp_ck=%lu", clk_get_rate(priv->clk), clk_get_rate(priv->disp_clk));
+       DBG("lcd_clk=%lu, mode clock=%d, div=%u",
+               lcd_clk, crtc->mode.clock, clkdiv);
 
        /* Configure the LCD clock divisor. */
-       tilcdc_write(dev, LCDC_CTRL_REG, LCDC_CLK_DIVISOR(div) |
+       tilcdc_write(dev, LCDC_CTRL_REG, LCDC_CLK_DIVISOR(clkdiv) |
                        LCDC_RASTER_MODE);
 
        if (priv->rev == 2)
@@ -611,44 +664,58 @@ out:
        pm_runtime_put_sync(dev->dev);
 }
 
+#define SYNC_LOST_COUNT_LIMIT 50
+
 irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
 {
        struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
        struct drm_device *dev = crtc->dev;
        struct tilcdc_drm_private *priv = dev->dev_private;
-       uint32_t stat = tilcdc_read_irqstatus(dev);
+       uint32_t stat;
 
-       if ((stat & LCDC_SYNC_LOST) && (stat & LCDC_FIFO_UNDERFLOW)) {
-               stop(crtc);
-               dev_err(dev->dev, "error: %08x\n", stat);
-               tilcdc_clear_irqstatus(dev, stat);
-               start(crtc);
-       } else if (stat & LCDC_PL_LOAD_DONE) {
-               tilcdc_clear_irqstatus(dev, stat);
-       } else {
-               struct drm_pending_vblank_event *event;
+       stat = tilcdc_read_irqstatus(dev);
+       tilcdc_clear_irqstatus(dev, stat);
+
+       if (stat & LCDC_END_OF_FRAME0) {
                unsigned long flags;
-               uint32_t dirty = tilcdc_crtc->dirty & stat;
+               bool skip_event = false;
+               ktime_t now;
+
+               now = ktime_get();
 
-               tilcdc_clear_irqstatus(dev, stat);
+               drm_flip_work_commit(&tilcdc_crtc->unref_work, priv->wq);
 
-               if (dirty & LCDC_END_OF_FRAME0)
-                       set_scanout(crtc, 0);
+               spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags);
 
-               if (dirty & LCDC_END_OF_FRAME1)
-                       set_scanout(crtc, 1);
+               tilcdc_crtc->last_vblank = now;
+
+               if (tilcdc_crtc->next_fb) {
+                       set_scanout(crtc, tilcdc_crtc->next_fb);
+                       tilcdc_crtc->next_fb = NULL;
+                       skip_event = true;
+               }
+
+               spin_unlock_irqrestore(&tilcdc_crtc->irq_lock, flags);
 
                drm_handle_vblank(dev, 0);
 
-               spin_lock_irqsave(&dev->event_lock, flags);
-               event = tilcdc_crtc->event;
-               tilcdc_crtc->event = NULL;
-               if (event)
-                       drm_send_vblank_event(dev, 0, event);
-               spin_unlock_irqrestore(&dev->event_lock, flags);
+               if (!skip_event) {
+                       struct drm_pending_vblank_event *event;
+
+                       spin_lock_irqsave(&dev->event_lock, flags);
+
+                       event = tilcdc_crtc->event;
+                       tilcdc_crtc->event = NULL;
+                       if (event)
+                               drm_send_vblank_event(dev, 0, event);
+
+                       spin_unlock_irqrestore(&dev->event_lock, flags);
+               }
 
-               if (dirty && !tilcdc_crtc->dirty)
-                       drm_vblank_put(dev, 0);
+               if (tilcdc_crtc->frame_intact)
+                       tilcdc_crtc->sync_lost_count = 0;
+               else
+                       tilcdc_crtc->frame_intact = true;
        }
 
        if (priv->rev == 2) {
@@ -659,16 +726,34 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
                tilcdc_write(dev, LCDC_END_OF_INT_IND_REG, 0);
        }
 
+       if (stat & LCDC_SYNC_LOST) {
+               dev_err_ratelimited(dev->dev, "%s(0x%08x): Sync lost",
+                                   __func__, stat);
+               tilcdc_crtc->frame_intact = false;
+               if (tilcdc_crtc->sync_lost_count++ > SYNC_LOST_COUNT_LIMIT) {
+                       dev_err(dev->dev,
+                               "%s(0x%08x): Sync lost flood detected, disabling the interrupt",
+                               __func__, stat);
+                       tilcdc_write(dev, LCDC_INT_ENABLE_CLR_REG,
+                                    LCDC_SYNC_LOST);
+               }
+       }
+
+       if (stat & LCDC_FIFO_UNDERFLOW)
+               dev_err_ratelimited(dev->dev, "%s(0x%08x): FIFO underfow",
+                                   __func__, stat);
+
        return IRQ_HANDLED;
 }
 
 struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev)
 {
+       struct tilcdc_drm_private *priv = dev->dev_private;
        struct tilcdc_crtc *tilcdc_crtc;
        struct drm_crtc *crtc;
        int ret;
 
-       tilcdc_crtc = kzalloc(sizeof(*tilcdc_crtc), GFP_KERNEL);
+       tilcdc_crtc = devm_kzalloc(dev->dev, sizeof(*tilcdc_crtc), GFP_KERNEL);
        if (!tilcdc_crtc) {
                dev_err(dev->dev, "allocation failed\n");
                return NULL;
@@ -682,12 +767,32 @@ struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev)
        drm_flip_work_init(&tilcdc_crtc->unref_work,
                        "unref", unref_worker);
 
+       spin_lock_init(&tilcdc_crtc->irq_lock);
+
        ret = drm_crtc_init(dev, crtc, &tilcdc_crtc_funcs);
        if (ret < 0)
                goto fail;
 
        drm_crtc_helper_add(crtc, &tilcdc_crtc_helper_funcs);
 
+       if (priv->is_componentized) {
+               struct device_node *ports =
+                       of_get_child_by_name(dev->dev->of_node, "ports");
+
+               if (ports) {
+                       crtc->port = of_get_child_by_name(ports, "port");
+                       of_node_put(ports);
+               } else {
+                       crtc->port =
+                               of_get_child_by_name(dev->dev->of_node, "port");
+               }
+               if (!crtc->port) { /* This should never happen */
+                       dev_err(dev->dev, "Port node not found in %s\n",
+                               dev->dev->of_node->full_name);
+                       goto fail;
+               }
+       }
+
        return crtc;
 
 fail:
index 8190ac3..709bc90 100644 (file)
@@ -18,6 +18,8 @@
 /* LCDC DRM driver, based on da8xx-fb */
 
 #include <linux/component.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/suspend.h>
 
 #include "tilcdc_drv.h"
 #include "tilcdc_regs.h"
@@ -110,6 +112,8 @@ static int tilcdc_unload(struct drm_device *dev)
 {
        struct tilcdc_drm_private *priv = dev->dev_private;
 
+       tilcdc_crtc_dpms(priv->crtc, DRM_MODE_DPMS_OFF);
+
        tilcdc_remove_external_encoders(dev);
 
        drm_fbdev_cma_fini(priv->fbdev);
@@ -139,11 +143,11 @@ static int tilcdc_unload(struct drm_device *dev)
 
        pm_runtime_disable(dev->dev);
 
-       kfree(priv);
-
        return 0;
 }
 
+static size_t tilcdc_num_regs(void);
+
 static int tilcdc_load(struct drm_device *dev, unsigned long flags)
 {
        struct platform_device *pdev = dev->platformdev;
@@ -154,8 +158,12 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
        u32 bpp = 0;
        int ret;
 
-       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-       if (!priv) {
+       priv = devm_kzalloc(dev->dev, sizeof(*priv), GFP_KERNEL);
+       if (priv)
+               priv->saved_register =
+                       devm_kcalloc(dev->dev, tilcdc_num_regs(),
+                                    sizeof(*priv->saved_register), GFP_KERNEL);
+       if (!priv || !priv->saved_register) {
                dev_err(dev->dev, "failed to allocate private data\n");
                return -ENOMEM;
        }
@@ -168,7 +176,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
        priv->wq = alloc_ordered_workqueue("tilcdc", 0);
        if (!priv->wq) {
                ret = -ENOMEM;
-               goto fail_free_priv;
+               goto fail_unset_priv;
        }
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -192,13 +200,6 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
                goto fail_iounmap;
        }
 
-       priv->disp_clk = clk_get(dev->dev, "dpll_disp_ck");
-       if (IS_ERR(priv->clk)) {
-               dev_err(dev->dev, "failed to get display clock\n");
-               ret = -ENODEV;
-               goto fail_put_clk;
-       }
-
 #ifdef CONFIG_CPU_FREQ
        priv->lcd_fck_rate = clk_get_rate(priv->clk);
        priv->freq_transition.notifier_call = cpufreq_transition;
@@ -206,7 +207,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
                        CPUFREQ_TRANSITION_NOTIFIER);
        if (ret) {
                dev_err(dev->dev, "failed to register cpufreq notifier\n");
-               goto fail_put_disp_clk;
+               goto fail_put_clk;
        }
 #endif
 
@@ -227,7 +228,6 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
        DBG("Maximum Pixel Clock Value %dKHz", priv->max_pixelclock);
 
        pm_runtime_enable(dev->dev);
-       pm_runtime_irq_safe(dev->dev);
 
        /* Determine LCD IP Version */
        pm_runtime_get_sync(dev->dev);
@@ -330,11 +330,9 @@ fail_cpufreq_unregister:
 #ifdef CONFIG_CPU_FREQ
        cpufreq_unregister_notifier(&priv->freq_transition,
                        CPUFREQ_TRANSITION_NOTIFIER);
-fail_put_disp_clk:
-       clk_put(priv->disp_clk);
-#endif
 
 fail_put_clk:
+#endif
        clk_put(priv->clk);
 
 fail_iounmap:
@@ -344,9 +342,9 @@ fail_free_wq:
        flush_workqueue(priv->wq);
        destroy_workqueue(priv->wq);
 
-fail_free_priv:
+fail_unset_priv:
        dev->dev_private = NULL;
-       kfree(priv);
+
        return ret;
 }
 
@@ -373,10 +371,14 @@ static int tilcdc_irq_postinstall(struct drm_device *dev)
        struct tilcdc_drm_private *priv = dev->dev_private;
 
        /* enable FIFO underflow irq: */
-       if (priv->rev == 1)
+       if (priv->rev == 1) {
                tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_V1_UNDERFLOW_INT_ENA);
-       else
-               tilcdc_set(dev, LCDC_INT_ENABLE_SET_REG, LCDC_V2_UNDERFLOW_INT_ENA);
+       } else {
+               tilcdc_write(dev, LCDC_INT_ENABLE_SET_REG,
+                          LCDC_V2_UNDERFLOW_INT_ENA |
+                          LCDC_V2_END_OF_FRAME0_INT_ENA |
+                          LCDC_FRAME_DONE | LCDC_SYNC_LOST);
+       }
 
        return 0;
 }
@@ -391,43 +393,21 @@ static void tilcdc_irq_uninstall(struct drm_device *dev)
                                LCDC_V1_UNDERFLOW_INT_ENA | LCDC_V1_PL_INT_ENA);
                tilcdc_clear(dev, LCDC_DMA_CTRL_REG, LCDC_V1_END_OF_FRAME_INT_ENA);
        } else {
-               tilcdc_clear(dev, LCDC_INT_ENABLE_SET_REG,
+               tilcdc_write(dev, LCDC_INT_ENABLE_CLR_REG,
                        LCDC_V2_UNDERFLOW_INT_ENA | LCDC_V2_PL_INT_ENA |
-                       LCDC_V2_END_OF_FRAME0_INT_ENA | LCDC_V2_END_OF_FRAME1_INT_ENA |
-                       LCDC_FRAME_DONE);
-       }
-
-}
-
-static void enable_vblank(struct drm_device *dev, bool enable)
-{
-       struct tilcdc_drm_private *priv = dev->dev_private;
-       u32 reg, mask;
-
-       if (priv->rev == 1) {
-               reg = LCDC_DMA_CTRL_REG;
-               mask = LCDC_V1_END_OF_FRAME_INT_ENA;
-       } else {
-               reg = LCDC_INT_ENABLE_SET_REG;
-               mask = LCDC_V2_END_OF_FRAME0_INT_ENA |
-                       LCDC_V2_END_OF_FRAME1_INT_ENA | LCDC_FRAME_DONE;
+                       LCDC_V2_END_OF_FRAME0_INT_ENA |
+                       LCDC_FRAME_DONE | LCDC_SYNC_LOST);
        }
-
-       if (enable)
-               tilcdc_set(dev, reg, mask);
-       else
-               tilcdc_clear(dev, reg, mask);
 }
 
 static int tilcdc_enable_vblank(struct drm_device *dev, unsigned int pipe)
 {
-       enable_vblank(dev, true);
        return 0;
 }
 
 static void tilcdc_disable_vblank(struct drm_device *dev, unsigned int pipe)
 {
-       enable_vblank(dev, false);
+       return;
 }
 
 #if defined(CONFIG_DEBUG_FS) || defined(CONFIG_PM_SLEEP)
@@ -454,13 +434,22 @@ static const struct {
                /* new in revision 2: */
                REG(2, false, LCDC_RAW_STAT_REG),
                REG(2, false, LCDC_MASKED_STAT_REG),
-               REG(2, false, LCDC_INT_ENABLE_SET_REG),
+               REG(2, true, LCDC_INT_ENABLE_SET_REG),
                REG(2, false, LCDC_INT_ENABLE_CLR_REG),
                REG(2, false, LCDC_END_OF_INT_IND_REG),
                REG(2, true,  LCDC_CLK_ENABLE_REG),
-               REG(2, true,  LCDC_INT_ENABLE_SET_REG),
 #undef REG
 };
+
+static size_t tilcdc_num_regs(void)
+{
+       return ARRAY_SIZE(registers);
+}
+#else
+static size_t tilcdc_num_regs(void)
+{
+       return 0;
+}
 #endif
 
 #ifdef CONFIG_DEBUG_FS
@@ -547,7 +536,8 @@ static const struct file_operations fops = {
 };
 
 static struct drm_driver tilcdc_driver = {
-       .driver_features    = DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET,
+       .driver_features    = (DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET |
+                              DRIVER_PRIME),
        .load               = tilcdc_load,
        .unload             = tilcdc_unload,
        .lastclose          = tilcdc_lastclose,
@@ -564,6 +554,16 @@ static struct drm_driver tilcdc_driver = {
        .dumb_create        = drm_gem_cma_dumb_create,
        .dumb_map_offset    = drm_gem_cma_dumb_map_offset,
        .dumb_destroy       = drm_gem_dumb_destroy,
+
+       .prime_handle_to_fd     = drm_gem_prime_handle_to_fd,
+       .prime_fd_to_handle     = drm_gem_prime_fd_to_handle,
+       .gem_prime_import       = drm_gem_prime_import,
+       .gem_prime_export       = drm_gem_prime_export,
+       .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
+       .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+       .gem_prime_vmap         = drm_gem_cma_prime_vmap,
+       .gem_prime_vunmap       = drm_gem_cma_prime_vunmap,
+       .gem_prime_mmap         = drm_gem_cma_prime_mmap,
 #ifdef CONFIG_DEBUG_FS
        .debugfs_init       = tilcdc_debugfs_init,
        .debugfs_cleanup    = tilcdc_debugfs_cleanup,
@@ -589,11 +589,24 @@ static int tilcdc_pm_suspend(struct device *dev)
 
        drm_kms_helper_poll_disable(ddev);
 
+       /* Select sleep pin state */
+       pinctrl_pm_select_sleep_state(dev);
+
+       if (pm_runtime_suspended(dev)) {
+               priv->ctx_valid = false;
+               return 0;
+       }
+
+       /* Disable the LCDC controller, to avoid locking up the PRCM */
+       tilcdc_crtc_dpms(priv->crtc, DRM_MODE_DPMS_OFF);
+
        /* Save register state: */
        for (i = 0; i < ARRAY_SIZE(registers); i++)
                if (registers[i].save && (priv->rev >= registers[i].rev))
                        priv->saved_register[n++] = tilcdc_read(ddev, registers[i].reg);
 
+       priv->ctx_valid = true;
+
        return 0;
 }
 
@@ -603,10 +616,17 @@ static int tilcdc_pm_resume(struct device *dev)
        struct tilcdc_drm_private *priv = ddev->dev_private;
        unsigned i, n = 0;
 
-       /* Restore register state: */
-       for (i = 0; i < ARRAY_SIZE(registers); i++)
-               if (registers[i].save && (priv->rev >= registers[i].rev))
-                       tilcdc_write(ddev, registers[i].reg, priv->saved_register[n++]);
+       /* Select default pin state */
+       pinctrl_pm_select_default_state(dev);
+
+       if (priv->ctx_valid == true) {
+               /* Restore register state: */
+               for (i = 0; i < ARRAY_SIZE(registers); i++)
+                       if (registers[i].save &&
+                           (priv->rev >= registers[i].rev))
+                               tilcdc_write(ddev, registers[i].reg,
+                                            priv->saved_register[n++]);
+       }
 
        drm_kms_helper_poll_enable(ddev);
 
index 66105d8..c1de18b 100644 (file)
@@ -49,7 +49,6 @@
 struct tilcdc_drm_private {
        void __iomem *mmio;
 
-       struct clk *disp_clk;    /* display dpll */
        struct clk *clk;         /* functional clock */
        int rev;                 /* IP revision */
 
@@ -67,7 +66,8 @@ struct tilcdc_drm_private {
        uint32_t max_width;
 
        /* register contents saved across suspend/resume: */
-       u32 saved_register[12];
+       u32 *saved_register;
+       bool ctx_valid;
 
 #ifdef CONFIG_CPU_FREQ
        struct notifier_block freq_transition;
@@ -171,5 +171,6 @@ void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
                                        bool simulate_vesa_sync);
 int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode);
 int tilcdc_crtc_max_width(struct drm_crtc *crtc);
+void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode);
 
 #endif /* __TILCDC_DRV_H__ */
index 8dcf02a..ff7774c 100644 (file)
@@ -45,14 +45,6 @@ struct panel_encoder {
 };
 #define to_panel_encoder(x) container_of(x, struct panel_encoder, base)
 
-
-static void panel_encoder_destroy(struct drm_encoder *encoder)
-{
-       struct panel_encoder *panel_encoder = to_panel_encoder(encoder);
-       drm_encoder_cleanup(encoder);
-       kfree(panel_encoder);
-}
-
 static void panel_encoder_dpms(struct drm_encoder *encoder, int mode)
 {
        struct panel_encoder *panel_encoder = to_panel_encoder(encoder);
@@ -90,7 +82,7 @@ static void panel_encoder_mode_set(struct drm_encoder *encoder,
 }
 
 static const struct drm_encoder_funcs panel_encoder_funcs = {
-               .destroy        = panel_encoder_destroy,
+               .destroy        = drm_encoder_cleanup,
 };
 
 static const struct drm_encoder_helper_funcs panel_encoder_helper_funcs = {
@@ -107,7 +99,8 @@ static struct drm_encoder *panel_encoder_create(struct drm_device *dev,
        struct drm_encoder *encoder;
        int ret;
 
-       panel_encoder = kzalloc(sizeof(*panel_encoder), GFP_KERNEL);
+       panel_encoder = devm_kzalloc(dev->dev, sizeof(*panel_encoder),
+                                    GFP_KERNEL);
        if (!panel_encoder) {
                dev_err(dev->dev, "allocation failed\n");
                return NULL;
@@ -128,7 +121,7 @@ static struct drm_encoder *panel_encoder_create(struct drm_device *dev,
        return encoder;
 
 fail:
-       panel_encoder_destroy(encoder);
+       drm_encoder_cleanup(encoder);
        return NULL;
 }
 
@@ -147,10 +140,8 @@ struct panel_connector {
 
 static void panel_connector_destroy(struct drm_connector *connector)
 {
-       struct panel_connector *panel_connector = to_panel_connector(connector);
        drm_connector_unregister(connector);
        drm_connector_cleanup(connector);
-       kfree(panel_connector);
 }
 
 static enum drm_connector_status panel_connector_detect(
@@ -223,7 +214,8 @@ static struct drm_connector *panel_connector_create(struct drm_device *dev,
        struct drm_connector *connector;
        int ret;
 
-       panel_connector = kzalloc(sizeof(*panel_connector), GFP_KERNEL);
+       panel_connector = devm_kzalloc(dev->dev, sizeof(*panel_connector),
+                                      GFP_KERNEL);
        if (!panel_connector) {
                dev_err(dev->dev, "allocation failed\n");
                return NULL;
index 1c23017..7716f42 100644 (file)
@@ -54,14 +54,6 @@ struct tfp410_encoder {
 };
 #define to_tfp410_encoder(x) container_of(x, struct tfp410_encoder, base)
 
-
-static void tfp410_encoder_destroy(struct drm_encoder *encoder)
-{
-       struct tfp410_encoder *tfp410_encoder = to_tfp410_encoder(encoder);
-       drm_encoder_cleanup(encoder);
-       kfree(tfp410_encoder);
-}
-
 static void tfp410_encoder_dpms(struct drm_encoder *encoder, int mode)
 {
        struct tfp410_encoder *tfp410_encoder = to_tfp410_encoder(encoder);
@@ -99,7 +91,7 @@ static void tfp410_encoder_mode_set(struct drm_encoder *encoder,
 }
 
 static const struct drm_encoder_funcs tfp410_encoder_funcs = {
-               .destroy        = tfp410_encoder_destroy,
+               .destroy        = drm_encoder_cleanup,
 };
 
 static const struct drm_encoder_helper_funcs tfp410_encoder_helper_funcs = {
@@ -116,7 +108,8 @@ static struct drm_encoder *tfp410_encoder_create(struct drm_device *dev,
        struct drm_encoder *encoder;
        int ret;
 
-       tfp410_encoder = kzalloc(sizeof(*tfp410_encoder), GFP_KERNEL);
+       tfp410_encoder = devm_kzalloc(dev->dev, sizeof(*tfp410_encoder),
+                                     GFP_KERNEL);
        if (!tfp410_encoder) {
                dev_err(dev->dev, "allocation failed\n");
                return NULL;
@@ -138,7 +131,7 @@ static struct drm_encoder *tfp410_encoder_create(struct drm_device *dev,
        return encoder;
 
 fail:
-       tfp410_encoder_destroy(encoder);
+       drm_encoder_cleanup(encoder);
        return NULL;
 }
 
@@ -157,10 +150,8 @@ struct tfp410_connector {
 
 static void tfp410_connector_destroy(struct drm_connector *connector)
 {
-       struct tfp410_connector *tfp410_connector = to_tfp410_connector(connector);
        drm_connector_unregister(connector);
        drm_connector_cleanup(connector);
-       kfree(tfp410_connector);
 }
 
 static enum drm_connector_status tfp410_connector_detect(
@@ -228,7 +219,8 @@ static struct drm_connector *tfp410_connector_create(struct drm_device *dev,
        struct drm_connector *connector;
        int ret;
 
-       tfp410_connector = kzalloc(sizeof(*tfp410_connector), GFP_KERNEL);
+       tfp410_connector = devm_kzalloc(dev->dev, sizeof(*tfp410_connector),
+                                       GFP_KERNEL);
        if (!tfp410_connector) {
                dev_err(dev->dev, "allocation failed\n");
                return NULL;
@@ -313,7 +305,7 @@ static int tfp410_probe(struct platform_device *pdev)
                return -ENXIO;
        }
 
-       tfp410_mod = kzalloc(sizeof(*tfp410_mod), GFP_KERNEL);
+       tfp410_mod = devm_kzalloc(&pdev->dev, sizeof(*tfp410_mod), GFP_KERNEL);
        if (!tfp410_mod)
                return -ENOMEM;
 
@@ -366,7 +358,6 @@ fail_adapter:
        i2c_put_adapter(tfp410_mod->i2c);
 
 fail:
-       kfree(tfp410_mod);
        tilcdc_module_cleanup(mod);
        return ret;
 }
@@ -380,7 +371,6 @@ static int tfp410_remove(struct platform_device *pdev)
        gpio_free(tfp410_mod->gpio);
 
        tilcdc_module_cleanup(mod);
-       kfree(tfp410_mod);
 
        return 0;
 }
index 160ef2a..b87afee 100644 (file)
@@ -279,14 +279,6 @@ static void udl_crtc_dpms(struct drm_crtc *crtc, int mode)
 
 }
 
-static bool udl_crtc_mode_fixup(struct drm_crtc *crtc,
-                                 const struct drm_display_mode *mode,
-                                 struct drm_display_mode *adjusted_mode)
-
-{
-       return true;
-}
-
 #if 0
 static int
 udl_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb,
@@ -402,7 +394,6 @@ static void udl_crtc_commit(struct drm_crtc *crtc)
 
 static const struct drm_crtc_helper_funcs udl_helper_funcs = {
        .dpms = udl_crtc_dpms,
-       .mode_fixup = udl_crtc_mode_fixup,
        .mode_set = udl_crtc_mode_set,
        .prepare = udl_crtc_prepare,
        .commit = udl_crtc_commit,
index 18dfe3e..ac8eafe 100644 (file)
@@ -215,7 +215,7 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
        struct drm_gem_cma_object *cma_obj;
 
        if (size == 0)
-               return NULL;
+               return ERR_PTR(-EINVAL);
 
        /* First, try to get a vc4_bo from the kernel BO cache. */
        if (from_cache) {
@@ -237,7 +237,7 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
                if (IS_ERR(cma_obj)) {
                        DRM_ERROR("Failed to allocate from CMA:\n");
                        vc4_bo_stats_dump(vc4);
-                       return NULL;
+                       return ERR_PTR(-ENOMEM);
                }
        }
 
@@ -259,8 +259,8 @@ int vc4_dumb_create(struct drm_file *file_priv,
                args->size = args->pitch * args->height;
 
        bo = vc4_bo_create(dev, args->size, false);
-       if (!bo)
-               return -ENOMEM;
+       if (IS_ERR(bo))
+               return PTR_ERR(bo);
 
        ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
        drm_gem_object_unreference_unlocked(&bo->base.base);
@@ -443,8 +443,8 @@ int vc4_create_bo_ioctl(struct drm_device *dev, void *data,
         * get zeroed, and that might leak data between users.
         */
        bo = vc4_bo_create(dev, args->size, false);
-       if (!bo)
-               return -ENOMEM;
+       if (IS_ERR(bo))
+               return PTR_ERR(bo);
 
        ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
        drm_gem_object_unreference_unlocked(&bo->base.base);
@@ -496,14 +496,15 @@ vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
        }
 
        bo = vc4_bo_create(dev, args->size, true);
-       if (!bo)
-               return -ENOMEM;
+       if (IS_ERR(bo))
+               return PTR_ERR(bo);
 
-       ret = copy_from_user(bo->base.vaddr,
+       if (copy_from_user(bo->base.vaddr,
                             (void __user *)(uintptr_t)args->data,
-                            args->size);
-       if (ret != 0)
+                            args->size)) {
+               ret = -EFAULT;
                goto fail;
+       }
        /* Clear the rest of the memory from allocating from the BO
         * cache.
         */
index 619dc78..355ee4b 100644 (file)
@@ -88,7 +88,7 @@ static const struct {
 } crtc_regs[] = {
        CRTC_REG(PV_CONTROL),
        CRTC_REG(PV_V_CONTROL),
-       CRTC_REG(PV_VSYNCD),
+       CRTC_REG(PV_VSYNCD_EVEN),
        CRTC_REG(PV_HORZA),
        CRTC_REG(PV_HORZB),
        CRTC_REG(PV_VERTA),
@@ -188,6 +188,8 @@ static int vc4_get_clock_select(struct drm_crtc *crtc)
 
 static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
+       struct drm_device *dev = crtc->dev;
+       struct vc4_dev *vc4 = to_vc4_dev(dev);
        struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
        struct drm_crtc_state *state = crtc->state;
        struct drm_display_mode *mode = &state->adjusted_mode;
@@ -217,6 +219,16 @@ static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc)
                                 PV_HORZB_HFP) |
                   VC4_SET_FIELD(mode->hdisplay, PV_HORZB_HACTIVE));
 
+       CRTC_WRITE(PV_VERTA,
+                  VC4_SET_FIELD(mode->vtotal - mode->vsync_end,
+                                PV_VERTA_VBP) |
+                  VC4_SET_FIELD(mode->vsync_end - mode->vsync_start,
+                                PV_VERTA_VSYNC));
+       CRTC_WRITE(PV_VERTB,
+                  VC4_SET_FIELD(mode->vsync_start - mode->vdisplay,
+                                PV_VERTB_VFP) |
+                  VC4_SET_FIELD(vactive, PV_VERTB_VACTIVE));
+
        if (interlace) {
                CRTC_WRITE(PV_VERTA_EVEN,
                           VC4_SET_FIELD(mode->vtotal - mode->vsync_end - 1,
@@ -246,6 +258,10 @@ static void vc4_crtc_mode_set_nofb(struct drm_crtc *crtc)
                   PV_CONTROL_FIFO_CLR |
                   PV_CONTROL_EN);
 
+       HVS_WRITE(SCALER_DISPBKGNDX(vc4_crtc->channel),
+                 SCALER_DISPBKGND_AUTOHS |
+                 (interlace ? SCALER_DISPBKGND_INTERLACE : 0));
+
        if (debug_dump_regs) {
                DRM_INFO("CRTC %d regs after:\n", drm_crtc_index(crtc));
                vc4_crtc_dump_regs(vc4_crtc);
@@ -527,6 +543,7 @@ static int vc4_async_page_flip(struct drm_crtc *crtc,
        /* Make sure all other async modesetes have landed. */
        ret = down_interruptible(&vc4->async_modeset);
        if (ret) {
+               drm_framebuffer_unreference(fb);
                kfree(flip_state);
                return ret;
        }
index 3d1df6b..fa2ad15 100644 (file)
@@ -52,7 +52,7 @@ struct vc4_dev {
        /* Protects bo_cache and the BO stats. */
        struct mutex bo_lock;
 
-       /* Sequence number for the last job queued in job_list.
+       /* Sequence number for the last job queued in bin_job_list.
         * Starts at 0 (no jobs emitted).
         */
        uint64_t emit_seqno;
@@ -62,11 +62,19 @@ struct vc4_dev {
         */
        uint64_t finished_seqno;
 
-       /* List of all struct vc4_exec_info for jobs to be executed.
-        * The first job in the list is the one currently programmed
-        * into ct0ca/ct1ca for execution.
+       /* List of all struct vc4_exec_info for jobs to be executed in
+        * the binner.  The first job in the list is the one currently
+        * programmed into ct0ca for execution.
         */
-       struct list_head job_list;
+       struct list_head bin_job_list;
+
+       /* List of all struct vc4_exec_info for jobs that have
+        * completed binning and are ready for rendering.  The first
+        * job in the list is the one currently programmed into ct1ca
+        * for execution.
+        */
+       struct list_head render_job_list;
+
        /* List of the finished vc4_exec_infos waiting to be freed by
         * job_done_work.
         */
@@ -91,8 +99,12 @@ struct vc4_dev {
        struct vc4_bo *overflow_mem;
        struct work_struct overflow_mem_work;
 
+       int power_refcount;
+
+       /* Mutex controlling the power refcount. */
+       struct mutex power_lock;
+
        struct {
-               uint32_t last_ct0ca, last_ct1ca;
                struct timer_list timer;
                struct work_struct reset_work;
        } hangcheck;
@@ -142,6 +154,7 @@ struct vc4_seqno_cb {
 };
 
 struct vc4_v3d {
+       struct vc4_dev *vc4;
        struct platform_device *pdev;
        void __iomem *regs;
 };
@@ -202,6 +215,11 @@ struct vc4_exec_info {
        /* Sequence number for this bin/render job. */
        uint64_t seqno;
 
+       /* Last current addresses the hardware was processing when the
+        * hangcheck timer checked on us.
+        */
+       uint32_t last_ct0ca, last_ct1ca;
+
        /* Kernel-space copy of the ioctl arguments */
        struct drm_vc4_submit_cl *args;
 
@@ -286,11 +304,20 @@ struct vc4_exec_info {
 };
 
 static inline struct vc4_exec_info *
-vc4_first_job(struct vc4_dev *vc4)
+vc4_first_bin_job(struct vc4_dev *vc4)
+{
+       if (list_empty(&vc4->bin_job_list))
+               return NULL;
+       return list_first_entry(&vc4->bin_job_list, struct vc4_exec_info, head);
+}
+
+static inline struct vc4_exec_info *
+vc4_first_render_job(struct vc4_dev *vc4)
 {
-       if (list_empty(&vc4->job_list))
+       if (list_empty(&vc4->render_job_list))
                return NULL;
-       return list_first_entry(&vc4->job_list, struct vc4_exec_info, head);
+       return list_first_entry(&vc4->render_job_list,
+                               struct vc4_exec_info, head);
 }
 
 /**
@@ -404,7 +431,9 @@ int vc4_wait_seqno_ioctl(struct drm_device *dev, void *data,
                         struct drm_file *file_priv);
 int vc4_wait_bo_ioctl(struct drm_device *dev, void *data,
                      struct drm_file *file_priv);
-void vc4_submit_next_job(struct drm_device *dev);
+void vc4_submit_next_bin_job(struct drm_device *dev);
+void vc4_submit_next_render_job(struct drm_device *dev);
+void vc4_move_job_to_render(struct drm_device *dev, struct vc4_exec_info *exec);
 int vc4_wait_for_seqno(struct drm_device *dev, uint64_t seqno,
                       uint64_t timeout_ns, bool interruptible);
 void vc4_job_handle_completed(struct vc4_dev *vc4);
@@ -443,7 +472,6 @@ void vc4_plane_async_set_fb(struct drm_plane *plane,
 extern struct platform_driver vc4_v3d_driver;
 int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused);
 int vc4_v3d_debugfs_regs(struct seq_file *m, void *unused);
-int vc4_v3d_set_power(struct vc4_dev *vc4, bool on);
 
 /* vc4_validate.c */
 int
index 48ce30a..8d4384f 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/device.h>
 #include <linux/io.h>
 
@@ -140,10 +141,10 @@ vc4_save_hang_state(struct drm_device *dev)
        struct vc4_dev *vc4 = to_vc4_dev(dev);
        struct drm_vc4_get_hang_state *state;
        struct vc4_hang_state *kernel_state;
-       struct vc4_exec_info *exec;
+       struct vc4_exec_info *exec[2];
        struct vc4_bo *bo;
        unsigned long irqflags;
-       unsigned int i, unref_list_count;
+       unsigned int i, j, unref_list_count, prev_idx;
 
        kernel_state = kcalloc(1, sizeof(*kernel_state), GFP_KERNEL);
        if (!kernel_state)
@@ -152,37 +153,55 @@ vc4_save_hang_state(struct drm_device *dev)
        state = &kernel_state->user_state;
 
        spin_lock_irqsave(&vc4->job_lock, irqflags);
-       exec = vc4_first_job(vc4);
-       if (!exec) {
+       exec[0] = vc4_first_bin_job(vc4);
+       exec[1] = vc4_first_render_job(vc4);
+       if (!exec[0] && !exec[1]) {
                spin_unlock_irqrestore(&vc4->job_lock, irqflags);
                return;
        }
 
-       unref_list_count = 0;
-       list_for_each_entry(bo, &exec->unref_list, unref_head)
-               unref_list_count++;
+       /* Get the bos from both binner and renderer into hang state. */
+       state->bo_count = 0;
+       for (i = 0; i < 2; i++) {
+               if (!exec[i])
+                       continue;
+
+               unref_list_count = 0;
+               list_for_each_entry(bo, &exec[i]->unref_list, unref_head)
+                       unref_list_count++;
+               state->bo_count += exec[i]->bo_count + unref_list_count;
+       }
+
+       kernel_state->bo = kcalloc(state->bo_count,
+                                  sizeof(*kernel_state->bo), GFP_ATOMIC);
 
-       state->bo_count = exec->bo_count + unref_list_count;
-       kernel_state->bo = kcalloc(state->bo_count, sizeof(*kernel_state->bo),
-                                  GFP_ATOMIC);
        if (!kernel_state->bo) {
                spin_unlock_irqrestore(&vc4->job_lock, irqflags);
                return;
        }
 
-       for (i = 0; i < exec->bo_count; i++) {
-               drm_gem_object_reference(&exec->bo[i]->base);
-               kernel_state->bo[i] = &exec->bo[i]->base;
-       }
+       prev_idx = 0;
+       for (i = 0; i < 2; i++) {
+               if (!exec[i])
+                       continue;
 
-       list_for_each_entry(bo, &exec->unref_list, unref_head) {
-               drm_gem_object_reference(&bo->base.base);
-               kernel_state->bo[i] = &bo->base.base;
-               i++;
+               for (j = 0; j < exec[i]->bo_count; j++) {
+                       drm_gem_object_reference(&exec[i]->bo[j]->base);
+                       kernel_state->bo[j + prev_idx] = &exec[i]->bo[j]->base;
+               }
+
+               list_for_each_entry(bo, &exec[i]->unref_list, unref_head) {
+                       drm_gem_object_reference(&bo->base.base);
+                       kernel_state->bo[j + prev_idx] = &bo->base.base;
+                       j++;
+               }
+               prev_idx = j + 1;
        }
 
-       state->start_bin = exec->ct0ca;
-       state->start_render = exec->ct1ca;
+       if (exec[0])
+               state->start_bin = exec[0]->ct0ca;
+       if (exec[1])
+               state->start_render = exec[1]->ct1ca;
 
        spin_unlock_irqrestore(&vc4->job_lock, irqflags);
 
@@ -228,8 +247,16 @@ vc4_reset(struct drm_device *dev)
        struct vc4_dev *vc4 = to_vc4_dev(dev);
 
        DRM_INFO("Resetting GPU.\n");
-       vc4_v3d_set_power(vc4, false);
-       vc4_v3d_set_power(vc4, true);
+
+       mutex_lock(&vc4->power_lock);
+       if (vc4->power_refcount) {
+               /* Power the device off and back on the by dropping the
+                * reference on runtime PM.
+                */
+               pm_runtime_put_sync_suspend(&vc4->v3d->pdev->dev);
+               pm_runtime_get_sync(&vc4->v3d->pdev->dev);
+       }
+       mutex_unlock(&vc4->power_lock);
 
        vc4_irq_reset(dev);
 
@@ -257,10 +284,19 @@ vc4_hangcheck_elapsed(unsigned long data)
        struct drm_device *dev = (struct drm_device *)data;
        struct vc4_dev *vc4 = to_vc4_dev(dev);
        uint32_t ct0ca, ct1ca;
+       unsigned long irqflags;
+       struct vc4_exec_info *bin_exec, *render_exec;
+
+       spin_lock_irqsave(&vc4->job_lock, irqflags);
+
+       bin_exec = vc4_first_bin_job(vc4);
+       render_exec = vc4_first_render_job(vc4);
 
        /* If idle, we can stop watching for hangs. */
-       if (list_empty(&vc4->job_list))
+       if (!bin_exec && !render_exec) {
+               spin_unlock_irqrestore(&vc4->job_lock, irqflags);
                return;
+       }
 
        ct0ca = V3D_READ(V3D_CTNCA(0));
        ct1ca = V3D_READ(V3D_CTNCA(1));
@@ -268,14 +304,19 @@ vc4_hangcheck_elapsed(unsigned long data)
        /* If we've made any progress in execution, rearm the timer
         * and wait.
         */
-       if (ct0ca != vc4->hangcheck.last_ct0ca ||
-           ct1ca != vc4->hangcheck.last_ct1ca) {
-               vc4->hangcheck.last_ct0ca = ct0ca;
-               vc4->hangcheck.last_ct1ca = ct1ca;
+       if ((bin_exec && ct0ca != bin_exec->last_ct0ca) ||
+           (render_exec && ct1ca != render_exec->last_ct1ca)) {
+               if (bin_exec)
+                       bin_exec->last_ct0ca = ct0ca;
+               if (render_exec)
+                       render_exec->last_ct1ca = ct1ca;
+               spin_unlock_irqrestore(&vc4->job_lock, irqflags);
                vc4_queue_hangcheck(dev);
                return;
        }
 
+       spin_unlock_irqrestore(&vc4->job_lock, irqflags);
+
        /* We've gone too long with no progress, reset.  This has to
         * be done from a work struct, since resetting can sleep and
         * this timer hook isn't allowed to.
@@ -340,12 +381,7 @@ vc4_wait_for_seqno(struct drm_device *dev, uint64_t seqno, uint64_t timeout_ns,
        finish_wait(&vc4->job_wait_queue, &wait);
        trace_vc4_wait_for_seqno_end(dev, seqno);
 
-       if (ret && ret != -ERESTARTSYS) {
-               DRM_ERROR("timeout waiting for render thread idle\n");
-               return ret;
-       }
-
-       return 0;
+       return ret;
 }
 
 static void
@@ -373,11 +409,13 @@ vc4_flush_caches(struct drm_device *dev)
  * The job_lock should be held during this.
  */
 void
-vc4_submit_next_job(struct drm_device *dev)
+vc4_submit_next_bin_job(struct drm_device *dev)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
-       struct vc4_exec_info *exec = vc4_first_job(vc4);
+       struct vc4_exec_info *exec;
 
+again:
+       exec = vc4_first_bin_job(vc4);
        if (!exec)
                return;
 
@@ -387,11 +425,40 @@ vc4_submit_next_job(struct drm_device *dev)
        V3D_WRITE(V3D_BPOA, 0);
        V3D_WRITE(V3D_BPOS, 0);
 
-       if (exec->ct0ca != exec->ct0ea)
+       /* Either put the job in the binner if it uses the binner, or
+        * immediately move it to the to-be-rendered queue.
+        */
+       if (exec->ct0ca != exec->ct0ea) {
                submit_cl(dev, 0, exec->ct0ca, exec->ct0ea);
+       } else {
+               vc4_move_job_to_render(dev, exec);
+               goto again;
+       }
+}
+
+void
+vc4_submit_next_render_job(struct drm_device *dev)
+{
+       struct vc4_dev *vc4 = to_vc4_dev(dev);
+       struct vc4_exec_info *exec = vc4_first_render_job(vc4);
+
+       if (!exec)
+               return;
+
        submit_cl(dev, 1, exec->ct1ca, exec->ct1ea);
 }
 
+void
+vc4_move_job_to_render(struct drm_device *dev, struct vc4_exec_info *exec)
+{
+       struct vc4_dev *vc4 = to_vc4_dev(dev);
+       bool was_empty = list_empty(&vc4->render_job_list);
+
+       list_move_tail(&exec->head, &vc4->render_job_list);
+       if (was_empty)
+               vc4_submit_next_render_job(dev);
+}
+
 static void
 vc4_update_bo_seqnos(struct vc4_exec_info *exec, uint64_t seqno)
 {
@@ -430,14 +497,14 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec)
        exec->seqno = seqno;
        vc4_update_bo_seqnos(exec, seqno);
 
-       list_add_tail(&exec->head, &vc4->job_list);
+       list_add_tail(&exec->head, &vc4->bin_job_list);
 
        /* If no job was executing, kick ours off.  Otherwise, it'll
-        * get started when the previous job's frame done interrupt
+        * get started when the previous job's flush done interrupt
         * occurs.
         */
-       if (vc4_first_job(vc4) == exec) {
-               vc4_submit_next_job(dev);
+       if (vc4_first_bin_job(vc4) == exec) {
+               vc4_submit_next_bin_job(dev);
                vc4_queue_hangcheck(dev);
        }
 
@@ -578,9 +645,9 @@ vc4_get_bcl(struct drm_device *dev, struct vc4_exec_info *exec)
        }
 
        bo = vc4_bo_create(dev, exec_size, true);
-       if (!bo) {
+       if (IS_ERR(bo)) {
                DRM_ERROR("Couldn't allocate BO for binning\n");
-               ret = -ENOMEM;
+               ret = PTR_ERR(bo);
                goto fail;
        }
        exec->exec_bo = &bo->base;
@@ -617,6 +684,7 @@ fail:
 static void
 vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
 {
+       struct vc4_dev *vc4 = to_vc4_dev(dev);
        unsigned i;
 
        /* Need the struct lock for drm_gem_object_unreference(). */
@@ -635,6 +703,11 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
        }
        mutex_unlock(&dev->struct_mutex);
 
+       mutex_lock(&vc4->power_lock);
+       if (--vc4->power_refcount == 0)
+               pm_runtime_put(&vc4->v3d->pdev->dev);
+       mutex_unlock(&vc4->power_lock);
+
        kfree(exec);
 }
 
@@ -746,6 +819,9 @@ vc4_wait_bo_ioctl(struct drm_device *dev, void *data,
        struct drm_gem_object *gem_obj;
        struct vc4_bo *bo;
 
+       if (args->pad != 0)
+               return -EINVAL;
+
        gem_obj = drm_gem_object_lookup(dev, file_priv, args->handle);
        if (!gem_obj) {
                DRM_ERROR("Failed to look up GEM BO %d\n", args->handle);
@@ -772,7 +848,7 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
        struct vc4_dev *vc4 = to_vc4_dev(dev);
        struct drm_vc4_submit_cl *args = data;
        struct vc4_exec_info *exec;
-       int ret;
+       int ret = 0;
 
        if ((args->flags & ~VC4_SUBMIT_CL_USE_CLEAR_COLOR) != 0) {
                DRM_ERROR("Unknown flags: 0x%02x\n", args->flags);
@@ -785,6 +861,15 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
                return -ENOMEM;
        }
 
+       mutex_lock(&vc4->power_lock);
+       if (vc4->power_refcount++ == 0)
+               ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
+       mutex_unlock(&vc4->power_lock);
+       if (ret < 0) {
+               kfree(exec);
+               return ret;
+       }
+
        exec->args = args;
        INIT_LIST_HEAD(&exec->unref_list);
 
@@ -828,7 +913,8 @@ vc4_gem_init(struct drm_device *dev)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
 
-       INIT_LIST_HEAD(&vc4->job_list);
+       INIT_LIST_HEAD(&vc4->bin_job_list);
+       INIT_LIST_HEAD(&vc4->render_job_list);
        INIT_LIST_HEAD(&vc4->job_done_list);
        INIT_LIST_HEAD(&vc4->seqno_cb_list);
        spin_lock_init(&vc4->job_lock);
@@ -839,6 +925,8 @@ vc4_gem_init(struct drm_device *dev)
                    (unsigned long)dev);
 
        INIT_WORK(&vc4->job_done_work, vc4_job_done_work);
+
+       mutex_init(&vc4->power_lock);
 }
 
 void
index c69c046..d8b8649 100644 (file)
@@ -47,6 +47,7 @@ struct vc4_hdmi {
        void __iomem *hdmicore_regs;
        void __iomem *hd_regs;
        int hpd_gpio;
+       bool hpd_active_low;
 
        struct clk *pixel_clock;
        struct clk *hsm_clock;
@@ -95,6 +96,7 @@ static const struct {
        HDMI_REG(VC4_HDMI_SW_RESET_CONTROL),
        HDMI_REG(VC4_HDMI_HOTPLUG_INT),
        HDMI_REG(VC4_HDMI_HOTPLUG),
+       HDMI_REG(VC4_HDMI_RAM_PACKET_CONFIG),
        HDMI_REG(VC4_HDMI_HORZA),
        HDMI_REG(VC4_HDMI_HORZB),
        HDMI_REG(VC4_HDMI_FIFO_CTL),
@@ -165,7 +167,8 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)
        struct vc4_dev *vc4 = to_vc4_dev(dev);
 
        if (vc4->hdmi->hpd_gpio) {
-               if (gpio_get_value(vc4->hdmi->hpd_gpio))
+               if (gpio_get_value_cansleep(vc4->hdmi->hpd_gpio) ^
+                   vc4->hdmi->hpd_active_low)
                        return connector_status_connected;
                else
                        return connector_status_disconnected;
@@ -495,6 +498,16 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
                goto err_put_i2c;
        }
 
+       /* This is the rate that is set by the firmware.  The number
+        * needs to be a bit higher than the pixel clock rate
+        * (generally 148.5Mhz).
+        */
+       ret = clk_set_rate(hdmi->hsm_clock, 163682864);
+       if (ret) {
+               DRM_ERROR("Failed to set HSM clock rate: %d\n", ret);
+               goto err_unprepare_pix;
+       }
+
        ret = clk_prepare_enable(hdmi->hsm_clock);
        if (ret) {
                DRM_ERROR("Failed to turn on HDMI state machine clock: %d\n",
@@ -506,17 +519,40 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
         * we'll use the HDMI core's register.
         */
        if (of_find_property(dev->of_node, "hpd-gpios", &value)) {
-               hdmi->hpd_gpio = of_get_named_gpio(dev->of_node, "hpd-gpios", 0);
+               enum of_gpio_flags hpd_gpio_flags;
+
+               hdmi->hpd_gpio = of_get_named_gpio_flags(dev->of_node,
+                                                        "hpd-gpios", 0,
+                                                        &hpd_gpio_flags);
                if (hdmi->hpd_gpio < 0) {
                        ret = hdmi->hpd_gpio;
                        goto err_unprepare_hsm;
                }
+
+               hdmi->hpd_active_low = hpd_gpio_flags & OF_GPIO_ACTIVE_LOW;
        }
 
        vc4->hdmi = hdmi;
 
        /* HDMI core must be enabled. */
-       WARN_ON_ONCE((HD_READ(VC4_HD_M_CTL) & VC4_HD_M_ENABLE) == 0);
+       if (!(HD_READ(VC4_HD_M_CTL) & VC4_HD_M_ENABLE)) {
+               HD_WRITE(VC4_HD_M_CTL, VC4_HD_M_SW_RST);
+               udelay(1);
+               HD_WRITE(VC4_HD_M_CTL, 0);
+
+               HD_WRITE(VC4_HD_M_CTL, VC4_HD_M_ENABLE);
+
+               HDMI_WRITE(VC4_HDMI_SW_RESET_CONTROL,
+                          VC4_HDMI_SW_RESET_HDMI |
+                          VC4_HDMI_SW_RESET_FORMAT_DETECT);
+
+               HDMI_WRITE(VC4_HDMI_SW_RESET_CONTROL, 0);
+
+               /* PHY should be in reset, like
+                * vc4_hdmi_encoder_disable() does.
+                */
+               HDMI_WRITE(VC4_HDMI_TX_PHY_RESET_CTL, 0xf << 16);
+       }
 
        drm_encoder_init(drm, hdmi->encoder, &vc4_hdmi_encoder_funcs,
                         DRM_MODE_ENCODER_TMDS, NULL);
index b68060e..b0104a3 100644 (file)
  * disables that specific interrupt, and 0s written are ignored
  * (reading either one returns the set of enabled interrupts).
  *
+ * When we take a binning flush done interrupt, we need to submit the
+ * next frame for binning and move the finished frame to the render
+ * thread.
+ *
  * When we take a render frame interrupt, we need to wake the
  * processes waiting for some frame to be done, and get the next frame
  * submitted ASAP (so the hardware doesn't sit idle when there's work
@@ -44,6 +48,7 @@
 #include "vc4_regs.h"
 
 #define V3D_DRIVER_IRQS (V3D_INT_OUTOMEM | \
+                        V3D_INT_FLDONE | \
                         V3D_INT_FRDONE)
 
 DECLARE_WAIT_QUEUE_HEAD(render_wait);
@@ -57,7 +62,7 @@ vc4_overflow_mem_work(struct work_struct *work)
        struct vc4_bo *bo;
 
        bo = vc4_bo_create(dev, 256 * 1024, true);
-       if (!bo) {
+       if (IS_ERR(bo)) {
                DRM_ERROR("Couldn't allocate binner overflow mem\n");
                return;
        }
@@ -77,7 +82,7 @@ vc4_overflow_mem_work(struct work_struct *work)
                unsigned long irqflags;
 
                spin_lock_irqsave(&vc4->job_lock, irqflags);
-               current_exec = vc4_first_job(vc4);
+               current_exec = vc4_first_bin_job(vc4);
                if (current_exec) {
                        vc4->overflow_mem->seqno = vc4->finished_seqno + 1;
                        list_add_tail(&vc4->overflow_mem->unref_head,
@@ -98,17 +103,43 @@ vc4_overflow_mem_work(struct work_struct *work)
 }
 
 static void
-vc4_irq_finish_job(struct drm_device *dev)
+vc4_irq_finish_bin_job(struct drm_device *dev)
+{
+       struct vc4_dev *vc4 = to_vc4_dev(dev);
+       struct vc4_exec_info *exec = vc4_first_bin_job(vc4);
+
+       if (!exec)
+               return;
+
+       vc4_move_job_to_render(dev, exec);
+       vc4_submit_next_bin_job(dev);
+}
+
+static void
+vc4_cancel_bin_job(struct drm_device *dev)
+{
+       struct vc4_dev *vc4 = to_vc4_dev(dev);
+       struct vc4_exec_info *exec = vc4_first_bin_job(vc4);
+
+       if (!exec)
+               return;
+
+       list_move_tail(&exec->head, &vc4->bin_job_list);
+       vc4_submit_next_bin_job(dev);
+}
+
+static void
+vc4_irq_finish_render_job(struct drm_device *dev)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
-       struct vc4_exec_info *exec = vc4_first_job(vc4);
+       struct vc4_exec_info *exec = vc4_first_render_job(vc4);
 
        if (!exec)
                return;
 
        vc4->finished_seqno++;
        list_move_tail(&exec->head, &vc4->job_done_list);
-       vc4_submit_next_job(dev);
+       vc4_submit_next_render_job(dev);
 
        wake_up_all(&vc4->job_wait_queue);
        schedule_work(&vc4->job_done_work);
@@ -125,9 +156,10 @@ vc4_irq(int irq, void *arg)
        barrier();
        intctl = V3D_READ(V3D_INTCTL);
 
-       /* Acknowledge the interrupts we're handling here. The render
-        * frame done interrupt will be cleared, while OUTOMEM will
-        * stay high until the underlying cause is cleared.
+       /* Acknowledge the interrupts we're handling here. The binner
+        * last flush / render frame done interrupt will be cleared,
+        * while OUTOMEM will stay high until the underlying cause is
+        * cleared.
         */
        V3D_WRITE(V3D_INTCTL, intctl);
 
@@ -138,9 +170,16 @@ vc4_irq(int irq, void *arg)
                status = IRQ_HANDLED;
        }
 
+       if (intctl & V3D_INT_FLDONE) {
+               spin_lock(&vc4->job_lock);
+               vc4_irq_finish_bin_job(dev);
+               spin_unlock(&vc4->job_lock);
+               status = IRQ_HANDLED;
+       }
+
        if (intctl & V3D_INT_FRDONE) {
                spin_lock(&vc4->job_lock);
-               vc4_irq_finish_job(dev);
+               vc4_irq_finish_render_job(dev);
                spin_unlock(&vc4->job_lock);
                status = IRQ_HANDLED;
        }
@@ -205,6 +244,7 @@ void vc4_irq_reset(struct drm_device *dev)
        V3D_WRITE(V3D_INTENA, V3D_DRIVER_IRQS);
 
        spin_lock_irqsave(&vc4->job_lock, irqflags);
-       vc4_irq_finish_job(dev);
+       vc4_cancel_bin_job(dev);
+       vc4_irq_finish_render_job(dev);
        spin_unlock_irqrestore(&vc4->job_lock, irqflags);
 }
index 25df20e..bf42a8e 100644 (file)
 # define PV_VCONTROL_CONTINUOUS                        BIT(1)
 # define PV_VCONTROL_VIDEN                     BIT(0)
 
-#define PV_VSYNCD                              0x08
+#define PV_VSYNCD_EVEN                         0x08
 
 #define PV_HORZA                               0x0c
 # define PV_HORZA_HBP_MASK                     VC4_MASK(31, 16)
 # define SCALER_DISPCTRLX_HEIGHT_SHIFT         0
 
 #define SCALER_DISPBKGND0                       0x00000044
+# define SCALER_DISPBKGND_AUTOHS               BIT(31)
+# define SCALER_DISPBKGND_INTERLACE            BIT(30)
+# define SCALER_DISPBKGND_GAMMA                        BIT(29)
+# define SCALER_DISPBKGND_TESTMODE_MASK                VC4_MASK(28, 25)
+# define SCALER_DISPBKGND_TESTMODE_SHIFT       25
+/* Enables filling the scaler line with the RGB value in the low 24
+ * bits before compositing.  Costs cycles, so should be skipped if
+ * opaque display planes will cover everything.
+ */
+# define SCALER_DISPBKGND_FILL                 BIT(24)
+
 #define SCALER_DISPSTAT0                        0x00000048
 #define SCALER_DISPBASE0                        0x0000004c
 # define SCALER_DISPSTATX_MODE_MASK            VC4_MASK(31, 30)
 # define SCALER_DISPSTATX_EMPTY                        BIT(28)
 #define SCALER_DISPCTRL1                        0x00000050
 #define SCALER_DISPBKGND1                       0x00000054
+#define SCALER_DISPBKGNDX(x)                   (SCALER_DISPBKGND0 +        \
+                                                (x) * (SCALER_DISPBKGND1 - \
+                                                       SCALER_DISPBKGND0))
 #define SCALER_DISPSTAT1                        0x00000058
 #define SCALER_DISPSTATX(x)                    (SCALER_DISPSTAT0 +        \
                                                 (x) * (SCALER_DISPSTAT1 - \
 #define VC4_HDMI_TX_PHY_RESET_CTL              0x2c0
 
 #define VC4_HD_M_CTL                           0x00c
+# define VC4_HD_M_REGISTER_FILE_STANDBY                (3 << 6)
+# define VC4_HD_M_RAM_STANDBY                  (3 << 4)
 # define VC4_HD_M_SW_RST                       BIT(2)
 # define VC4_HD_M_ENABLE                       BIT(0)
 
index 8a2a312..0f12418 100644 (file)
@@ -316,20 +316,11 @@ static int vc4_create_rcl_bo(struct drm_device *dev, struct vc4_exec_info *exec,
        size += xtiles * ytiles * loop_body_size;
 
        setup->rcl = &vc4_bo_create(dev, size, true)->base;
-       if (!setup->rcl)
-               return -ENOMEM;
+       if (IS_ERR(setup->rcl))
+               return PTR_ERR(setup->rcl);
        list_add_tail(&to_vc4_bo(&setup->rcl->base)->unref_head,
                      &exec->unref_list);
 
-       rcl_u8(setup, VC4_PACKET_TILE_RENDERING_MODE_CONFIG);
-       rcl_u32(setup,
-               (setup->color_write ? (setup->color_write->paddr +
-                                      args->color_write.offset) :
-                0));
-       rcl_u16(setup, args->width);
-       rcl_u16(setup, args->height);
-       rcl_u16(setup, args->color_write.bits);
-
        /* The tile buffer gets cleared when the previous tile is stored.  If
         * the clear values changed between frames, then the tile buffer has
         * stale clear values in it, so we have to do a store in None mode (no
@@ -349,6 +340,15 @@ static int vc4_create_rcl_bo(struct drm_device *dev, struct vc4_exec_info *exec,
                rcl_u32(setup, 0); /* no address, since we're in None mode */
        }
 
+       rcl_u8(setup, VC4_PACKET_TILE_RENDERING_MODE_CONFIG);
+       rcl_u32(setup,
+               (setup->color_write ? (setup->color_write->paddr +
+                                      args->color_write.offset) :
+                0));
+       rcl_u16(setup, args->width);
+       rcl_u16(setup, args->height);
+       rcl_u16(setup, args->color_write.bits);
+
        for (y = min_y_tile; y <= max_y_tile; y++) {
                for (x = min_x_tile; x <= max_x_tile; x++) {
                        bool first = (x == min_x_tile && y == min_y_tile);
index 314ff71..e6d3c60 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #include "linux/component.h"
+#include "linux/pm_runtime.h"
 #include "vc4_drv.h"
 #include "vc4_regs.h"
 
@@ -144,18 +145,6 @@ int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused)
 }
 #endif /* CONFIG_DEBUG_FS */
 
-int
-vc4_v3d_set_power(struct vc4_dev *vc4, bool on)
-{
-       /* XXX: This interface is needed for GPU reset, and the way to
-        * do it is to turn our power domain off and back on.  We
-        * can't just reset from within the driver, because the reset
-        * bits are in the power domain's register area, and get set
-        * during the poweron process.
-        */
-       return 0;
-}
-
 static void vc4_v3d_init_hw(struct drm_device *dev)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
@@ -167,6 +156,29 @@ static void vc4_v3d_init_hw(struct drm_device *dev)
        V3D_WRITE(V3D_VPMBASE, 0);
 }
 
+#ifdef CONFIG_PM
+static int vc4_v3d_runtime_suspend(struct device *dev)
+{
+       struct vc4_v3d *v3d = dev_get_drvdata(dev);
+       struct vc4_dev *vc4 = v3d->vc4;
+
+       vc4_irq_uninstall(vc4->dev);
+
+       return 0;
+}
+
+static int vc4_v3d_runtime_resume(struct device *dev)
+{
+       struct vc4_v3d *v3d = dev_get_drvdata(dev);
+       struct vc4_dev *vc4 = v3d->vc4;
+
+       vc4_v3d_init_hw(vc4->dev);
+       vc4_irq_postinstall(vc4->dev);
+
+       return 0;
+}
+#endif
+
 static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
 {
        struct platform_device *pdev = to_platform_device(dev);
@@ -179,6 +191,8 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
        if (!v3d)
                return -ENOMEM;
 
+       dev_set_drvdata(dev, v3d);
+
        v3d->pdev = pdev;
 
        v3d->regs = vc4_ioremap_regs(pdev, 0);
@@ -186,6 +200,7 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
                return PTR_ERR(v3d->regs);
 
        vc4->v3d = v3d;
+       v3d->vc4 = vc4;
 
        if (V3D_READ(V3D_IDENT0) != V3D_EXPECTED_IDENT0) {
                DRM_ERROR("V3D_IDENT0 read 0x%08x instead of 0x%08x\n",
@@ -207,6 +222,8 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
                return ret;
        }
 
+       pm_runtime_enable(dev);
+
        return 0;
 }
 
@@ -216,6 +233,8 @@ static void vc4_v3d_unbind(struct device *dev, struct device *master,
        struct drm_device *drm = dev_get_drvdata(master);
        struct vc4_dev *vc4 = to_vc4_dev(drm);
 
+       pm_runtime_disable(dev);
+
        drm_irq_uninstall(drm);
 
        /* Disable the binner's overflow memory address, so the next
@@ -228,6 +247,10 @@ static void vc4_v3d_unbind(struct device *dev, struct device *master,
        vc4->v3d = NULL;
 }
 
+static const struct dev_pm_ops vc4_v3d_pm_ops = {
+       SET_RUNTIME_PM_OPS(vc4_v3d_runtime_suspend, vc4_v3d_runtime_resume, NULL)
+};
+
 static const struct component_ops vc4_v3d_ops = {
        .bind   = vc4_v3d_bind,
        .unbind = vc4_v3d_unbind,
@@ -245,6 +268,7 @@ static int vc4_v3d_dev_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id vc4_v3d_dt_match[] = {
+       { .compatible = "brcm,bcm2835-v3d" },
        { .compatible = "brcm,vc4-v3d" },
        {}
 };
@@ -255,5 +279,6 @@ struct platform_driver vc4_v3d_driver = {
        .driver = {
                .name = "vc4_v3d",
                .of_match_table = vc4_v3d_dt_match,
+               .pm = &vc4_v3d_pm_ops,
        },
 };
index e26d9f6..24c2c74 100644 (file)
@@ -401,8 +401,8 @@ validate_tile_binning_config(VALIDATE_ARGS)
        tile_bo = vc4_bo_create(dev, exec->tile_alloc_offset + tile_alloc_size,
                                true);
        exec->tile_bo = &tile_bo->base;
-       if (!exec->tile_bo)
-               return -ENOMEM;
+       if (IS_ERR(exec->tile_bo))
+               return PTR_ERR(exec->tile_bo);
        list_add_tail(&tile_bo->unref_head, &exec->unref_list);
 
        /* tile alloc address. */
index 429aa31..4854dac 100644 (file)
@@ -237,13 +237,6 @@ virtio_gpu_framebuffer_init(struct drm_device *dev,
        return 0;
 }
 
-static bool virtio_gpu_crtc_mode_fixup(struct drm_crtc *crtc,
-                                      const struct drm_display_mode *mode,
-                                      struct drm_display_mode *adjusted_mode)
-{
-       return true;
-}
-
 static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
        struct drm_device *dev = crtc->dev;
@@ -277,7 +270,6 @@ static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
 static const struct drm_crtc_helper_funcs virtio_gpu_crtc_helper_funcs = {
        .enable        = virtio_gpu_crtc_enable,
        .disable       = virtio_gpu_crtc_disable,
-       .mode_fixup    = virtio_gpu_crtc_mode_fixup,
        .mode_set_nofb = virtio_gpu_crtc_mode_set_nofb,
        .atomic_check  = virtio_gpu_crtc_atomic_check,
 };
index 0ee76e5..6cbb7d4 100644 (file)
@@ -195,7 +195,7 @@ static const struct drm_ioctl_desc vmw_ioctls[] = {
                      DRM_MASTER | DRM_AUTH),
        VMW_IOCTL_DEF(VMW_UPDATE_LAYOUT,
                      vmw_kms_update_layout_ioctl,
-                     DRM_MASTER),
+                     DRM_MASTER | DRM_CONTROL_ALLOW),
        VMW_IOCTL_DEF(VMW_CREATE_SHADER,
                      vmw_shader_define_ioctl,
                      DRM_AUTH | DRM_RENDER_ALLOW),
@@ -1204,6 +1204,7 @@ static int vmw_master_set(struct drm_device *dev,
        }
 
        dev_priv->active_master = vmaster;
+       drm_sysfs_hotplug_event(dev);
 
        return 0;
 }
index 5cb1b16..019a6ca 100644 (file)
@@ -40,9 +40,9 @@
 #include <drm/ttm/ttm_module.h>
 #include "vmwgfx_fence.h"
 
-#define VMWGFX_DRIVER_DATE "20150810"
+#define VMWGFX_DRIVER_DATE "20160210"
 #define VMWGFX_DRIVER_MAJOR 2
-#define VMWGFX_DRIVER_MINOR 9
+#define VMWGFX_DRIVER_MINOR 10
 #define VMWGFX_DRIVER_PATCHLEVEL 0
 #define VMWGFX_FILE_PAGE_OFFSET 0x00100000
 #define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
@@ -407,8 +407,11 @@ struct vmw_private {
        void *fb_info;
        enum vmw_display_unit_type active_display_unit;
        struct vmw_legacy_display *ldu_priv;
-       struct vmw_screen_object_display *sou_priv;
        struct vmw_overlay *overlay_priv;
+       struct drm_property *hotplug_mode_update_property;
+       struct drm_property *implicit_placement_property;
+       unsigned num_implicit;
+       struct vmw_framebuffer *implicit_fb;
 
        /*
         * Context and surface management.
index 5da5de0..723ba16 100644 (file)
@@ -3009,6 +3009,26 @@ out_unref:
        return ret;
 }
 
+/**
+ * vmw_cmd_dx_genmips - Validate an SVGA_3D_CMD_DX_GENMIPS command
+ *
+ * @dev_priv: Pointer to a device private struct.
+ * @sw_context: The software context being used for this batch.
+ * @header: Pointer to the command header in the command stream.
+ */
+static int vmw_cmd_dx_genmips(struct vmw_private *dev_priv,
+                             struct vmw_sw_context *sw_context,
+                             SVGA3dCmdHeader *header)
+{
+       struct {
+               SVGA3dCmdHeader header;
+               SVGA3dCmdDXGenMips body;
+       } *cmd = container_of(header, typeof(*cmd), header);
+
+       return vmw_view_id_val_add(sw_context, vmw_view_sr,
+                                  cmd->body.shaderResourceViewId);
+}
+
 static int vmw_cmd_check_not_3d(struct vmw_private *dev_priv,
                                struct vmw_sw_context *sw_context,
                                void *buf, uint32_t *size)
@@ -3297,7 +3317,7 @@ static const struct vmw_cmd_entry vmw_cmd_entries[SVGA_3D_CMD_MAX] = {
                    &vmw_cmd_dx_clear_depthstencil_view, true, false, true),
        VMW_CMD_DEF(SVGA_3D_CMD_DX_PRED_COPY, &vmw_cmd_invalid,
                    true, false, true),
-       VMW_CMD_DEF(SVGA_3D_CMD_DX_GENMIPS, &vmw_cmd_invalid,
+       VMW_CMD_DEF(SVGA_3D_CMD_DX_GENMIPS, &vmw_cmd_dx_genmips,
                    true, false, true),
        VMW_CMD_DEF(SVGA_3D_CMD_DX_UPDATE_SUBRESOURCE,
                    &vmw_cmd_dx_check_subresource, true, false, true),
index b221a8c..4742ec4 100644 (file)
@@ -236,8 +236,8 @@ int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
        struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
        bool shown = du->cursor_surface || du->cursor_dmabuf ? true : false;
 
-       du->cursor_x = x + crtc->x;
-       du->cursor_y = y + crtc->y;
+       du->cursor_x = x + du->set_gui_x;
+       du->cursor_y = y + du->set_gui_y;
 
        /*
         * FIXME: Unclear whether there's any global state touched by the
@@ -663,9 +663,8 @@ static int vmw_framebuffer_dmabuf_dirty(struct drm_framebuffer *framebuffer,
                break;
        case vmw_du_screen_object:
                ret = vmw_kms_sou_do_dmabuf_dirty(dev_priv, &vfbd->base,
-                                                 clips, num_clips, increment,
-                                                 true,
-                                                 NULL);
+                                                 clips, NULL, num_clips,
+                                                 increment, true, NULL);
                break;
        case vmw_du_legacy:
                ret = vmw_kms_ldu_do_dmabuf_dirty(dev_priv, &vfbd->base, 0, 0,
@@ -1109,6 +1108,22 @@ int vmw_kms_present(struct vmw_private *dev_priv,
        return 0;
 }
 
+static void
+vmw_kms_create_hotplug_mode_update_property(struct vmw_private *dev_priv)
+{
+       if (dev_priv->hotplug_mode_update_property)
+               return;
+
+       dev_priv->hotplug_mode_update_property =
+               drm_property_create_range(dev_priv->dev,
+                                         DRM_MODE_PROP_IMMUTABLE,
+                                         "hotplug_mode_update", 0, 1);
+
+       if (!dev_priv->hotplug_mode_update_property)
+               return;
+
+}
+
 int vmw_kms_init(struct vmw_private *dev_priv)
 {
        struct drm_device *dev = dev_priv->dev;
@@ -1121,6 +1136,9 @@ int vmw_kms_init(struct vmw_private *dev_priv)
        dev->mode_config.max_width = dev_priv->texture_max_width;
        dev->mode_config.max_height = dev_priv->texture_max_height;
 
+       drm_mode_create_suggested_offset_properties(dev);
+       vmw_kms_create_hotplug_mode_update_property(dev_priv);
+
        ret = vmw_kms_stdu_init_display(dev_priv);
        if (ret) {
                ret = vmw_kms_sou_init_display(dev_priv);
@@ -1360,15 +1378,28 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
                        du->pref_active = true;
                        du->gui_x = rects[du->unit].x;
                        du->gui_y = rects[du->unit].y;
+                       drm_object_property_set_value
+                         (&con->base, dev->mode_config.suggested_x_property,
+                          du->gui_x);
+                       drm_object_property_set_value
+                         (&con->base, dev->mode_config.suggested_y_property,
+                          du->gui_y);
                } else {
                        du->pref_width = 800;
                        du->pref_height = 600;
                        du->pref_active = false;
+                       drm_object_property_set_value
+                         (&con->base, dev->mode_config.suggested_x_property,
+                          0);
+                       drm_object_property_set_value
+                         (&con->base, dev->mode_config.suggested_y_property,
+                          0);
                }
                con->status = vmw_du_connector_detect(con, true);
        }
 
        mutex_unlock(&dev->mode_config.mutex);
+       drm_sysfs_hotplug_event(dev);
 
        return 0;
 }
@@ -1591,6 +1622,12 @@ int vmw_du_connector_set_property(struct drm_connector *connector,
                                  struct drm_property *property,
                                  uint64_t val)
 {
+       struct vmw_display_unit *du = vmw_connector_to_du(connector);
+       struct vmw_private *dev_priv = vmw_priv(connector->dev);
+
+       if (property == dev_priv->implicit_placement_property)
+               du->is_implicit = val;
+
        return 0;
 }
 
@@ -2096,3 +2133,119 @@ int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
 
        return 0;
 }
+
+/**
+ * vmw_kms_del_active - unregister a crtc binding to the implicit framebuffer
+ *
+ * @dev_priv: Pointer to a device private struct.
+ * @du: The display unit of the crtc.
+ */
+void vmw_kms_del_active(struct vmw_private *dev_priv,
+                       struct vmw_display_unit *du)
+{
+       lockdep_assert_held_once(&dev_priv->dev->mode_config.mutex);
+
+       if (du->active_implicit) {
+               if (--(dev_priv->num_implicit) == 0)
+                       dev_priv->implicit_fb = NULL;
+               du->active_implicit = false;
+       }
+}
+
+/**
+ * vmw_kms_add_active - register a crtc binding to an implicit framebuffer
+ *
+ * @vmw_priv: Pointer to a device private struct.
+ * @du: The display unit of the crtc.
+ * @vfb: The implicit framebuffer
+ *
+ * Registers a binding to an implicit framebuffer.
+ */
+void vmw_kms_add_active(struct vmw_private *dev_priv,
+                       struct vmw_display_unit *du,
+                       struct vmw_framebuffer *vfb)
+{
+       lockdep_assert_held_once(&dev_priv->dev->mode_config.mutex);
+
+       WARN_ON_ONCE(!dev_priv->num_implicit && dev_priv->implicit_fb);
+
+       if (!du->active_implicit && du->is_implicit) {
+               dev_priv->implicit_fb = vfb;
+               du->active_implicit = true;
+               dev_priv->num_implicit++;
+       }
+}
+
+/**
+ * vmw_kms_screen_object_flippable - Check whether we can page-flip a crtc.
+ *
+ * @dev_priv: Pointer to device-private struct.
+ * @crtc: The crtc we want to flip.
+ *
+ * Returns true or false depending whether it's OK to flip this crtc
+ * based on the criterion that we must not have more than one implicit
+ * frame-buffer at any one time.
+ */
+bool vmw_kms_crtc_flippable(struct vmw_private *dev_priv,
+                           struct drm_crtc *crtc)
+{
+       struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
+
+       lockdep_assert_held_once(&dev_priv->dev->mode_config.mutex);
+
+       if (!du->is_implicit)
+               return true;
+
+       if (dev_priv->num_implicit != 1)
+               return false;
+
+       return true;
+}
+
+/**
+ * vmw_kms_update_implicit_fb - Update the implicit fb.
+ *
+ * @dev_priv: Pointer to device-private struct.
+ * @crtc: The crtc the new implicit frame-buffer is bound to.
+ */
+void vmw_kms_update_implicit_fb(struct vmw_private *dev_priv,
+                               struct drm_crtc *crtc)
+{
+       struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
+       struct vmw_framebuffer *vfb;
+
+       lockdep_assert_held_once(&dev_priv->dev->mode_config.mutex);
+
+       if (!du->is_implicit)
+               return;
+
+       vfb = vmw_framebuffer_to_vfb(crtc->primary->fb);
+       WARN_ON_ONCE(dev_priv->num_implicit != 1 &&
+                    dev_priv->implicit_fb != vfb);
+
+       dev_priv->implicit_fb = vfb;
+}
+
+/**
+ * vmw_kms_create_implicit_placement_proparty - Set up the implicit placement
+ * property.
+ *
+ * @dev_priv: Pointer to a device private struct.
+ * @immutable: Whether the property is immutable.
+ *
+ * Sets up the implicit placement property unless it's already set up.
+ */
+void
+vmw_kms_create_implicit_placement_property(struct vmw_private *dev_priv,
+                                          bool immutable)
+{
+       if (dev_priv->implicit_placement_property)
+               return;
+
+       dev_priv->implicit_placement_property =
+               drm_property_create_range(dev_priv->dev,
+                                         immutable ?
+                                         DRM_MODE_PROP_IMMUTABLE : 0,
+                                         "implicit_placement", 0, 1);
+
+}
index edd8150..5720321 100644 (file)
@@ -178,6 +178,9 @@ struct vmw_display_unit {
        int gui_x;
        int gui_y;
        bool is_implicit;
+       bool active_implicit;
+       int set_gui_x;
+       int set_gui_y;
 };
 
 #define vmw_crtc_to_du(x) \
@@ -254,6 +257,18 @@ int vmw_kms_fbdev_init_data(struct vmw_private *dev_priv,
                            struct drm_crtc **p_crtc,
                            struct drm_display_mode **p_mode);
 void vmw_guess_mode_timing(struct drm_display_mode *mode);
+void vmw_kms_del_active(struct vmw_private *dev_priv,
+                       struct vmw_display_unit *du);
+void vmw_kms_add_active(struct vmw_private *dev_priv,
+                       struct vmw_display_unit *du,
+                       struct vmw_framebuffer *vfb);
+bool vmw_kms_crtc_flippable(struct vmw_private *dev_priv,
+                           struct drm_crtc *crtc);
+void vmw_kms_update_implicit_fb(struct vmw_private *dev_priv,
+                               struct drm_crtc *crtc);
+void vmw_kms_create_implicit_placement_property(struct vmw_private *dev_priv,
+                                               bool immutable);
+
 
 /*
  * Legacy display unit functions - vmwgfx_ldu.c
@@ -287,6 +302,7 @@ int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
 int vmw_kms_sou_do_dmabuf_dirty(struct vmw_private *dev_priv,
                                struct vmw_framebuffer *framebuffer,
                                struct drm_clip_rect *clips,
+                               struct drm_vmw_rect *vclips,
                                unsigned num_clips, int increment,
                                bool interruptible,
                                struct vmw_fence_obj **out_fence);
index b6fa44f..63ccd98 100644 (file)
@@ -288,6 +288,8 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set)
        crtc->y = set->y;
        crtc->mode = *mode;
        crtc->enabled = true;
+       ldu->base.set_gui_x = set->x;
+       ldu->base.set_gui_y = set->y;
 
        vmw_ldu_add_active(dev_priv, ldu, vfb);
 
@@ -375,8 +377,19 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
        drm_mode_crtc_set_gamma_size(crtc, 256);
 
        drm_object_attach_property(&connector->base,
-                                     dev->mode_config.dirty_info_property,
-                                     1);
+                                  dev->mode_config.dirty_info_property,
+                                  1);
+       drm_object_attach_property(&connector->base,
+                                  dev_priv->hotplug_mode_update_property, 1);
+       drm_object_attach_property(&connector->base,
+                                  dev->mode_config.suggested_x_property, 0);
+       drm_object_attach_property(&connector->base,
+                                  dev->mode_config.suggested_y_property, 0);
+       if (dev_priv->implicit_placement_property)
+               drm_object_attach_property
+                       (&connector->base,
+                        dev_priv->implicit_placement_property,
+                        1);
 
        return 0;
 }
@@ -412,6 +425,8 @@ int vmw_kms_ldu_init_display(struct vmw_private *dev_priv)
        if (ret != 0)
                goto err_vblank_cleanup;
 
+       vmw_kms_create_implicit_placement_property(dev_priv, true);
+
        if (dev_priv->capabilities & SVGA_CAP_MULTIMON)
                for (i = 0; i < VMWGFX_NUM_DISPLAY_UNITS; ++i)
                        vmw_ldu_init(dev_priv, i);
index db082be..0ea22fd 100644 (file)
@@ -74,19 +74,6 @@ struct vmw_kms_sou_dirty_cmd {
        SVGA3dCmdBlitSurfaceToScreen body;
 };
 
-
-/*
- * Other structs.
- */
-
-struct vmw_screen_object_display {
-       unsigned num_implicit;
-
-       struct vmw_framebuffer *implicit_fb;
-       SVGAFifoCmdDefineGMRFB cur;
-       struct vmw_dma_buffer *pinned_gmrfb;
-};
-
 /**
  * Display unit using screen objects.
  */
@@ -97,7 +84,6 @@ struct vmw_screen_object_unit {
        struct vmw_dma_buffer *buffer; /**< Backing store buffer */
 
        bool defined;
-       bool active_implicit;
 };
 
 static void vmw_sou_destroy(struct vmw_screen_object_unit *sou)
@@ -116,33 +102,6 @@ static void vmw_sou_crtc_destroy(struct drm_crtc *crtc)
        vmw_sou_destroy(vmw_crtc_to_sou(crtc));
 }
 
-static void vmw_sou_del_active(struct vmw_private *vmw_priv,
-                              struct vmw_screen_object_unit *sou)
-{
-       struct vmw_screen_object_display *ld = vmw_priv->sou_priv;
-
-       if (sou->active_implicit) {
-               if (--(ld->num_implicit) == 0)
-                       ld->implicit_fb = NULL;
-               sou->active_implicit = false;
-       }
-}
-
-static void vmw_sou_add_active(struct vmw_private *vmw_priv,
-                              struct vmw_screen_object_unit *sou,
-                              struct vmw_framebuffer *vfb)
-{
-       struct vmw_screen_object_display *ld = vmw_priv->sou_priv;
-
-       BUG_ON(!ld->num_implicit && ld->implicit_fb);
-
-       if (!sou->active_implicit && sou->base.is_implicit) {
-               ld->implicit_fb = vfb;
-               sou->active_implicit = true;
-               ld->num_implicit++;
-       }
-}
-
 /**
  * Send the fifo command to create a screen.
  */
@@ -185,6 +144,8 @@ static int vmw_sou_fifo_create(struct vmw_private *dev_priv,
                cmd->obj.root.x = sou->base.gui_x;
                cmd->obj.root.y = sou->base.gui_y;
        }
+       sou->base.set_gui_x = cmd->obj.root.x;
+       sou->base.set_gui_y = cmd->obj.root.y;
 
        /* Ok to assume that buffer is pinned in vram */
        vmw_bo_get_guest_ptr(&sou->buffer->base, &cmd->obj.backingStore.ptr);
@@ -323,13 +284,13 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set)
                return -EINVAL;
        }
 
-       /* sou only supports one fb active at the time */
+       /* Only one active implicit frame-buffer at a time. */
        if (sou->base.is_implicit &&
-           dev_priv->sou_priv->implicit_fb && vfb &&
-           !(dev_priv->sou_priv->num_implicit == 1 &&
-             sou->active_implicit) &&
-           dev_priv->sou_priv->implicit_fb != vfb) {
-               DRM_ERROR("Multiple framebuffers not supported\n");
+           dev_priv->implicit_fb && vfb &&
+           !(dev_priv->num_implicit == 1 &&
+             sou->base.active_implicit) &&
+           dev_priv->implicit_fb != vfb) {
+               DRM_ERROR("Multiple implicit framebuffers not supported.\n");
                return -EINVAL;
        }
 
@@ -351,7 +312,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set)
                crtc->y = 0;
                crtc->enabled = false;
 
-               vmw_sou_del_active(dev_priv, sou);
+               vmw_kms_del_active(dev_priv, &sou->base);
 
                vmw_sou_backing_free(dev_priv, sou);
 
@@ -415,7 +376,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set)
                return ret;
        }
 
-       vmw_sou_add_active(dev_priv, sou, vfb);
+       vmw_kms_add_active(dev_priv, &sou->base, vfb);
 
        connector->encoder = encoder;
        encoder->crtc = crtc;
@@ -428,39 +389,6 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set)
        return 0;
 }
 
-/**
- * Returns if this unit can be page flipped.
- * Must be called with the mode_config mutex held.
- */
-static bool vmw_sou_screen_object_flippable(struct vmw_private *dev_priv,
-                                           struct drm_crtc *crtc)
-{
-       struct vmw_screen_object_unit *sou = vmw_crtc_to_sou(crtc);
-
-       if (!sou->base.is_implicit)
-               return true;
-
-       if (dev_priv->sou_priv->num_implicit != 1)
-               return false;
-
-       return true;
-}
-
-/**
- * Update the implicit fb to the current fb of this crtc.
- * Must be called with the mode_config mutex held.
- */
-static void vmw_sou_update_implicit_fb(struct vmw_private *dev_priv,
-                                      struct drm_crtc *crtc)
-{
-       struct vmw_screen_object_unit *sou = vmw_crtc_to_sou(crtc);
-
-       BUG_ON(!sou->base.is_implicit);
-
-       dev_priv->sou_priv->implicit_fb =
-               vmw_framebuffer_to_vfb(sou->base.crtc.primary->fb);
-}
-
 static int vmw_sou_crtc_page_flip(struct drm_crtc *crtc,
                                  struct drm_framebuffer *fb,
                                  struct drm_pending_vblank_event *event,
@@ -470,30 +398,27 @@ static int vmw_sou_crtc_page_flip(struct drm_crtc *crtc,
        struct drm_framebuffer *old_fb = crtc->primary->fb;
        struct vmw_framebuffer *vfb = vmw_framebuffer_to_vfb(fb);
        struct vmw_fence_obj *fence = NULL;
-       struct drm_clip_rect clips;
+       struct drm_vmw_rect vclips;
        int ret;
 
-       /* require ScreenObject support for page flipping */
-       if (!dev_priv->sou_priv)
-               return -ENOSYS;
-
-       if (!vmw_sou_screen_object_flippable(dev_priv, crtc))
+       if (!vmw_kms_crtc_flippable(dev_priv, crtc))
                return -EINVAL;
 
        crtc->primary->fb = fb;
 
        /* do a full screen dirty update */
-       clips.x1 = clips.y1 = 0;
-       clips.x2 = fb->width;
-       clips.y2 = fb->height;
+       vclips.x = crtc->x;
+       vclips.y = crtc->y;
+       vclips.w = crtc->mode.hdisplay;
+       vclips.h = crtc->mode.vdisplay;
 
        if (vfb->dmabuf)
                ret = vmw_kms_sou_do_dmabuf_dirty(dev_priv, vfb,
-                                                 &clips, 1, 1,
+                                                 NULL, &vclips, 1, 1,
                                                  true, &fence);
        else
                ret = vmw_kms_sou_do_surface_dirty(dev_priv, vfb,
-                                                  &clips, NULL, NULL,
+                                                  NULL, &vclips, NULL,
                                                   0, 0, 1, 1, &fence);
 
 
@@ -521,7 +446,7 @@ static int vmw_sou_crtc_page_flip(struct drm_crtc *crtc,
        vmw_fence_obj_unreference(&fence);
 
        if (vmw_crtc_to_du(crtc)->is_implicit)
-               vmw_sou_update_implicit_fb(dev_priv, crtc);
+               vmw_kms_update_implicit_fb(dev_priv, crtc);
 
        return ret;
 
@@ -563,6 +488,8 @@ static void vmw_sou_connector_destroy(struct drm_connector *connector)
 
 static const struct drm_connector_funcs vmw_sou_connector_funcs = {
        .dpms = vmw_du_connector_dpms,
+       .detect = vmw_du_connector_detect,
+       .fill_modes = vmw_du_connector_fill_modes,
        .set_property = vmw_du_connector_set_property,
        .destroy = vmw_sou_connector_destroy,
 };
@@ -584,13 +511,12 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)
        encoder = &sou->base.encoder;
        connector = &sou->base.connector;
 
-       sou->active_implicit = false;
-
+       sou->base.active_implicit = false;
        sou->base.pref_active = (unit == 0);
        sou->base.pref_width = dev_priv->initial_width;
        sou->base.pref_height = dev_priv->initial_height;
        sou->base.pref_mode = NULL;
-       sou->base.is_implicit = true;
+       sou->base.is_implicit = false;
 
        drm_connector_init(dev, connector, &vmw_sou_connector_funcs,
                           DRM_MODE_CONNECTOR_VIRTUAL);
@@ -609,8 +535,19 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)
        drm_mode_crtc_set_gamma_size(crtc, 256);
 
        drm_object_attach_property(&connector->base,
-                                     dev->mode_config.dirty_info_property,
-                                     1);
+                                  dev->mode_config.dirty_info_property,
+                                  1);
+       drm_object_attach_property(&connector->base,
+                                  dev_priv->hotplug_mode_update_property, 1);
+       drm_object_attach_property(&connector->base,
+                                  dev->mode_config.suggested_x_property, 0);
+       drm_object_attach_property(&connector->base,
+                                  dev->mode_config.suggested_y_property, 0);
+       if (dev_priv->implicit_placement_property)
+               drm_object_attach_property
+                       (&connector->base,
+                        dev_priv->implicit_placement_property,
+                        sou->base.is_implicit);
 
        return 0;
 }
@@ -620,11 +557,6 @@ int vmw_kms_sou_init_display(struct vmw_private *dev_priv)
        struct drm_device *dev = dev_priv->dev;
        int i, ret;
 
-       if (dev_priv->sou_priv) {
-               DRM_INFO("sou system already on\n");
-               return -EINVAL;
-       }
-
        if (!(dev_priv->capabilities & SVGA_CAP_SCREEN_OBJECT_2)) {
                DRM_INFO("Not using screen objects,"
                         " missing cap SCREEN_OBJECT_2\n");
@@ -632,21 +564,19 @@ int vmw_kms_sou_init_display(struct vmw_private *dev_priv)
        }
 
        ret = -ENOMEM;
-       dev_priv->sou_priv = kmalloc(sizeof(*dev_priv->sou_priv), GFP_KERNEL);
-       if (unlikely(!dev_priv->sou_priv))
-               goto err_no_mem;
-
-       dev_priv->sou_priv->num_implicit = 0;
-       dev_priv->sou_priv->implicit_fb = NULL;
+       dev_priv->num_implicit = 0;
+       dev_priv->implicit_fb = NULL;
 
        ret = drm_vblank_init(dev, VMWGFX_NUM_DISPLAY_UNITS);
        if (unlikely(ret != 0))
-               goto err_free;
+               return ret;
 
        ret = drm_mode_create_dirty_info_property(dev);
        if (unlikely(ret != 0))
                goto err_vblank_cleanup;
 
+       vmw_kms_create_implicit_placement_property(dev_priv, false);
+
        for (i = 0; i < VMWGFX_NUM_DISPLAY_UNITS; ++i)
                vmw_sou_init(dev_priv, i);
 
@@ -658,10 +588,6 @@ int vmw_kms_sou_init_display(struct vmw_private *dev_priv)
 
 err_vblank_cleanup:
        drm_vblank_cleanup(dev);
-err_free:
-       kfree(dev_priv->sou_priv);
-       dev_priv->sou_priv = NULL;
-err_no_mem:
        return ret;
 }
 
@@ -669,13 +595,8 @@ int vmw_kms_sou_close_display(struct vmw_private *dev_priv)
 {
        struct drm_device *dev = dev_priv->dev;
 
-       if (!dev_priv->sou_priv)
-               return -ENOSYS;
-
        drm_vblank_cleanup(dev);
 
-       kfree(dev_priv->sou_priv);
-
        return 0;
 }
 
@@ -736,6 +657,11 @@ static void vmw_sou_surface_fifo_commit(struct vmw_kms_dirty *dirty)
        SVGASignedRect *blit = (SVGASignedRect *) &cmd[1];
        int i;
 
+       if (!dirty->num_hits) {
+               vmw_fifo_commit(dirty->dev_priv, 0);
+               return;
+       }
+
        cmd->header.id = SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN;
        cmd->header.size = sizeof(cmd->body) + region_size;
 
@@ -873,6 +799,11 @@ int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
  */
 static void vmw_sou_dmabuf_fifo_commit(struct vmw_kms_dirty *dirty)
 {
+       if (!dirty->num_hits) {
+               vmw_fifo_commit(dirty->dev_priv, 0);
+               return;
+       }
+
        vmw_fifo_commit(dirty->dev_priv,
                        sizeof(struct vmw_kms_sou_dmabuf_blit) *
                        dirty->num_hits);
@@ -907,6 +838,8 @@ static void vmw_sou_dmabuf_clip(struct vmw_kms_dirty *dirty)
  * @dev_priv: Pointer to the device private structure.
  * @framebuffer: Pointer to the dma-buffer backed framebuffer.
  * @clips: Array of clip rects.
+ * @vclips: Alternate array of clip rects. Either @clips or @vclips must
+ * be NULL.
  * @num_clips: Number of clip rects in @clips.
  * @increment: Increment to use when looping over @clips.
  * @interruptible: Whether to perform waits interruptible if possible.
@@ -920,6 +853,7 @@ static void vmw_sou_dmabuf_clip(struct vmw_kms_dirty *dirty)
 int vmw_kms_sou_do_dmabuf_dirty(struct vmw_private *dev_priv,
                                struct vmw_framebuffer *framebuffer,
                                struct drm_clip_rect *clips,
+                               struct drm_vmw_rect *vclips,
                                unsigned num_clips, int increment,
                                bool interruptible,
                                struct vmw_fence_obj **out_fence)
@@ -943,7 +877,7 @@ int vmw_kms_sou_do_dmabuf_dirty(struct vmw_private *dev_priv,
        dirty.clip = vmw_sou_dmabuf_clip;
        dirty.fifo_reserve_size = sizeof(struct vmw_kms_sou_dmabuf_blit) *
                num_clips;
-       ret = vmw_kms_helper_dirty(dev_priv, framebuffer, clips, NULL,
+       ret = vmw_kms_helper_dirty(dev_priv, framebuffer, clips, vclips,
                                   0, 0, num_clips, increment, &dirty);
        vmw_kms_helper_buffer_finish(dev_priv, NULL, buf, out_fence, NULL);
 
@@ -965,6 +899,11 @@ out_revert:
  */
 static void vmw_sou_readback_fifo_commit(struct vmw_kms_dirty *dirty)
 {
+       if (!dirty->num_hits) {
+               vmw_fifo_commit(dirty->dev_priv, 0);
+               return;
+       }
+
        vmw_fifo_commit(dirty->dev_priv,
                        sizeof(struct vmw_kms_sou_readback_blit) *
                        dirty->num_hits);
index 4ef5ffd..b949102 100644 (file)
@@ -96,7 +96,6 @@ struct vmw_stdu_surface_copy {
  *               content_vfbs dimensions, then this is a pointer into the
  *               corresponding field in content_vfbs.  If not, then this
  *               is a separate buffer to which content_vfbs will blit to.
- * @content_fb: holds the rendered content, can be a surface or DMA buffer
  * @content_type:  content_fb type
  * @defined:  true if the current display unit has been initialized
  */
@@ -104,8 +103,6 @@ struct vmw_screen_target_display_unit {
        struct vmw_display_unit base;
 
        struct vmw_surface     *display_srf;
-       struct drm_framebuffer *content_fb;
-
        enum stdu_content_type content_fb_type;
 
        bool defined;
@@ -122,22 +119,6 @@ static void vmw_stdu_destroy(struct vmw_screen_target_display_unit *stdu);
  *****************************************************************************/
 
 /**
- * vmw_stdu_pin_display - pins the resource associated with the display surface
- *
- * @stdu: contains the display surface
- *
- * Since the display surface can either be a private surface allocated by us,
- * or it can point to the content surface, we use this function to not pin the
- * same resource twice.
- */
-static int vmw_stdu_pin_display(struct vmw_screen_target_display_unit *stdu)
-{
-       return vmw_resource_pin(&stdu->display_srf->res, false);
-}
-
-
-
-/**
  * vmw_stdu_unpin_display - unpins the resource associated with display surface
  *
  * @stdu: contains the display surface
@@ -153,13 +134,7 @@ static void vmw_stdu_unpin_display(struct vmw_screen_target_display_unit *stdu)
                struct vmw_resource *res = &stdu->display_srf->res;
 
                vmw_resource_unpin(res);
-
-               if (stdu->content_fb_type != SAME_AS_DISPLAY) {
-                       vmw_resource_unreference(&res);
-                       stdu->content_fb_type = SAME_AS_DISPLAY;
-               }
-
-               stdu->display_srf = NULL;
+               vmw_surface_unreference(&stdu->display_srf);
        }
 }
 
@@ -185,6 +160,9 @@ static void vmw_stdu_crtc_destroy(struct drm_crtc *crtc)
  *
  * @dev_priv:  VMW DRM device
  * @stdu: display unit to create a Screen Target for
+ * @mode: The mode to set.
+ * @crtc_x: X coordinate of screen target relative to framebuffer origin.
+ * @crtc_y: Y coordinate of screen target relative to framebuffer origin.
  *
  * Creates a STDU that we can used later.  This function is called whenever the
  * framebuffer size changes.
@@ -193,7 +171,9 @@ static void vmw_stdu_crtc_destroy(struct drm_crtc *crtc)
  * 0 on success, error code on failure
  */
 static int vmw_stdu_define_st(struct vmw_private *dev_priv,
-                             struct vmw_screen_target_display_unit *stdu)
+                             struct vmw_screen_target_display_unit *stdu,
+                             struct drm_display_mode *mode,
+                             int crtc_x, int crtc_y)
 {
        struct {
                SVGA3dCmdHeader header;
@@ -211,17 +191,19 @@ static int vmw_stdu_define_st(struct vmw_private *dev_priv,
        cmd->header.size = sizeof(cmd->body);
 
        cmd->body.stid   = stdu->base.unit;
-       cmd->body.width  = stdu->display_srf->base_size.width;
-       cmd->body.height = stdu->display_srf->base_size.height;
+       cmd->body.width  = mode->hdisplay;
+       cmd->body.height = mode->vdisplay;
        cmd->body.flags  = (0 == cmd->body.stid) ? SVGA_STFLAG_PRIMARY : 0;
        cmd->body.dpi    = 0;
-       cmd->body.xRoot  = stdu->base.crtc.x;
-       cmd->body.yRoot  = stdu->base.crtc.y;
-
-       if (!stdu->base.is_implicit) {
+       if (stdu->base.is_implicit) {
+               cmd->body.xRoot  = crtc_x;
+               cmd->body.yRoot  = crtc_y;
+       } else {
                cmd->body.xRoot  = stdu->base.gui_x;
                cmd->body.yRoot  = stdu->base.gui_y;
        }
+       stdu->base.set_gui_x = cmd->body.xRoot;
+       stdu->base.set_gui_y = cmd->body.yRoot;
 
        vmw_fifo_commit(dev_priv, sizeof(*cmd));
 
@@ -392,126 +374,43 @@ static int vmw_stdu_destroy_st(struct vmw_private *dev_priv,
        return ret;
 }
 
-
-
 /**
- * vmw_stdu_crtc_set_config - Sets a mode
+ * vmw_stdu_bind_fb - Bind an fb to a defined screen target
  *
- * @set:  mode parameters
- *
- * This function is the device-specific portion of the DRM CRTC mode set.
- * For the SVGA device, we do this by defining a Screen Target, binding a
- * GB Surface to that target, and finally update the screen target.
+ * @dev_priv: Pointer to a device private struct.
+ * @crtc: The crtc holding the screen target.
+ * @mode: The mode currently used by the screen target. Must be non-NULL.
+ * @new_fb: The new framebuffer to bind. Must be non-NULL.
  *
  * RETURNS:
- * 0 on success, error code otherwise
+ * 0 on success, error code on failure.
  */
-static int vmw_stdu_crtc_set_config(struct drm_mode_set *set)
+static int vmw_stdu_bind_fb(struct vmw_private *dev_priv,
+                           struct drm_crtc *crtc,
+                           struct drm_display_mode *mode,
+                           struct drm_framebuffer *new_fb)
 {
-       struct vmw_private *dev_priv;
-       struct vmw_screen_target_display_unit *stdu;
-       struct vmw_framebuffer *vfb;
+       struct vmw_screen_target_display_unit *stdu = vmw_crtc_to_stdu(crtc);
+       struct vmw_framebuffer *vfb = vmw_framebuffer_to_vfb(new_fb);
+       struct vmw_surface *new_display_srf = NULL;
+       enum stdu_content_type new_content_type;
        struct vmw_framebuffer_surface *new_vfbs;
-       struct drm_display_mode *mode;
-       struct drm_framebuffer  *new_fb;
-       struct drm_crtc      *crtc;
-       struct drm_encoder   *encoder;
-       struct drm_connector *connector;
-       int    ret;
-
-
-       if (!set || !set->crtc)
-               return -EINVAL;
-
-       crtc     = set->crtc;
-       crtc->x  = set->x;
-       crtc->y  = set->y;
-       stdu     = vmw_crtc_to_stdu(crtc);
-       mode     = set->mode;
-       new_fb   = set->fb;
-       dev_priv = vmw_priv(crtc->dev);
-
-
-       if (set->num_connectors > 1) {
-               DRM_ERROR("Too many connectors\n");
-               return -EINVAL;
-       }
-
-       if (set->num_connectors == 1 &&
-           set->connectors[0] != &stdu->base.connector) {
-               DRM_ERROR("Connectors don't match %p %p\n",
-                       set->connectors[0], &stdu->base.connector);
-               return -EINVAL;
-       }
-
-
-       /* Since they always map one to one these are safe */
-       connector = &stdu->base.connector;
-       encoder   = &stdu->base.encoder;
-
-
-       /*
-        * After this point the CRTC will be considered off unless a new fb
-        * is bound
-        */
-       if (stdu->defined) {
-               /* Unbind current surface by binding an invalid one */
-               ret = vmw_stdu_bind_st(dev_priv, stdu, NULL);
-               if (unlikely(ret != 0))
-                       return ret;
-
-               /* Update Screen Target, display will now be blank */
-               if (crtc->primary->fb) {
-                       vmw_stdu_update_st(dev_priv, stdu);
-                       if (unlikely(ret != 0))
-                               return ret;
-               }
-
-               crtc->primary->fb  = NULL;
-               crtc->enabled      = false;
-               encoder->crtc      = NULL;
-               connector->encoder = NULL;
-
-               vmw_stdu_unpin_display(stdu);
-               stdu->content_fb      = NULL;
-               stdu->content_fb_type = SAME_AS_DISPLAY;
-
-               ret = vmw_stdu_destroy_st(dev_priv, stdu);
-               /* The hardware is hung, give up */
-               if (unlikely(ret != 0))
-                       return ret;
-       }
-
-
-       /* Any of these conditions means the caller wants CRTC off */
-       if (set->num_connectors == 0 || !mode || !new_fb)
-               return 0;
-
-
-       if (set->x + mode->hdisplay > new_fb->width ||
-           set->y + mode->vdisplay > new_fb->height) {
-               DRM_ERROR("Set outside of framebuffer\n");
-               return -EINVAL;
-       }
+       int ret;
 
-       stdu->content_fb = new_fb;
-       vfb = vmw_framebuffer_to_vfb(stdu->content_fb);
+       WARN_ON_ONCE(!stdu->defined);
 
-       if (vfb->dmabuf)
-               stdu->content_fb_type = SEPARATE_DMA;
+       if (!vfb->dmabuf && new_fb->width == mode->hdisplay &&
+           new_fb->height == mode->vdisplay)
+               new_content_type = SAME_AS_DISPLAY;
+       else if (vfb->dmabuf)
+               new_content_type = SEPARATE_DMA;
+       else
+               new_content_type = SEPARATE_SURFACE;
 
-       /*
-        * If the requested mode is different than the width and height
-        * of the FB or if the content buffer is a DMA buf, then allocate
-        * a display FB that matches the dimension of the mode
-        */
-       if (mode->hdisplay != new_fb->width  ||
-           mode->vdisplay != new_fb->height ||
-           stdu->content_fb_type != SAME_AS_DISPLAY) {
+       if (new_content_type != SAME_AS_DISPLAY &&
+           !stdu->display_srf) {
                struct vmw_surface content_srf;
                struct drm_vmw_size display_base_size = {0};
-               struct vmw_surface *display_srf;
-
 
                display_base_size.width  = mode->hdisplay;
                display_base_size.height = mode->vdisplay;
@@ -521,7 +420,7 @@ static int vmw_stdu_crtc_set_config(struct drm_mode_set *set)
                 * If content buffer is a DMA buf, then we have to construct
                 * surface info
                 */
-               if (stdu->content_fb_type == SEPARATE_DMA) {
+               if (new_content_type == SEPARATE_DMA) {
 
                        switch (new_fb->bits_per_pixel) {
                        case 32:
@@ -538,17 +437,13 @@ static int vmw_stdu_crtc_set_config(struct drm_mode_set *set)
 
                        default:
                                DRM_ERROR("Invalid format\n");
-                               ret = -EINVAL;
-                               goto err_unref_content;
+                               return -EINVAL;
                        }
 
                        content_srf.flags             = 0;
                        content_srf.mip_levels[0]     = 1;
                        content_srf.multisample_count = 0;
                } else {
-
-                       stdu->content_fb_type = SEPARATE_SURFACE;
-
                        new_vfbs = vmw_framebuffer_to_vfbs(new_fb);
                        content_srf = *new_vfbs->surface;
                }
@@ -563,26 +458,136 @@ static int vmw_stdu_crtc_set_config(struct drm_mode_set *set)
                                content_srf.multisample_count,
                                0,
                                display_base_size,
-                               &display_srf);
+                               &new_display_srf);
                if (unlikely(ret != 0)) {
-                       DRM_ERROR("Cannot allocate a display FB.\n");
-                       goto err_unref_content;
+                       DRM_ERROR("Could not allocate screen target surface.\n");
+                       return ret;
                }
-
-               stdu->display_srf = display_srf;
-       } else {
+       } else if (new_content_type == SAME_AS_DISPLAY) {
                new_vfbs = vmw_framebuffer_to_vfbs(new_fb);
-               stdu->display_srf = new_vfbs->surface;
+               new_display_srf = vmw_surface_reference(new_vfbs->surface);
        }
 
+       if (new_display_srf) {
+               /* Pin new surface before flipping */
+               ret = vmw_resource_pin(&new_display_srf->res, false);
+               if (ret)
+                       goto out_srf_unref;
+
+               ret = vmw_stdu_bind_st(dev_priv, stdu, &new_display_srf->res);
+               if (ret)
+                       goto out_srf_unpin;
+
+               /* Unpin and unreference old surface */
+               vmw_stdu_unpin_display(stdu);
 
-       ret = vmw_stdu_pin_display(stdu);
-       if (unlikely(ret != 0)) {
-               stdu->display_srf = NULL;
-               goto err_unref_content;
+               /* Transfer the reference */
+               stdu->display_srf = new_display_srf;
+               new_display_srf = NULL;
        }
 
-       vmw_svga_enable(dev_priv);
+       crtc->primary->fb = new_fb;
+       stdu->content_fb_type = new_content_type;
+       return 0;
+
+out_srf_unpin:
+       vmw_resource_unpin(&new_display_srf->res);
+out_srf_unref:
+       vmw_surface_unreference(&new_display_srf);
+       return ret;
+}
+
+/**
+ * vmw_stdu_crtc_set_config - Sets a mode
+ *
+ * @set:  mode parameters
+ *
+ * This function is the device-specific portion of the DRM CRTC mode set.
+ * For the SVGA device, we do this by defining a Screen Target, binding a
+ * GB Surface to that target, and finally update the screen target.
+ *
+ * RETURNS:
+ * 0 on success, error code otherwise
+ */
+static int vmw_stdu_crtc_set_config(struct drm_mode_set *set)
+{
+       struct vmw_private *dev_priv;
+       struct vmw_framebuffer *vfb;
+       struct vmw_screen_target_display_unit *stdu;
+       struct drm_display_mode *mode;
+       struct drm_framebuffer  *new_fb;
+       struct drm_crtc      *crtc;
+       struct drm_encoder   *encoder;
+       struct drm_connector *connector;
+       bool turning_off;
+       int    ret;
+
+
+       if (!set || !set->crtc)
+               return -EINVAL;
+
+       crtc     = set->crtc;
+       stdu     = vmw_crtc_to_stdu(crtc);
+       mode     = set->mode;
+       new_fb   = set->fb;
+       dev_priv = vmw_priv(crtc->dev);
+       turning_off = set->num_connectors == 0 || !mode || !new_fb;
+       vfb = (new_fb) ? vmw_framebuffer_to_vfb(new_fb) : NULL;
+
+       if (set->num_connectors > 1) {
+               DRM_ERROR("Too many connectors\n");
+               return -EINVAL;
+       }
+
+       if (set->num_connectors == 1 &&
+           set->connectors[0] != &stdu->base.connector) {
+               DRM_ERROR("Connectors don't match %p %p\n",
+                       set->connectors[0], &stdu->base.connector);
+               return -EINVAL;
+       }
+
+       if (!turning_off && (set->x + mode->hdisplay > new_fb->width ||
+                            set->y + mode->vdisplay > new_fb->height)) {
+               DRM_ERROR("Set outside of framebuffer\n");
+               return -EINVAL;
+       }
+
+       /* Only one active implicit frame-buffer at a time. */
+       if (!turning_off && stdu->base.is_implicit && dev_priv->implicit_fb &&
+           !(dev_priv->num_implicit == 1 && stdu->base.active_implicit)
+           && dev_priv->implicit_fb != vfb) {
+               DRM_ERROR("Multiple implicit framebuffers not supported.\n");
+               return -EINVAL;
+       }
+
+       /* Since they always map one to one these are safe */
+       connector = &stdu->base.connector;
+       encoder   = &stdu->base.encoder;
+
+       if (stdu->defined) {
+               ret = vmw_stdu_bind_st(dev_priv, stdu, NULL);
+               if (ret)
+                       return ret;
+
+               vmw_stdu_unpin_display(stdu);
+               (void) vmw_stdu_update_st(dev_priv, stdu);
+               vmw_kms_del_active(dev_priv, &stdu->base);
+
+               ret = vmw_stdu_destroy_st(dev_priv, stdu);
+               if (ret)
+                       return ret;
+
+               crtc->primary->fb = NULL;
+               crtc->enabled = false;
+               encoder->crtc = NULL;
+               connector->encoder = NULL;
+               stdu->content_fb_type = SAME_AS_DISPLAY;
+               crtc->x = set->x;
+               crtc->y = set->y;
+       }
+
+       if (turning_off)
+               return 0;
 
        /*
         * Steps to displaying a surface, assume surface is already
@@ -592,35 +597,33 @@ static int vmw_stdu_crtc_set_config(struct drm_mode_set *set)
         *   3.  update that screen target (this is done later by
         *       vmw_kms_stdu_do_surface_dirty_or_present)
         */
-       ret = vmw_stdu_define_st(dev_priv, stdu);
-       if (unlikely(ret != 0))
-               goto err_unpin_display_and_content;
+       /*
+        * Note on error handling: We can't really restore the crtc to
+        * it's original state on error, but we at least update the
+        * current state to what's submitted to hardware to enable
+        * future recovery.
+        */
+       vmw_svga_enable(dev_priv);
+       ret = vmw_stdu_define_st(dev_priv, stdu, mode, set->x, set->y);
+       if (ret)
+               return ret;
 
-       ret = vmw_stdu_bind_st(dev_priv, stdu, &stdu->display_srf->res);
-       if (unlikely(ret != 0))
-               goto err_unpin_destroy_st;
+       crtc->x = set->x;
+       crtc->y = set->y;
+       crtc->mode = *mode;
 
+       ret = vmw_stdu_bind_fb(dev_priv, crtc, mode, new_fb);
+       if (ret)
+               return ret;
 
+       vmw_kms_add_active(dev_priv, &stdu->base, vfb);
+       crtc->enabled = true;
        connector->encoder = encoder;
        encoder->crtc      = crtc;
 
-       crtc->mode    = *mode;
-       crtc->primary->fb = new_fb;
-       crtc->enabled = true;
-
-       return ret;
-
-err_unpin_destroy_st:
-       vmw_stdu_destroy_st(dev_priv, stdu);
-err_unpin_display_and_content:
-       vmw_stdu_unpin_display(stdu);
-err_unref_content:
-       stdu->content_fb = NULL;
-       return ret;
+       return 0;
 }
 
-
-
 /**
  * vmw_stdu_crtc_page_flip - Binds a buffer to a screen target
  *
@@ -648,59 +651,34 @@ static int vmw_stdu_crtc_page_flip(struct drm_crtc *crtc,
 {
        struct vmw_private *dev_priv = vmw_priv(crtc->dev);
        struct vmw_screen_target_display_unit *stdu;
+       struct drm_vmw_rect vclips;
+       struct vmw_framebuffer *vfb = vmw_framebuffer_to_vfb(new_fb);
        int ret;
 
-       if (crtc == NULL)
-               return -EINVAL;
-
        dev_priv          = vmw_priv(crtc->dev);
        stdu              = vmw_crtc_to_stdu(crtc);
-       crtc->primary->fb = new_fb;
-       stdu->content_fb  = new_fb;
-
-       if (stdu->display_srf) {
-               /*
-                * If the display surface is the same as the content surface
-                * then remove the reference
-                */
-               if (stdu->content_fb_type == SAME_AS_DISPLAY) {
-                       if (stdu->defined) {
-                               /* Unbind the current surface */
-                               ret = vmw_stdu_bind_st(dev_priv, stdu, NULL);
-                               if (unlikely(ret != 0))
-                                       goto err_out;
-                       }
-                       vmw_stdu_unpin_display(stdu);
-                       stdu->display_srf = NULL;
-               }
-       }
-
-
-       if (!new_fb) {
-               /* Blanks the display */
-               (void) vmw_stdu_update_st(dev_priv, stdu);
-
-               return 0;
-       }
 
+       if (!stdu->defined || !vmw_kms_crtc_flippable(dev_priv, crtc))
+               return -EINVAL;
 
-       if (stdu->content_fb_type == SAME_AS_DISPLAY) {
-               stdu->display_srf = vmw_framebuffer_to_vfbs(new_fb)->surface;
-               ret = vmw_stdu_pin_display(stdu);
-               if (ret) {
-                       stdu->display_srf = NULL;
-                       goto err_out;
-               }
+       ret = vmw_stdu_bind_fb(dev_priv, crtc, &crtc->mode, new_fb);
+       if (ret)
+               return ret;
 
-               /* Bind display surface */
-               ret = vmw_stdu_bind_st(dev_priv, stdu, &stdu->display_srf->res);
-               if (unlikely(ret != 0))
-                       goto err_unpin_display_and_content;
-       }
+       if (stdu->base.is_implicit)
+               vmw_kms_update_implicit_fb(dev_priv, crtc);
 
-       /* Update display surface: after this point everything is bound */
-       ret = vmw_stdu_update_st(dev_priv, stdu);
-       if (unlikely(ret != 0))
+       vclips.x = crtc->x;
+       vclips.y = crtc->y;
+       vclips.w = crtc->mode.hdisplay;
+       vclips.h = crtc->mode.vdisplay;
+       if (vfb->dmabuf)
+               ret = vmw_kms_stdu_dma(dev_priv, NULL, vfb, NULL, NULL, &vclips,
+                                      1, 1, true, false);
+       else
+               ret = vmw_kms_stdu_surface_dirty(dev_priv, vfb, NULL, &vclips,
+                                                NULL, 0, 0, 1, 1, NULL);
+       if (ret)
                return ret;
 
        if (event) {
@@ -721,14 +699,7 @@ static int vmw_stdu_crtc_page_flip(struct drm_crtc *crtc,
                vmw_fifo_flush(dev_priv, false);
        }
 
-       return ret;
-
-err_unpin_display_and_content:
-       vmw_stdu_unpin_display(stdu);
-err_out:
-       crtc->primary->fb = NULL;
-       stdu->content_fb = NULL;
-       return ret;
+       return 0;
 }
 
 
@@ -1138,7 +1109,7 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
        stdu->base.pref_active = (unit == 0);
        stdu->base.pref_width  = dev_priv->initial_width;
        stdu->base.pref_height = dev_priv->initial_height;
-       stdu->base.is_implicit = true;
+       stdu->base.is_implicit = false;
 
        drm_connector_init(dev, connector, &vmw_stdu_connector_funcs,
                           DRM_MODE_CONNECTOR_VIRTUAL);
@@ -1159,7 +1130,17 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, unsigned unit)
        drm_object_attach_property(&connector->base,
                                   dev->mode_config.dirty_info_property,
                                   1);
-
+       drm_object_attach_property(&connector->base,
+                                  dev_priv->hotplug_mode_update_property, 1);
+       drm_object_attach_property(&connector->base,
+                                  dev->mode_config.suggested_x_property, 0);
+       drm_object_attach_property(&connector->base,
+                                  dev->mode_config.suggested_y_property, 0);
+       if (dev_priv->implicit_placement_property)
+               drm_object_attach_property
+                       (&connector->base,
+                        dev_priv->implicit_placement_property,
+                        stdu->base.is_implicit);
        return 0;
 }
 
@@ -1224,6 +1205,8 @@ int vmw_kms_stdu_init_display(struct vmw_private *dev_priv)
 
        dev_priv->active_display_unit = vmw_du_screen_target;
 
+       vmw_kms_create_implicit_placement_property(dev_priv, false);
+
        for (i = 0; i < VMWGFX_NUM_DISPLAY_UNITS; ++i) {
                ret = vmw_stdu_init(dev_priv, i);
 
index da462af..c27858a 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/host1x.h>
 #include <linux/of.h>
 #include <linux/slab.h>
+#include <linux/of_device.h>
 
 #include "bus.h"
 #include "dev.h"
@@ -82,8 +83,10 @@ static int host1x_device_parse_dt(struct host1x_device *device,
                if (of_match_node(driver->subdevs, np) &&
                    of_device_is_available(np)) {
                        err = host1x_subdev_add(device, np);
-                       if (err < 0)
+                       if (err < 0) {
+                               of_node_put(np);
                                return err;
+                       }
                }
        }
 
@@ -394,6 +397,7 @@ static int host1x_device_add(struct host1x *host1x,
        device->dev.coherent_dma_mask = host1x->dev->coherent_dma_mask;
        device->dev.dma_mask = &device->dev.coherent_dma_mask;
        dev_set_name(&device->dev, "%s", driver->driver.name);
+       of_dma_configure(&device->dev, host1x->dev->of_node);
        device->dev.release = host1x_device_release;
        device->dev.bus = &host1x_bus_type;
        device->dev.parent = host1x->dev;
index 314bf37..ff34869 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/of_device.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/dma-mapping.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/host1x.h>
@@ -68,6 +69,7 @@ static const struct host1x_info host1x01_info = {
        .nb_bases       = 8,
        .init           = host1x01_init,
        .sync_offset    = 0x3000,
+       .dma_mask       = DMA_BIT_MASK(32),
 };
 
 static const struct host1x_info host1x02_info = {
@@ -77,6 +79,7 @@ static const struct host1x_info host1x02_info = {
        .nb_bases = 12,
        .init = host1x02_init,
        .sync_offset = 0x3000,
+       .dma_mask = DMA_BIT_MASK(32),
 };
 
 static const struct host1x_info host1x04_info = {
@@ -86,6 +89,7 @@ static const struct host1x_info host1x04_info = {
        .nb_bases = 64,
        .init = host1x04_init,
        .sync_offset = 0x2100,
+       .dma_mask = DMA_BIT_MASK(34),
 };
 
 static const struct host1x_info host1x05_info = {
@@ -95,6 +99,7 @@ static const struct host1x_info host1x05_info = {
        .nb_bases = 64,
        .init = host1x05_init,
        .sync_offset = 0x2100,
+       .dma_mask = DMA_BIT_MASK(34),
 };
 
 static struct of_device_id host1x_of_match[] = {
@@ -148,6 +153,8 @@ static int host1x_probe(struct platform_device *pdev)
        if (IS_ERR(host->regs))
                return PTR_ERR(host->regs);
 
+       dma_set_mask_and_coherent(host->dev, host->info->dma_mask);
+
        if (host->info->init) {
                err = host->info->init(host);
                if (err)
index 0b6e8e9..dace124 100644 (file)
@@ -96,6 +96,7 @@ struct host1x_info {
        int     nb_mlocks;              /* host1x: number of mlocks */
        int     (*init)(struct host1x *); /* initialize per SoC ops */
        int     sync_offset;
+       u64     dma_mask;               /* mask of addressable memory */
 };
 
 struct host1x {
index 63bd63f..1919aab 100644 (file)
@@ -225,7 +225,7 @@ unpin:
        return 0;
 }
 
-static unsigned int do_relocs(struct host1x_job *job, struct host1x_bo *cmdbuf)
+static int do_relocs(struct host1x_job *job, struct host1x_bo *cmdbuf)
 {
        int i = 0;
        u32 last_page = ~0;
index f2e13eb..e00db3f 100644 (file)
@@ -1050,6 +1050,17 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
        for (i = 0; i < ARRAY_SIZE(client_reg); i++) {
                const struct ipu_platform_reg *reg = &client_reg[i];
                struct platform_device *pdev;
+               struct device_node *of_node;
+
+               /* Associate subdevice with the corresponding port node */
+               of_node = of_graph_get_port_by_id(dev->of_node, i);
+               if (!of_node) {
+                       dev_info(dev,
+                                "no port@%d node in %s, not using %s%d\n",
+                                i, dev->of_node->full_name,
+                                (i / 2) ? "DI" : "CSI", i % 2);
+                       continue;
+               }
 
                pdev = platform_device_alloc(reg->name, id++);
                if (!pdev) {
@@ -1057,17 +1068,9 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
                        goto err_register;
                }
 
+               pdev->dev.of_node = of_node;
                pdev->dev.parent = dev;
 
-               /* Associate subdevice with the corresponding port node */
-               pdev->dev.of_node = of_graph_get_port_by_id(dev->of_node, i);
-               if (!pdev->dev.of_node) {
-                       dev_err(dev, "missing port@%d node in %s\n", i,
-                               dev->of_node->full_name);
-                       ret = -ENODEV;
-                       goto err_register;
-               }
-
                ret = platform_device_add_data(pdev, &reg->pdata,
                                               sizeof(reg->pdata));
                if (!ret)
@@ -1289,10 +1292,6 @@ static int ipu_probe(struct platform_device *pdev)
        ipu->irq_sync = irq_sync;
        ipu->irq_err = irq_err;
 
-       ret = ipu_irq_init(ipu);
-       if (ret)
-               goto out_failed_irq;
-
        ret = device_reset(&pdev->dev);
        if (ret) {
                dev_err(&pdev->dev, "failed to reset: %d\n", ret);
@@ -1302,6 +1301,10 @@ static int ipu_probe(struct platform_device *pdev)
        if (ret)
                goto out_failed_reset;
 
+       ret = ipu_irq_init(ipu);
+       if (ret)
+               goto out_failed_irq;
+
        /* Set MCU_T to divide MCU access window into 2 */
        ipu_cm_write(ipu, 0x00400000L | (IPU_MCU_T_DEFAULT << 18),
                        IPU_DISP_GEN);
@@ -1324,9 +1327,9 @@ static int ipu_probe(struct platform_device *pdev)
 failed_add_clients:
        ipu_submodules_exit(ipu);
 failed_submodules_init:
-out_failed_reset:
        ipu_irq_exit(ipu);
 out_failed_irq:
+out_failed_reset:
        clk_disable_unprepare(ipu->clk);
        return ret;
 }
index d3ad534..2f29780 100644 (file)
@@ -171,6 +171,7 @@ int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced,
                u32 bus_format, u32 width)
 {
        struct ipu_dc_priv *priv = dc->priv;
+       int addr, sync;
        u32 reg = 0;
        int map;
 
@@ -182,41 +183,39 @@ int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced,
                return map;
        }
 
-       if (interlaced) {
-               int addr;
-
-               if (dc->di)
-                       addr = 1;
-               else
-                       addr = 0;
+       /*
+        * In interlaced mode we need more counters to create the asymmetric
+        * per-field VSYNC signals. The pixel active signal synchronising DC
+        * to DI moves to signal generator #6 (see ipu-di.c). In progressive
+        * mode counter #5 is used.
+        */
+       sync = interlaced ? 6 : 5;
+
+       /* Reserve 5 microcode template words for each DI */
+       if (dc->di)
+               addr = 5;
+       else
+               addr = 0;
 
+       if (interlaced) {
                dc_link_event(dc, DC_EVT_NL, addr, 3);
                dc_link_event(dc, DC_EVT_EOL, addr, 2);
                dc_link_event(dc, DC_EVT_NEW_DATA, addr, 1);
 
                /* Init template microcode */
-               dc_write_tmpl(dc, addr, WROD(0), 0, map, SYNC_WAVE, 0, 6, 1);
+               dc_write_tmpl(dc, addr, WROD(0), 0, map, SYNC_WAVE, 0, sync, 1);
        } else {
-               if (dc->di) {
-                       dc_link_event(dc, DC_EVT_NL, 2, 3);
-                       dc_link_event(dc, DC_EVT_EOL, 3, 2);
-                       dc_link_event(dc, DC_EVT_NEW_DATA, 1, 1);
-                       /* Init template microcode */
-                       dc_write_tmpl(dc, 2, WROD(0), 0, map, SYNC_WAVE, 8, 5, 1);
-                       dc_write_tmpl(dc, 3, WROD(0), 0, map, SYNC_WAVE, 4, 5, 0);
-                       dc_write_tmpl(dc, 4, WRG, 0, map, NULL_WAVE, 0, 0, 1);
-                       dc_write_tmpl(dc, 1, WROD(0), 0, map, SYNC_WAVE, 0, 5, 1);
-               } else {
-                       dc_link_event(dc, DC_EVT_NL, 5, 3);
-                       dc_link_event(dc, DC_EVT_EOL, 6, 2);
-                       dc_link_event(dc, DC_EVT_NEW_DATA, 8, 1);
-                       /* Init template microcode */
-                       dc_write_tmpl(dc, 5, WROD(0), 0, map, SYNC_WAVE, 8, 5, 1);
-                       dc_write_tmpl(dc, 6, WROD(0), 0, map, SYNC_WAVE, 4, 5, 0);
-                       dc_write_tmpl(dc, 7, WRG, 0, map, NULL_WAVE, 0, 0, 1);
-                       dc_write_tmpl(dc, 8, WROD(0), 0, map, SYNC_WAVE, 0, 5, 1);
-               }
+               dc_link_event(dc, DC_EVT_NL, addr + 2, 3);
+               dc_link_event(dc, DC_EVT_EOL, addr + 3, 2);
+               dc_link_event(dc, DC_EVT_NEW_DATA, addr + 1, 1);
+
+               /* Init template microcode */
+               dc_write_tmpl(dc, addr + 2, WROD(0), 0, map, SYNC_WAVE, 8, sync, 1);
+               dc_write_tmpl(dc, addr + 3, WROD(0), 0, map, SYNC_WAVE, 4, sync, 0);
+               dc_write_tmpl(dc, addr + 4, WRG, 0, map, NULL_WAVE, 0, 0, 1);
+               dc_write_tmpl(dc, addr + 1, WROD(0), 0, map, SYNC_WAVE, 0, sync, 1);
        }
+
        dc_link_event(dc, DC_EVT_NF, 0, 0);
        dc_link_event(dc, DC_EVT_NFIELD, 0, 0);
        dc_link_event(dc, DC_EVT_EOF, 0, 0);
index f155b83..2b3105c 100644 (file)
@@ -126,7 +126,7 @@ static int ads1015_reg_to_mv(struct i2c_client *client, unsigned int channel,
        struct ads1015_data *data = i2c_get_clientdata(client);
        unsigned int pga = data->channel_data[channel].pga;
        int fullscale = fullscale_table[pga];
-       const unsigned mask = data->id == ads1115 ? 0x7fff : 0x7ff0;
+       const int mask = data->id == ads1115 ? 0x7fff : 0x7ff0;
 
        return DIV_ROUND_CLOSEST(reg * fullscale, mask);
 }
index 82de3de..685568b 100644 (file)
@@ -406,16 +406,11 @@ static int gpio_fan_get_cur_state(struct thermal_cooling_device *cdev,
                                  unsigned long *state)
 {
        struct gpio_fan_data *fan_data = cdev->devdata;
-       int r;
 
        if (!fan_data)
                return -EINVAL;
 
-       r = get_fan_speed_index(fan_data);
-       if (r < 0)
-               return r;
-
-       *state = r;
+       *state = fan_data->speed_index;
        return 0;
 }
 
index 3711df1..4a45408 100644 (file)
@@ -586,8 +586,7 @@ static int brcmstb_i2c_probe(struct platform_device *pdev)
        if (!dev)
                return -ENOMEM;
 
-       dev->bsc_regmap = devm_kzalloc(&pdev->dev, sizeof(struct bsc_regs *),
-                                      GFP_KERNEL);
+       dev->bsc_regmap = devm_kzalloc(&pdev->dev, sizeof(*dev->bsc_regmap), GFP_KERNEL);
        if (!dev->bsc_regmap)
                return -ENOMEM;
 
index f62d697..27fa0cb 100644 (file)
@@ -1271,6 +1271,8 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
        switch (dev->device) {
        case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_SMBUS:
        case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_SMBUS:
+       case PCI_DEVICE_ID_INTEL_LEWISBURG_SMBUS:
+       case PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS:
        case PCI_DEVICE_ID_INTEL_DNV_SMBUS:
                priv->features |= FEATURE_I2C_BLOCK_READ;
                priv->features |= FEATURE_IRQ;
index 08d26ba..13c4529 100644 (file)
@@ -1450,7 +1450,8 @@ omap_i2c_probe(struct platform_device *pdev)
 
 err_unuse_clocks:
        omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0);
-       pm_runtime_put(omap->dev);
+       pm_runtime_dont_use_autosuspend(omap->dev);
+       pm_runtime_put_sync(omap->dev);
        pm_runtime_disable(&pdev->dev);
 err_free_mem:
 
@@ -1468,6 +1469,7 @@ static int omap_i2c_remove(struct platform_device *pdev)
                return ret;
 
        omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0);
+       pm_runtime_dont_use_autosuspend(&pdev->dev);
        pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
        return 0;
index f3e5ff8..213ba55 100644 (file)
@@ -467,7 +467,7 @@ static int uniphier_fi2c_clk_init(struct device *dev,
                bus_speed = UNIPHIER_FI2C_DEFAULT_SPEED;
 
        if (!bus_speed) {
-               dev_err(dev, "clock-freqyency should not be zero\n");
+               dev_err(dev, "clock-frequency should not be zero\n");
                return -EINVAL;
        }
 
index 1f4f3f5..89eaa8a 100644 (file)
@@ -328,7 +328,7 @@ static int uniphier_i2c_clk_init(struct device *dev,
                bus_speed = UNIPHIER_I2C_DEFAULT_SPEED;
 
        if (!bus_speed) {
-               dev_err(dev, "clock-freqyency should not be zero\n");
+               dev_err(dev, "clock-frequency should not be zero\n");
                return -EINVAL;
        }
 
index 00da80e..94b80a5 100644 (file)
@@ -358,6 +358,7 @@ int ib_register_device(struct ib_device *device,
        ret = device->query_device(device, &device->attrs, &uhw);
        if (ret) {
                printk(KERN_WARNING "Couldn't query the device attributes\n");
+               ib_cache_cleanup_one(device);
                goto out;
        }
 
index f334090..1e37f35 100644 (file)
@@ -1071,7 +1071,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
                }
        }
 
-       if (rec->hop_limit > 1 || use_roce) {
+       if (rec->hop_limit > 0 || use_roce) {
                ah_attr->ah_flags = IB_AH_GRH;
                ah_attr->grh.dgid = rec->dgid;
 
index 3de9351..14606af 100644 (file)
@@ -336,7 +336,6 @@ static ssize_t _show_port_gid_attr(struct ib_port *p,
        union ib_gid gid;
        struct ib_gid_attr gid_attr = {};
        ssize_t ret;
-       va_list args;
 
        ret = ib_query_gid(p->ibdev, p->port_num, tab_attr->index, &gid,
                           &gid_attr);
@@ -348,7 +347,6 @@ static ssize_t _show_port_gid_attr(struct ib_port *p,
 err:
        if (gid_attr.ndev)
                dev_put(gid_attr.ndev);
-       va_end(args);
        return ret;
 }
 
@@ -722,12 +720,11 @@ static struct attribute_group *get_counter_table(struct ib_device *dev,
 
        if (get_perf_mad(dev, port_num, IB_PMA_CLASS_PORT_INFO,
                                &cpi, 40, sizeof(cpi)) >= 0) {
-
-               if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH)
+               if (cpi.capability_mask & IB_PMA_CLASS_CAP_EXT_WIDTH)
                        /* We have extended counters */
                        return &pma_group_ext;
 
-               if (cpi.capability_mask && IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF)
+               if (cpi.capability_mask & IB_PMA_CLASS_CAP_EXT_WIDTH_NOIETF)
                        /* But not the IETF ones */
                        return &pma_group_noietf;
        }
index 6ffc9c4..6c6fbff 100644 (file)
@@ -1970,7 +1970,8 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
                   resp_size);
        INIT_UDATA(&uhw, buf + sizeof(cmd),
                   (unsigned long)cmd.response + resp_size,
-                  in_len - sizeof(cmd), out_len - resp_size);
+                  in_len - sizeof(cmd) - sizeof(struct ib_uverbs_cmd_hdr),
+                  out_len - resp_size);
 
        memset(&cmd_ex, 0, sizeof(cmd_ex));
        cmd_ex.user_handle = cmd.user_handle;
@@ -3413,7 +3414,8 @@ ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,
 
        INIT_UDATA(&udata, buf + sizeof cmd,
                   (unsigned long) cmd.response + sizeof resp,
-                  in_len - sizeof cmd, out_len - sizeof resp);
+                  in_len - sizeof cmd - sizeof(struct ib_uverbs_cmd_hdr),
+                  out_len - sizeof resp);
 
        ret = __uverbs_create_xsrq(file, ib_dev, &xcmd, &udata);
        if (ret)
@@ -3439,7 +3441,8 @@ ssize_t ib_uverbs_create_xsrq(struct ib_uverbs_file *file,
 
        INIT_UDATA(&udata, buf + sizeof cmd,
                   (unsigned long) cmd.response + sizeof resp,
-                  in_len - sizeof cmd, out_len - sizeof resp);
+                  in_len - sizeof cmd - sizeof(struct ib_uverbs_cmd_hdr),
+                  out_len - sizeof resp);
 
        ret = __uverbs_create_xsrq(file, ib_dev, &cmd, &udata);
        if (ret)
index 26833bf..d68f506 100644 (file)
@@ -817,17 +817,48 @@ static int ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
        return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
 }
 
-static void edit_counter(struct mlx4_counter *cnt,
-                                       struct ib_pma_portcounters *pma_cnt)
+static void edit_counter(struct mlx4_counter *cnt, void *counters,
+                        __be16 attr_id)
 {
-       ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_data,
-                            (be64_to_cpu(cnt->tx_bytes) >> 2));
-       ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_data,
-                            (be64_to_cpu(cnt->rx_bytes) >> 2));
-       ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_packets,
-                            be64_to_cpu(cnt->tx_frames));
-       ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_packets,
-                            be64_to_cpu(cnt->rx_frames));
+       switch (attr_id) {
+       case IB_PMA_PORT_COUNTERS:
+       {
+               struct ib_pma_portcounters *pma_cnt =
+                       (struct ib_pma_portcounters *)counters;
+
+               ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_data,
+                                    (be64_to_cpu(cnt->tx_bytes) >> 2));
+               ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_data,
+                                    (be64_to_cpu(cnt->rx_bytes) >> 2));
+               ASSIGN_32BIT_COUNTER(pma_cnt->port_xmit_packets,
+                                    be64_to_cpu(cnt->tx_frames));
+               ASSIGN_32BIT_COUNTER(pma_cnt->port_rcv_packets,
+                                    be64_to_cpu(cnt->rx_frames));
+               break;
+       }
+       case IB_PMA_PORT_COUNTERS_EXT:
+       {
+               struct ib_pma_portcounters_ext *pma_cnt_ext =
+                       (struct ib_pma_portcounters_ext *)counters;
+
+               pma_cnt_ext->port_xmit_data =
+                       cpu_to_be64(be64_to_cpu(cnt->tx_bytes) >> 2);
+               pma_cnt_ext->port_rcv_data =
+                       cpu_to_be64(be64_to_cpu(cnt->rx_bytes) >> 2);
+               pma_cnt_ext->port_xmit_packets = cnt->tx_frames;
+               pma_cnt_ext->port_rcv_packets = cnt->rx_frames;
+               break;
+       }
+       }
+}
+
+static int iboe_process_mad_port_info(void *out_mad)
+{
+       struct ib_class_port_info cpi = {};
+
+       cpi.capability_mask = IB_PMA_CLASS_CAP_EXT_WIDTH;
+       memcpy(out_mad, &cpi, sizeof(cpi));
+       return IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
 }
 
 static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
@@ -842,6 +873,9 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
        if (in_mad->mad_hdr.mgmt_class != IB_MGMT_CLASS_PERF_MGMT)
                return -EINVAL;
 
+       if (in_mad->mad_hdr.attr_id == IB_PMA_CLASS_PORT_INFO)
+               return iboe_process_mad_port_info((void *)(out_mad->data + 40));
+
        memset(&counter_stats, 0, sizeof(counter_stats));
        mutex_lock(&dev->counters_table[port_num - 1].mutex);
        list_for_each_entry(tmp_counter,
@@ -863,7 +897,8 @@ static int iboe_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
                switch (counter_stats.counter_mode & 0xf) {
                case 0:
                        edit_counter(&counter_stats,
-                                    (void *)(out_mad->data + 40));
+                                    (void *)(out_mad->data + 40),
+                                    in_mad->mad_hdr.attr_id);
                        err = IB_MAD_RESULT_SUCCESS | IB_MAD_RESULT_REPLY;
                        break;
                default:
@@ -894,8 +929,10 @@ int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
         */
        if (link == IB_LINK_LAYER_INFINIBAND) {
                if (mlx4_is_slave(dev->dev) &&
-                   in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
-                   in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS)
+                   (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT &&
+                    (in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS ||
+                     in_mad->mad_hdr.attr_id == IB_PMA_PORT_COUNTERS_EXT ||
+                     in_mad->mad_hdr.attr_id == IB_PMA_CLASS_PORT_INFO)))
                        return iboe_process_mad(ibdev, mad_flags, port_num, in_wc,
                                                in_grh, in_mad, out_mad);
 
index bc5536f..fd97534 100644 (file)
@@ -1681,9 +1681,12 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
        }
 
        if (qp->ibqp.uobject)
-               context->usr_page = cpu_to_be32(to_mucontext(ibqp->uobject->context)->uar.index);
+               context->usr_page = cpu_to_be32(
+                       mlx4_to_hw_uar_index(dev->dev,
+                                            to_mucontext(ibqp->uobject->context)->uar.index));
        else
-               context->usr_page = cpu_to_be32(dev->priv_uar.index);
+               context->usr_page = cpu_to_be32(
+                       mlx4_to_hw_uar_index(dev->dev, dev->priv_uar.index));
 
        if (attr_mask & IB_QP_DEST_QPN)
                context->remote_qpn = cpu_to_be32(attr->dest_qp_num);
index 9116bc3..34cb8e8 100644 (file)
@@ -270,8 +270,10 @@ static int sq_overhead(enum ib_qp_type qp_type)
                /* fall through */
        case IB_QPT_RC:
                size += sizeof(struct mlx5_wqe_ctrl_seg) +
-                       sizeof(struct mlx5_wqe_atomic_seg) +
-                       sizeof(struct mlx5_wqe_raddr_seg);
+                       max(sizeof(struct mlx5_wqe_atomic_seg) +
+                           sizeof(struct mlx5_wqe_raddr_seg),
+                           sizeof(struct mlx5_wqe_umr_ctrl_seg) +
+                           sizeof(struct mlx5_mkey_seg));
                break;
 
        case IB_QPT_XRC_TGT:
@@ -279,9 +281,9 @@ static int sq_overhead(enum ib_qp_type qp_type)
 
        case IB_QPT_UC:
                size += sizeof(struct mlx5_wqe_ctrl_seg) +
-                       sizeof(struct mlx5_wqe_raddr_seg) +
-                       sizeof(struct mlx5_wqe_umr_ctrl_seg) +
-                       sizeof(struct mlx5_mkey_seg);
+                       max(sizeof(struct mlx5_wqe_raddr_seg),
+                           sizeof(struct mlx5_wqe_umr_ctrl_seg) +
+                           sizeof(struct mlx5_mkey_seg));
                break;
 
        case IB_QPT_UD:
index 4659256..3b2ddd6 100644 (file)
@@ -75,7 +75,8 @@ static void mlx5_ib_srq_event(struct mlx5_core_srq *srq, enum mlx5_event type)
 
 static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
                           struct mlx5_create_srq_mbox_in **in,
-                          struct ib_udata *udata, int buf_size, int *inlen)
+                          struct ib_udata *udata, int buf_size, int *inlen,
+                          int is_xrc)
 {
        struct mlx5_ib_dev *dev = to_mdev(pd->device);
        struct mlx5_ib_create_srq ucmd = {};
@@ -87,13 +88,8 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
        int ncont;
        u32 offset;
        u32 uidx = MLX5_IB_DEFAULT_UIDX;
-       int drv_data = udata->inlen - sizeof(struct ib_uverbs_cmd_hdr);
 
-       if (drv_data < 0)
-               return -EINVAL;
-
-       ucmdlen = (drv_data < sizeof(ucmd)) ?
-                 drv_data : sizeof(ucmd);
+       ucmdlen = min(udata->inlen, sizeof(ucmd));
 
        if (ib_copy_from_udata(&ucmd, udata, ucmdlen)) {
                mlx5_ib_dbg(dev, "failed copy udata\n");
@@ -103,15 +99,17 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
        if (ucmd.reserved0 || ucmd.reserved1)
                return -EINVAL;
 
-       if (drv_data > sizeof(ucmd) &&
+       if (udata->inlen > sizeof(ucmd) &&
            !ib_is_udata_cleared(udata, sizeof(ucmd),
-                                drv_data - sizeof(ucmd)))
+                                udata->inlen - sizeof(ucmd)))
                return -EINVAL;
 
-       err = get_srq_user_index(to_mucontext(pd->uobject->context),
-                                &ucmd, udata->inlen, &uidx);
-       if (err)
-               return err;
+       if (is_xrc) {
+               err = get_srq_user_index(to_mucontext(pd->uobject->context),
+                                        &ucmd, udata->inlen, &uidx);
+               if (err)
+                       return err;
+       }
 
        srq->wq_sig = !!(ucmd.flags & MLX5_SRQ_FLAG_SIGNATURE);
 
@@ -151,7 +149,8 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
        (*in)->ctx.log_pg_sz = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
        (*in)->ctx.pgoff_cqn = cpu_to_be32(offset << 26);
 
-       if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1) {
+       if ((MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1) &&
+            is_xrc){
                xsrqc = MLX5_ADDR_OF(create_xrc_srq_in, *in,
                                     xrc_srq_context_entry);
                MLX5_SET(xrc_srqc, xsrqc, user_index, uidx);
@@ -170,7 +169,7 @@ err_umem:
 
 static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
                             struct mlx5_create_srq_mbox_in **in, int buf_size,
-                            int *inlen)
+                            int *inlen, int is_xrc)
 {
        int err;
        int i;
@@ -224,7 +223,8 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
 
        (*in)->ctx.log_pg_sz = page_shift - MLX5_ADAPTER_PAGE_SHIFT;
 
-       if (MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1) {
+       if ((MLX5_CAP_GEN(dev->mdev, cqe_version) == MLX5_CQE_VERSION_V1) &&
+            is_xrc){
                xsrqc = MLX5_ADDR_OF(create_xrc_srq_in, *in,
                                     xrc_srq_context_entry);
                /* 0xffffff means we ask to work with cqe version 0 */
@@ -302,10 +302,14 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
                    desc_size, init_attr->attr.max_wr, srq->msrq.max, srq->msrq.max_gs,
                    srq->msrq.max_avail_gather);
 
+       is_xrc = (init_attr->srq_type == IB_SRQT_XRC);
+
        if (pd->uobject)
-               err = create_srq_user(pd, srq, &in, udata, buf_size, &inlen);
+               err = create_srq_user(pd, srq, &in, udata, buf_size, &inlen,
+                                     is_xrc);
        else
-               err = create_srq_kernel(dev, srq, &in, buf_size, &inlen);
+               err = create_srq_kernel(dev, srq, &in, buf_size, &inlen,
+                                       is_xrc);
 
        if (err) {
                mlx5_ib_warn(dev, "create srq %s failed, err %d\n",
@@ -313,7 +317,6 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd,
                goto err_srq;
        }
 
-       is_xrc = (init_attr->srq_type == IB_SRQT_XRC);
        in->ctx.state_log_sz = ilog2(srq->msrq.max);
        flgs = ((srq->msrq.wqe_shift - 4) | (is_xrc << 5) | (srq->wq_sig << 7)) << 24;
        xrcdn = 0;
index 040bb8b..12503f1 100644 (file)
@@ -323,9 +323,6 @@ struct ocrdma_cq {
                         */
        u32 max_hw_cqe;
        bool phase_change;
-       bool deferred_arm, deferred_sol;
-       bool first_arm;
-
        spinlock_t cq_lock ____cacheline_aligned; /* provide synchronization
                                                   * to cq polling
                                                   */
index 5738493..f387430 100644 (file)
@@ -228,6 +228,11 @@ static int ocrdma_alloc_resources(struct ocrdma_dev *dev)
 
        ocrdma_alloc_pd_pool(dev);
 
+       if (!ocrdma_alloc_stats_resources(dev)) {
+               pr_err("%s: stats resource allocation failed\n", __func__);
+               goto alloc_err;
+       }
+
        spin_lock_init(&dev->av_tbl.lock);
        spin_lock_init(&dev->flush_q_lock);
        return 0;
@@ -238,6 +243,7 @@ alloc_err:
 
 static void ocrdma_free_resources(struct ocrdma_dev *dev)
 {
+       ocrdma_release_stats_resources(dev);
        kfree(dev->stag_arr);
        kfree(dev->qp_tbl);
        kfree(dev->cq_tbl);
index 86c303a..255f774 100644 (file)
@@ -64,10 +64,11 @@ static int ocrdma_add_stat(char *start, char *pcur,
        return cpy_len;
 }
 
-static bool ocrdma_alloc_stats_mem(struct ocrdma_dev *dev)
+bool ocrdma_alloc_stats_resources(struct ocrdma_dev *dev)
 {
        struct stats_mem *mem = &dev->stats_mem;
 
+       mutex_init(&dev->stats_lock);
        /* Alloc mbox command mem*/
        mem->size = max_t(u32, sizeof(struct ocrdma_rdma_stats_req),
                        sizeof(struct ocrdma_rdma_stats_resp));
@@ -91,13 +92,14 @@ static bool ocrdma_alloc_stats_mem(struct ocrdma_dev *dev)
        return true;
 }
 
-static void ocrdma_release_stats_mem(struct ocrdma_dev *dev)
+void ocrdma_release_stats_resources(struct ocrdma_dev *dev)
 {
        struct stats_mem *mem = &dev->stats_mem;
 
        if (mem->va)
                dma_free_coherent(&dev->nic_info.pdev->dev, mem->size,
                                  mem->va, mem->pa);
+       mem->va = NULL;
        kfree(mem->debugfs_mem);
 }
 
@@ -838,15 +840,9 @@ void ocrdma_add_port_stats(struct ocrdma_dev *dev)
                                &dev->reset_stats, &ocrdma_dbg_ops))
                goto err;
 
-       /* Now create dma_mem for stats mbx command */
-       if (!ocrdma_alloc_stats_mem(dev))
-               goto err;
-
-       mutex_init(&dev->stats_lock);
 
        return;
 err:
-       ocrdma_release_stats_mem(dev);
        debugfs_remove_recursive(dev->dir);
        dev->dir = NULL;
 }
@@ -855,9 +851,7 @@ void ocrdma_rem_port_stats(struct ocrdma_dev *dev)
 {
        if (!dev->dir)
                return;
-       debugfs_remove(dev->dir);
-       mutex_destroy(&dev->stats_lock);
-       ocrdma_release_stats_mem(dev);
+       debugfs_remove_recursive(dev->dir);
 }
 
 void ocrdma_init_debugfs(void)
index c9e58d0..bba1fec 100644 (file)
@@ -65,6 +65,8 @@ enum OCRDMA_STATS_TYPE {
 
 void ocrdma_rem_debugfs(void);
 void ocrdma_init_debugfs(void);
+bool ocrdma_alloc_stats_resources(struct ocrdma_dev *dev);
+void ocrdma_release_stats_resources(struct ocrdma_dev *dev);
 void ocrdma_rem_port_stats(struct ocrdma_dev *dev);
 void ocrdma_add_port_stats(struct ocrdma_dev *dev);
 int ocrdma_pma_counters(struct ocrdma_dev *dev,
index d4c687b..12420e4 100644 (file)
@@ -125,8 +125,8 @@ int ocrdma_query_device(struct ib_device *ibdev, struct ib_device_attr *attr,
                                        IB_DEVICE_SYS_IMAGE_GUID |
                                        IB_DEVICE_LOCAL_DMA_LKEY |
                                        IB_DEVICE_MEM_MGT_EXTENSIONS;
-       attr->max_sge = min(dev->attr.max_send_sge, dev->attr.max_srq_sge);
-       attr->max_sge_rd = 0;
+       attr->max_sge = dev->attr.max_send_sge;
+       attr->max_sge_rd = attr->max_sge;
        attr->max_cq = dev->attr.max_cq;
        attr->max_cqe = dev->attr.max_cqe;
        attr->max_mr = dev->attr.max_mr;
@@ -1094,7 +1094,6 @@ struct ib_cq *ocrdma_create_cq(struct ib_device *ibdev,
        spin_lock_init(&cq->comp_handler_lock);
        INIT_LIST_HEAD(&cq->sq_head);
        INIT_LIST_HEAD(&cq->rq_head);
-       cq->first_arm = true;
 
        if (ib_ctx) {
                uctx = get_ocrdma_ucontext(ib_ctx);
@@ -2726,8 +2725,7 @@ static int ocrdma_update_ud_rcqe(struct ib_wc *ibwc, struct ocrdma_cqe *cqe)
                OCRDMA_CQE_UD_STATUS_MASK) >> OCRDMA_CQE_UD_STATUS_SHIFT;
        ibwc->src_qp = le32_to_cpu(cqe->flags_status_srcqpn) &
                                                OCRDMA_CQE_SRCQP_MASK;
-       ibwc->pkey_index = le32_to_cpu(cqe->ud.rxlen_pkey) &
-                                               OCRDMA_CQE_PKEY_MASK;
+       ibwc->pkey_index = 0;
        ibwc->wc_flags = IB_WC_GRH;
        ibwc->byte_len = (le32_to_cpu(cqe->ud.rxlen_pkey) >>
                                        OCRDMA_CQE_UD_XFER_LEN_SHIFT);
@@ -2911,12 +2909,9 @@ expand_cqe:
        }
 stop_cqe:
        cq->getp = cur_getp;
-       if (cq->deferred_arm || polled_hw_cqes) {
-               ocrdma_ring_cq_db(dev, cq->id, cq->deferred_arm,
-                                 cq->deferred_sol, polled_hw_cqes);
-               cq->deferred_arm = false;
-               cq->deferred_sol = false;
-       }
+
+       if (polled_hw_cqes)
+               ocrdma_ring_cq_db(dev, cq->id, false, false, polled_hw_cqes);
 
        return i;
 }
@@ -3000,13 +2995,7 @@ int ocrdma_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags cq_flags)
        if (cq_flags & IB_CQ_SOLICITED)
                sol_needed = true;
 
-       if (cq->first_arm) {
-               ocrdma_ring_cq_db(dev, cq_id, arm_needed, sol_needed, 0);
-               cq->first_arm = false;
-       }
-
-       cq->deferred_arm = true;
-       cq->deferred_sol = sol_needed;
+       ocrdma_ring_cq_db(dev, cq_id, arm_needed, sol_needed, 0);
        spin_unlock_irqrestore(&cq->cq_lock, flags);
 
        return 0;
index 5ea0c14..fa9c42f 100644 (file)
@@ -245,8 +245,6 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
        skb_reset_mac_header(skb);
        skb_pull(skb, IPOIB_ENCAP_LEN);
 
-       skb->truesize = SKB_TRUESIZE(skb->len);
-
        ++dev->stats.rx_packets;
        dev->stats.rx_bytes += skb->len;
 
index 050dfa1..2588931 100644 (file)
@@ -456,7 +456,10 @@ out_locked:
        return status;
 }
 
-static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast)
+/*
+ * Caller must hold 'priv->lock'
+ */
+static int ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast)
 {
        struct ipoib_dev_priv *priv = netdev_priv(dev);
        struct ib_sa_multicast *multicast;
@@ -466,6 +469,10 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast)
        ib_sa_comp_mask comp_mask;
        int ret = 0;
 
+       if (!priv->broadcast ||
+           !test_bit(IPOIB_FLAG_OPER_UP, &priv->flags))
+               return -EINVAL;
+
        ipoib_dbg_mcast(priv, "joining MGID %pI6\n", mcast->mcmember.mgid.raw);
 
        rec.mgid     = mcast->mcmember.mgid;
@@ -525,20 +532,23 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast)
                        rec.join_state = 4;
 #endif
        }
+       spin_unlock_irq(&priv->lock);
 
        multicast = ib_sa_join_multicast(&ipoib_sa_client, priv->ca, priv->port,
                                         &rec, comp_mask, GFP_KERNEL,
                                         ipoib_mcast_join_complete, mcast);
+       spin_lock_irq(&priv->lock);
        if (IS_ERR(multicast)) {
                ret = PTR_ERR(multicast);
                ipoib_warn(priv, "ib_sa_join_multicast failed, status %d\n", ret);
-               spin_lock_irq(&priv->lock);
                /* Requeue this join task with a backoff delay */
                __ipoib_mcast_schedule_join_thread(priv, mcast, 1);
                clear_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags);
                spin_unlock_irq(&priv->lock);
                complete(&mcast->done);
+               spin_lock_irq(&priv->lock);
        }
+       return 0;
 }
 
 void ipoib_mcast_join_task(struct work_struct *work)
@@ -620,9 +630,10 @@ void ipoib_mcast_join_task(struct work_struct *work)
                                /* Found the next unjoined group */
                                init_completion(&mcast->done);
                                set_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags);
-                               spin_unlock_irq(&priv->lock);
-                               ipoib_mcast_join(dev, mcast);
-                               spin_lock_irq(&priv->lock);
+                               if (ipoib_mcast_join(dev, mcast)) {
+                                       spin_unlock_irq(&priv->lock);
+                                       return;
+                               }
                        } else if (!delay_until ||
                                 time_before(mcast->delay_until, delay_until))
                                delay_until = mcast->delay_until;
@@ -641,10 +652,9 @@ out:
        if (mcast) {
                init_completion(&mcast->done);
                set_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags);
+               ipoib_mcast_join(dev, mcast);
        }
        spin_unlock_irq(&priv->lock);
-       if (mcast)
-               ipoib_mcast_join(dev, mcast);
 }
 
 int ipoib_mcast_start_thread(struct net_device *dev)
index 6727954..e8a84d1 100644 (file)
@@ -1207,7 +1207,6 @@ static void xpad_led_disconnect(struct usb_xpad *xpad)
 #else
 static int xpad_led_probe(struct usb_xpad *xpad) { return 0; }
 static void xpad_led_disconnect(struct usb_xpad *xpad) { }
-static void xpad_identify_controller(struct usb_xpad *xpad) { }
 #endif
 
 static int xpad_start_input(struct usb_xpad *xpad)
index 4d446d5..c01a1d6 100644 (file)
@@ -235,7 +235,7 @@ struct adp5589_kpad {
        unsigned short gpimapsize;
        unsigned extend_cfg;
        bool is_adp5585;
-       bool adp5585_support_row5;
+       bool support_row5;
 #ifdef CONFIG_GPIOLIB
        unsigned char gpiomap[ADP5589_MAXGPIO];
        bool export_gpio;
@@ -485,7 +485,7 @@ static int adp5589_build_gpiomap(struct adp5589_kpad *kpad,
        if (kpad->extend_cfg & C4_EXTEND_CFG)
                pin_used[kpad->var->c4_extend_cfg] = true;
 
-       if (!kpad->adp5585_support_row5)
+       if (!kpad->support_row5)
                pin_used[5] = true;
 
        for (i = 0; i < kpad->var->maxgpio; i++)
@@ -884,12 +884,13 @@ static int adp5589_probe(struct i2c_client *client,
 
        switch (id->driver_data) {
        case ADP5585_02:
-               kpad->adp5585_support_row5 = true;
+               kpad->support_row5 = true;
        case ADP5585_01:
                kpad->is_adp5585 = true;
                kpad->var = &const_adp5585;
                break;
        case ADP5589:
+               kpad->support_row5 = true;
                kpad->var = &const_adp5589;
                break;
        }
index 378db10..4401be2 100644 (file)
@@ -304,8 +304,10 @@ static int cap11xx_init_leds(struct device *dev,
                led->cdev.brightness = LED_OFF;
 
                error = of_property_read_u32(child, "reg", &reg);
-               if (error != 0 || reg >= num_leds)
+               if (error != 0 || reg >= num_leds) {
+                       of_node_put(child);
                        return -EINVAL;
+               }
 
                led->reg = reg;
                led->priv = priv;
@@ -313,8 +315,10 @@ static int cap11xx_init_leds(struct device *dev,
                INIT_WORK(&led->work, cap11xx_led_work);
 
                error = devm_led_classdev_register(dev, &led->cdev);
-               if (error)
+               if (error) {
+                       of_node_put(child);
                        return error;
+               }
 
                priv->num_leds++;
                led++;
index d6d16fa..1f2337a 100644 (file)
@@ -733,7 +733,7 @@ config INPUT_XEN_KBDDEV_FRONTEND
          module will be called xen-kbdfront.
 
 config INPUT_SIRFSOC_ONKEY
-       bool "CSR SiRFSoC power on/off/suspend key support"
+       tristate "CSR SiRFSoC power on/off/suspend key support"
        depends on ARCH_SIRF && OF
        default y
        help
index 9d5b89b..ed7237f 100644 (file)
@@ -101,7 +101,7 @@ static void sirfsoc_pwrc_close(struct input_dev *input)
 static const struct of_device_id sirfsoc_pwrc_of_match[] = {
        { .compatible = "sirf,prima2-pwrc" },
        {},
-}
+};
 MODULE_DEVICE_TABLE(of, sirfsoc_pwrc_of_match);
 
 static int sirfsoc_pwrc_probe(struct platform_device *pdev)
index e272f06..a3f0f5a 100644 (file)
@@ -458,8 +458,6 @@ int vmmouse_init(struct psmouse *psmouse)
        priv->abs_dev = abs_dev;
        psmouse->private = priv;
 
-       input_set_capability(rel_dev, EV_REL, REL_WHEEL);
-
        /* Set up and register absolute device */
        snprintf(priv->phys, sizeof(priv->phys), "%s/input1",
                 psmouse->ps2dev.serio->phys);
@@ -475,10 +473,6 @@ int vmmouse_init(struct psmouse *psmouse)
        abs_dev->id.version = psmouse->model;
        abs_dev->dev.parent = &psmouse->ps2dev.serio->dev;
 
-       error = input_register_device(priv->abs_dev);
-       if (error)
-               goto init_fail;
-
        /* Set absolute device capabilities */
        input_set_capability(abs_dev, EV_KEY, BTN_LEFT);
        input_set_capability(abs_dev, EV_KEY, BTN_RIGHT);
@@ -488,6 +482,13 @@ int vmmouse_init(struct psmouse *psmouse)
        input_set_abs_params(abs_dev, ABS_X, 0, VMMOUSE_MAX_X, 0, 0);
        input_set_abs_params(abs_dev, ABS_Y, 0, VMMOUSE_MAX_Y, 0, 0);
 
+       error = input_register_device(priv->abs_dev);
+       if (error)
+               goto init_fail;
+
+       /* Add wheel capability to the relative device */
+       input_set_capability(rel_dev, EV_REL, REL_WHEEL);
+
        psmouse->protocol_handler = vmmouse_process_byte;
        psmouse->disconnect = vmmouse_disconnect;
        psmouse->reconnect = vmmouse_reconnect;
index 8f82897..1ca7f55 100644 (file)
@@ -134,7 +134,7 @@ static void serio_find_driver(struct serio *serio)
        int error;
 
        error = device_attach(&serio->dev);
-       if (error < 0)
+       if (error < 0 && error != -EPROBE_DEFER)
                dev_warn(&serio->dev,
                         "device_attach() failed for %s (%s), error: %d\n",
                         serio->phys, serio->name, error);
index 5d4903a..69828d0 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
index 0b0f8c1..23fbe38 100644 (file)
@@ -822,16 +822,22 @@ static void edt_ft5x06_ts_get_defaults(struct device *dev,
        int error;
 
        error = device_property_read_u32(dev, "threshold", &val);
-       if (!error)
-               reg_addr->reg_threshold = val;
+       if (!error) {
+               edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold, val);
+               tsdata->threshold = val;
+       }
 
        error = device_property_read_u32(dev, "gain", &val);
-       if (!error)
-               reg_addr->reg_gain = val;
+       if (!error) {
+               edt_ft5x06_register_write(tsdata, reg_addr->reg_gain, val);
+               tsdata->gain = val;
+       }
 
        error = device_property_read_u32(dev, "offset", &val);
-       if (!error)
-               reg_addr->reg_offset = val;
+       if (!error) {
+               edt_ft5x06_register_write(tsdata, reg_addr->reg_offset, val);
+               tsdata->offset = val;
+       }
 }
 
 static void
index e5e2239..374c129 100644 (file)
@@ -114,6 +114,7 @@ struct kmem_cache *amd_iommu_irq_cache;
 
 static void update_domain(struct protection_domain *domain);
 static int protection_domain_init(struct protection_domain *domain);
+static void detach_device(struct device *dev);
 
 /*
  * For dynamic growth the aperture size is split into ranges of 128MB of
@@ -384,6 +385,9 @@ static void iommu_uninit_device(struct device *dev)
        if (!dev_data)
                return;
 
+       if (dev_data->domain)
+               detach_device(dev);
+
        iommu_device_unlink(amd_iommu_rlookup_table[dev_data->devid]->iommu_dev,
                            dev);
 
index 013bdff..bf4959f 100644 (file)
@@ -228,6 +228,10 @@ static int amd_iommu_enable_interrupts(void);
 static int __init iommu_go_to_state(enum iommu_init_state state);
 static void init_device_table_dma(void);
 
+static int iommu_pc_get_set_reg_val(struct amd_iommu *iommu,
+                                   u8 bank, u8 cntr, u8 fxn,
+                                   u64 *value, bool is_write);
+
 static inline void update_last_devid(u16 devid)
 {
        if (devid > amd_iommu_last_bdf)
@@ -1016,6 +1020,34 @@ static void amd_iommu_erratum_746_workaround(struct amd_iommu *iommu)
 }
 
 /*
+ * Family15h Model 30h-3fh (IOMMU Mishandles ATS Write Permission)
+ * Workaround:
+ *     BIOS should enable ATS write permission check by setting
+ *     L2_DEBUG_3[AtsIgnoreIWDis](D0F2xF4_x47[0]) = 1b
+ */
+static void amd_iommu_ats_write_check_workaround(struct amd_iommu *iommu)
+{
+       u32 value;
+
+       if ((boot_cpu_data.x86 != 0x15) ||
+           (boot_cpu_data.x86_model < 0x30) ||
+           (boot_cpu_data.x86_model > 0x3f))
+               return;
+
+       /* Test L2_DEBUG_3[AtsIgnoreIWDis] == 1 */
+       value = iommu_read_l2(iommu, 0x47);
+
+       if (value & BIT(0))
+               return;
+
+       /* Set L2_DEBUG_3[AtsIgnoreIWDis] = 1 */
+       iommu_write_l2(iommu, 0x47, value | BIT(0));
+
+       pr_info("AMD-Vi: Applying ATS write check workaround for IOMMU at %s\n",
+               dev_name(&iommu->dev->dev));
+}
+
+/*
  * This function clues the initialization function for one IOMMU
  * together and also allocates the command buffer and programs the
  * hardware. It does NOT enable the IOMMU. This is done afterwards.
@@ -1142,8 +1174,8 @@ static void init_iommu_perf_ctr(struct amd_iommu *iommu)
        amd_iommu_pc_present = true;
 
        /* Check if the performance counters can be written to */
-       if ((0 != amd_iommu_pc_get_set_reg_val(0, 0, 0, 0, &val, true)) ||
-           (0 != amd_iommu_pc_get_set_reg_val(0, 0, 0, 0, &val2, false)) ||
+       if ((0 != iommu_pc_get_set_reg_val(iommu, 0, 0, 0, &val, true)) ||
+           (0 != iommu_pc_get_set_reg_val(iommu, 0, 0, 0, &val2, false)) ||
            (val != val2)) {
                pr_err("AMD-Vi: Unable to write to IOMMU perf counter.\n");
                amd_iommu_pc_present = false;
@@ -1284,6 +1316,7 @@ static int iommu_init_pci(struct amd_iommu *iommu)
        }
 
        amd_iommu_erratum_746_workaround(iommu);
+       amd_iommu_ats_write_check_workaround(iommu);
 
        iommu->iommu_dev = iommu_device_create(&iommu->dev->dev, iommu,
                                               amd_iommu_groups, "ivhd%d",
@@ -2283,22 +2316,15 @@ u8 amd_iommu_pc_get_max_counters(u16 devid)
 }
 EXPORT_SYMBOL(amd_iommu_pc_get_max_counters);
 
-int amd_iommu_pc_get_set_reg_val(u16 devid, u8 bank, u8 cntr, u8 fxn,
+static int iommu_pc_get_set_reg_val(struct amd_iommu *iommu,
+                                   u8 bank, u8 cntr, u8 fxn,
                                    u64 *value, bool is_write)
 {
-       struct amd_iommu *iommu;
        u32 offset;
        u32 max_offset_lim;
 
-       /* Make sure the IOMMU PC resource is available */
-       if (!amd_iommu_pc_present)
-               return -ENODEV;
-
-       /* Locate the iommu associated with the device ID */
-       iommu = amd_iommu_rlookup_table[devid];
-
        /* Check for valid iommu and pc register indexing */
-       if (WARN_ON((iommu == NULL) || (fxn > 0x28) || (fxn & 7)))
+       if (WARN_ON((fxn > 0x28) || (fxn & 7)))
                return -ENODEV;
 
        offset = (u32)(((0x40|bank) << 12) | (cntr << 8) | fxn);
@@ -2322,3 +2348,16 @@ int amd_iommu_pc_get_set_reg_val(u16 devid, u8 bank, u8 cntr, u8 fxn,
        return 0;
 }
 EXPORT_SYMBOL(amd_iommu_pc_get_set_reg_val);
+
+int amd_iommu_pc_get_set_reg_val(u16 devid, u8 bank, u8 cntr, u8 fxn,
+                                   u64 *value, bool is_write)
+{
+       struct amd_iommu *iommu = amd_iommu_rlookup_table[devid];
+
+       /* Make sure the IOMMU PC resource is available */
+       if (!amd_iommu_pc_present || iommu == NULL)
+               return -ENODEV;
+
+       return iommu_pc_get_set_reg_val(iommu, bank, cntr, fxn,
+                                       value, is_write);
+}
index 62a400c..8ffd756 100644 (file)
@@ -329,7 +329,8 @@ static int dmar_pci_bus_notifier(struct notifier_block *nb,
        /* Only care about add/remove events for physical functions */
        if (pdev->is_virtfn)
                return NOTIFY_DONE;
-       if (action != BUS_NOTIFY_ADD_DEVICE && action != BUS_NOTIFY_DEL_DEVICE)
+       if (action != BUS_NOTIFY_ADD_DEVICE &&
+           action != BUS_NOTIFY_REMOVED_DEVICE)
                return NOTIFY_DONE;
 
        info = dmar_alloc_pci_notify_info(pdev, action);
@@ -339,7 +340,7 @@ static int dmar_pci_bus_notifier(struct notifier_block *nb,
        down_write(&dmar_global_lock);
        if (action == BUS_NOTIFY_ADD_DEVICE)
                dmar_pci_bus_add_dev(info);
-       else if (action == BUS_NOTIFY_DEL_DEVICE)
+       else if (action == BUS_NOTIFY_REMOVED_DEVICE)
                dmar_pci_bus_del_dev(info);
        up_write(&dmar_global_lock);
 
@@ -1353,7 +1354,7 @@ void dmar_disable_qi(struct intel_iommu *iommu)
 
        raw_spin_lock_irqsave(&iommu->register_lock, flags);
 
-       sts =  dmar_readq(iommu->reg + DMAR_GSTS_REG);
+       sts =  readl(iommu->reg + DMAR_GSTS_REG);
        if (!(sts & DMA_GSTS_QIES))
                goto end;
 
index 986a53e..a2e1b7f 100644 (file)
@@ -4367,7 +4367,7 @@ int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info)
                                rmrru->devices_cnt);
                        if(ret < 0)
                                return ret;
-               } else if (info->event == BUS_NOTIFY_DEL_DEVICE) {
+               } else if (info->event == BUS_NOTIFY_REMOVED_DEVICE) {
                        dmar_remove_dev_scope(info, rmrr->segment,
                                rmrru->devices, rmrru->devices_cnt);
                }
@@ -4387,7 +4387,7 @@ int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info)
                                break;
                        else if(ret < 0)
                                return ret;
-               } else if (info->event == BUS_NOTIFY_DEL_DEVICE) {
+               } else if (info->event == BUS_NOTIFY_REMOVED_DEVICE) {
                        if (dmar_remove_dev_scope(info, atsr->segment,
                                        atsru->devices, atsru->devices_cnt))
                                break;
index 5046483..d9939fa 100644 (file)
@@ -249,12 +249,30 @@ static void intel_flush_pasid_dev(struct intel_svm *svm, struct intel_svm_dev *s
 static void intel_mm_release(struct mmu_notifier *mn, struct mm_struct *mm)
 {
        struct intel_svm *svm = container_of(mn, struct intel_svm, notifier);
+       struct intel_svm_dev *sdev;
 
+       /* This might end up being called from exit_mmap(), *before* the page
+        * tables are cleared. And __mmu_notifier_release() will delete us from
+        * the list of notifiers so that our invalidate_range() callback doesn't
+        * get called when the page tables are cleared. So we need to protect
+        * against hardware accessing those page tables.
+        *
+        * We do it by clearing the entry in the PASID table and then flushing
+        * the IOTLB and the PASID table caches. This might upset hardware;
+        * perhaps we'll want to point the PASID to a dummy PGD (like the zero
+        * page) so that we end up taking a fault that the hardware really
+        * *has* to handle gracefully without affecting other processes.
+        */
        svm->iommu->pasid_table[svm->pasid].val = 0;
+       wmb();
+
+       rcu_read_lock();
+       list_for_each_entry_rcu(sdev, &svm->devs, list) {
+               intel_flush_pasid_dev(svm, sdev, svm->pasid);
+               intel_flush_svm_range_dev(svm, sdev, 0, -1, 0, !svm->mm);
+       }
+       rcu_read_unlock();
 
-       /* There's no need to do any flush because we can't get here if there
-        * are any devices left anyway. */
-       WARN_ON(!list_empty(&svm->devs));
 }
 
 static const struct mmu_notifier_ops intel_mmuops = {
@@ -379,7 +397,6 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_
                                goto out;
                        }
                        iommu->pasid_table[svm->pasid].val = (u64)__pa(mm->pgd) | 1;
-                       mm = NULL;
                } else
                        iommu->pasid_table[svm->pasid].val = (u64)__pa(init_mm.pgd) | 1 | (1ULL << 11);
                wmb();
@@ -442,11 +459,11 @@ int intel_svm_unbind_mm(struct device *dev, int pasid)
                                kfree_rcu(sdev, rcu);
 
                                if (list_empty(&svm->devs)) {
-                                       mmu_notifier_unregister(&svm->notifier, svm->mm);
 
                                        idr_remove(&svm->iommu->pasid_idr, svm->pasid);
                                        if (svm->mm)
-                                               mmput(svm->mm);
+                                               mmu_notifier_unregister(&svm->notifier, svm->mm);
+
                                        /* We mandate that no page faults may be outstanding
                                         * for the PASID when intel_svm_unbind_mm() is called.
                                         * If that is not obeyed, subtle errors will happen.
@@ -507,6 +524,10 @@ static irqreturn_t prq_event_thread(int irq, void *d)
        struct intel_svm *svm = NULL;
        int head, tail, handled = 0;
 
+       /* Clear PPR bit before reading head/tail registers, to
+        * ensure that we get a new interrupt if needed. */
+       writel(DMA_PRS_PPR, iommu->reg + DMAR_PRS_REG);
+
        tail = dmar_readq(iommu->reg + DMAR_PQT_REG) & PRQ_RING_MASK;
        head = dmar_readq(iommu->reg + DMAR_PQH_REG) & PRQ_RING_MASK;
        while (head != tail) {
@@ -551,6 +572,9 @@ static irqreturn_t prq_event_thread(int irq, void *d)
                 * any faults on kernel addresses. */
                if (!svm->mm)
                        goto bad_req;
+               /* If the mm is already defunct, don't handle faults. */
+               if (!atomic_inc_not_zero(&svm->mm->mm_users))
+                       goto bad_req;
                down_read(&svm->mm->mmap_sem);
                vma = find_extend_vma(svm->mm, address);
                if (!vma || address < vma->vm_start)
@@ -567,6 +591,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)
                result = QI_RESP_SUCCESS;
        invalid:
                up_read(&svm->mm->mmap_sem);
+               mmput(svm->mm);
        bad_req:
                /* Accounting for major/minor faults? */
                rcu_read_lock();
index c12ba45..ac59692 100644 (file)
@@ -629,7 +629,7 @@ static void iommu_disable_irq_remapping(struct intel_iommu *iommu)
 
        raw_spin_lock_irqsave(&iommu->register_lock, flags);
 
-       sts = dmar_readq(iommu->reg + DMAR_GSTS_REG);
+       sts = readl(iommu->reg + DMAR_GSTS_REG);
        if (!(sts & DMA_GSTS_IRES))
                goto end;
 
index 3447549..43dfd15 100644 (file)
@@ -66,7 +66,10 @@ struct its_node {
        unsigned long           phys_base;
        struct its_cmd_block    *cmd_base;
        struct its_cmd_block    *cmd_write;
-       void                    *tables[GITS_BASER_NR_REGS];
+       struct {
+               void            *base;
+               u32             order;
+       } tables[GITS_BASER_NR_REGS];
        struct its_collection   *collections;
        struct list_head        its_device_list;
        u64                     flags;
@@ -75,6 +78,9 @@ struct its_node {
 
 #define ITS_ITT_ALIGN          SZ_256
 
+/* Convert page order to size in bytes */
+#define PAGE_ORDER_TO_SIZE(o)  (PAGE_SIZE << (o))
+
 struct event_lpi_map {
        unsigned long           *lpi_map;
        u16                     *col_map;
@@ -597,11 +603,6 @@ static void its_unmask_irq(struct irq_data *d)
        lpi_set_config(d, true);
 }
 
-static void its_eoi_irq(struct irq_data *d)
-{
-       gic_write_eoir(d->hwirq);
-}
-
 static int its_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
                            bool force)
 {
@@ -638,7 +639,7 @@ static struct irq_chip its_irq_chip = {
        .name                   = "ITS",
        .irq_mask               = its_mask_irq,
        .irq_unmask             = its_unmask_irq,
-       .irq_eoi                = its_eoi_irq,
+       .irq_eoi                = irq_chip_eoi_parent,
        .irq_set_affinity       = its_set_affinity,
        .irq_compose_msi_msg    = its_irq_compose_msi_msg,
 };
@@ -807,9 +808,10 @@ static void its_free_tables(struct its_node *its)
        int i;
 
        for (i = 0; i < GITS_BASER_NR_REGS; i++) {
-               if (its->tables[i]) {
-                       free_page((unsigned long)its->tables[i]);
-                       its->tables[i] = NULL;
+               if (its->tables[i].base) {
+                       free_pages((unsigned long)its->tables[i].base,
+                                  its->tables[i].order);
+                       its->tables[i].base = NULL;
                }
        }
 }
@@ -842,7 +844,6 @@ static int its_alloc_tables(const char *node_name, struct its_node *its)
                u64 type = GITS_BASER_TYPE(val);
                u64 entry_size = GITS_BASER_ENTRY_SIZE(val);
                int order = get_order(psz);
-               int alloc_size;
                int alloc_pages;
                u64 tmp;
                void *base;
@@ -874,9 +875,8 @@ static int its_alloc_tables(const char *node_name, struct its_node *its)
                        }
                }
 
-               alloc_size = (1 << order) * PAGE_SIZE;
 retry_alloc_baser:
-               alloc_pages = (alloc_size / psz);
+               alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz);
                if (alloc_pages > GITS_BASER_PAGES_MAX) {
                        alloc_pages = GITS_BASER_PAGES_MAX;
                        order = get_order(GITS_BASER_PAGES_MAX * psz);
@@ -890,7 +890,8 @@ retry_alloc_baser:
                        goto out_free;
                }
 
-               its->tables[i] = base;
+               its->tables[i].base = base;
+               its->tables[i].order = order;
 
 retry_baser:
                val = (virt_to_phys(base)                                |
@@ -928,7 +929,7 @@ retry_baser:
                        shr = tmp & GITS_BASER_SHAREABILITY_MASK;
                        if (!shr) {
                                cache = GITS_BASER_nC;
-                               __flush_dcache_area(base, alloc_size);
+                               __flush_dcache_area(base, PAGE_ORDER_TO_SIZE(order));
                        }
                        goto retry_baser;
                }
@@ -940,7 +941,7 @@ retry_baser:
                         * something is horribly wrong...
                         */
                        free_pages((unsigned long)base, order);
-                       its->tables[i] = NULL;
+                       its->tables[i].base = NULL;
 
                        switch (psz) {
                        case SZ_16K:
@@ -961,7 +962,7 @@ retry_baser:
                }
 
                pr_info("ITS: allocated %d %s @%lx (psz %dK, shr %d)\n",
-                       (int)(alloc_size / entry_size),
+                       (int)(PAGE_ORDER_TO_SIZE(order) / entry_size),
                        its_base_type_string[type],
                        (unsigned long)virt_to_phys(base),
                        psz / SZ_1K, (int)shr >> GITS_BASER_SHAREABILITY_SHIFT);
index 911758c..8f9ebf7 100644 (file)
@@ -384,9 +384,6 @@ static struct irq_chip gic_chip = {
        .irq_unmask             = gic_unmask_irq,
        .irq_eoi                = gic_eoi_irq,
        .irq_set_type           = gic_set_type,
-#ifdef CONFIG_SMP
-       .irq_set_affinity       = gic_set_affinity,
-#endif
        .irq_get_irqchip_state  = gic_irq_get_irqchip_state,
        .irq_set_irqchip_state  = gic_irq_set_irqchip_state,
        .flags                  = IRQCHIP_SET_TYPE_MASKED |
@@ -400,9 +397,6 @@ static struct irq_chip gic_eoimode1_chip = {
        .irq_unmask             = gic_unmask_irq,
        .irq_eoi                = gic_eoimode1_eoi_irq,
        .irq_set_type           = gic_set_type,
-#ifdef CONFIG_SMP
-       .irq_set_affinity       = gic_set_affinity,
-#endif
        .irq_get_irqchip_state  = gic_irq_get_irqchip_state,
        .irq_set_irqchip_state  = gic_irq_set_irqchip_state,
        .irq_set_vcpu_affinity  = gic_irq_set_vcpu_affinity,
@@ -443,7 +437,7 @@ static void gic_cpu_if_up(struct gic_chip_data *gic)
        u32 bypass = 0;
        u32 mode = 0;
 
-       if (static_key_true(&supports_deactivate))
+       if (gic == &gic_data[0] && static_key_true(&supports_deactivate))
                mode = GIC_CPU_CTRL_EOImodeNS;
 
        /*
@@ -1039,6 +1033,11 @@ static void __init __gic_init_bases(unsigned int gic_nr, int irq_start,
                gic->chip.name = kasprintf(GFP_KERNEL, "GIC-%d", gic_nr);
        }
 
+#ifdef CONFIG_SMP
+       if (gic_nr == 0)
+               gic->chip.irq_set_affinity = gic_set_affinity;
+#endif
+
 #ifdef CONFIG_GIC_NON_BANKED
        if (percpu_offset) { /* Frankein-GIC without banked registers... */
                unsigned int cpu;
index 0704362..376b280 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/of_irq.h>
 
 #include <asm/exception.h>
-#include <asm/mach/irq.h>
 
 #define SUN4I_IRQ_VECTOR_REG           0x00
 #define SUN4I_IRQ_PROTECTION_REG       0x08
index 2a506fe..d1f8ab9 100644 (file)
@@ -373,13 +373,7 @@ static void gigaset_freecshw(struct cardstate *cs)
 
 static void gigaset_device_release(struct device *dev)
 {
-       struct cardstate *cs = dev_get_drvdata(dev);
-
-       if (!cs)
-               return;
-       dev_set_drvdata(dev, NULL);
-       kfree(cs->hw.ser);
-       cs->hw.ser = NULL;
+       kfree(container_of(dev, struct ser_cardstate, dev.dev));
 }
 
 /*
@@ -408,7 +402,6 @@ static int gigaset_initcshw(struct cardstate *cs)
                cs->hw.ser = NULL;
                return rc;
        }
-       dev_set_drvdata(&cs->hw.ser->dev.dev, cs);
 
        tasklet_init(&cs->write_tasklet,
                     gigaset_modem_fill, (unsigned long) cs);
index 8e29447..afde4ed 100644 (file)
@@ -392,7 +392,7 @@ read_dma(struct tiger_ch *bc, u32 idx, int cnt)
        }
        stat = bchannel_get_rxbuf(&bc->bch, cnt);
        /* only transparent use the count here, HDLC overun is detected later */
-       if (stat == ENOMEM) {
+       if (stat == -ENOMEM) {
                pr_warning("%s.B%d: No memory for %d bytes\n",
                           card->name, bc->bch.nr, cnt);
                return;
index 33224cb..9f6acd5 100644 (file)
@@ -572,11 +572,13 @@ int nvm_register(struct request_queue *q, char *disk_name,
                }
        }
 
-       ret = nvm_get_sysblock(dev, &dev->sb);
-       if (!ret)
-               pr_err("nvm: device not initialized.\n");
-       else if (ret < 0)
-               pr_err("nvm: err (%d) on device initialization\n", ret);
+       if (dev->identity.cap & NVM_ID_DCAP_BBLKMGMT) {
+               ret = nvm_get_sysblock(dev, &dev->sb);
+               if (!ret)
+                       pr_err("nvm: device not initialized.\n");
+               else if (ret < 0)
+                       pr_err("nvm: err (%d) on device initialization\n", ret);
+       }
 
        /* register device with a supported media manager */
        down_write(&nvm_lock);
@@ -1055,9 +1057,11 @@ static long __nvm_ioctl_dev_init(struct nvm_ioctl_dev_init *init)
        strncpy(info.mmtype, init->mmtype, NVM_MMTYPE_LEN);
        info.fs_ppa.ppa = -1;
 
-       ret = nvm_init_sysblock(dev, &info);
-       if (ret)
-               return ret;
+       if (dev->identity.cap & NVM_ID_DCAP_BBLKMGMT) {
+               ret = nvm_init_sysblock(dev, &info);
+               if (ret)
+                       return ret;
+       }
 
        memcpy(&dev->sb, &info, sizeof(struct nvm_sb_info));
 
@@ -1117,7 +1121,10 @@ static long nvm_ioctl_dev_factory(struct file *file, void __user *arg)
                dev->mt = NULL;
        }
 
-       return nvm_dev_factory(dev, fact.flags);
+       if (dev->identity.cap & NVM_ID_DCAP_BBLKMGMT)
+               return nvm_dev_factory(dev, fact.flags);
+
+       return 0;
 }
 
 static long nvm_ctl_ioctl(struct file *file, uint cmd, unsigned long arg)
index d8c7595..307db1e 100644 (file)
@@ -300,8 +300,10 @@ static int rrpc_move_valid_pages(struct rrpc *rrpc, struct rrpc_block *rblk)
        }
 
        page = mempool_alloc(rrpc->page_pool, GFP_NOIO);
-       if (!page)
+       if (!page) {
+               bio_put(bio);
                return -ENOMEM;
+       }
 
        while ((slot = find_first_zero_bit(rblk->invalid_pages,
                                            nr_pgs_per_blk)) < nr_pgs_per_blk) {
index ef13ac7..f7b3733 100644 (file)
@@ -174,8 +174,7 @@ static inline sector_t rrpc_get_sector(sector_t laddr)
 static inline int request_intersects(struct rrpc_inflight_rq *r,
                                sector_t laddr_start, sector_t laddr_end)
 {
-       return (laddr_end >= r->l_start && laddr_end <= r->l_end) &&
-               (laddr_start >= r->l_start && laddr_start <= r->l_end);
+       return (laddr_end >= r->l_start) && (laddr_start <= r->l_end);
 }
 
 static int __rrpc_lock_laddr(struct rrpc *rrpc, sector_t laddr,
@@ -184,6 +183,8 @@ static int __rrpc_lock_laddr(struct rrpc *rrpc, sector_t laddr,
        sector_t laddr_end = laddr + pages - 1;
        struct rrpc_inflight_rq *rtmp;
 
+       WARN_ON(irqs_disabled());
+
        spin_lock_irq(&rrpc->inflights.lock);
        list_for_each_entry(rtmp, &rrpc->inflights.reqs, list) {
                if (unlikely(request_intersects(rtmp, laddr, laddr_end))) {
index 5df4048..dd83492 100644 (file)
@@ -1191,6 +1191,8 @@ static void dm_unprep_request(struct request *rq)
 
        if (clone)
                free_rq_clone(clone);
+       else if (!tio->md->queue->mq_ops)
+               free_rq_tio(tio);
 }
 
 /*
index 9c59f43..f595640 100644 (file)
@@ -38,7 +38,7 @@ static int flexcop_fe_request_firmware(struct dvb_frontend *fe,
 #endif
 
 /* lnb control */
-#if FE_SUPPORTED(MT312) || FE_SUPPORTED(STV0299)
+#if (FE_SUPPORTED(MT312) || FE_SUPPORTED(STV0299)) && FE_SUPPORTED(PLL)
 static int flexcop_set_voltage(struct dvb_frontend *fe,
                               enum fe_sec_voltage voltage)
 {
@@ -68,7 +68,7 @@ static int flexcop_set_voltage(struct dvb_frontend *fe,
 #endif
 
 #if FE_SUPPORTED(S5H1420) || FE_SUPPORTED(STV0299) || FE_SUPPORTED(MT312)
-static int flexcop_sleep(struct dvb_frontend* fe)
+static int __maybe_unused flexcop_sleep(struct dvb_frontend* fe)
 {
        struct flexcop_device *fc = fe->dvb->priv;
        if (fc->fe_sleep)
index 412c5da..0f5114d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
  * flexcop.c - main module part
- * Copyright (C) 2004-9 Patrick Boettcher <patrick.boettcher@desy.de>
+ * Copyright (C) 2004-9 Patrick Boettcher <patrick.boettcher@posteo.de>
  * based on skystar2-driver Copyright (C) 2003 Vadim Catana, skystar@moldova.cc
  *
  * Acknowledgements:
@@ -34,7 +34,7 @@
 #include "flexcop.h"
 
 #define DRIVER_NAME "B2C2 FlexcopII/II(b)/III digital TV receiver chip"
-#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de"
+#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@posteo.de"
 
 #ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
 #define DEBSTATUS ""
index 577e820..50e3f76 100644 (file)
@@ -1,6 +1,6 @@
 /*  cypress_firmware.c is part of the DVB USB library.
  *
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * This file contains functions for downloading the firmware to Cypress FX 1
index e493cbc..1e4f273 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * This file contains functions for downloading the firmware to Cypress FX 1
index 2a8d9a3..f3a4283 100644 (file)
@@ -1167,8 +1167,8 @@ static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
                return rc;
        }
        pr_debug("read fw %s, buffer size=0x%zx\n", fw_filename, fw->size);
-       fw_buf = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT),
-                        GFP_KERNEL | GFP_DMA);
+       fw_buf = kmalloc(ALIGN(fw->size + sizeof(struct sms_firmware),
+                        SMS_ALLOC_ALIGNMENT), GFP_KERNEL | GFP_DMA);
        if (!fw_buf) {
                pr_err("failed to allocate firmware buffer\n");
                rc = -ENOMEM;
index d31f468..9148e14 100644 (file)
@@ -1015,12 +1015,6 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe)
        }
 }
 
-/* Nothing to do here, as stats are automatically updated */
-static int smsdvb_get_frontend(struct dvb_frontend *fe)
-{
-       return 0;
-}
-
 static int smsdvb_init(struct dvb_frontend *fe)
 {
        struct smsdvb_client_t *client =
@@ -1069,7 +1063,6 @@ static struct dvb_frontend_ops smsdvb_fe_ops = {
        .release = smsdvb_release,
 
        .set_frontend = smsdvb_set_frontend,
-       .get_frontend = smsdvb_get_frontend,
        .get_tune_settings = smsdvb_get_tune_settings,
 
        .read_status = smsdvb_read_status,
index 1c1c298..dbdbb84 100644 (file)
@@ -1,6 +1,6 @@
 /* dvb-usb-ids.h is part of the DVB USB library.
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) see
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de) see
  * dvb-usb-init.c for copyright information.
  *
  * a header file containing define's for the USB device supported by the
 #define USB_PID_DIBCOM_STK807XP                                0x1f90
 #define USB_PID_DIBCOM_STK807XPVR                      0x1f98
 #define USB_PID_DIBCOM_STK8096GP                        0x1fa0
+#define USB_PID_DIBCOM_STK8096PVR                       0x1faa
 #define USB_PID_DIBCOM_NIM8096MD                        0x1fa8
 #define USB_PID_DIBCOM_TFE8096P                                0x1f9C
 #define USB_PID_DIBCOM_ANCHOR_2135_COLD                        0x2131
 #define USB_PID_TECHNOTREND_CONNECT_CT3650             0x300d
 #define USB_PID_TECHNOTREND_CONNECT_S2_4600             0x3011
 #define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI                0x3012
+#define USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2      0x3015
 #define USB_PID_TECHNOTREND_TVSTICK_CT2_4400           0x3014
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY       0x005a
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY_2     0x0081
 #define USB_PID_TERRATEC_CINERGY_T_EXPRESS             0x0062
 #define USB_PID_TERRATEC_CINERGY_T_XXS                 0x0078
 #define USB_PID_TERRATEC_CINERGY_T_XXS_2               0x00ab
+#define USB_PID_TERRATEC_CINERGY_S2_R1                 0x00a8
+#define USB_PID_TERRATEC_CINERGY_S2_R2                 0x00b0
+#define USB_PID_TERRATEC_CINERGY_S2_R3                 0x0102
+#define USB_PID_TERRATEC_CINERGY_S2_R4                 0x0105
 #define USB_PID_TERRATEC_H7                            0x10b4
 #define USB_PID_TERRATEC_H7_2                          0x10a3
 #define USB_PID_TERRATEC_H7_3                          0x10a5
index 4008064..4c35eb4 100644 (file)
@@ -140,9 +140,12 @@ struct dvb_frontend_private {
 
 static void dvb_frontend_wakeup(struct dvb_frontend *fe);
 static int dtv_get_frontend(struct dvb_frontend *fe,
+                           struct dtv_frontend_properties *c,
                            struct dvb_frontend_parameters *p_out);
-static int dtv_property_legacy_params_sync(struct dvb_frontend *fe,
-                                          struct dvb_frontend_parameters *p);
+static int
+dtv_property_legacy_params_sync(struct dvb_frontend *fe,
+                               const struct dtv_frontend_properties *c,
+                               struct dvb_frontend_parameters *p);
 
 static bool has_get_frontend(struct dvb_frontend *fe)
 {
@@ -202,6 +205,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe,
                                   enum fe_status status)
 {
        struct dvb_frontend_private *fepriv = fe->frontend_priv;
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct dvb_fe_events *events = &fepriv->events;
        struct dvb_frontend_event *e;
        int wp;
@@ -209,7 +213,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe,
        dev_dbg(fe->dvb->device, "%s:\n", __func__);
 
        if ((status & FE_HAS_LOCK) && has_get_frontend(fe))
-               dtv_get_frontend(fe, &fepriv->parameters_out);
+               dtv_get_frontend(fe, c, &fepriv->parameters_out);
 
        mutex_lock(&events->mtx);
 
@@ -687,6 +691,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
 static int dvb_frontend_thread(void *data)
 {
        struct dvb_frontend *fe = data;
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct dvb_frontend_private *fepriv = fe->frontend_priv;
        enum fe_status s;
        enum dvbfe_algo algo;
@@ -807,7 +812,7 @@ restart:
                                        fepriv->algo_status |= DVBFE_ALGO_SEARCH_AGAIN;
                                        fepriv->delay = HZ / 2;
                                }
-                               dtv_property_legacy_params_sync(fe, &fepriv->parameters_out);
+                               dtv_property_legacy_params_sync(fe, c, &fepriv->parameters_out);
                                fe->ops.read_status(fe, &s);
                                if (s != fepriv->status) {
                                        dvb_frontend_add_event(fe, s); /* update event list */
@@ -899,10 +904,10 @@ void dvb_frontend_sleep_until(ktime_t *waketime, u32 add_usec)
        s32 delta;
 
        *waketime = ktime_add_us(*waketime, add_usec);
-       delta = ktime_us_delta(ktime_get_real(), *waketime);
+       delta = ktime_us_delta(ktime_get_boottime(), *waketime);
        if (delta > 2500) {
                msleep((delta - 1500) / 1000);
-               delta = ktime_us_delta(ktime_get_real(), *waketime);
+               delta = ktime_us_delta(ktime_get_boottime(), *waketime);
        }
        if (delta > 0)
                udelay(delta);
@@ -1162,18 +1167,24 @@ static struct dtv_cmds_h dtv_cmds[DTV_MAX_COMMAND + 1] = {
        _DTV_CMD(DTV_STAT_TOTAL_BLOCK_COUNT, 0, 0),
 };
 
-static void dtv_property_dump(struct dvb_frontend *fe, struct dtv_property *tvp)
+static void dtv_property_dump(struct dvb_frontend *fe,
+                             bool is_set,
+                             struct dtv_property *tvp)
 {
        int i;
 
        if (tvp->cmd <= 0 || tvp->cmd > DTV_MAX_COMMAND) {
-               dev_warn(fe->dvb->device, "%s: tvp.cmd = 0x%08x undefined\n",
-                               __func__, tvp->cmd);
+               dev_warn(fe->dvb->device, "%s: %s tvp.cmd = 0x%08x undefined\n",
+                               __func__,
+                               is_set ? "SET" : "GET",
+                               tvp->cmd);
                return;
        }
 
-       dev_dbg(fe->dvb->device, "%s: tvp.cmd    = 0x%08x (%s)\n", __func__,
-                       tvp->cmd, dtv_cmds[tvp->cmd].name);
+       dev_dbg(fe->dvb->device, "%s: %s tvp.cmd    = 0x%08x (%s)\n", __func__,
+               is_set ? "SET" : "GET",
+               tvp->cmd,
+               dtv_cmds[tvp->cmd].name);
 
        if (dtv_cmds[tvp->cmd].buffer) {
                dev_dbg(fe->dvb->device, "%s: tvp.u.buffer.len = 0x%02x\n",
@@ -1268,11 +1279,11 @@ static int dtv_property_cache_sync(struct dvb_frontend *fe,
 /* Ensure the cached values are set correctly in the frontend
  * legacy tuning structures, for the advanced tuning API.
  */
-static int dtv_property_legacy_params_sync(struct dvb_frontend *fe,
-                                           struct dvb_frontend_parameters *p)
+static int
+dtv_property_legacy_params_sync(struct dvb_frontend *fe,
+                               const struct dtv_frontend_properties *c,
+                               struct dvb_frontend_parameters *p)
 {
-       const struct dtv_frontend_properties *c = &fe->dtv_property_cache;
-
        p->frequency = c->frequency;
        p->inversion = c->inversion;
 
@@ -1344,16 +1355,17 @@ static int dtv_property_legacy_params_sync(struct dvb_frontend *fe,
  * If p_out is not null, it will update the DVBv3 params pointed by it.
  */
 static int dtv_get_frontend(struct dvb_frontend *fe,
+                           struct dtv_frontend_properties *c,
                            struct dvb_frontend_parameters *p_out)
 {
        int r;
 
        if (fe->ops.get_frontend) {
-               r = fe->ops.get_frontend(fe);
+               r = fe->ops.get_frontend(fe, c);
                if (unlikely(r < 0))
                        return r;
                if (p_out)
-                       dtv_property_legacy_params_sync(fe, p_out);
+                       dtv_property_legacy_params_sync(fe, c, p_out);
                return 0;
        }
 
@@ -1589,7 +1601,7 @@ static int dtv_property_process_get(struct dvb_frontend *fe,
                        return r;
        }
 
-       dtv_property_dump(fe, tvp);
+       dtv_property_dump(fe, false, tvp);
 
        return 0;
 }
@@ -1830,6 +1842,8 @@ static int dtv_property_process_set(struct dvb_frontend *fe,
                        return r;
        }
 
+       dtv_property_dump(fe, true, tvp);
+
        switch(tvp->cmd) {
        case DTV_CLEAR:
                /*
@@ -2073,6 +2087,8 @@ static int dvb_frontend_ioctl_properties(struct file *file,
                        dev_dbg(fe->dvb->device, "%s: Property cache is full, tuning\n", __func__);
 
        } else if (cmd == FE_GET_PROPERTY) {
+               struct dtv_frontend_properties getp = fe->dtv_property_cache;
+
                dev_dbg(fe->dvb->device, "%s: properties.num = %d\n", __func__, tvps->num);
                dev_dbg(fe->dvb->device, "%s: properties.props = %p\n", __func__, tvps->props);
 
@@ -2094,17 +2110,18 @@ static int dvb_frontend_ioctl_properties(struct file *file,
                }
 
                /*
-                * Fills the cache out struct with the cache contents, plus
-                * the data retrieved from get_frontend, if the frontend
-                * is not idle. Otherwise, returns the cached content
+                * Let's use our own copy of property cache, in order to
+                * avoid mangling with DTV zigzag logic, as drivers might
+                * return crap, if they don't check if the data is available
+                * before updating the properties cache.
                 */
                if (fepriv->state != FESTATE_IDLE) {
-                       err = dtv_get_frontend(fe, NULL);
+                       err = dtv_get_frontend(fe, &getp, NULL);
                        if (err < 0)
                                goto out;
                }
                for (i = 0; i < tvps->num; i++) {
-                       err = dtv_property_process_get(fe, c, tvp + i, file);
+                       err = dtv_property_process_get(fe, &getp, tvp + i, file);
                        if (err < 0)
                                goto out;
                        (tvp + i)->result = err;
@@ -2139,7 +2156,7 @@ static int dtv_set_frontend(struct dvb_frontend *fe)
         * the user. FE_SET_FRONTEND triggers an initial frontend event
         * with status = 0, which copies output parameters to userspace.
         */
-       dtv_property_legacy_params_sync(fe, &fepriv->parameters_out);
+       dtv_property_legacy_params_sync(fe, c, &fepriv->parameters_out);
 
        /*
         * Be sure that the bandwidth will be filled for all
@@ -2451,7 +2468,7 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
                        u8 last = 1;
                        if (dvb_frontend_debug)
                                printk("%s switch command: 0x%04lx\n", __func__, swcmd);
-                       nexttime = ktime_get_real();
+                       nexttime = ktime_get_boottime();
                        if (dvb_frontend_debug)
                                tv[0] = nexttime;
                        /* before sending a command, initialize by sending
@@ -2462,7 +2479,7 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
 
                        for (i = 0; i < 9; i++) {
                                if (dvb_frontend_debug)
-                                       tv[i+1] = ktime_get_real();
+                                       tv[i+1] = ktime_get_boottime();
                                if ((swcmd & 0x01) != last) {
                                        /* set voltage to (last ? 13V : 18V) */
                                        fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18);
@@ -2509,10 +2526,18 @@ static int dvb_frontend_ioctl_legacy(struct file *file,
                err = dvb_frontend_get_event (fe, parg, file->f_flags);
                break;
 
-       case FE_GET_FRONTEND:
-               err = dtv_get_frontend(fe, parg);
-               break;
+       case FE_GET_FRONTEND: {
+               struct dtv_frontend_properties getp = fe->dtv_property_cache;
 
+               /*
+                * Let's use our own copy of property cache, in order to
+                * avoid mangling with DTV zigzag logic, as drivers might
+                * return crap, if they don't check if the data is available
+                * before updating the properties cache.
+                */
+               err = dtv_get_frontend(fe, &getp, parg);
+               break;
+       }
        case FE_SET_FRONTEND_TUNE_MODE:
                fepriv->tune_mode_flags = (unsigned long) parg;
                err = 0;
index 458bcce..9592573 100644 (file)
@@ -449,7 +449,8 @@ struct dvb_frontend_ops {
        int (*set_frontend)(struct dvb_frontend *fe);
        int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
 
-       int (*get_frontend)(struct dvb_frontend *fe);
+       int (*get_frontend)(struct dvb_frontend *fe,
+                           struct dtv_frontend_properties *props);
 
        int (*read_status)(struct dvb_frontend *fe, enum fe_status *status);
        int (*read_ber)(struct dvb_frontend* fe, u32* ber);
index 560450a..1b9732e 100644 (file)
@@ -58,7 +58,7 @@ static const char * const dnames[] = {
 #define DVB_MAX_IDS            MAX_DVB_MINORS
 #else
 #define DVB_MAX_IDS            4
-#define nums2minor(num,type,id)        ((num << 6) | (id << 4) | type)
+#define nums2minor(num, type, id)      ((num << 6) | (id << 4) | type)
 #define MAX_DVB_MINORS         (DVB_MAX_ADAPTERS*64)
 #endif
 
@@ -85,7 +85,7 @@ static int dvb_device_open(struct inode *inode, struct file *file)
                file->private_data = dvbdev;
                replace_fops(file, new_fops);
                if (file->f_op->open)
-                       err = file->f_op->open(inode,file);
+                       err = file->f_op->open(inode, file);
                up_read(&minor_rwsem);
                mutex_unlock(&dvbdev_mutex);
                return err;
@@ -352,7 +352,7 @@ static int dvb_create_media_entity(struct dvb_device *dvbdev,
        ret = media_device_register_entity(dvbdev->adapter->mdev,
                                           dvbdev->entity);
        if (ret)
-               return (ret);
+               return ret;
 
        printk(KERN_DEBUG "%s: media entity '%s' registered.\n",
                __func__, dvbdev->entity->name);
@@ -620,8 +620,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,
                        return -ENOMEM;
                adap->conn = conn;
 
-               adap->conn_pads = kcalloc(1, sizeof(*adap->conn_pads),
-                                           GFP_KERNEL);
+               adap->conn_pads = kzalloc(sizeof(*adap->conn_pads), GFP_KERNEL);
                if (!adap->conn_pads)
                        return -ENOMEM;
 
@@ -661,7 +660,7 @@ int dvb_create_media_graph(struct dvb_adapter *adap,
        if (ntuner && ndemod) {
                ret = media_create_pad_links(mdev,
                                             MEDIA_ENT_F_TUNER,
-                                            tuner, TUNER_PAD_IF_OUTPUT,
+                                            tuner, TUNER_PAD_OUTPUT,
                                             MEDIA_ENT_F_DTV_DEMOD,
                                             demod, 0, MEDIA_LNK_FL_ENABLED,
                                             false);
@@ -868,7 +867,7 @@ int dvb_usercopy(struct file *file,
                        parg = sbuf;
                } else {
                        /* too big to allocate from stack */
-                       mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
+                       mbuf = kmalloc(_IOC_SIZE(cmd), GFP_KERNEL);
                        if (NULL == mbuf)
                                return -ENOMEM;
                        parg = mbuf;
index e23197d..8bcde33 100644 (file)
@@ -866,9 +866,9 @@ err:
        return ret;
 }
 
-static int af9013_get_frontend(struct dvb_frontend *fe)
+static int af9013_get_frontend(struct dvb_frontend *fe,
+                              struct dtv_frontend_properties *c)
 {
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct af9013_state *state = fe->demodulator_priv;
        int ret;
        u8 buf[3];
@@ -1344,6 +1344,10 @@ err:
 static void af9013_release(struct dvb_frontend *fe)
 {
        struct af9013_state *state = fe->demodulator_priv;
+
+       /* stop statistics polling */
+       cancel_delayed_work_sync(&state->statistics_work);
+
        kfree(state);
 }
 
index bc35206..efebe5c 100644 (file)
@@ -691,10 +691,10 @@ err:
        return ret;
 }
 
-static int af9033_get_frontend(struct dvb_frontend *fe)
+static int af9033_get_frontend(struct dvb_frontend *fe,
+                              struct dtv_frontend_properties *c)
 {
        struct af9033_dev *dev = fe->demodulator_priv;
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret;
        u8 buf[8];
 
@@ -1372,6 +1372,9 @@ static int af9033_remove(struct i2c_client *client)
 
        dev_dbg(&dev->client->dev, "\n");
 
+       /* stop statistics polling */
+       cancel_delayed_work_sync(&dev->stat_work);
+
        dev->fe.ops.release = NULL;
        dev->fe.demodulator_priv = NULL;
        kfree(dev);
index 544c5f6..9412fcd 100644 (file)
@@ -190,10 +190,10 @@ static int as102_fe_set_frontend(struct dvb_frontend *fe)
        return state->ops->set_tune(state->priv, &tune_args);
 }
 
-static int as102_fe_get_frontend(struct dvb_frontend *fe)
+static int as102_fe_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *c)
 {
        struct as102_state *state = fe->demodulator_priv;
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret = 0;
        struct as10x_tps tps = { 0 };
 
index 8fe552e..47248b8 100644 (file)
@@ -297,9 +297,9 @@ static int atbm8830_set_fe(struct dvb_frontend *fe)
        return 0;
 }
 
-static int atbm8830_get_fe(struct dvb_frontend *fe)
+static int atbm8830_get_fe(struct dvb_frontend *fe,
+                          struct dtv_frontend_properties *c)
 {
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        dprintk("%s\n", __func__);
 
        /* TODO: get real readings from device */
index 6c1e976..e676b94 100644 (file)
@@ -816,9 +816,9 @@ static int au8522_read_ber(struct dvb_frontend *fe, u32 *ber)
        return au8522_read_ucblocks(fe, ber);
 }
 
-static int au8522_get_frontend(struct dvb_frontend *fe)
+static int au8522_get_frontend(struct dvb_frontend *fe,
+                              struct dtv_frontend_properties *c)
 {
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct au8522_state *state = fe->demodulator_priv;
 
        c->frequency = state->current_frequency;
index d30275f..bb69883 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Copyright (C) 2001-5, B2C2 inc.
  *
- *  GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@desy.de>
+ *  GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@posteo.de>
  *
  *  This driver is "hard-coded" to be used with the 1st generation of
  *  Technisat/B2C2's Air2PC ATSC PCI/USB cards/boxes. The pll-programming
@@ -865,5 +865,5 @@ static struct dvb_frontend_ops bcm3510_ops = {
 };
 
 MODULE_DESCRIPTION("Broadcom BCM3510 ATSC (8VSB/16VSB & ITU J83 AnnexB FEC QAM64/256) demodulator driver");
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_LICENSE("GPL");
index ff66492..961c2eb 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Copyright (C) 2001-5, B2C2 inc.
  *
- *  GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@desy.de>
+ *  GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@posteo.de>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index 3bb1bc2..67f2468 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Copyright (C) 2001-5, B2C2 inc.
  *
- *  GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@desy.de>
+ *  GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@posteo.de>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index fd033cc..5cad925 100644 (file)
@@ -345,9 +345,9 @@ static int cx22700_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int cx22700_get_frontend(struct dvb_frontend *fe)
+static int cx22700_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *c)
 {
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct cx22700_state* state = fe->demodulator_priv;
        u8 reg09 = cx22700_readreg (state, 0x09);
 
index d2d06dc..c0e54c5 100644 (file)
@@ -562,9 +562,9 @@ static int cx22702_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
        return 0;
 }
 
-static int cx22702_get_frontend(struct dvb_frontend *fe)
+static int cx22702_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *c)
 {
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct cx22702_state *state = fe->demodulator_priv;
 
        u8 reg0C = cx22702_readreg(state, 0x0C);
index cb36475..6cb81ec 100644 (file)
@@ -550,9 +550,9 @@ static int cx24110_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int cx24110_get_frontend(struct dvb_frontend *fe)
+static int cx24110_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct cx24110_state *state = fe->demodulator_priv;
        s32 afc; unsigned sclk;
 
index 5f77bc8..a3f7eb4 100644 (file)
@@ -1560,10 +1560,10 @@ static int cx24117_get_algo(struct dvb_frontend *fe)
        return DVBFE_ALGO_HW;
 }
 
-static int cx24117_get_frontend(struct dvb_frontend *fe)
+static int cx24117_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *c)
 {
        struct cx24117_state *state = fe->demodulator_priv;
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct cx24117_cmd cmd;
        u8 reg, st, inv;
        int ret, idx;
index 3b0ef52..6ccbd86 100644 (file)
@@ -1502,9 +1502,9 @@ static int cx24120_sleep(struct dvb_frontend *fe)
        return 0;
 }
 
-static int cx24120_get_frontend(struct dvb_frontend *fe)
+static int cx24120_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *c)
 {
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct cx24120_state *state = fe->demodulator_priv;
        u8 freq1, freq2, freq3;
 
index 0fe7fb1..113b094 100644 (file)
@@ -945,9 +945,9 @@ static int cx24123_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int cx24123_get_frontend(struct dvb_frontend *fe)
+static int cx24123_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct cx24123_state *state = fe->demodulator_priv;
 
        dprintk("\n");
index 42fad6a..a674a63 100644 (file)
@@ -101,10 +101,10 @@ error:
        return ret;
 }
 
-int cxd2820r_get_frontend_c(struct dvb_frontend *fe)
+int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
+                           struct dtv_frontend_properties *c)
 {
        struct cxd2820r_priv *priv = fe->demodulator_priv;
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret;
        u8 buf[2];
 
index 24a457d..314d3b8 100644 (file)
@@ -313,7 +313,8 @@ static int cxd2820r_read_status(struct dvb_frontend *fe, enum fe_status *status)
        return ret;
 }
 
-static int cxd2820r_get_frontend(struct dvb_frontend *fe)
+static int cxd2820r_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *p)
 {
        struct cxd2820r_priv *priv = fe->demodulator_priv;
        int ret;
@@ -326,13 +327,13 @@ static int cxd2820r_get_frontend(struct dvb_frontend *fe)
 
        switch (fe->dtv_property_cache.delivery_system) {
        case SYS_DVBT:
-               ret = cxd2820r_get_frontend_t(fe);
+               ret = cxd2820r_get_frontend_t(fe, p);
                break;
        case SYS_DVBT2:
-               ret = cxd2820r_get_frontend_t2(fe);
+               ret = cxd2820r_get_frontend_t2(fe, p);
                break;
        case SYS_DVBC_ANNEX_A:
-               ret = cxd2820r_get_frontend_c(fe);
+               ret = cxd2820r_get_frontend_c(fe, p);
                break;
        default:
                ret = -EINVAL;
@@ -606,8 +607,7 @@ static int cxd2820r_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
 static int cxd2820r_gpio_direction_output(struct gpio_chip *chip, unsigned nr,
                int val)
 {
-       struct cxd2820r_priv *priv =
-                       container_of(chip, struct cxd2820r_priv, gpio_chip);
+       struct cxd2820r_priv *priv = gpiochip_get_data(chip);
        u8 gpio[GPIO_COUNT];
 
        dev_dbg(&priv->i2c->dev, "%s: nr=%d val=%d\n", __func__, nr, val);
@@ -620,8 +620,7 @@ static int cxd2820r_gpio_direction_output(struct gpio_chip *chip, unsigned nr,
 
 static void cxd2820r_gpio_set(struct gpio_chip *chip, unsigned nr, int val)
 {
-       struct cxd2820r_priv *priv =
-                       container_of(chip, struct cxd2820r_priv, gpio_chip);
+       struct cxd2820r_priv *priv = gpiochip_get_data(chip);
        u8 gpio[GPIO_COUNT];
 
        dev_dbg(&priv->i2c->dev, "%s: nr=%d val=%d\n", __func__, nr, val);
@@ -636,8 +635,7 @@ static void cxd2820r_gpio_set(struct gpio_chip *chip, unsigned nr, int val)
 
 static int cxd2820r_gpio_get(struct gpio_chip *chip, unsigned nr)
 {
-       struct cxd2820r_priv *priv =
-                       container_of(chip, struct cxd2820r_priv, gpio_chip);
+       struct cxd2820r_priv *priv = gpiochip_get_data(chip);
 
        dev_dbg(&priv->i2c->dev, "%s: nr=%d\n", __func__, nr);
 
@@ -731,7 +729,7 @@ struct dvb_frontend *cxd2820r_attach(const struct cxd2820r_config *cfg,
                priv->gpio_chip.base = -1; /* dynamic allocation */
                priv->gpio_chip.ngpio = GPIO_COUNT;
                priv->gpio_chip.can_sleep = 1;
-               ret = gpiochip_add(&priv->gpio_chip);
+               ret = gpiochip_add_data(&priv->gpio_chip, priv);
                if (ret)
                        goto error;
 
index a0d53f0..e31c48e 100644 (file)
@@ -76,7 +76,8 @@ int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val);
 
 /* cxd2820r_c.c */
 
-int cxd2820r_get_frontend_c(struct dvb_frontend *fe);
+int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
+                           struct dtv_frontend_properties *p);
 
 int cxd2820r_set_frontend_c(struct dvb_frontend *fe);
 
@@ -99,7 +100,8 @@ int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe,
 
 /* cxd2820r_t.c */
 
-int cxd2820r_get_frontend_t(struct dvb_frontend *fe);
+int cxd2820r_get_frontend_t(struct dvb_frontend *fe,
+                           struct dtv_frontend_properties *p);
 
 int cxd2820r_set_frontend_t(struct dvb_frontend *fe);
 
@@ -122,7 +124,8 @@ int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
 
 /* cxd2820r_t2.c */
 
-int cxd2820r_get_frontend_t2(struct dvb_frontend *fe);
+int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
+                            struct dtv_frontend_properties *p);
 
 int cxd2820r_set_frontend_t2(struct dvb_frontend *fe);
 
index 21abf1b..75ce7d8 100644 (file)
@@ -138,10 +138,10 @@ error:
        return ret;
 }
 
-int cxd2820r_get_frontend_t(struct dvb_frontend *fe)
+int cxd2820r_get_frontend_t(struct dvb_frontend *fe,
+                           struct dtv_frontend_properties *c)
 {
        struct cxd2820r_priv *priv = fe->demodulator_priv;
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret;
        u8 buf[2];
 
index 4e028b4..7044756 100644 (file)
@@ -23,8 +23,8 @@
 
 int cxd2820r_set_frontend_t2(struct dvb_frontend *fe)
 {
-       struct cxd2820r_priv *priv = fe->demodulator_priv;
        struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+       struct cxd2820r_priv *priv = fe->demodulator_priv;
        int ret, i, bw_i;
        u32 if_freq, if_ctl;
        u64 num;
@@ -169,10 +169,10 @@ error:
 
 }
 
-int cxd2820r_get_frontend_t2(struct dvb_frontend *fe)
+int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
+                            struct dtv_frontend_properties *c)
 {
        struct cxd2820r_priv *priv = fe->demodulator_priv;
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret;
        u8 buf[2];
 
index fdffb2f..900186b 100644 (file)
@@ -2090,13 +2090,13 @@ static int cxd2841er_sleep_tc_to_active_c(struct cxd2841er_priv *priv,
        return 0;
 }
 
-static int cxd2841er_get_frontend(struct dvb_frontend *fe)
+static int cxd2841er_get_frontend(struct dvb_frontend *fe,
+                                 struct dtv_frontend_properties *p)
 {
        enum fe_status status = 0;
        u16 strength = 0, snr = 0;
        u32 errors = 0, ber = 0;
        struct cxd2841er_priv *priv = fe->demodulator_priv;
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
 
        dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
        if (priv->state == STATE_ACTIVE_S)
index 0b8fb5d..ee7d669 100644 (file)
@@ -774,6 +774,6 @@ free_mem:
 }
 EXPORT_SYMBOL(dib0070_attach);
 
-MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for the DiBcom 0070 base-band RF Tuner");
 MODULE_LICENSE("GPL");
index 47cb722..976ee03 100644 (file)
@@ -2669,7 +2669,7 @@ free_mem:
 }
 EXPORT_SYMBOL(dib0090_fw_register);
 
-MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
-MODULE_AUTHOR("Olivier Grenie <olivier.grenie@dibcom.fr>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
+MODULE_AUTHOR("Olivier Grenie <olivier.grenie@parrot.com>");
 MODULE_DESCRIPTION("Driver for the DiBcom 0090 base-band RF Tuner");
 MODULE_LICENSE("GPL");
index 6ae9899..d5dfafb 100644 (file)
@@ -2,11 +2,11 @@
  * public header file of the frontend drivers for mobile DVB-T demodulators
  * DiBcom 3000M-B and DiBcom 3000P/M-C (http://www.dibcom.fr/)
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * based on GPL code from DibCom, which has
  *
- * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
+ * Copyright (C) 2004 Amaury Demol for DiBcom
  *
  *     This program is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU General Public License as
@@ -14,7 +14,7 @@
  *
  * Acknowledgements
  *
- *  Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
+ *  Amaury Demol from DiBcom for providing specs and driver
  *  sources, on which this driver (and the dvb-dibusb) are based.
  *
  * see Documentation/dvb/README.dvb-usb for more information
index 7a61172..6821ecb 100644 (file)
@@ -2,11 +2,11 @@
  * Frontend driver for mobile DVB-T demodulator DiBcom 3000M-B
  * DiBcom (http://www.dibcom.fr/)
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * based on GPL code from DibCom, which has
  *
- * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
+ * Copyright (C) 2004 Amaury Demol for DiBcom
  *
  *     This program is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU General Public License as
@@ -14,7 +14,7 @@
  *
  * Acknowledgements
  *
- *  Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
+ *  Amaury Demol from DiBcom for providing specs and driver
  *  sources, on which this driver (and the dvb-dibusb) are based.
  *
  * see Documentation/dvb/README.dvb-usb for more information
@@ -36,7 +36,7 @@
 /* Version information */
 #define DRIVER_VERSION "0.1"
 #define DRIVER_DESC "DiBcom 3000M-B DVB-T demodulator"
-#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de"
+#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@posteo.de"
 
 static int debug;
 module_param(debug, int, 0644);
@@ -112,7 +112,8 @@ static u16 dib3000_seq[2][2][2] =     /* fft,gua,   inv   */
                }
        };
 
-static int dib3000mb_get_frontend(struct dvb_frontend* fe);
+static int dib3000mb_get_frontend(struct dvb_frontend* fe,
+                                 struct dtv_frontend_properties *c);
 
 static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
 {
@@ -359,7 +360,7 @@ static int dib3000mb_set_frontend(struct dvb_frontend *fe, int tuner)
                deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count);
 
                if (search_state == 1) {
-                       if (dib3000mb_get_frontend(fe) == 0) {
+                       if (dib3000mb_get_frontend(fe, c) == 0) {
                                deb_setf("reading tuning data from frontend succeeded.\n");
                                return dib3000mb_set_frontend(fe, 0);
                        }
@@ -450,9 +451,9 @@ static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode)
        return 0;
 }
 
-static int dib3000mb_get_frontend(struct dvb_frontend* fe)
+static int dib3000mb_get_frontend(struct dvb_frontend* fe,
+                                 struct dtv_frontend_properties *c)
 {
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct dib3000_state* state = fe->demodulator_priv;
        enum fe_code_rate *cr;
        u16 tps_val;
index 9dc235a..0459d5c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * dib3000mb_priv.h
  *
- * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  *     This program is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU General Public License as
index 583d6b7..da0f1dc 100644 (file)
@@ -2,7 +2,7 @@
  * Driver for DiBcom DiB3000MC/P-demodulator.
  *
  * Copyright (C) 2004-7 DiBcom (http://www.dibcom.fr/)
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * This code is partially based on the previous dib3000mc.c .
  *
@@ -636,9 +636,9 @@ struct i2c_adapter * dib3000mc_get_tuner_i2c_master(struct dvb_frontend *demod,
 
 EXPORT_SYMBOL(dib3000mc_get_tuner_i2c_master);
 
-static int dib3000mc_get_frontend(struct dvb_frontend* fe)
+static int dib3000mc_get_frontend(struct dvb_frontend* fe,
+                                 struct dtv_frontend_properties *fep)
 {
-       struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
        struct dib3000mc_state *state = fe->demodulator_priv;
        u16 tps = dib3000mc_read_word(state,458);
 
@@ -726,7 +726,7 @@ static int dib3000mc_set_frontend(struct dvb_frontend *fe)
                if (found == 0 || found == 1)
                        return 0; // no channel found
 
-               dib3000mc_get_frontend(fe);
+               dib3000mc_get_frontend(fe, fep);
        }
 
        ret = dib3000mc_tune(fe);
@@ -939,6 +939,6 @@ static struct dvb_frontend_ops dib3000mc_ops = {
        .read_ucblocks        = dib3000mc_read_unc_blocks,
 };
 
-MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for the DiBcom 3000MC/P COFDM demodulator");
 MODULE_LICENSE("GPL");
index 74816f7..b37e69e 100644 (file)
@@ -2,7 +2,7 @@
  * Driver for DiBcom DiB3000MC/P-demodulator.
  *
  * Copyright (C) 2004-6 DiBcom (http://www.dibcom.fr/)
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher\@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * This code is partially based on the previous dib3000mc.c .
  *
index 35eb71f..b3ddae8 100644 (file)
@@ -1151,9 +1151,9 @@ static int dib7000m_identify(struct dib7000m_state *state)
 }
 
 
-static int dib7000m_get_frontend(struct dvb_frontend* fe)
+static int dib7000m_get_frontend(struct dvb_frontend* fe,
+                                struct dtv_frontend_properties *fep)
 {
-       struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
        struct dib7000m_state *state = fe->demodulator_priv;
        u16 tps = dib7000m_read_word(state,480);
 
@@ -1246,7 +1246,7 @@ static int dib7000m_set_frontend(struct dvb_frontend *fe)
                if (found == 0 || found == 1)
                        return 0; // no channel found
 
-               dib7000m_get_frontend(fe);
+               dib7000m_get_frontend(fe, fep);
        }
 
        ret = dib7000m_tune(fe);
@@ -1465,6 +1465,6 @@ static struct dvb_frontend_ops dib7000m_ops = {
        .read_ucblocks        = dib7000m_read_unc_blocks,
 };
 
-MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for the DiBcom 7000MA/MB/PA/PB/MC COFDM demodulator");
 MODULE_LICENSE("GPL");
index 33be5d6..b861d44 100644 (file)
@@ -1405,9 +1405,9 @@ static int dib7000p_identify(struct dib7000p_state *st)
        return 0;
 }
 
-static int dib7000p_get_frontend(struct dvb_frontend *fe)
+static int dib7000p_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *fep)
 {
-       struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
        struct dib7000p_state *state = fe->demodulator_priv;
        u16 tps = dib7000p_read_word(state, 463);
 
@@ -1540,7 +1540,7 @@ static int dib7000p_set_frontend(struct dvb_frontend *fe)
                if (found == 0 || found == 1)
                        return 0;
 
-               dib7000p_get_frontend(fe);
+               dib7000p_get_frontend(fe, fep);
        }
 
        ret = dib7000p_tune(fe);
@@ -2834,7 +2834,7 @@ static struct dvb_frontend_ops dib7000p_ops = {
        .read_ucblocks = dib7000p_read_unc_blocks,
 };
 
-MODULE_AUTHOR("Olivier Grenie <ogrenie@dibcom.fr>");
-MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
+MODULE_AUTHOR("Olivier Grenie <olivie.grenie@parrot.com>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for the DiBcom 7000PC COFDM demodulator");
 MODULE_LICENSE("GPL");
index 94c2627..ddf9c44 100644 (file)
@@ -3382,14 +3382,15 @@ static int dib8000_sleep(struct dvb_frontend *fe)
 
 static int dib8000_read_status(struct dvb_frontend *fe, enum fe_status *stat);
 
-static int dib8000_get_frontend(struct dvb_frontend *fe)
+static int dib8000_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *c)
 {
        struct dib8000_state *state = fe->demodulator_priv;
        u16 i, val = 0;
        enum fe_status stat = 0;
        u8 index_frontend, sub_index_frontend;
 
-       fe->dtv_property_cache.bandwidth_hz = 6000000;
+       c->bandwidth_hz = 6000000;
 
        /*
         * If called to early, get_frontend makes dib8000_tune to either
@@ -3406,7 +3407,7 @@ static int dib8000_get_frontend(struct dvb_frontend *fe)
                if (stat&FE_HAS_SYNC) {
                        dprintk("TMCC lock on the slave%i", index_frontend);
                        /* synchronize the cache with the other frontends */
-                       state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend]);
+                       state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], c);
                        for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL); sub_index_frontend++) {
                                if (sub_index_frontend != index_frontend) {
                                        state->fe[sub_index_frontend]->dtv_property_cache.isdbt_sb_mode = state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode;
@@ -3426,57 +3427,57 @@ static int dib8000_get_frontend(struct dvb_frontend *fe)
                }
        }
 
-       fe->dtv_property_cache.isdbt_sb_mode = dib8000_read_word(state, 508) & 0x1;
+       c->isdbt_sb_mode = dib8000_read_word(state, 508) & 0x1;
 
        if (state->revision == 0x8090)
                val = dib8000_read_word(state, 572);
        else
                val = dib8000_read_word(state, 570);
-       fe->dtv_property_cache.inversion = (val & 0x40) >> 6;
+       c->inversion = (val & 0x40) >> 6;
        switch ((val & 0x30) >> 4) {
        case 1:
-               fe->dtv_property_cache.transmission_mode = TRANSMISSION_MODE_2K;
+               c->transmission_mode = TRANSMISSION_MODE_2K;
                dprintk("dib8000_get_frontend: transmission mode 2K");
                break;
        case 2:
-               fe->dtv_property_cache.transmission_mode = TRANSMISSION_MODE_4K;
+               c->transmission_mode = TRANSMISSION_MODE_4K;
                dprintk("dib8000_get_frontend: transmission mode 4K");
                break;
        case 3:
        default:
-               fe->dtv_property_cache.transmission_mode = TRANSMISSION_MODE_8K;
+               c->transmission_mode = TRANSMISSION_MODE_8K;
                dprintk("dib8000_get_frontend: transmission mode 8K");
                break;
        }
 
        switch (val & 0x3) {
        case 0:
-               fe->dtv_property_cache.guard_interval = GUARD_INTERVAL_1_32;
+               c->guard_interval = GUARD_INTERVAL_1_32;
                dprintk("dib8000_get_frontend: Guard Interval = 1/32 ");
                break;
        case 1:
-               fe->dtv_property_cache.guard_interval = GUARD_INTERVAL_1_16;
+               c->guard_interval = GUARD_INTERVAL_1_16;
                dprintk("dib8000_get_frontend: Guard Interval = 1/16 ");
                break;
        case 2:
                dprintk("dib8000_get_frontend: Guard Interval = 1/8 ");
-               fe->dtv_property_cache.guard_interval = GUARD_INTERVAL_1_8;
+               c->guard_interval = GUARD_INTERVAL_1_8;
                break;
        case 3:
                dprintk("dib8000_get_frontend: Guard Interval = 1/4 ");
-               fe->dtv_property_cache.guard_interval = GUARD_INTERVAL_1_4;
+               c->guard_interval = GUARD_INTERVAL_1_4;
                break;
        }
 
        val = dib8000_read_word(state, 505);
-       fe->dtv_property_cache.isdbt_partial_reception = val & 1;
-       dprintk("dib8000_get_frontend: partial_reception = %d ", fe->dtv_property_cache.isdbt_partial_reception);
+       c->isdbt_partial_reception = val & 1;
+       dprintk("dib8000_get_frontend: partial_reception = %d ", c->isdbt_partial_reception);
 
        for (i = 0; i < 3; i++) {
                int show;
 
                val = dib8000_read_word(state, 493 + i) & 0x0f;
-               fe->dtv_property_cache.layer[i].segment_count = val;
+               c->layer[i].segment_count = val;
 
                if (val == 0 || val > 13)
                        show = 0;
@@ -3485,41 +3486,41 @@ static int dib8000_get_frontend(struct dvb_frontend *fe)
 
                if (show)
                        dprintk("dib8000_get_frontend: Layer %d segments = %d ",
-                               i, fe->dtv_property_cache.layer[i].segment_count);
+                               i, c->layer[i].segment_count);
 
                val = dib8000_read_word(state, 499 + i) & 0x3;
                /* Interleaving can be 0, 1, 2 or 4 */
                if (val == 3)
                        val = 4;
-               fe->dtv_property_cache.layer[i].interleaving = val;
+               c->layer[i].interleaving = val;
                if (show)
                        dprintk("dib8000_get_frontend: Layer %d time_intlv = %d ",
-                               i, fe->dtv_property_cache.layer[i].interleaving);
+                               i, c->layer[i].interleaving);
 
                val = dib8000_read_word(state, 481 + i);
                switch (val & 0x7) {
                case 1:
-                       fe->dtv_property_cache.layer[i].fec = FEC_1_2;
+                       c->layer[i].fec = FEC_1_2;
                        if (show)
                                dprintk("dib8000_get_frontend: Layer %d Code Rate = 1/2 ", i);
                        break;
                case 2:
-                       fe->dtv_property_cache.layer[i].fec = FEC_2_3;
+                       c->layer[i].fec = FEC_2_3;
                        if (show)
                                dprintk("dib8000_get_frontend: Layer %d Code Rate = 2/3 ", i);
                        break;
                case 3:
-                       fe->dtv_property_cache.layer[i].fec = FEC_3_4;
+                       c->layer[i].fec = FEC_3_4;
                        if (show)
                                dprintk("dib8000_get_frontend: Layer %d Code Rate = 3/4 ", i);
                        break;
                case 5:
-                       fe->dtv_property_cache.layer[i].fec = FEC_5_6;
+                       c->layer[i].fec = FEC_5_6;
                        if (show)
                                dprintk("dib8000_get_frontend: Layer %d Code Rate = 5/6 ", i);
                        break;
                default:
-                       fe->dtv_property_cache.layer[i].fec = FEC_7_8;
+                       c->layer[i].fec = FEC_7_8;
                        if (show)
                                dprintk("dib8000_get_frontend: Layer %d Code Rate = 7/8 ", i);
                        break;
@@ -3528,23 +3529,23 @@ static int dib8000_get_frontend(struct dvb_frontend *fe)
                val = dib8000_read_word(state, 487 + i);
                switch (val & 0x3) {
                case 0:
-                       fe->dtv_property_cache.layer[i].modulation = DQPSK;
+                       c->layer[i].modulation = DQPSK;
                        if (show)
                                dprintk("dib8000_get_frontend: Layer %d DQPSK ", i);
                        break;
                case 1:
-                       fe->dtv_property_cache.layer[i].modulation = QPSK;
+                       c->layer[i].modulation = QPSK;
                        if (show)
                                dprintk("dib8000_get_frontend: Layer %d QPSK ", i);
                        break;
                case 2:
-                       fe->dtv_property_cache.layer[i].modulation = QAM_16;
+                       c->layer[i].modulation = QAM_16;
                        if (show)
                                dprintk("dib8000_get_frontend: Layer %d QAM16 ", i);
                        break;
                case 3:
                default:
-                       fe->dtv_property_cache.layer[i].modulation = QAM_64;
+                       c->layer[i].modulation = QAM_64;
                        if (show)
                                dprintk("dib8000_get_frontend: Layer %d QAM64 ", i);
                        break;
@@ -3553,16 +3554,16 @@ static int dib8000_get_frontend(struct dvb_frontend *fe)
 
        /* synchronize the cache with the other frontends */
        for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
-               state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode = fe->dtv_property_cache.isdbt_sb_mode;
-               state->fe[index_frontend]->dtv_property_cache.inversion = fe->dtv_property_cache.inversion;
-               state->fe[index_frontend]->dtv_property_cache.transmission_mode = fe->dtv_property_cache.transmission_mode;
-               state->fe[index_frontend]->dtv_property_cache.guard_interval = fe->dtv_property_cache.guard_interval;
-               state->fe[index_frontend]->dtv_property_cache.isdbt_partial_reception = fe->dtv_property_cache.isdbt_partial_reception;
+               state->fe[index_frontend]->dtv_property_cache.isdbt_sb_mode = c->isdbt_sb_mode;
+               state->fe[index_frontend]->dtv_property_cache.inversion = c->inversion;
+               state->fe[index_frontend]->dtv_property_cache.transmission_mode = c->transmission_mode;
+               state->fe[index_frontend]->dtv_property_cache.guard_interval = c->guard_interval;
+               state->fe[index_frontend]->dtv_property_cache.isdbt_partial_reception = c->isdbt_partial_reception;
                for (i = 0; i < 3; i++) {
-                       state->fe[index_frontend]->dtv_property_cache.layer[i].segment_count = fe->dtv_property_cache.layer[i].segment_count;
-                       state->fe[index_frontend]->dtv_property_cache.layer[i].interleaving = fe->dtv_property_cache.layer[i].interleaving;
-                       state->fe[index_frontend]->dtv_property_cache.layer[i].fec = fe->dtv_property_cache.layer[i].fec;
-                       state->fe[index_frontend]->dtv_property_cache.layer[i].modulation = fe->dtv_property_cache.layer[i].modulation;
+                       state->fe[index_frontend]->dtv_property_cache.layer[i].segment_count = c->layer[i].segment_count;
+                       state->fe[index_frontend]->dtv_property_cache.layer[i].interleaving = c->layer[i].interleaving;
+                       state->fe[index_frontend]->dtv_property_cache.layer[i].fec = c->layer[i].fec;
+                       state->fe[index_frontend]->dtv_property_cache.layer[i].modulation = c->layer[i].modulation;
                }
        }
        return 0;
@@ -3671,7 +3672,7 @@ static int dib8000_set_frontend(struct dvb_frontend *fe)
                        if (state->channel_parameters_set == 0) { /* searching */
                                if ((dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_DEMOD_SUCCESS) || (dib8000_get_status(state->fe[index_frontend]) == FE_STATUS_FFT_SUCCESS)) {
                                        dprintk("autosearch succeeded on fe%i", index_frontend);
-                                       dib8000_get_frontend(state->fe[index_frontend]); /* we read the channel parameters from the frontend which was successful */
+                                       dib8000_get_frontend(state->fe[index_frontend], c); /* we read the channel parameters from the frontend which was successful */
                                        state->channel_parameters_set = 1;
 
                                        for (l = 0; (l < MAX_NUMBER_OF_FRONTENDS) && (state->fe[l] != NULL); l++) {
@@ -4516,6 +4517,6 @@ void *dib8000_attach(struct dib8000_ops *ops)
 }
 EXPORT_SYMBOL(dib8000_attach);
 
-MODULE_AUTHOR("Olivier Grenie <Olivier.Grenie@dibcom.fr, " "Patrick Boettcher <pboettcher@dibcom.fr>");
+MODULE_AUTHOR("Olivier Grenie <Olivier.Grenie@parrot.com, Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for the DiBcom 8000 ISDB-T demodulator");
 MODULE_LICENSE("GPL");
index 8f92aca..bab8c5a 100644 (file)
@@ -1889,7 +1889,8 @@ static int dib9000_fe_get_tune_settings(struct dvb_frontend *fe, struct dvb_fron
        return 0;
 }
 
-static int dib9000_get_frontend(struct dvb_frontend *fe)
+static int dib9000_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *c)
 {
        struct dib9000_state *state = fe->demodulator_priv;
        u8 index_frontend, sub_index_frontend;
@@ -1909,7 +1910,7 @@ static int dib9000_get_frontend(struct dvb_frontend *fe)
                        dprintk("TPS lock on the slave%i", index_frontend);
 
                        /* synchronize the cache with the other frontends */
-                       state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend]);
+                       state->fe[index_frontend]->ops.get_frontend(state->fe[index_frontend], c);
                        for (sub_index_frontend = 0; (sub_index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[sub_index_frontend] != NULL);
                             sub_index_frontend++) {
                                if (sub_index_frontend != index_frontend) {
@@ -1943,14 +1944,14 @@ static int dib9000_get_frontend(struct dvb_frontend *fe)
 
        /* synchronize the cache with the other frontends */
        for (index_frontend = 1; (index_frontend < MAX_NUMBER_OF_FRONTENDS) && (state->fe[index_frontend] != NULL); index_frontend++) {
-               state->fe[index_frontend]->dtv_property_cache.inversion = fe->dtv_property_cache.inversion;
-               state->fe[index_frontend]->dtv_property_cache.transmission_mode = fe->dtv_property_cache.transmission_mode;
-               state->fe[index_frontend]->dtv_property_cache.guard_interval = fe->dtv_property_cache.guard_interval;
-               state->fe[index_frontend]->dtv_property_cache.modulation = fe->dtv_property_cache.modulation;
-               state->fe[index_frontend]->dtv_property_cache.hierarchy = fe->dtv_property_cache.hierarchy;
-               state->fe[index_frontend]->dtv_property_cache.code_rate_HP = fe->dtv_property_cache.code_rate_HP;
-               state->fe[index_frontend]->dtv_property_cache.code_rate_LP = fe->dtv_property_cache.code_rate_LP;
-               state->fe[index_frontend]->dtv_property_cache.rolloff = fe->dtv_property_cache.rolloff;
+               state->fe[index_frontend]->dtv_property_cache.inversion = c->inversion;
+               state->fe[index_frontend]->dtv_property_cache.transmission_mode = c->transmission_mode;
+               state->fe[index_frontend]->dtv_property_cache.guard_interval = c->guard_interval;
+               state->fe[index_frontend]->dtv_property_cache.modulation = c->modulation;
+               state->fe[index_frontend]->dtv_property_cache.hierarchy = c->hierarchy;
+               state->fe[index_frontend]->dtv_property_cache.code_rate_HP = c->code_rate_HP;
+               state->fe[index_frontend]->dtv_property_cache.code_rate_LP = c->code_rate_LP;
+               state->fe[index_frontend]->dtv_property_cache.rolloff = c->rolloff;
        }
        ret = 0;
 
@@ -2083,7 +2084,7 @@ static int dib9000_set_frontend(struct dvb_frontend *fe)
 
        /* synchronize all the channel cache */
        state->get_frontend_internal = 1;
-       dib9000_get_frontend(state->fe[0]);
+       dib9000_get_frontend(state->fe[0], &state->fe[0]->dtv_property_cache);
        state->get_frontend_internal = 0;
 
        /* retune the other frontends with the found channel */
@@ -2589,7 +2590,7 @@ static struct dvb_frontend_ops dib9000_ops = {
        .read_ucblocks = dib9000_read_unc_blocks,
 };
 
-MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
-MODULE_AUTHOR("Olivier Grenie <ogrenie@dibcom.fr>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
+MODULE_AUTHOR("Olivier Grenie <olivier.grenie@parrot.com>");
 MODULE_DESCRIPTION("Driver for the DiBcom 9000 COFDM demodulator");
 MODULE_LICENSE("GPL");
index 43be723..723358d 100644 (file)
@@ -510,6 +510,6 @@ u32 systime(void)
 }
 EXPORT_SYMBOL(systime);
 
-MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Common function the DiBcom demodulator family");
 MODULE_LICENSE("GPL");
index 14e996d..e5bd8c6 100644 (file)
@@ -70,9 +70,12 @@ static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
 }
 
 /*
- * Only needed if it actually reads something from the hardware
+ * Should only be implemented if it actually reads something from the hardware.
+ * Also, it should check for the locks, in order to avoid report wrong data
+ * to userspace.
  */
-static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe)
+static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe,
+                                    struct dtv_frontend_properties *p)
 {
        return 0;
 }
index 40e359f..1c7eb47 100644 (file)
@@ -560,11 +560,11 @@ static int hd29l2_get_frontend_algo(struct dvb_frontend *fe)
        return DVBFE_ALGO_CUSTOM;
 }
 
-static int hd29l2_get_frontend(struct dvb_frontend *fe)
+static int hd29l2_get_frontend(struct dvb_frontend *fe,
+                              struct dtv_frontend_properties *c)
 {
        int ret;
        struct hd29l2_priv *priv = fe->demodulator_priv;
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        u8 buf[3];
        u32 if_ctl;
        char *str_constellation, *str_code_rate, *str_constellation_code_rate,
index 0977871..2f3d051 100644 (file)
@@ -243,9 +243,9 @@ static int apply_frontend_param(struct dvb_frontend *fe)
        return 0;
 }
 
-static int get_frontend(struct dvb_frontend *fe)
+static int get_frontend(struct dvb_frontend *fe,
+                       struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct l64781_state* state = fe->demodulator_priv;
        int tmp;
 
index 7880f71..f51a3a0 100644 (file)
@@ -942,101 +942,102 @@ static int lg216x_read_rs_err_count(struct lg216x_state *state, u16 *err)
 
 /* ------------------------------------------------------------------------ */
 
-static int lg216x_get_frontend(struct dvb_frontend *fe)
+static int lg216x_get_frontend(struct dvb_frontend *fe,
+                              struct dtv_frontend_properties *c)
 {
        struct lg216x_state *state = fe->demodulator_priv;
        int ret;
 
        lg_dbg("\n");
 
-       fe->dtv_property_cache.modulation = VSB_8;
-       fe->dtv_property_cache.frequency = state->current_frequency;
-       fe->dtv_property_cache.delivery_system = SYS_ATSCMH;
+       c->modulation = VSB_8;
+       c->frequency = state->current_frequency;
+       c->delivery_system = SYS_ATSCMH;
 
        ret = lg216x_get_fic_version(state,
-                                    &fe->dtv_property_cache.atscmh_fic_ver);
+                                    &c->atscmh_fic_ver);
        if (lg_fail(ret))
                goto fail;
-       if (state->fic_ver != fe->dtv_property_cache.atscmh_fic_ver) {
-               state->fic_ver = fe->dtv_property_cache.atscmh_fic_ver;
+       if (state->fic_ver != c->atscmh_fic_ver) {
+               state->fic_ver = c->atscmh_fic_ver;
 
 #if 0
                ret = lg2160_get_parade_id(state,
-                               &fe->dtv_property_cache.atscmh_parade_id);
+                               &c->atscmh_parade_id);
                if (lg_fail(ret))
                        goto fail;
 /* #else */
-               fe->dtv_property_cache.atscmh_parade_id = state->parade_id;
+               c->atscmh_parade_id = state->parade_id;
 #endif
                ret = lg216x_get_nog(state,
-                                    &fe->dtv_property_cache.atscmh_nog);
+                                    &c->atscmh_nog);
                if (lg_fail(ret))
                        goto fail;
                ret = lg216x_get_tnog(state,
-                                     &fe->dtv_property_cache.atscmh_tnog);
+                                     &c->atscmh_tnog);
                if (lg_fail(ret))
                        goto fail;
                ret = lg216x_get_sgn(state,
-                                    &fe->dtv_property_cache.atscmh_sgn);
+                                    &c->atscmh_sgn);
                if (lg_fail(ret))
                        goto fail;
                ret = lg216x_get_prc(state,
-                                    &fe->dtv_property_cache.atscmh_prc);
+                                    &c->atscmh_prc);
                if (lg_fail(ret))
                        goto fail;
 
                ret = lg216x_get_rs_frame_mode(state,
                        (enum atscmh_rs_frame_mode *)
-                       &fe->dtv_property_cache.atscmh_rs_frame_mode);
+                       &c->atscmh_rs_frame_mode);
                if (lg_fail(ret))
                        goto fail;
                ret = lg216x_get_rs_frame_ensemble(state,
                        (enum atscmh_rs_frame_ensemble *)
-                       &fe->dtv_property_cache.atscmh_rs_frame_ensemble);
+                       &c->atscmh_rs_frame_ensemble);
                if (lg_fail(ret))
                        goto fail;
                ret = lg216x_get_rs_code_mode(state,
                        (enum atscmh_rs_code_mode *)
-                       &fe->dtv_property_cache.atscmh_rs_code_mode_pri,
+                       &c->atscmh_rs_code_mode_pri,
                        (enum atscmh_rs_code_mode *)
-                       &fe->dtv_property_cache.atscmh_rs_code_mode_sec);
+                       &c->atscmh_rs_code_mode_sec);
                if (lg_fail(ret))
                        goto fail;
                ret = lg216x_get_sccc_block_mode(state,
                        (enum atscmh_sccc_block_mode *)
-                       &fe->dtv_property_cache.atscmh_sccc_block_mode);
+                       &c->atscmh_sccc_block_mode);
                if (lg_fail(ret))
                        goto fail;
                ret = lg216x_get_sccc_code_mode(state,
                        (enum atscmh_sccc_code_mode *)
-                       &fe->dtv_property_cache.atscmh_sccc_code_mode_a,
+                       &c->atscmh_sccc_code_mode_a,
                        (enum atscmh_sccc_code_mode *)
-                       &fe->dtv_property_cache.atscmh_sccc_code_mode_b,
+                       &c->atscmh_sccc_code_mode_b,
                        (enum atscmh_sccc_code_mode *)
-                       &fe->dtv_property_cache.atscmh_sccc_code_mode_c,
+                       &c->atscmh_sccc_code_mode_c,
                        (enum atscmh_sccc_code_mode *)
-                       &fe->dtv_property_cache.atscmh_sccc_code_mode_d);
+                       &c->atscmh_sccc_code_mode_d);
                if (lg_fail(ret))
                        goto fail;
        }
 #if 0
        ret = lg216x_read_fic_err_count(state,
-                               (u8 *)&fe->dtv_property_cache.atscmh_fic_err);
+                               (u8 *)&c->atscmh_fic_err);
        if (lg_fail(ret))
                goto fail;
        ret = lg216x_read_crc_err_count(state,
-                               &fe->dtv_property_cache.atscmh_crc_err);
+                               &c->atscmh_crc_err);
        if (lg_fail(ret))
                goto fail;
        ret = lg216x_read_rs_err_count(state,
-                               &fe->dtv_property_cache.atscmh_rs_err);
+                               &c->atscmh_rs_err);
        if (lg_fail(ret))
                goto fail;
 
        switch (state->cfg->lg_chip) {
        case LG2160:
-               if (((fe->dtv_property_cache.atscmh_rs_err >= 240) &&
-                    (fe->dtv_property_cache.atscmh_crc_err >= 240)) &&
+               if (((c->atscmh_rs_err >= 240) &&
+                    (c->atscmh_crc_err >= 240)) &&
                    ((jiffies_to_msecs(jiffies) - state->last_reset) > 6000))
                        ret = lg216x_soft_reset(state);
                break;
@@ -1054,14 +1055,17 @@ fail:
 static int lg216x_get_property(struct dvb_frontend *fe,
                               struct dtv_property *tvp)
 {
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+
        return (DTV_ATSCMH_FIC_VER == tvp->cmd) ?
-               lg216x_get_frontend(fe) : 0;
+               lg216x_get_frontend(fe, c) : 0;
 }
 
 
 static int lg2160_set_frontend(struct dvb_frontend *fe)
 {
        struct lg216x_state *state = fe->demodulator_priv;
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret;
 
        lg_dbg("(%d)\n", fe->dtv_property_cache.frequency);
@@ -1129,7 +1133,7 @@ static int lg2160_set_frontend(struct dvb_frontend *fe)
        ret = lg216x_enable_fic(state, 1);
        lg_fail(ret);
 
-       lg216x_get_frontend(fe);
+       lg216x_get_frontend(fe, c);
 fail:
        return ret;
 }
index 4712186..4503e88 100644 (file)
@@ -812,9 +812,9 @@ fail:
        return ret;
 }
 
-static int lgdt3305_get_frontend(struct dvb_frontend *fe)
+static int lgdt3305_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct lgdt3305_state *state = fe->demodulator_priv;
 
        lg_dbg("\n");
index 721fbc0..179c26e 100644 (file)
@@ -1040,10 +1040,10 @@ fail:
        return ret;
 }
 
-static int lgdt3306a_get_frontend(struct dvb_frontend *fe)
+static int lgdt3306a_get_frontend(struct dvb_frontend *fe,
+                                 struct dtv_frontend_properties *p)
 {
        struct lgdt3306a_state *state = fe->demodulator_priv;
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
 
        dbg_info("(%u, %d)\n",
                 state->current_frequency, state->current_modulation);
index cf3cc20..96bf254 100644 (file)
@@ -439,10 +439,11 @@ static int lgdt330x_set_parameters(struct dvb_frontend *fe)
        return 0;
 }
 
-static int lgdt330x_get_frontend(struct dvb_frontend *fe)
+static int lgdt330x_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct lgdt330x_state *state = fe->demodulator_priv;
+
        p->frequency = state->current_frequency;
        return 0;
 }
index 7bbb2c1..fbfd87b 100644 (file)
@@ -336,10 +336,11 @@ lgs8gl5_set_frontend(struct dvb_frontend *fe)
 
 
 static int
-lgs8gl5_get_frontend(struct dvb_frontend *fe)
+lgs8gl5_get_frontend(struct dvb_frontend *fe,
+                    struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct lgs8gl5_state *state = fe->demodulator_priv;
+
        u8 inv = lgs8gl5_read_reg(state, REG_INVERSION);
 
        p->inversion = (inv & REG_INVERSION_ON) ? INVERSION_ON : INVERSION_OFF;
index e2c191c..919daeb 100644 (file)
@@ -672,7 +672,7 @@ static int lgs8gxx_write(struct dvb_frontend *fe, const u8 buf[], int len)
 
 static int lgs8gxx_set_fe(struct dvb_frontend *fe)
 {
-
+       struct dtv_frontend_properties *fe_params = &fe->dtv_property_cache;
        struct lgs8gxx_state *priv = fe->demodulator_priv;
 
        dprintk("%s\n", __func__);
@@ -689,17 +689,7 @@ static int lgs8gxx_set_fe(struct dvb_frontend *fe)
 
        msleep(10);
 
-       return 0;
-}
-
-static int lgs8gxx_get_fe(struct dvb_frontend *fe)
-{
-       struct dtv_frontend_properties *fe_params = &fe->dtv_property_cache;
-       dprintk("%s\n", __func__);
-
        /* TODO: get real readings from device */
-       /* inversion status */
-       fe_params->inversion = INVERSION_OFF;
 
        /* bandwidth */
        fe_params->bandwidth_hz = 8000000;
@@ -1016,7 +1006,6 @@ static struct dvb_frontend_ops lgs8gxx_ops = {
        .i2c_gate_ctrl = lgs8gxx_i2c_gate_ctrl,
 
        .set_frontend = lgs8gxx_set_fe,
-       .get_frontend = lgs8gxx_get_fe,
        .get_tune_settings = lgs8gxx_get_tune_settings,
 
        .read_status = lgs8gxx_read_status,
index ce73a5e..7688360 100644 (file)
@@ -791,11 +791,11 @@ err:
        return ret;
 }
 
-static int m88ds3103_get_frontend(struct dvb_frontend *fe)
+static int m88ds3103_get_frontend(struct dvb_frontend *fe,
+                                 struct dtv_frontend_properties *c)
 {
        struct m88ds3103_dev *dev = fe->demodulator_priv;
        struct i2c_client *client = dev->client;
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret;
        u8 buf[3];
 
index 9b6f464..a09b123 100644 (file)
@@ -708,10 +708,11 @@ static int m88rs2000_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int m88rs2000_get_frontend(struct dvb_frontend *fe)
+static int m88rs2000_get_frontend(struct dvb_frontend *fe,
+                                 struct dtv_frontend_properties *c)
 {
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct m88rs2000_state *state = fe->demodulator_priv;
+
        c->fec_inner = state->fec_inner;
        c->frequency = state->tuner_frequency;
        c->symbol_rate = state->symbol_rate;
index cfc005e..fb88ddd 100644 (file)
@@ -2028,16 +2028,6 @@ static int mb86a20s_read_signal_strength_from_cache(struct dvb_frontend *fe,
        return 0;
 }
 
-static int mb86a20s_get_frontend_dummy(struct dvb_frontend *fe)
-{
-       /*
-        * get_frontend is now handled together with other stats
-        * retrival, when read_status() is called, as some statistics
-        * will depend on the layers detection.
-        */
-       return 0;
-};
-
 static int mb86a20s_tune(struct dvb_frontend *fe,
                        bool re_tune,
                        unsigned int mode_flags,
@@ -2136,7 +2126,6 @@ static struct dvb_frontend_ops mb86a20s_ops = {
 
        .init = mb86a20s_initfe,
        .set_frontend = mb86a20s_set_frontend,
-       .get_frontend = mb86a20s_get_frontend_dummy,
        .read_status = mb86a20s_read_status_and_stats,
        .read_signal_strength = mb86a20s_read_signal_strength_from_cache,
        .tune = mb86a20s_tune,
index c36e676..fc08429 100644 (file)
@@ -647,9 +647,9 @@ static int mt312_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int mt312_get_frontend(struct dvb_frontend *fe)
+static int mt312_get_frontend(struct dvb_frontend *fe,
+                             struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct mt312_state *state = fe->demodulator_priv;
        int ret;
 
index 123bb2f..c0bb632 100644 (file)
@@ -311,9 +311,9 @@ static int mt352_set_parameters(struct dvb_frontend *fe)
        return 0;
 }
 
-static int mt352_get_parameters(struct dvb_frontend* fe)
+static int mt352_get_parameters(struct dvb_frontend* fe,
+                               struct dtv_frontend_properties *op)
 {
-       struct dtv_frontend_properties *op = &fe->dtv_property_cache;
        struct mt352_state* state = fe->demodulator_priv;
        u16 tps;
        u16 div;
index 35b1053..a165af9 100644 (file)
@@ -375,9 +375,9 @@ static int or51132_set_parameters(struct dvb_frontend *fe)
        return 0;
 }
 
-static int or51132_get_parameters(struct dvb_frontend* fe)
+static int or51132_get_parameters(struct dvb_frontend* fe,
+                                 struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct or51132_state* state = fe->demodulator_priv;
        int status;
        int retry = 1;
index b792f30..3f96429 100644 (file)
@@ -279,11 +279,11 @@ err:
        return ret;
 }
 
-static int rtl2830_get_frontend(struct dvb_frontend *fe)
+static int rtl2830_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *c)
 {
        struct i2c_client *client = fe->demodulator_priv;
        struct rtl2830_dev *dev = i2c_get_clientdata(client);
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret;
        u8 buf[3];
 
@@ -900,6 +900,9 @@ static int rtl2830_remove(struct i2c_client *client)
 
        dev_dbg(&client->dev, "\n");
 
+       /* stop statistics polling */
+       cancel_delayed_work_sync(&dev->stat_work);
+
        i2c_del_mux_adapter(dev->adapter);
        regmap_exit(dev->regmap);
        kfree(dev);
index 10f2119..c2469fb 100644 (file)
@@ -575,11 +575,11 @@ err:
        return ret;
 }
 
-static int rtl2832_get_frontend(struct dvb_frontend *fe)
+static int rtl2832_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *c)
 {
        struct rtl2832_dev *dev = fe->demodulator_priv;
        struct i2c_client *client = dev->client;
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret;
        u8 buf[3];
 
index 1096484..c68965a 100644 (file)
@@ -925,9 +925,9 @@ static int s5h1409_read_ber(struct dvb_frontend *fe, u32 *ber)
        return s5h1409_read_ucblocks(fe, ber);
 }
 
-static int s5h1409_get_frontend(struct dvb_frontend *fe)
+static int s5h1409_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct s5h1409_state *state = fe->demodulator_priv;
 
        p->frequency = state->current_frequency;
index 9afc3f4..90f86e8 100644 (file)
@@ -840,9 +840,9 @@ static int s5h1411_read_ber(struct dvb_frontend *fe, u32 *ber)
        return s5h1411_read_ucblocks(fe, ber);
 }
 
-static int s5h1411_get_frontend(struct dvb_frontend *fe)
+static int s5h1411_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct s5h1411_state *state = fe->demodulator_priv;
 
        p->frequency = state->current_frequency;
index 9c22a4c..d7d0b7d 100644 (file)
@@ -756,9 +756,9 @@ static int s5h1420_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int s5h1420_get_frontend(struct dvb_frontend* fe)
+static int s5h1420_get_frontend(struct dvb_frontend* fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct s5h1420_state* state = fe->demodulator_priv;
 
        p->frequency = state->tunedfreq + s5h1420_getfreqoffset(state);
index d6a8fa6..b5e3d90 100644 (file)
@@ -433,9 +433,9 @@ static int s921_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int s921_get_frontend(struct dvb_frontend *fe)
+static int s921_get_frontend(struct dvb_frontend *fe,
+                            struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct s921_state *state = fe->demodulator_priv;
 
        /* FIXME: Probably it is possible to get it from regs f1 and f2 */
index 2b93241..8bf716a 100644 (file)
@@ -225,22 +225,18 @@ static int si2165_writereg32(struct si2165_state *state, const u16 reg, u32 val)
 static int si2165_writereg_mask8(struct si2165_state *state, const u16 reg,
                                 u8 val, u8 mask)
 {
-       int ret;
-       u8 tmp;
-
        if (mask != 0xff) {
-               ret = si2165_readreg8(state, reg, &tmp);
+               u8 tmp;
+               int ret = si2165_readreg8(state, reg, &tmp);
+
                if (ret < 0)
-                       goto err;
+                       return ret;
 
                val &= mask;
                tmp &= ~mask;
                val |= tmp;
        }
-
-       ret = si2165_writereg8(state, reg, val);
-err:
-       return ret;
+       return si2165_writereg8(state, reg, val);
 }
 
 #define REG16(reg, val) { (reg), (val) & 0xff }, { (reg)+1, (val)>>8 & 0xff }
@@ -825,19 +821,19 @@ static int si2165_set_frontend_dvbt(struct dvb_frontend *fe)
        struct si2165_state *state = fe->demodulator_priv;
        u32 dvb_rate = 0;
        u16 bw10k;
+       u32 bw_hz = p->bandwidth_hz;
 
        dprintk("%s: called\n", __func__);
 
        if (!state->has_dvbt)
                return -EINVAL;
 
-       if (p->bandwidth_hz > 0) {
-               dvb_rate = p->bandwidth_hz * 8 / 7;
-               bw10k = p->bandwidth_hz / 10000;
-       } else {
-               dvb_rate = 8 * 8 / 7;
-               bw10k = 800;
-       }
+       /* no bandwidth auto-detection */
+       if (bw_hz == 0)
+               return -EINVAL;
+
+       dvb_rate = bw_hz * 8 / 7;
+       bw10k = bw_hz / 10000;
 
        ret = si2165_adjust_pll_divl(state, 12);
        if (ret < 0)
index 756650f..3d171b0 100644 (file)
@@ -1568,9 +1568,9 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe)
        return DVBFE_ALGO_SEARCH_ERROR;
 }
 
-static int stb0899_get_frontend(struct dvb_frontend *fe)
+static int stb0899_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct stb0899_state *state             = fe->demodulator_priv;
        struct stb0899_internal *internal       = &state->internal;
 
index c978c80..b9c2511 100644 (file)
@@ -346,7 +346,7 @@ static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
 
        if (fe->ops.get_frontend) {
                dprintk(verbose, FE_DEBUG, 1, "Get frontend parameters");
-               fe->ops.get_frontend(fe);
+               fe->ops.get_frontend(fe, p);
        }
        srate = p->symbol_rate;
 
index 75b4d8b..81b27b7 100644 (file)
@@ -615,9 +615,9 @@ timeout:
        return 0;
 }
 
-static int stv0297_get_frontend(struct dvb_frontend *fe)
+static int stv0297_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct stv0297_state *state = fe->demodulator_priv;
        int reg_00, reg_83;
 
index a817780..7927fa9 100644 (file)
@@ -422,7 +422,7 @@ static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long
        if (debug_legacy_dish_switch)
                printk ("%s switch command: 0x%04lx\n",__func__, cmd);
 
-       nexttime = ktime_get_real();
+       nexttime = ktime_get_boottime();
        if (debug_legacy_dish_switch)
                tv[0] = nexttime;
        stv0299_writeregI (state, 0x0c, reg0x0c | 0x50); /* set LNB to 18V */
@@ -431,7 +431,7 @@ static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long
 
        for (i=0; i<9; i++) {
                if (debug_legacy_dish_switch)
-                       tv[i+1] = ktime_get_real();
+                       tv[i+1] = ktime_get_boottime();
                if((cmd & 0x01) != last) {
                        /* set voltage to (last ? 13V : 18V) */
                        stv0299_writeregI (state, 0x0c, reg0x0c | (last ? lv_mask : 0x50));
@@ -602,9 +602,9 @@ static int stv0299_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int stv0299_get_frontend(struct dvb_frontend *fe)
+static int stv0299_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct stv0299_state* state = fe->demodulator_priv;
        s32 derot_freq;
        int invval;
index 44cb73f..abc379a 100644 (file)
@@ -1938,9 +1938,9 @@ static int stv0367ter_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
        return 0;
 }
 
-static int stv0367ter_get_frontend(struct dvb_frontend *fe)
+static int stv0367ter_get_frontend(struct dvb_frontend *fe,
+                                  struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct stv0367_state *state = fe->demodulator_priv;
        struct stv0367ter_state *ter_state = state->ter_state;
        enum stv0367_ter_mode mode;
@@ -3146,9 +3146,9 @@ static int stv0367cab_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int stv0367cab_get_frontend(struct dvb_frontend *fe)
+static int stv0367cab_get_frontend(struct dvb_frontend *fe,
+                                  struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct stv0367_state *state = fe->demodulator_priv;
        struct stv0367cab_state *cab_state = state->cab_state;
 
index fe31dd5..28239b1 100644 (file)
@@ -1859,9 +1859,9 @@ static int stv0900_sleep(struct dvb_frontend *fe)
        return 0;
 }
 
-static int stv0900_get_frontend(struct dvb_frontend *fe)
+static int stv0900_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct stv0900_state *state = fe->demodulator_priv;
        struct stv0900_internal *intp = state->internal;
        enum fe_stv0900_demod_num demod = state->demod;
index e66154e..a62c01e 100644 (file)
@@ -355,7 +355,7 @@ static struct dvb_tuner_ops stv6110x_ops = {
        .release                = stv6110x_release
 };
 
-static struct stv6110x_devctl stv6110x_ctl = {
+static const struct stv6110x_devctl stv6110x_ctl = {
        .tuner_init             = stv6110x_init,
        .tuner_sleep            = stv6110x_sleep,
        .tuner_set_mode         = stv6110x_set_mode,
@@ -369,7 +369,7 @@ static struct stv6110x_devctl stv6110x_ctl = {
        .tuner_get_status       = stv6110x_get_status,
 };
 
-struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
+const struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
                                        const struct stv6110x_config *config,
                                        struct i2c_adapter *i2c)
 {
index 9f7eb25..696b6e5 100644 (file)
@@ -55,12 +55,12 @@ struct stv6110x_devctl {
 
 #if IS_REACHABLE(CONFIG_DVB_STV6110x)
 
-extern struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
+extern const struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
                                               const struct stv6110x_config *config,
                                               struct i2c_adapter *i2c);
 
 #else
-static inline struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
+static inline const struct stv6110x_devctl *stv6110x_attach(struct dvb_frontend *fe,
                                                      const struct stv6110x_config *config,
                                                      struct i2c_adapter *i2c)
 {
index 0ec936a..a993aba 100644 (file)
@@ -70,7 +70,7 @@ struct stv6110x_state {
        const struct stv6110x_config    *config;
        u8                              regs[8];
 
-       struct stv6110x_devctl          *devctl;
+       const struct stv6110x_devctl    *devctl;
 };
 
 #endif /* __STV6110x_PRIV_H */
index 456cdc7..31cd325 100644 (file)
@@ -201,10 +201,10 @@ static const enum fe_code_rate fec_conv_sat[] = {
        FEC_2_3, /* for 8PSK. (trellis code) */
 };
 
-static int tc90522s_get_frontend(struct dvb_frontend *fe)
+static int tc90522s_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *c)
 {
        struct tc90522_state *state;
-       struct dtv_frontend_properties *c;
        struct dtv_fe_stats *stats;
        int ret, i;
        int layers;
@@ -212,7 +212,6 @@ static int tc90522s_get_frontend(struct dvb_frontend *fe)
        u32 cndat;
 
        state = fe->demodulator_priv;
-       c = &fe->dtv_property_cache;
        c->delivery_system = SYS_ISDBS;
        c->symbol_rate = 28860000;
 
@@ -337,10 +336,10 @@ static const enum fe_modulation mod_conv[] = {
        DQPSK, QPSK, QAM_16, QAM_64, 0, 0, 0, 0
 };
 
-static int tc90522t_get_frontend(struct dvb_frontend *fe)
+static int tc90522t_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *c)
 {
        struct tc90522_state *state;
-       struct dtv_frontend_properties *c;
        struct dtv_fe_stats *stats;
        int ret, i;
        int layers;
@@ -348,7 +347,6 @@ static int tc90522t_get_frontend(struct dvb_frontend *fe)
        u32 cndat;
 
        state = fe->demodulator_priv;
-       c = &fe->dtv_property_cache;
        c->delivery_system = SYS_ISDBT;
        c->bandwidth_hz = 6000000;
        mode = 1;
index a684424..806c566 100644 (file)
@@ -387,9 +387,9 @@ static int tda10021_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
        return 0;
 }
 
-static int tda10021_get_frontend(struct dvb_frontend *fe)
+static int tda10021_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct tda10021_state* state = fe->demodulator_priv;
        int sync;
        s8 afc = 0;
index 44a5565..3b8c7e4 100644 (file)
@@ -457,9 +457,9 @@ static int tda10023_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
        return 0;
 }
 
-static int tda10023_get_frontend(struct dvb_frontend *fe)
+static int tda10023_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct tda10023_state* state = fe->demodulator_priv;
        int sync,inv;
        s8 afc = 0;
index 8451086..c2bf89d 100644 (file)
@@ -1028,9 +1028,9 @@ static int tda10048_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
        return 0;
 }
 
-static int tda10048_get_frontend(struct dvb_frontend *fe)
+static int tda10048_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct tda10048_state *state = fe->demodulator_priv;
 
        dprintk(1, "%s()\n", __func__);
index c6abeb4..b898483 100644 (file)
@@ -899,9 +899,9 @@ static int tda1004x_set_fe(struct dvb_frontend *fe)
        return 0;
 }
 
-static int tda1004x_get_fe(struct dvb_frontend *fe)
+static int tda1004x_get_fe(struct dvb_frontend *fe,
+                          struct dtv_frontend_properties *fe_params)
 {
-       struct dtv_frontend_properties *fe_params = &fe->dtv_property_cache;
        struct tda1004x_state* state = fe->demodulator_priv;
        int status;
 
index 119d475..37ebeef 100644 (file)
@@ -701,11 +701,11 @@ error:
        return ret;
 }
 
-static int tda10071_get_frontend(struct dvb_frontend *fe)
+static int tda10071_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *c)
 {
        struct tda10071_dev *dev = fe->demodulator_priv;
        struct i2c_client *client = dev->client;
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        int ret, i;
        u8 buf[5], tmp;
 
index 95a33e1..31d0acb 100644 (file)
@@ -459,9 +459,9 @@ static int tda10086_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int tda10086_get_frontend(struct dvb_frontend *fe)
+static int tda10086_get_frontend(struct dvb_frontend *fe,
+                                struct dtv_frontend_properties *fe_params)
 {
-       struct dtv_frontend_properties *fe_params = &fe->dtv_property_cache;
        struct tda10086_state* state = fe->demodulator_priv;
        u8 val;
        int tmp;
index 796543f..9072d64 100644 (file)
@@ -342,9 +342,9 @@ static int tda8083_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int tda8083_get_frontend(struct dvb_frontend *fe)
+static int tda8083_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct tda8083_state* state = fe->demodulator_priv;
 
        /*  FIXME: get symbolrate & frequency offset...*/
index 7979e5d..14b410f 100644 (file)
@@ -712,6 +712,10 @@ static int ts2020_remove(struct i2c_client *client)
 
        dev_dbg(&client->dev, "\n");
 
+       /* stop statistics polling */
+       if (!dev->dont_poll)
+               cancel_delayed_work_sync(&dev->stat_work);
+
        regmap_exit(dev->regmap);
        kfree(dev);
        return 0;
index aacfdda..b09fe88 100644 (file)
@@ -312,9 +312,9 @@ static int ves1820_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
        return 0;
 }
 
-static int ves1820_get_frontend(struct dvb_frontend *fe)
+static int ves1820_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct ves1820_state* state = fe->demodulator_priv;
        int sync;
        s8 afc = 0;
index 5269523..ed113e2 100644 (file)
@@ -406,9 +406,9 @@ static int ves1x93_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int ves1x93_get_frontend(struct dvb_frontend *fe)
+static int ves1x93_get_frontend(struct dvb_frontend *fe,
+                               struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct ves1x93_state* state = fe->demodulator_priv;
        int afc;
 
index ef9764a..1832c2f 100644 (file)
@@ -371,9 +371,9 @@ static int zl10353_set_parameters(struct dvb_frontend *fe)
        return 0;
 }
 
-static int zl10353_get_parameters(struct dvb_frontend *fe)
+static int zl10353_get_parameters(struct dvb_frontend *fe,
+                                 struct dtv_frontend_properties *c)
 {
-       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
        struct zl10353_state *state = fe->demodulator_priv;
        int s6, s9;
        u16 tps;
index 7e9cbf7..fb7ed73 100644 (file)
@@ -497,7 +497,7 @@ static int adp1653_probe(struct i2c_client *client,
                if (!client->dev.platform_data) {
                        dev_err(&client->dev,
                                "Neither DT not platform data provided\n");
-                       return EINVAL;
+                       return -EINVAL;
                }
                flash->platform_data = client->dev.platform_data;
        }
index 471fd23..bd822f0 100644 (file)
@@ -103,12 +103,14 @@ struct adv7511_state {
        u32 ycbcr_enc;
        u32 quantization;
        u32 xfer_func;
+       u32 content_type;
        /* controls */
        struct v4l2_ctrl *hdmi_mode_ctrl;
        struct v4l2_ctrl *hotplug_ctrl;
        struct v4l2_ctrl *rx_sense_ctrl;
        struct v4l2_ctrl *have_edid0_ctrl;
        struct v4l2_ctrl *rgb_quantization_range_ctrl;
+       struct v4l2_ctrl *content_type_ctrl;
        struct i2c_client *i2c_edid;
        struct i2c_client *i2c_pktmem;
        struct adv7511_state_edid edid;
@@ -400,6 +402,16 @@ static int adv7511_s_ctrl(struct v4l2_ctrl *ctrl)
        }
        if (state->rgb_quantization_range_ctrl == ctrl)
                return adv7511_set_rgb_quantization_mode(sd, ctrl);
+       if (state->content_type_ctrl == ctrl) {
+               u8 itc, cn;
+
+               state->content_type = ctrl->val;
+               itc = state->content_type != V4L2_DV_IT_CONTENT_TYPE_NO_ITC;
+               cn = itc ? state->content_type : V4L2_DV_IT_CONTENT_TYPE_GRAPHICS;
+               adv7511_wr_and_or(sd, 0x57, 0x7f, itc << 7);
+               adv7511_wr_and_or(sd, 0x59, 0xcf, cn << 4);
+               return 0;
+       }
 
        return -EINVAL;
 }
@@ -1002,6 +1014,8 @@ static int adv7511_set_fmt(struct v4l2_subdev *sd,
        u8 y = HDMI_COLORSPACE_RGB;
        u8 q = HDMI_QUANTIZATION_RANGE_DEFAULT;
        u8 yq = HDMI_YCC_QUANTIZATION_RANGE_LIMITED;
+       u8 itc = state->content_type != V4L2_DV_IT_CONTENT_TYPE_NO_ITC;
+       u8 cn = itc ? state->content_type : V4L2_DV_IT_CONTENT_TYPE_GRAPHICS;
 
        if (format->pad != 0)
                return -EINVAL;
@@ -1115,8 +1129,8 @@ static int adv7511_set_fmt(struct v4l2_subdev *sd,
        adv7511_wr_and_or(sd, 0x4a, 0xbf, 0);
        adv7511_wr_and_or(sd, 0x55, 0x9f, y << 5);
        adv7511_wr_and_or(sd, 0x56, 0x3f, c << 6);
-       adv7511_wr_and_or(sd, 0x57, 0x83, (ec << 4) | (q << 2));
-       adv7511_wr_and_or(sd, 0x59, 0x3f, yq << 6);
+       adv7511_wr_and_or(sd, 0x57, 0x83, (ec << 4) | (q << 2) | (itc << 7));
+       adv7511_wr_and_or(sd, 0x59, 0x0f, (yq << 6) | (cn << 4));
        adv7511_wr_and_or(sd, 0x4a, 0xff, 1);
 
        return 0;
@@ -1161,12 +1175,23 @@ static void adv7511_dbg_dump_edid(int lvl, int debug, struct v4l2_subdev *sd, in
        }
 }
 
+static void adv7511_notify_no_edid(struct v4l2_subdev *sd)
+{
+       struct adv7511_state *state = get_adv7511_state(sd);
+       struct adv7511_edid_detect ed;
+
+       /* We failed to read the EDID, so send an event for this. */
+       ed.present = false;
+       ed.segment = adv7511_rd(sd, 0xc4);
+       v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed);
+       v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, 0x0);
+}
+
 static void adv7511_edid_handler(struct work_struct *work)
 {
        struct delayed_work *dwork = to_delayed_work(work);
        struct adv7511_state *state = container_of(dwork, struct adv7511_state, edid_handler);
        struct v4l2_subdev *sd = &state->sd;
-       struct adv7511_edid_detect ed;
 
        v4l2_dbg(1, debug, sd, "%s:\n", __func__);
 
@@ -1191,9 +1216,7 @@ static void adv7511_edid_handler(struct work_struct *work)
        }
 
        /* We failed to read the EDID, so send an event for this. */
-       ed.present = false;
-       ed.segment = adv7511_rd(sd, 0xc4);
-       v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed);
+       adv7511_notify_no_edid(sd);
        v4l2_dbg(1, debug, sd, "%s: no edid found\n", __func__);
 }
 
@@ -1264,7 +1287,6 @@ static void adv7511_check_monitor_present_status(struct v4l2_subdev *sd)
        /* update read only ctrls */
        v4l2_ctrl_s_ctrl(state->hotplug_ctrl, adv7511_have_hotplug(sd) ? 0x1 : 0x0);
        v4l2_ctrl_s_ctrl(state->rx_sense_ctrl, adv7511_have_rx_sense(sd) ? 0x1 : 0x0);
-       v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, state->edid.segments ? 0x1 : 0x0);
 
        if ((status & MASK_ADV7511_HPD_DETECT) && ((status & MASK_ADV7511_MSEN_DETECT) || state->edid.segments)) {
                v4l2_dbg(1, debug, sd, "%s: hotplug and (rx-sense or edid)\n", __func__);
@@ -1294,6 +1316,7 @@ static void adv7511_check_monitor_present_status(struct v4l2_subdev *sd)
                }
                adv7511_s_power(sd, false);
                memset(&state->edid, 0, sizeof(struct adv7511_state_edid));
+               adv7511_notify_no_edid(sd);
        }
 }
 
@@ -1370,6 +1393,7 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd)
                }
                /* one more segment read ok */
                state->edid.segments = segment + 1;
+               v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, 0x1);
                if (((state->edid.data[0x7e] >> 1) + 1) > state->edid.segments) {
                        /* Request next EDID segment */
                        v4l2_dbg(1, debug, sd, "%s: request segment %d\n", __func__, state->edid.segments);
@@ -1389,7 +1413,6 @@ static bool adv7511_check_edid_status(struct v4l2_subdev *sd)
                ed.present = true;
                ed.segment = 0;
                state->edid_detect_counter++;
-               v4l2_ctrl_s_ctrl(state->have_edid0_ctrl, state->edid.segments ? 0x1 : 0x0);
                v4l2_subdev_notify(sd, ADV7511_EDID_DETECT, (void *)&ed);
                return ed.present;
        }
@@ -1470,6 +1493,10 @@ static int adv7511_probe(struct i2c_client *client, const struct i2c_device_id *
                v4l2_ctrl_new_std_menu(hdl, &adv7511_ctrl_ops,
                        V4L2_CID_DV_TX_RGB_RANGE, V4L2_DV_RGB_RANGE_FULL,
                        0, V4L2_DV_RGB_RANGE_AUTO);
+       state->content_type_ctrl =
+               v4l2_ctrl_new_std_menu(hdl, &adv7511_ctrl_ops,
+                       V4L2_CID_DV_TX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC,
+                       0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC);
        sd->ctrl_handler = hdl;
        if (hdl->error) {
                err = hdl->error;
index f8dd750..befb07d 100644 (file)
@@ -207,71 +207,22 @@ static bool adv76xx_has_afe(struct adv76xx_state *state)
        return state->info->has_afe;
 }
 
-/* Supported CEA and DMT timings */
-static const struct v4l2_dv_timings adv76xx_timings[] = {
-       V4L2_DV_BT_CEA_720X480P59_94,
-       V4L2_DV_BT_CEA_720X576P50,
-       V4L2_DV_BT_CEA_1280X720P24,
-       V4L2_DV_BT_CEA_1280X720P25,
-       V4L2_DV_BT_CEA_1280X720P50,
-       V4L2_DV_BT_CEA_1280X720P60,
-       V4L2_DV_BT_CEA_1920X1080P24,
-       V4L2_DV_BT_CEA_1920X1080P25,
-       V4L2_DV_BT_CEA_1920X1080P30,
-       V4L2_DV_BT_CEA_1920X1080P50,
-       V4L2_DV_BT_CEA_1920X1080P60,
-
-       /* sorted by DMT ID */
-       V4L2_DV_BT_DMT_640X350P85,
-       V4L2_DV_BT_DMT_640X400P85,
-       V4L2_DV_BT_DMT_720X400P85,
-       V4L2_DV_BT_DMT_640X480P60,
-       V4L2_DV_BT_DMT_640X480P72,
-       V4L2_DV_BT_DMT_640X480P75,
-       V4L2_DV_BT_DMT_640X480P85,
-       V4L2_DV_BT_DMT_800X600P56,
-       V4L2_DV_BT_DMT_800X600P60,
-       V4L2_DV_BT_DMT_800X600P72,
-       V4L2_DV_BT_DMT_800X600P75,
-       V4L2_DV_BT_DMT_800X600P85,
-       V4L2_DV_BT_DMT_848X480P60,
-       V4L2_DV_BT_DMT_1024X768P60,
-       V4L2_DV_BT_DMT_1024X768P70,
-       V4L2_DV_BT_DMT_1024X768P75,
-       V4L2_DV_BT_DMT_1024X768P85,
-       V4L2_DV_BT_DMT_1152X864P75,
-       V4L2_DV_BT_DMT_1280X768P60_RB,
-       V4L2_DV_BT_DMT_1280X768P60,
-       V4L2_DV_BT_DMT_1280X768P75,
-       V4L2_DV_BT_DMT_1280X768P85,
-       V4L2_DV_BT_DMT_1280X800P60_RB,
-       V4L2_DV_BT_DMT_1280X800P60,
-       V4L2_DV_BT_DMT_1280X800P75,
-       V4L2_DV_BT_DMT_1280X800P85,
-       V4L2_DV_BT_DMT_1280X960P60,
-       V4L2_DV_BT_DMT_1280X960P85,
-       V4L2_DV_BT_DMT_1280X1024P60,
-       V4L2_DV_BT_DMT_1280X1024P75,
-       V4L2_DV_BT_DMT_1280X1024P85,
-       V4L2_DV_BT_DMT_1360X768P60,
-       V4L2_DV_BT_DMT_1400X1050P60_RB,
-       V4L2_DV_BT_DMT_1400X1050P60,
-       V4L2_DV_BT_DMT_1400X1050P75,
-       V4L2_DV_BT_DMT_1400X1050P85,
-       V4L2_DV_BT_DMT_1440X900P60_RB,
-       V4L2_DV_BT_DMT_1440X900P60,
-       V4L2_DV_BT_DMT_1600X1200P60,
-       V4L2_DV_BT_DMT_1680X1050P60_RB,
-       V4L2_DV_BT_DMT_1680X1050P60,
-       V4L2_DV_BT_DMT_1792X1344P60,
-       V4L2_DV_BT_DMT_1856X1392P60,
-       V4L2_DV_BT_DMT_1920X1200P60_RB,
-       V4L2_DV_BT_DMT_1366X768P60_RB,
-       V4L2_DV_BT_DMT_1366X768P60,
-       V4L2_DV_BT_DMT_1920X1080P60,
-       { },
+/* Unsupported timings. This device cannot support 720p30. */
+static const struct v4l2_dv_timings adv76xx_timings_exceptions[] = {
+       V4L2_DV_BT_CEA_1280X720P30,
+       { }
 };
 
+static bool adv76xx_check_dv_timings(const struct v4l2_dv_timings *t, void *hdl)
+{
+       int i;
+
+       for (i = 0; adv76xx_timings_exceptions[i].bt.width; i++)
+               if (v4l2_match_dv_timings(t, adv76xx_timings_exceptions + i, 0, false))
+                       return false;
+       return true;
+}
+
 struct adv76xx_video_standards {
        struct v4l2_dv_timings timings;
        u8 vid_std;
@@ -806,6 +757,36 @@ static inline bool is_digital_input(struct v4l2_subdev *sd)
               state->selected_input == ADV7604_PAD_HDMI_PORT_D;
 }
 
+static const struct v4l2_dv_timings_cap adv7604_timings_cap_analog = {
+       .type = V4L2_DV_BT_656_1120,
+       /* keep this initialization for compatibility with GCC < 4.4.6 */
+       .reserved = { 0 },
+       V4L2_INIT_BT_TIMINGS(0, 1920, 0, 1200, 25000000, 170000000,
+               V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
+                       V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
+               V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_REDUCED_BLANKING |
+                       V4L2_DV_BT_CAP_CUSTOM)
+};
+
+static const struct v4l2_dv_timings_cap adv76xx_timings_cap_digital = {
+       .type = V4L2_DV_BT_656_1120,
+       /* keep this initialization for compatibility with GCC < 4.4.6 */
+       .reserved = { 0 },
+       V4L2_INIT_BT_TIMINGS(0, 1920, 0, 1200, 25000000, 225000000,
+               V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
+                       V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT,
+               V4L2_DV_BT_CAP_PROGRESSIVE | V4L2_DV_BT_CAP_REDUCED_BLANKING |
+                       V4L2_DV_BT_CAP_CUSTOM)
+};
+
+static inline const struct v4l2_dv_timings_cap *
+adv76xx_get_dv_timings_cap(struct v4l2_subdev *sd)
+{
+       return is_digital_input(sd) ? &adv76xx_timings_cap_digital :
+                                     &adv7604_timings_cap_analog;
+}
+
+
 /* ----------------------------------------------------------------------- */
 
 #ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -1216,6 +1197,20 @@ static int adv76xx_s_ctrl(struct v4l2_ctrl *ctrl)
        return -EINVAL;
 }
 
+static int adv76xx_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
+{
+       struct v4l2_subdev *sd =
+               &container_of(ctrl->handler, struct adv76xx_state, hdl)->sd;
+
+       if (ctrl->id == V4L2_CID_DV_RX_IT_CONTENT_TYPE) {
+               ctrl->val = V4L2_DV_IT_CONTENT_TYPE_NO_ITC;
+               if ((io_read(sd, 0x60) & 1) && (infoframe_read(sd, 0x03) & 0x80))
+                       ctrl->val = (infoframe_read(sd, 0x05) >> 4) & 3;
+               return 0;
+       }
+       return -EINVAL;
+}
+
 /* ----------------------------------------------------------------------- */
 
 static inline bool no_power(struct v4l2_subdev *sd)
@@ -1330,17 +1325,23 @@ static int stdi2dv_timings(struct v4l2_subdev *sd,
        u32 pix_clk;
        int i;
 
-       for (i = 0; adv76xx_timings[i].bt.height; i++) {
-               if (vtotal(&adv76xx_timings[i].bt) != stdi->lcf + 1)
+       for (i = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
+               const struct v4l2_bt_timings *bt = &v4l2_dv_timings_presets[i].bt;
+
+               if (!v4l2_valid_dv_timings(&v4l2_dv_timings_presets[i],
+                                          adv76xx_get_dv_timings_cap(sd),
+                                          adv76xx_check_dv_timings, NULL))
+                       continue;
+               if (vtotal(bt) != stdi->lcf + 1)
                        continue;
-               if (adv76xx_timings[i].bt.vsync != stdi->lcvs)
+               if (bt->vsync != stdi->lcvs)
                        continue;
 
-               pix_clk = hfreq * htotal(&adv76xx_timings[i].bt);
+               pix_clk = hfreq * htotal(bt);
 
-               if ((pix_clk < adv76xx_timings[i].bt.pixelclock + 1000000) &&
-                   (pix_clk > adv76xx_timings[i].bt.pixelclock - 1000000)) {
-                       *timings = adv76xx_timings[i];
+               if ((pix_clk < bt->pixelclock + 1000000) &&
+                   (pix_clk > bt->pixelclock - 1000000)) {
+                       *timings = v4l2_dv_timings_presets[i];
                        return 0;
                }
        }
@@ -1425,15 +1426,11 @@ static int adv76xx_enum_dv_timings(struct v4l2_subdev *sd,
 {
        struct adv76xx_state *state = to_state(sd);
 
-       if (timings->index >= ARRAY_SIZE(adv76xx_timings) - 1)
-               return -EINVAL;
-
        if (timings->pad >= state->source_pad)
                return -EINVAL;
 
-       memset(timings->reserved, 0, sizeof(timings->reserved));
-       timings->timings = adv76xx_timings[timings->index];
-       return 0;
+       return v4l2_enum_dv_timings_cap(timings,
+               adv76xx_get_dv_timings_cap(sd), adv76xx_check_dv_timings, NULL);
 }
 
 static int adv76xx_dv_timings_cap(struct v4l2_subdev *sd,
@@ -1444,29 +1441,7 @@ static int adv76xx_dv_timings_cap(struct v4l2_subdev *sd,
        if (cap->pad >= state->source_pad)
                return -EINVAL;
 
-       cap->type = V4L2_DV_BT_656_1120;
-       cap->bt.max_width = 1920;
-       cap->bt.max_height = 1200;
-       cap->bt.min_pixelclock = 25000000;
-
-       switch (cap->pad) {
-       case ADV76XX_PAD_HDMI_PORT_A:
-       case ADV7604_PAD_HDMI_PORT_B:
-       case ADV7604_PAD_HDMI_PORT_C:
-       case ADV7604_PAD_HDMI_PORT_D:
-               cap->bt.max_pixelclock = 225000000;
-               break;
-       case ADV7604_PAD_VGA_RGB:
-       case ADV7604_PAD_VGA_COMP:
-       default:
-               cap->bt.max_pixelclock = 170000000;
-               break;
-       }
-
-       cap->bt.standards = V4L2_DV_BT_STD_CEA861 | V4L2_DV_BT_STD_DMT |
-                        V4L2_DV_BT_STD_GTF | V4L2_DV_BT_STD_CVT;
-       cap->bt.capabilities = V4L2_DV_BT_CAP_PROGRESSIVE |
-               V4L2_DV_BT_CAP_REDUCED_BLANKING | V4L2_DV_BT_CAP_CUSTOM;
+       *cap = *adv76xx_get_dv_timings_cap(sd);
        return 0;
 }
 
@@ -1475,15 +1450,9 @@ static int adv76xx_dv_timings_cap(struct v4l2_subdev *sd,
 static void adv76xx_fill_optional_dv_timings_fields(struct v4l2_subdev *sd,
                struct v4l2_dv_timings *timings)
 {
-       int i;
-
-       for (i = 0; adv76xx_timings[i].bt.width; i++) {
-               if (v4l2_match_dv_timings(timings, &adv76xx_timings[i],
-                               is_digital_input(sd) ? 250000 : 1000000, false)) {
-                       *timings = adv76xx_timings[i];
-                       break;
-               }
-       }
+       v4l2_find_dv_timings_cap(timings, adv76xx_get_dv_timings_cap(sd),
+                       is_digital_input(sd) ? 250000 : 1000000,
+                       adv76xx_check_dv_timings, NULL);
 }
 
 static unsigned int adv7604_read_hdmi_pixelclock(struct v4l2_subdev *sd)
@@ -1651,12 +1620,9 @@ static int adv76xx_s_dv_timings(struct v4l2_subdev *sd,
 
        bt = &timings->bt;
 
-       if ((is_analog_input(sd) && bt->pixelclock > 170000000) ||
-                       (is_digital_input(sd) && bt->pixelclock > 225000000)) {
-               v4l2_dbg(1, debug, sd, "%s: pixelclock out of range %d\n",
-                               __func__, (u32)bt->pixelclock);
+       if (!v4l2_valid_dv_timings(timings, adv76xx_get_dv_timings_cap(sd),
+                                  adv76xx_check_dv_timings, NULL))
                return -ERANGE;
-       }
 
        adv76xx_fill_optional_dv_timings_fields(sd, timings);
 
@@ -1884,6 +1850,26 @@ static int adv76xx_get_format(struct v4l2_subdev *sd,
        return 0;
 }
 
+static int adv76xx_get_selection(struct v4l2_subdev *sd,
+                                struct v4l2_subdev_pad_config *cfg,
+                                struct v4l2_subdev_selection *sel)
+{
+       struct adv76xx_state *state = to_state(sd);
+
+       if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE)
+               return -EINVAL;
+       /* Only CROP, CROP_DEFAULT and CROP_BOUNDS are supported */
+       if (sel->target > V4L2_SEL_TGT_CROP_BOUNDS)
+               return -EINVAL;
+
+       sel->r.left     = 0;
+       sel->r.top      = 0;
+       sel->r.width    = state->timings.bt.width;
+       sel->r.height   = state->timings.bt.height;
+
+       return 0;
+}
+
 static int adv76xx_set_format(struct v4l2_subdev *sd,
                              struct v4l2_subdev_pad_config *cfg,
                              struct v4l2_subdev_format *format)
@@ -1960,10 +1946,9 @@ static int adv76xx_isr(struct v4l2_subdev *sd, u32 status, bool *handled)
        }
 
        /* tx 5v detect */
-       tx_5v = io_read(sd, 0x70) & info->cable_det_mask;
+       tx_5v = irq_reg_0x70 & info->cable_det_mask;
        if (tx_5v) {
                v4l2_dbg(1, debug, sd, "%s: tx_5v: 0x%x\n", __func__, tx_5v);
-               io_write(sd, 0x71, tx_5v);
                adv76xx_s_detect_tx_5v_ctrl(sd);
                if (handled)
                        *handled = true;
@@ -2381,6 +2366,7 @@ static int adv76xx_subscribe_event(struct v4l2_subdev *sd,
 
 static const struct v4l2_ctrl_ops adv76xx_ctrl_ops = {
        .s_ctrl = adv76xx_s_ctrl,
+       .g_volatile_ctrl = adv76xx_g_volatile_ctrl,
 };
 
 static const struct v4l2_subdev_core_ops adv76xx_core_ops = {
@@ -2404,6 +2390,7 @@ static const struct v4l2_subdev_video_ops adv76xx_video_ops = {
 
 static const struct v4l2_subdev_pad_ops adv76xx_pad_ops = {
        .enum_mbus_code = adv76xx_enum_mbus_code,
+       .get_selection = adv76xx_get_selection,
        .get_fmt = adv76xx_get_format,
        .set_fmt = adv76xx_set_format,
        .get_edid = adv76xx_get_edid,
@@ -2799,6 +2786,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
        struct device_node *endpoint;
        struct device_node *np;
        unsigned int flags;
+       int ret;
        u32 v;
 
        np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
@@ -2808,7 +2796,11 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
        if (!endpoint)
                return -EINVAL;
 
-       v4l2_of_parse_endpoint(endpoint, &bus_cfg);
+       ret = v4l2_of_parse_endpoint(endpoint, &bus_cfg);
+       if (ret) {
+               of_node_put(endpoint);
+               return ret;
+       }
 
        if (!of_property_read_u32(endpoint, "default-input", &v))
                state->pdata.default_input = v;
@@ -3010,6 +3002,7 @@ static int adv76xx_probe(struct i2c_client *client,
                V4L2_DV_BT_CEA_640X480P59_94;
        struct adv76xx_state *state;
        struct v4l2_ctrl_handler *hdl;
+       struct v4l2_ctrl *ctrl;
        struct v4l2_subdev *sd;
        unsigned int i;
        unsigned int val, val2;
@@ -3141,6 +3134,11 @@ static int adv76xx_probe(struct i2c_client *client,
                        V4L2_CID_SATURATION, 0, 255, 1, 128);
        v4l2_ctrl_new_std(hdl, &adv76xx_ctrl_ops,
                        V4L2_CID_HUE, 0, 128, 1, 0);
+       ctrl = v4l2_ctrl_new_std_menu(hdl, &adv76xx_ctrl_ops,
+                       V4L2_CID_DV_RX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC,
+                       0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC);
+       if (ctrl)
+               ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
 
        /* private controls */
        state->detect_tx_5v_ctrl = v4l2_ctrl_new_std(hdl, NULL,
index 5fbb788..7ccb85d 100644 (file)
@@ -1359,6 +1359,19 @@ static int adv7842_s_ctrl(struct v4l2_ctrl *ctrl)
        return -EINVAL;
 }
 
+static int adv7842_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
+{
+       struct v4l2_subdev *sd = to_sd(ctrl);
+
+       if (ctrl->id == V4L2_CID_DV_RX_IT_CONTENT_TYPE) {
+               ctrl->val = V4L2_DV_IT_CONTENT_TYPE_NO_ITC;
+               if ((io_read(sd, 0x60) & 1) && (infoframe_read(sd, 0x03) & 0x80))
+                       ctrl->val = (infoframe_read(sd, 0x05) >> 4) & 3;
+               return 0;
+       }
+       return -EINVAL;
+}
+
 static inline bool no_power(struct v4l2_subdev *sd)
 {
        return io_read(sd, 0x0c) & 0x24;
@@ -3022,6 +3035,7 @@ static int adv7842_subscribe_event(struct v4l2_subdev *sd,
 
 static const struct v4l2_ctrl_ops adv7842_ctrl_ops = {
        .s_ctrl = adv7842_s_ctrl,
+       .g_volatile_ctrl = adv7842_g_volatile_ctrl,
 };
 
 static const struct v4l2_subdev_core_ops adv7842_core_ops = {
@@ -3196,6 +3210,7 @@ static int adv7842_probe(struct i2c_client *client,
                V4L2_DV_BT_CEA_640X480P59_94;
        struct adv7842_platform_data *pdata = client->dev.platform_data;
        struct v4l2_ctrl_handler *hdl;
+       struct v4l2_ctrl *ctrl;
        struct v4l2_subdev *sd;
        u16 rev;
        int err;
@@ -3261,6 +3276,11 @@ static int adv7842_probe(struct i2c_client *client,
                          V4L2_CID_SATURATION, 0, 255, 1, 128);
        v4l2_ctrl_new_std(hdl, &adv7842_ctrl_ops,
                          V4L2_CID_HUE, 0, 128, 1, 0);
+       ctrl = v4l2_ctrl_new_std_menu(hdl, &adv7842_ctrl_ops,
+                       V4L2_CID_DV_RX_IT_CONTENT_TYPE, V4L2_DV_IT_CONTENT_TYPE_NO_ITC,
+                       0, V4L2_DV_IT_CONTENT_TYPE_NO_ITC);
+       if (ctrl)
+               ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
 
        /* custom controls */
        state->detect_tx_5v_ctrl = v4l2_ctrl_new_std(hdl, NULL,
index a84561d..e016626 100644 (file)
@@ -688,6 +688,9 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
        int msp_revision;
        int msp_product, msp_prod_hi, msp_prod_lo;
        int msp_rom;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       int ret;
+#endif
 
        if (!id)
                strlcpy(client->name, "msp3400", sizeof(client->name));
@@ -704,6 +707,17 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
        sd = &state->sd;
        v4l2_i2c_subdev_init(sd, client, &msp_ops);
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       state->pads[IF_AUD_DEC_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
+       state->pads[IF_AUD_DEC_PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
+
+       sd->entity.function = MEDIA_ENT_F_IF_AUD_DECODER;
+
+       ret = media_entity_pads_init(&sd->entity, 2, state->pads);
+       if (ret < 0)
+               return ret;
+#endif
+
        state->v4l2_std = V4L2_STD_NTSC;
        state->detected_std = V4L2_STD_ALL;
        state->audmode = V4L2_TUNER_MODE_STEREO;
index 6cae213..a8702ac 100644 (file)
@@ -7,6 +7,7 @@
 #include <media/drv-intf/msp3400.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ctrls.h>
+#include <media/v4l2-mc.h>
 
 /* ---------------------------------------------------------------------- */
 
@@ -102,6 +103,10 @@ struct msp_state {
        wait_queue_head_t    wq;
        unsigned int         restart:1;
        unsigned int         watch_stereo:1;
+
+#if IS_ENABLED(CONFIG_MEDIA_CONTROLLER)
+       struct media_pad pads[IF_AUD_DEC_PAD_NUM_PADS];
+#endif
 };
 
 static inline struct msp_state *to_state(struct v4l2_subdev *sd)
index b9fea11..9ed1b26 100644 (file)
@@ -50,6 +50,9 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");
 
 struct mt9v011 {
        struct v4l2_subdev sd;
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct media_pad pad;
+#endif
        struct v4l2_ctrl_handler ctrls;
        unsigned width, height;
        unsigned xtal;
@@ -493,6 +496,9 @@ static int mt9v011_probe(struct i2c_client *c,
        u16 version;
        struct mt9v011 *core;
        struct v4l2_subdev *sd;
+#ifdef CONFIG_MEDIA_CONTROLLER
+       int ret;
+#endif
 
        /* Check if the adapter supports the needed features */
        if (!i2c_check_functionality(c->adapter,
@@ -506,6 +512,15 @@ static int mt9v011_probe(struct i2c_client *c,
        sd = &core->sd;
        v4l2_i2c_subdev_init(sd, c, &mt9v011_ops);
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+       core->pad.flags = MEDIA_PAD_FL_SOURCE;
+       sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;
+
+       ret = media_entity_pads_init(&sd->entity, 1, &core->pad);
+       if (ret < 0)
+               return ret;
+#endif
+
        /* Check if the sensor is really a MT9V011 */
        version = mt9v011_read(sd, R00_MT9V011_CHIP_VERSION);
        if ((version != MT9V011_VERSION) &&
index 2e1d116..501b370 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/log2.h>
 #include <linux/mutex.h>
@@ -251,6 +252,8 @@ struct mt9v032 {
 
        struct regmap *regmap;
        struct clk *clk;
+       struct gpio_desc *reset_gpio;
+       struct gpio_desc *standby_gpio;
 
        struct mt9v032_platform_data *pdata;
        const struct mt9v032_model_info *model;
@@ -312,16 +315,31 @@ static int mt9v032_power_on(struct mt9v032 *mt9v032)
        struct regmap *map = mt9v032->regmap;
        int ret;
 
+       if (mt9v032->reset_gpio)
+               gpiod_set_value_cansleep(mt9v032->reset_gpio, 1);
+
        ret = clk_set_rate(mt9v032->clk, mt9v032->sysclk);
        if (ret < 0)
                return ret;
 
+       /* System clock has to be enabled before releasing the reset */
        ret = clk_prepare_enable(mt9v032->clk);
        if (ret)
                return ret;
 
        udelay(1);
 
+       if (mt9v032->reset_gpio) {
+               gpiod_set_value_cansleep(mt9v032->reset_gpio, 0);
+
+               /* After releasing reset we need to wait 10 clock cycles
+                * before accessing the sensor over I2C. As the minimum SYSCLK
+                * frequency is 13MHz, waiting 1µs will be enough in the worst
+                * case.
+                */
+               udelay(1);
+       }
+
        /* Reset the chip and stop data read out */
        ret = regmap_write(map, MT9V032_RESET, 1);
        if (ret < 0)
@@ -954,6 +972,16 @@ static int mt9v032_probe(struct i2c_client *client,
        if (IS_ERR(mt9v032->clk))
                return PTR_ERR(mt9v032->clk);
 
+       mt9v032->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
+                                                     GPIOD_OUT_HIGH);
+       if (IS_ERR(mt9v032->reset_gpio))
+               return PTR_ERR(mt9v032->reset_gpio);
+
+       mt9v032->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby",
+                                                       GPIOD_OUT_LOW);
+       if (IS_ERR(mt9v032->standby_gpio))
+               return PTR_ERR(mt9v032->standby_gpio);
+
        mutex_init(&mt9v032->power_lock);
        mt9v032->pdata = pdata;
        mt9v032->model = (const void *)did->driver_data;
index 02b9a34..1f999e9 100644 (file)
@@ -1321,10 +1321,6 @@ static int ov2659_detect(struct v4l2_subdev *sd)
        }
        usleep_range(1000, 2000);
 
-       ret = ov2659_init(sd, 0);
-       if (ret < 0)
-               return ret;
-
        /* Check sensor revision */
        ret = ov2659_read(client, REG_SC_CHIP_ID_H, &pid);
        if (!ret)
@@ -1338,8 +1334,10 @@ static int ov2659_detect(struct v4l2_subdev *sd)
                        dev_err(&client->dev,
                                "Sensor detection failed (%04X, %d)\n",
                                id, ret);
-               else
+               else {
                        dev_info(&client->dev, "Found OV%04X sensor\n", id);
+                       ret = ov2659_init(sd, 0);
+               }
        }
 
        return ret;
index a0b3c9b..be5a7fd 100644 (file)
@@ -1046,8 +1046,8 @@ static int ov965x_initialize_controls(struct ov965x *ov965x)
        ctrls->exposure->flags |= V4L2_CTRL_FLAG_VOLATILE;
 
        v4l2_ctrl_auto_cluster(3, &ctrls->auto_wb, 0, false);
-       v4l2_ctrl_auto_cluster(3, &ctrls->auto_gain, 0, true);
-       v4l2_ctrl_auto_cluster(3, &ctrls->auto_exp, 1, true);
+       v4l2_ctrl_auto_cluster(2, &ctrls->auto_gain, 0, true);
+       v4l2_ctrl_auto_cluster(2, &ctrls->auto_exp, 1, true);
        v4l2_ctrl_cluster(2, &ctrls->hflip);
 
        ov965x->sd.ctrl_handler = hdl;
index 57b3d27..08af58f 100644 (file)
@@ -1639,8 +1639,10 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
                return 0;
        }
 
-       v4l2_of_parse_endpoint(node_ep, &ep);
+       ret = v4l2_of_parse_endpoint(node_ep, &ep);
        of_node_put(node_ep);
+       if (ret)
+               return ret;
 
        if (ep.bus_type != V4L2_MBUS_CSI2) {
                dev_err(dev, "unsupported bus type\n");
index 7d65b36..72ef9f9 100644 (file)
@@ -37,7 +37,6 @@ enum spi_direction {
        SPI_DIR_RX,
        SPI_DIR_TX
 };
-MODULE_DEVICE_TABLE(of, s5c73m3_spi_ids);
 
 static int spi_xmit(struct spi_device *spi_dev, void *addr, const int len,
                                                        enum spi_direction dir)
index fc3a5a8..db82ed0 100644 (file)
@@ -1868,8 +1868,11 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)
                return -EINVAL;
        }
 
-       v4l2_of_parse_endpoint(node_ep, &ep);
+       ret = v4l2_of_parse_endpoint(node_ep, &ep);
        of_node_put(node_ep);
+       if (ret)
+               return ret;
+
        state->bus_type = ep.bus_type;
 
        switch (state->bus_type) {
index 24d2b76..d2a1ce2 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/videodev2.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ctrls.h>
+#include <media/v4l2-mc.h>
 #include <media/i2c/saa7115.h>
 #include <asm/div64.h>
 
@@ -74,6 +75,9 @@ enum saa711x_model {
 
 struct saa711x_state {
        struct v4l2_subdev sd;
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct media_pad pads[DEMOD_NUM_PADS];
+#endif
        struct v4l2_ctrl_handler hdl;
 
        struct {
@@ -1809,6 +1813,9 @@ static int saa711x_probe(struct i2c_client *client,
        struct saa7115_platform_data *pdata;
        int ident;
        char name[CHIP_VER_SIZE + 1];
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       int ret;
+#endif
 
        /* Check if the adapter supports the needed features */
        if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
@@ -1832,6 +1839,18 @@ static int saa711x_probe(struct i2c_client *client,
        sd = &state->sd;
        v4l2_i2c_subdev_init(sd, client, &saa711x_ops);
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       state->pads[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
+       state->pads[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
+       state->pads[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
+
+       sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
+
+       ret = media_entity_pads_init(&sd->entity, DEMOD_NUM_PADS, state->pads);
+       if (ret < 0)
+               return ret;
+#endif
+
        v4l_info(client, "%s found @ 0x%x (%s)\n", name,
                 client->addr << 1, client->adapter->name);
        hdl = &state->hdl;
index 2e14e52..69becc3 100644 (file)
@@ -632,7 +632,7 @@ static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = {
        .s_mbus_config  = mt9m001_s_mbus_config,
 };
 
-static struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = {
+static const struct v4l2_subdev_sensor_ops mt9m001_subdev_sensor_ops = {
        .g_skip_top_lines       = mt9m001_g_skip_top_lines,
 };
 
index 3b6eeed..5c8e3ff 100644 (file)
@@ -728,7 +728,7 @@ static struct v4l2_subdev_video_ops mt9t031_subdev_video_ops = {
        .s_mbus_config  = mt9t031_s_mbus_config,
 };
 
-static struct v4l2_subdev_sensor_ops mt9t031_subdev_sensor_ops = {
+static const struct v4l2_subdev_sensor_ops mt9t031_subdev_sensor_ops = {
        .g_skip_top_lines       = mt9t031_g_skip_top_lines,
 };
 
index c2ba1fb..2721e58 100644 (file)
@@ -860,7 +860,7 @@ static struct v4l2_subdev_video_ops mt9v022_subdev_video_ops = {
        .s_mbus_config  = mt9v022_s_mbus_config,
 };
 
-static struct v4l2_subdev_sensor_ops mt9v022_subdev_sensor_ops = {
+static const struct v4l2_subdev_sensor_ops mt9v022_subdev_sensor_ops = {
        .g_skip_top_lines       = mt9v022_g_skip_top_lines,
 };
 
index 3397eb9..da7469b 100644 (file)
@@ -59,8 +59,7 @@ MODULE_LICENSE("GPL");
 #define EDID_NUM_BLOCKS_MAX 8
 #define EDID_BLOCK_SIZE 128
 
-/* Max transfer size done by I2C transfer functions */
-#define MAX_XFER_SIZE  (EDID_NUM_BLOCKS_MAX * EDID_BLOCK_SIZE + 2)
+#define I2C_MAX_XFER_SIZE  (EDID_BLOCK_SIZE + 2)
 
 static const struct v4l2_dv_timings_cap tc358743_timings_cap = {
        .type = V4L2_DV_BT_656_1120,
@@ -97,9 +96,6 @@ struct tc358743_state {
        /* edid  */
        u8 edid_blocks_written;
 
-       /* used by i2c_wr() */
-       u8 wr_data[MAX_XFER_SIZE];
-
        struct v4l2_dv_timings timings;
        u32 mbus_fmt_code;
 
@@ -149,13 +145,15 @@ static void i2c_wr(struct v4l2_subdev *sd, u16 reg, u8 *values, u32 n)
 {
        struct tc358743_state *state = to_state(sd);
        struct i2c_client *client = state->i2c_client;
-       u8 *data = state->wr_data;
        int err, i;
        struct i2c_msg msg;
+       u8 data[I2C_MAX_XFER_SIZE];
 
-       if ((2 + n) > sizeof(state->wr_data))
+       if ((2 + n) > I2C_MAX_XFER_SIZE) {
+               n = I2C_MAX_XFER_SIZE - 2;
                v4l2_warn(sd, "i2c wr reg=%04x: len=%d is too big!\n",
                          reg, 2 + n);
+       }
 
        msg.addr = client->addr;
        msg.buf = data;
@@ -859,15 +857,16 @@ static void tc358743_format_change(struct v4l2_subdev *sd)
        if (tc358743_get_detected_timings(sd, &timings)) {
                enable_stream(sd, false);
 
-               v4l2_dbg(1, debug, sd, "%s: Format changed. No signal\n",
+               v4l2_dbg(1, debug, sd, "%s: No signal\n",
                                __func__);
        } else {
                if (!v4l2_match_dv_timings(&state->timings, &timings, 0, false))
                        enable_stream(sd, false);
 
-               v4l2_print_dv_timings(sd->name,
-                               "tc358743_format_change: Format changed. New format: ",
-                               &timings, false);
+               if (debug)
+                       v4l2_print_dv_timings(sd->name,
+                                       "tc358743_format_change: New format: ",
+                                       &timings, false);
        }
 
        if (sd->devnode)
@@ -1581,6 +1580,7 @@ static int tc358743_s_edid(struct v4l2_subdev *sd,
 {
        struct tc358743_state *state = to_state(sd);
        u16 edid_len = edid->blocks * EDID_BLOCK_SIZE;
+       int i;
 
        v4l2_dbg(2, debug, sd, "%s, pad %d, start block %d, blocks %d\n",
                 __func__, edid->pad, edid->start_block, edid->blocks);
@@ -1606,7 +1606,8 @@ static int tc358743_s_edid(struct v4l2_subdev *sd,
                return 0;
        }
 
-       i2c_wr(sd, EDID_RAM, edid->edid, edid_len);
+       for (i = 0; i < edid_len; i += EDID_BLOCK_SIZE)
+               i2c_wr(sd, EDID_RAM + i, edid->edid + i, EDID_BLOCK_SIZE);
 
        state->edid_blocks_written = edid->blocks;
 
index 7fa5f1e..7cdd948 100644 (file)
@@ -1001,7 +1001,7 @@ static struct tvp514x_decoder tvp514x_dev = {
 static struct tvp514x_platform_data *
 tvp514x_get_pdata(struct i2c_client *client)
 {
-       struct tvp514x_platform_data *pdata;
+       struct tvp514x_platform_data *pdata = NULL;
        struct v4l2_of_endpoint bus_cfg;
        struct device_node *endpoint;
        unsigned int flags;
@@ -1013,11 +1013,13 @@ tvp514x_get_pdata(struct i2c_client *client)
        if (!endpoint)
                return NULL;
 
+       if (v4l2_of_parse_endpoint(endpoint, &bus_cfg))
+               goto done;
+
        pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
                goto done;
 
-       v4l2_of_parse_endpoint(endpoint, &bus_cfg);
        flags = bus_cfg.bus.parallel.flags;
 
        if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
index 6c3769d..ef393f5 100644 (file)
@@ -1,19 +1,22 @@
 /*
- * tvp5150 - Texas Instruments TVP5150A/AM1 video decoder driver
+ * tvp5150 - Texas Instruments TVP5150A/AM1 and TVP5151 video decoder driver
  *
  * Copyright (c) 2005,2006 Mauro Carvalho Chehab (mchehab@infradead.org)
  * This code is placed under the terms of the GNU General Public License v2
  */
 
+#include <dt-bindings/media/tvp5150.h>
 #include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/videodev2.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <media/v4l2-async.h>
 #include <media/v4l2-device.h>
-#include <media/i2c/tvp5150.h>
 #include <media/v4l2-ctrls.h>
+#include <media/v4l2-of.h>
+#include <media/v4l2-mc.h>
 
 #include "tvp5150_reg.h"
 
@@ -24,7 +27,7 @@
 #define TVP5150_MAX_CROP_TOP   127
 #define TVP5150_CROP_SHIFT     2
 
-MODULE_DESCRIPTION("Texas Instruments TVP5150A video decoder driver");
+MODULE_DESCRIPTION("Texas Instruments TVP5150A/TVP5150AM1/TVP5151 video decoder driver");
 MODULE_AUTHOR("Mauro Carvalho Chehab");
 MODULE_LICENSE("GPL");
 
@@ -35,6 +38,11 @@ MODULE_PARM_DESC(debug, "Debug level (0-2)");
 
 struct tvp5150 {
        struct v4l2_subdev sd;
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct media_pad pads[DEMOD_NUM_PADS];
+       struct media_entity input_ent[TVP5150_INPUT_NUM];
+       struct media_pad input_pad[TVP5150_INPUT_NUM];
+#endif
        struct v4l2_ctrl_handler hdl;
        struct v4l2_rect rect;
 
@@ -42,6 +50,11 @@ struct tvp5150 {
        u32 input;
        u32 output;
        int enable;
+
+       u16 dev_id;
+       u16 rom_ver;
+
+       enum v4l2_mbus_type mbus_type;
 };
 
 static inline struct tvp5150 *to_tvp5150(struct v4l2_subdev *sd)
@@ -246,8 +259,12 @@ static inline void tvp5150_selmux(struct v4l2_subdev *sd)
        int input = 0;
        int val;
 
-       if ((decoder->output & TVP5150_BLACK_SCREEN) || !decoder->enable)
-               input = 8;
+       /* Only tvp5150am1 and tvp5151 have signal generator support */
+       if ((decoder->dev_id == 0x5150 && decoder->rom_ver == 0x0400) ||
+           (decoder->dev_id == 0x5151 && decoder->rom_ver == 0x0100)) {
+               if (!decoder->enable)
+                       input = 8;
+       }
 
        switch (decoder->input) {
        case TVP5150_COMPOSITE1:
@@ -772,12 +789,17 @@ static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
        v4l2_ctrl_handler_setup(&decoder->hdl);
 
        tvp5150_set_std(sd, decoder->norm);
+
+       if (decoder->mbus_type == V4L2_MBUS_PARALLEL)
+               tvp5150_write(sd, TVP5150_DATA_RATE_SEL, 0x40);
+
        return 0;
 };
 
 static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
 {
        struct v4l2_subdev *sd = to_sd(ctrl);
+       struct tvp5150 *decoder = to_tvp5150(sd);
 
        switch (ctrl->id) {
        case V4L2_CID_BRIGHTNESS:
@@ -791,6 +813,9 @@ static int tvp5150_s_ctrl(struct v4l2_ctrl *ctrl)
                return 0;
        case V4L2_CID_HUE:
                tvp5150_write(sd, TVP5150_HUE_CTL, ctrl->val);
+       case V4L2_CID_TEST_PATTERN:
+               decoder->enable = ctrl->val ? false : true;
+               tvp5150_selmux(sd);
                return 0;
        }
        return -EINVAL;
@@ -818,17 +843,6 @@ static v4l2_std_id tvp5150_read_std(struct v4l2_subdev *sd)
        }
 }
 
-static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd,
-               struct v4l2_subdev_pad_config *cfg,
-               struct v4l2_subdev_mbus_code_enum *code)
-{
-       if (code->pad || code->index)
-               return -EINVAL;
-
-       code->code = MEDIA_BUS_FMT_UYVY8_2X8;
-       return 0;
-}
-
 static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
                struct v4l2_subdev_pad_config *cfg,
                struct v4l2_subdev_format *format)
@@ -844,10 +858,10 @@ static int tvp5150_fill_fmt(struct v4l2_subdev *sd,
        tvp5150_reset(sd, 0);
 
        f->width = decoder->rect.width;
-       f->height = decoder->rect.height;
+       f->height = decoder->rect.height / 2;
 
        f->code = MEDIA_BUS_FMT_UYVY8_2X8;
-       f->field = V4L2_FIELD_SEQ_TB;
+       f->field = V4L2_FIELD_ALTERNATE;
        f->colorspace = V4L2_COLORSPACE_SMPTE170M;
 
        v4l2_dbg(1, debug, sd, "width = %d, height = %d\n", f->width,
@@ -948,10 +962,110 @@ static int tvp5150_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
        return 0;
 }
 
+static int tvp5150_g_mbus_config(struct v4l2_subdev *sd,
+                                struct v4l2_mbus_config *cfg)
+{
+       struct tvp5150 *decoder = to_tvp5150(sd);
+
+       cfg->type = decoder->mbus_type;
+       cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING
+                  | V4L2_MBUS_FIELD_EVEN_LOW | V4L2_MBUS_DATA_ACTIVE_HIGH;
+
+       return 0;
+}
+
+/****************************************************************************
+                       V4L2 subdev pad ops
+ ****************************************************************************/
+static int tvp5150_enum_mbus_code(struct v4l2_subdev *sd,
+               struct v4l2_subdev_pad_config *cfg,
+               struct v4l2_subdev_mbus_code_enum *code)
+{
+       if (code->pad || code->index)
+               return -EINVAL;
+
+       code->code = MEDIA_BUS_FMT_UYVY8_2X8;
+       return 0;
+}
+
+static int tvp5150_enum_frame_size(struct v4l2_subdev *sd,
+                                  struct v4l2_subdev_pad_config *cfg,
+                                  struct v4l2_subdev_frame_size_enum *fse)
+{
+       struct tvp5150 *decoder = to_tvp5150(sd);
+
+       if (fse->index >= 8 || fse->code != MEDIA_BUS_FMT_UYVY8_2X8)
+               return -EINVAL;
+
+       fse->code = MEDIA_BUS_FMT_UYVY8_2X8;
+       fse->min_width = decoder->rect.width;
+       fse->max_width = decoder->rect.width;
+       fse->min_height = decoder->rect.height / 2;
+       fse->max_height = decoder->rect.height / 2;
+
+       return 0;
+}
+
+/****************************************************************************
+                       Media entity ops
+ ****************************************************************************/
+
+static int tvp5150_link_setup(struct media_entity *entity,
+                             const struct media_pad *local,
+                             const struct media_pad *remote, u32 flags)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
+       struct tvp5150 *decoder = to_tvp5150(sd);
+       int i;
+
+       for (i = 0; i < TVP5150_INPUT_NUM; i++) {
+               if (remote->entity == &decoder->input_ent[i])
+                       break;
+       }
+
+       /* Do nothing for entities that are not input connectors */
+       if (i == TVP5150_INPUT_NUM)
+               return 0;
+
+       decoder->input = i;
+
+       tvp5150_selmux(sd);
+#endif
+
+       return 0;
+}
+
+static const struct media_entity_operations tvp5150_sd_media_ops = {
+       .link_setup = tvp5150_link_setup,
+};
+
 /****************************************************************************
                        I2C Command
  ****************************************************************************/
 
+static int tvp5150_s_stream(struct v4l2_subdev *sd, int enable)
+{
+       struct tvp5150 *decoder = to_tvp5150(sd);
+       /* Output format: 8-bit ITU-R BT.656 with embedded syncs */
+       int val = 0x09;
+
+       /* Output format: 8-bit 4:2:2 YUV with discrete sync */
+       if (decoder->mbus_type == V4L2_MBUS_PARALLEL)
+               val = 0x0d;
+
+       /* Initializes TVP5150 to its default values */
+       /* # set PCLK (27MHz) */
+       tvp5150_write(sd, TVP5150_CONF_SHARED_PIN, 0x00);
+
+       if (enable)
+               tvp5150_write(sd, TVP5150_MISC_CTL, val);
+       else
+               tvp5150_write(sd, TVP5150_MISC_CTL, 0x00);
+
+       return 0;
+}
+
 static int tvp5150_s_routing(struct v4l2_subdev *sd,
                             u32 input, u32 output, u32 config)
 {
@@ -959,6 +1073,12 @@ static int tvp5150_s_routing(struct v4l2_subdev *sd,
 
        decoder->input = input;
        decoder->output = output;
+
+       if (output == TVP5150_BLACK_SCREEN)
+               decoder->enable = false;
+       else
+               decoder->enable = true;
+
        tvp5150_selmux(sd);
        return 0;
 }
@@ -1052,6 +1172,42 @@ static int tvp5150_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
        return 0;
 }
 
+static int tvp5150_registered_async(struct v4l2_subdev *sd)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct tvp5150 *decoder = to_tvp5150(sd);
+       int ret = 0;
+       int i;
+
+       for (i = 0; i < TVP5150_INPUT_NUM; i++) {
+               struct media_entity *input = &decoder->input_ent[i];
+               struct media_pad *pad = &decoder->input_pad[i];
+
+               if (!input->name)
+                       continue;
+
+               decoder->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
+
+               ret = media_entity_pads_init(input, 1, pad);
+               if (ret < 0)
+                       return ret;
+
+               ret = media_device_register_entity(sd->v4l2_dev->mdev, input);
+               if (ret < 0)
+                       return ret;
+
+               ret = media_create_pad_link(input, 0, &sd->entity,
+                                           DEMOD_PAD_IF_INPUT, 0);
+               if (ret < 0) {
+                       media_device_unregister_entity(input);
+                       return ret;
+               }
+       }
+#endif
+
+       return 0;
+}
+
 /* ----------------------------------------------------------------------- */
 
 static const struct v4l2_ctrl_ops tvp5150_ctrl_ops = {
@@ -1065,6 +1221,7 @@ static const struct v4l2_subdev_core_ops tvp5150_core_ops = {
        .g_register = tvp5150_g_register,
        .s_register = tvp5150_s_register,
 #endif
+       .registered_async = tvp5150_registered_async,
 };
 
 static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = {
@@ -1073,10 +1230,12 @@ static const struct v4l2_subdev_tuner_ops tvp5150_tuner_ops = {
 
 static const struct v4l2_subdev_video_ops tvp5150_video_ops = {
        .s_std = tvp5150_s_std,
+       .s_stream = tvp5150_s_stream,
        .s_routing = tvp5150_s_routing,
        .s_crop = tvp5150_s_crop,
        .g_crop = tvp5150_g_crop,
        .cropcap = tvp5150_cropcap,
+       .g_mbus_config = tvp5150_g_mbus_config,
 };
 
 static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
@@ -1088,6 +1247,7 @@ static const struct v4l2_subdev_vbi_ops tvp5150_vbi_ops = {
 
 static const struct v4l2_subdev_pad_ops tvp5150_pad_ops = {
        .enum_mbus_code = tvp5150_enum_mbus_code,
+       .enum_frame_size = tvp5150_enum_frame_size,
        .set_fmt = tvp5150_fill_fmt,
        .get_fmt = tvp5150_fill_fmt,
 };
@@ -1105,63 +1265,239 @@ static const struct v4l2_subdev_ops tvp5150_ops = {
                        I2C Client & Driver
  ****************************************************************************/
 
+static int tvp5150_detect_version(struct tvp5150 *core)
+{
+       struct v4l2_subdev *sd = &core->sd;
+       struct i2c_client *c = v4l2_get_subdevdata(sd);
+       unsigned int i;
+       u8 regs[4];
+       int res;
+
+       /*
+        * Read consequent registers - TVP5150_MSB_DEV_ID, TVP5150_LSB_DEV_ID,
+        * TVP5150_ROM_MAJOR_VER, TVP5150_ROM_MINOR_VER
+        */
+       for (i = 0; i < 4; i++) {
+               res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i);
+               if (res < 0)
+                       return res;
+               regs[i] = res;
+       }
+
+       core->dev_id = (regs[0] << 8) | regs[1];
+       core->rom_ver = (regs[2] << 8) | regs[3];
+
+       v4l2_info(sd, "tvp%04x (%u.%u) chip found @ 0x%02x (%s)\n",
+                 core->dev_id, regs[2], regs[3], c->addr << 1,
+                 c->adapter->name);
+
+       if (core->dev_id == 0x5150 && core->rom_ver == 0x0321) {
+               v4l2_info(sd, "tvp5150a detected.\n");
+       } else if (core->dev_id == 0x5150 && core->rom_ver == 0x0400) {
+               v4l2_info(sd, "tvp5150am1 detected.\n");
+
+               /* ITU-T BT.656.4 timing */
+               tvp5150_write(sd, TVP5150_REV_SELECT, 0);
+       } else if (core->dev_id == 0x5151 && core->rom_ver == 0x0100) {
+               v4l2_info(sd, "tvp5151 detected.\n");
+       } else {
+               v4l2_info(sd, "*** unknown tvp%04x chip detected.\n",
+                         core->dev_id);
+       }
+
+       return 0;
+}
+
+static int tvp5150_init(struct i2c_client *c)
+{
+       struct gpio_desc *pdn_gpio;
+       struct gpio_desc *reset_gpio;
+
+       pdn_gpio = devm_gpiod_get_optional(&c->dev, "pdn", GPIOD_OUT_HIGH);
+       if (IS_ERR(pdn_gpio))
+               return PTR_ERR(pdn_gpio);
+
+       if (pdn_gpio) {
+               gpiod_set_value_cansleep(pdn_gpio, 0);
+               /* Delay time between power supplies active and reset */
+               msleep(20);
+       }
+
+       reset_gpio = devm_gpiod_get_optional(&c->dev, "reset", GPIOD_OUT_HIGH);
+       if (IS_ERR(reset_gpio))
+               return PTR_ERR(reset_gpio);
+
+       if (reset_gpio) {
+               /* RESETB pulse duration */
+               ndelay(500);
+               gpiod_set_value_cansleep(reset_gpio, 0);
+               /* Delay time between end of reset to I2C active */
+               usleep_range(200, 250);
+       }
+
+       return 0;
+}
+
+static int tvp5150_parse_dt(struct tvp5150 *decoder, struct device_node *np)
+{
+       struct v4l2_of_endpoint bus_cfg;
+       struct device_node *ep;
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct device_node *connectors, *child;
+       struct media_entity *input;
+       const char *name;
+       u32 input_type;
+#endif
+       unsigned int flags;
+       int ret = 0;
+
+       ep = of_graph_get_next_endpoint(np, NULL);
+       if (!ep)
+               return -EINVAL;
+
+       ret = v4l2_of_parse_endpoint(ep, &bus_cfg);
+       if (ret)
+               goto err;
+
+       flags = bus_cfg.bus.parallel.flags;
+
+       if (bus_cfg.bus_type == V4L2_MBUS_PARALLEL &&
+           !(flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH &&
+             flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH &&
+             flags & V4L2_MBUS_FIELD_EVEN_LOW)) {
+               ret = -EINVAL;
+               goto err;
+       }
+
+       decoder->mbus_type = bus_cfg.bus_type;
+
+#ifdef CONFIG_MEDIA_CONTROLLER
+       connectors = of_get_child_by_name(np, "connectors");
+
+       if (!connectors)
+               goto err;
+
+       for_each_available_child_of_node(connectors, child) {
+               ret = of_property_read_u32(child, "input", &input_type);
+               if (ret) {
+                       v4l2_err(&decoder->sd,
+                                "missing type property in node %s\n",
+                                child->name);
+                       goto err_connector;
+               }
+
+               if (input_type > TVP5150_INPUT_NUM) {
+                       ret = -EINVAL;
+                       goto err_connector;
+               }
+
+               input = &decoder->input_ent[input_type];
+
+               /* Each input connector can only be defined once */
+               if (input->name) {
+                       v4l2_err(&decoder->sd,
+                                "input %s with same type already exists\n",
+                                input->name);
+                       ret = -EINVAL;
+                       goto err_connector;
+               }
+
+               switch (input_type) {
+               case TVP5150_COMPOSITE0:
+               case TVP5150_COMPOSITE1:
+                       input->function = MEDIA_ENT_F_CONN_COMPOSITE;
+                       break;
+               case TVP5150_SVIDEO:
+                       input->function = MEDIA_ENT_F_CONN_SVIDEO;
+                       break;
+               }
+
+               input->flags = MEDIA_ENT_FL_CONNECTOR;
+
+               ret = of_property_read_string(child, "label", &name);
+               if (ret < 0) {
+                       v4l2_err(&decoder->sd,
+                                "missing label property in node %s\n",
+                                child->name);
+                       goto err_connector;
+               }
+
+               input->name = name;
+       }
+
+err_connector:
+       of_node_put(connectors);
+#endif
+err:
+       of_node_put(ep);
+       return ret;
+}
+
+static const char * const tvp5150_test_patterns[2] = {
+       "Disabled",
+       "Black screen"
+};
+
 static int tvp5150_probe(struct i2c_client *c,
                         const struct i2c_device_id *id)
 {
        struct tvp5150 *core;
        struct v4l2_subdev *sd;
-       int tvp5150_id[4];
-       int i, res;
+       struct device_node *np = c->dev.of_node;
+       int res;
 
        /* Check if the adapter supports the needed features */
        if (!i2c_check_functionality(c->adapter,
             I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
                return -EIO;
 
+       res = tvp5150_init(c);
+       if (res)
+               return res;
+
        core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL);
        if (!core)
                return -ENOMEM;
+
        sd = &core->sd;
-       v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
 
-       /* 
-        * Read consequent registers - TVP5150_MSB_DEV_ID, TVP5150_LSB_DEV_ID,
-        * TVP5150_ROM_MAJOR_VER, TVP5150_ROM_MINOR_VER 
-        */
-       for (i = 0; i < 4; i++) {
-               res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i);
-               if (res < 0)
+       if (IS_ENABLED(CONFIG_OF) && np) {
+               res = tvp5150_parse_dt(core, np);
+               if (res) {
+                       v4l2_err(sd, "DT parsing error: %d\n", res);
                        return res;
-               tvp5150_id[i] = res;
+               }
+       } else {
+               /* Default to BT.656 embedded sync */
+               core->mbus_type = V4L2_MBUS_BT656;
        }
 
-       v4l_info(c, "chip found @ 0x%02x (%s)\n",
-                c->addr << 1, c->adapter->name);
+       v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
+       sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
-       if (tvp5150_id[2] == 4 && tvp5150_id[3] == 0) { /* Is TVP5150AM1 */
-               v4l2_info(sd, "tvp%02x%02xam1 detected.\n",
-                         tvp5150_id[0], tvp5150_id[1]);
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       core->pads[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
+       core->pads[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
+       core->pads[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
 
-               /* ITU-T BT.656.4 timing */
-               tvp5150_write(sd, TVP5150_REV_SELECT, 0);
-       } else {
-               /* Is TVP5150A */
-               if (tvp5150_id[2] == 3 || tvp5150_id[3] == 0x21) {
-                       v4l2_info(sd, "tvp%02x%02xa detected.\n",
-                                 tvp5150_id[0], tvp5150_id[1]);
-               } else {
-                       v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n",
-                                 tvp5150_id[0], tvp5150_id[1]);
-                       v4l2_info(sd, "*** Rom ver is %d.%d\n",
-                                 tvp5150_id[2], tvp5150_id[3]);
-               }
-       }
+       sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
+
+       res = media_entity_pads_init(&sd->entity, DEMOD_NUM_PADS, core->pads);
+       if (res < 0)
+               return res;
+
+       sd->entity.ops = &tvp5150_sd_media_ops;
+#endif
+
+       res = tvp5150_detect_version(core);
+       if (res < 0)
+               return res;
 
        core->norm = V4L2_STD_ALL;      /* Default is autodetect */
        core->input = TVP5150_COMPOSITE1;
-       core->enable = 1;
+       core->enable = true;
 
-       v4l2_ctrl_handler_init(&core->hdl, 4);
+       v4l2_ctrl_handler_init(&core->hdl, 5);
        v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
                        V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
        v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
@@ -1170,6 +1506,13 @@ static int tvp5150_probe(struct i2c_client *c,
                        V4L2_CID_SATURATION, 0, 255, 1, 128);
        v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
                        V4L2_CID_HUE, -128, 127, 1, 0);
+       v4l2_ctrl_new_std(&core->hdl, &tvp5150_ctrl_ops,
+                       V4L2_CID_PIXEL_RATE, 27000000,
+                       27000000, 1, 27000000);
+       v4l2_ctrl_new_std_menu_items(&core->hdl, &tvp5150_ctrl_ops,
+                                    V4L2_CID_TEST_PATTERN,
+                                    ARRAY_SIZE(tvp5150_test_patterns),
+                                    0, 0, tvp5150_test_patterns);
        sd->ctrl_handler = &core->hdl;
        if (core->hdl.error) {
                res = core->hdl.error;
@@ -1221,8 +1564,17 @@ static const struct i2c_device_id tvp5150_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, tvp5150_id);
 
+#if IS_ENABLED(CONFIG_OF)
+static const struct of_device_id tvp5150_of_match[] = {
+       { .compatible = "ti,tvp5150", },
+       { /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, tvp5150_of_match);
+#endif
+
 static struct i2c_driver tvp5150_driver = {
        .driver = {
+               .of_match_table = of_match_ptr(tvp5150_of_match),
                .name   = "tvp5150",
        },
        .probe          = tvp5150_probe,
index 83c79fa..4df640c 100644 (file)
@@ -894,7 +894,7 @@ static struct tvp7002_config *
 tvp7002_get_pdata(struct i2c_client *client)
 {
        struct v4l2_of_endpoint bus_cfg;
-       struct tvp7002_config *pdata;
+       struct tvp7002_config *pdata = NULL;
        struct device_node *endpoint;
        unsigned int flags;
 
@@ -905,11 +905,13 @@ tvp7002_get_pdata(struct i2c_client *client)
        if (!endpoint)
                return NULL;
 
+       if (v4l2_of_parse_endpoint(endpoint, &bus_cfg))
+               goto done;
+
        pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
                goto done;
 
-       v4l2_of_parse_endpoint(endpoint, &bus_cfg);
        flags = bus_cfg.bus.parallel.flags;
 
        if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
index 4b564f1..90b693f 100644 (file)
@@ -124,7 +124,7 @@ static int vpx3220_fp_write(struct v4l2_subdev *sd, u8 fpaddr, u16 data)
        return 0;
 }
 
-static u16 vpx3220_fp_read(struct v4l2_subdev *sd, u16 fpaddr)
+static int vpx3220_fp_read(struct v4l2_subdev *sd, u16 fpaddr)
 {
        struct i2c_client *client = v4l2_get_subdevdata(sd);
        s16 data;
index 7dae0ac..711c367 100644 (file)
@@ -20,6 +20,9 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+/* We need to access legacy defines from linux/media.h */
+#define __NEED_MEDIA_LEGACY_API
+
 #include <linux/compat.h>
 #include <linux/export.h>
 #include <linux/idr.h>
@@ -55,7 +58,11 @@ static int media_device_get_info(struct media_device *dev,
 
        memset(&info, 0, sizeof(info));
 
-       strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver));
+       if (dev->driver_name[0])
+               strlcpy(info.driver, dev->driver_name, sizeof(info.driver));
+       else
+               strlcpy(info.driver, dev->dev->driver->name, sizeof(info.driver));
+
        strlcpy(info.model, dev->model, sizeof(info.model));
        strlcpy(info.serial, dev->serial, sizeof(info.serial));
        strlcpy(info.bus_info, dev->bus_info, sizeof(info.bus_info));
@@ -115,6 +122,26 @@ static long media_device_enum_entities(struct media_device *mdev,
        u_ent.group_id = 0;             /* Unused */
        u_ent.pads = ent->num_pads;
        u_ent.links = ent->num_links - ent->num_backlinks;
+
+       /*
+        * Workaround for a bug at media-ctl <= v1.10 that makes it to
+        * do the wrong thing if the entity function doesn't belong to
+        * either MEDIA_ENT_F_OLD_BASE or MEDIA_ENT_F_OLD_SUBDEV_BASE
+        * Ranges.
+        *
+        * Non-subdevices are expected to be at the MEDIA_ENT_F_OLD_BASE,
+        * or, otherwise, will be silently ignored by media-ctl when
+        * printing the graphviz diagram. So, map them into the devnode
+        * old range.
+        */
+       if (ent->function < MEDIA_ENT_F_OLD_BASE ||
+           ent->function > MEDIA_ENT_T_DEVNODE_UNKNOWN) {
+               if (is_media_entity_v4l2_subdev(ent))
+                       u_ent.type = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;
+               else if (ent->function != MEDIA_ENT_F_IO_V4L)
+                       u_ent.type = MEDIA_ENT_T_DEVNODE_UNKNOWN;
+       }
+
        memcpy(&u_ent.raw, &ent->info, sizeof(ent->info));
        if (copy_to_user(uent, &u_ent, sizeof(u_ent)))
                return -EFAULT;
@@ -234,7 +261,6 @@ static long media_device_setup_link(struct media_device *mdev,
        return ret;
 }
 
-#if 0 /* Let's postpone it to Kernel 4.6 */
 static long __media_device_get_topology(struct media_device *mdev,
                                      struct media_v2_topology *topo)
 {
@@ -390,7 +416,6 @@ static long media_device_get_topology(struct media_device *mdev,
 
        return 0;
 }
-#endif
 
 static long media_device_ioctl(struct file *filp, unsigned int cmd,
                               unsigned long arg)
@@ -424,14 +449,13 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd,
                mutex_unlock(&dev->graph_mutex);
                break;
 
-#if 0 /* Let's postpone it to Kernel 4.6 */
        case MEDIA_IOC_G_TOPOLOGY:
                mutex_lock(&dev->graph_mutex);
                ret = media_device_get_topology(dev,
                                (struct media_v2_topology __user *)arg);
                mutex_unlock(&dev->graph_mutex);
                break;
-#endif
+
        default:
                ret = -ENOIOCTLCMD;
        }
@@ -480,9 +504,7 @@ static long media_device_compat_ioctl(struct file *filp, unsigned int cmd,
        case MEDIA_IOC_DEVICE_INFO:
        case MEDIA_IOC_ENUM_ENTITIES:
        case MEDIA_IOC_SETUP_LINK:
-#if 0 /* Let's postpone it to Kernel 4.6 */
        case MEDIA_IOC_G_TOPOLOGY:
-#endif
                return media_device_ioctl(filp, cmd, arg);
 
        case MEDIA_IOC_ENUM_LINKS32:
index cea35bf..29409f4 100644 (file)
@@ -181,6 +181,7 @@ static int media_open(struct inode *inode, struct file *filp)
                ret = mdev->fops->open(filp);
                if (ret) {
                        put_device(&mdev->dev);
+                       filp->private_data = NULL;
                        return ret;
                }
        }
index e89d85a..f2e4360 100644 (file)
@@ -452,9 +452,12 @@ error:
        media_entity_graph_walk_start(graph, entity_err);
 
        while ((entity_err = media_entity_graph_walk_next(graph))) {
-               entity_err->stream_count--;
-               if (entity_err->stream_count == 0)
-                       entity_err->pipe = NULL;
+               /* don't let the stream_count go negative */
+               if (entity->stream_count > 0) {
+                       entity_err->stream_count--;
+                       if (entity_err->stream_count == 0)
+                               entity_err->pipe = NULL;
+               }
 
                /*
                 * We haven't increased stream_count further than this
@@ -486,9 +489,12 @@ void media_entity_pipeline_stop(struct media_entity *entity)
        media_entity_graph_walk_start(graph, entity);
 
        while ((entity = media_entity_graph_walk_next(graph))) {
-               entity->stream_count--;
-               if (entity->stream_count == 0)
-                       entity->pipe = NULL;
+               /* don't let the stream_count go negative */
+               if (entity->stream_count > 0) {
+                       entity->stream_count--;
+                       if (entity->stream_count == 0)
+                               entity->pipe = NULL;
+               }
        }
 
        if (!--pipe->streaming_count)
index 8b5e0b3..4cac1fc 100644 (file)
@@ -39,7 +39,7 @@ MODULE_PARM_DESC(debug,
 
 #define DRIVER_VERSION "0.1"
 #define DRIVER_NAME "flexcop-pci"
-#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>"
+#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@posteo.de>"
 
 struct flexcop_pci {
        struct pci_dev *pdev;
index 9400e99..2c41237 100644 (file)
@@ -186,7 +186,7 @@ MODULE_VERSION(BTTV_VERSION);
 static ssize_t show_card(struct device *cd,
                         struct device_attribute *attr, char *buf)
 {
-       struct video_device *vfd = container_of(cd, struct video_device, dev);
+       struct video_device *vfd = to_video_device(cd);
        struct bttv *btv = video_get_drvdata(vfd);
        return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
 }
@@ -1726,22 +1726,15 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id id)
        struct bttv_fh *fh  = priv;
        struct bttv *btv = fh->btv;
        unsigned int i;
-       int err = 0;
 
        for (i = 0; i < BTTV_TVNORMS; i++)
                if (id & bttv_tvnorms[i].v4l2_id)
                        break;
-       if (i == BTTV_TVNORMS) {
-               err = -EINVAL;
-               goto err;
-       }
-
+       if (i == BTTV_TVNORMS)
+               return -EINVAL;
        btv->std = id;
        set_tvnorm(btv, i);
-
-err:
-
-       return err;
+       return 0;
 }
 
 static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id)
@@ -1770,12 +1763,9 @@ static int bttv_enum_input(struct file *file, void *priv,
 {
        struct bttv_fh *fh = priv;
        struct bttv *btv = fh->btv;
-       int rc = 0;
 
-       if (i->index >= bttv_tvcards[btv->c.type].video_inputs) {
-               rc = -EINVAL;
-               goto err;
-       }
+       if (i->index >= bttv_tvcards[btv->c.type].video_inputs)
+               return -EINVAL;
 
        i->type     = V4L2_INPUT_TYPE_CAMERA;
        i->audioset = 0;
@@ -1799,10 +1789,7 @@ static int bttv_enum_input(struct file *file, void *priv,
        }
 
        i->std = BTTV_NORMS;
-
-err:
-
-       return rc;
+       return 0;
 }
 
 static int bttv_g_input(struct file *file, void *priv, unsigned int *i)
index 4a90eee..35bc9b2 100644 (file)
@@ -1688,9 +1688,9 @@ static int dst_get_tuning_algo(struct dvb_frontend *fe)
        return dst_algo ? DVBFE_ALGO_HW : DVBFE_ALGO_SW;
 }
 
-static int dst_get_frontend(struct dvb_frontend *fe)
+static int dst_get_frontend(struct dvb_frontend *fe,
+                           struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct dst_state *state = fe->demodulator_priv;
 
        p->frequency = state->decode_freq;
index d407244..e69d338 100644 (file)
@@ -318,7 +318,7 @@ static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const s
        return request_firmware(fw, name, &bt->bt->dev->dev);
 }
 
-static struct sp887x_config microtune_mt7202dtf_config = {
+static const struct sp887x_config microtune_mt7202dtf_config = {
        .demod_address = 0x70,
        .request_firmware = microtune_mt7202dtf_request_firmware,
 };
@@ -458,7 +458,7 @@ static void or51211_sleep(struct dvb_frontend * fe)
        bttv_write_gpio(bt->bttv_nr, 0x0001, 0x0000);
 }
 
-static struct or51211_config or51211_config = {
+static const struct or51211_config or51211_config = {
        .demod_address = 0x15,
        .request_firmware = or51211_request_firmware,
        .setmode = or51211_setmode,
index 80319bb..5131c9f 100644 (file)
@@ -2301,7 +2301,8 @@ static int dvb_register(struct cx23885_tsport *port)
 
        /* register everything */
        ret = vb2_dvb_register_bus(&port->frontends, THIS_MODULE, port,
-                                       &dev->pci->dev, adapter_nr, mfe_shared);
+                                  &dev->pci->dev, NULL,
+                                  adapter_nr, mfe_shared);
        if (ret)
                goto frontend_detach;
 
index afb2075..851d2a9 100644 (file)
@@ -1642,7 +1642,8 @@ static int dvb_register(struct cx8802_dev *dev)
 
        /* register everything */
        res = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
-               &dev->pci->dev, adapter_nr, mfe_shared);
+                                  &dev->pci->dev, NULL, adapter_nr,
+                                  mfe_shared);
        if (res)
                goto frontend_detach;
        return res;
index 9d5b314..6e995ef 100644 (file)
@@ -690,7 +690,7 @@ static int tuner_attach_stv6110(struct ddb_input *input, int type)
        struct stv090x_config *feconf = type ? &stv0900_aa : &stv0900;
        struct stv6110x_config *tunerconf = (input->nr & 1) ?
                &stv6110b : &stv6110a;
-       struct stv6110x_devctl *ctl;
+       const struct stv6110x_devctl *ctl;
 
        ctl = dvb_attach(stv6110x_attach, input->fe, tunerconf, i2c);
        if (!ctl) {
index 525ebfe..2b667b3 100644 (file)
@@ -462,8 +462,8 @@ static int netup_unidvb_dvb_init(struct netup_unidvb_dev *ndev,
        }
 
        if (vb2_dvb_register_bus(&ndev->frontends[num],
-                       THIS_MODULE, NULL,
-                       &ndev->pci_dev->dev, adapter_nr, 1)) {
+                                THIS_MODULE, NULL,
+                                &ndev->pci_dev->dev, NULL, adapter_nr, 1)) {
                dev_dbg(&ndev->pci_dev->dev,
                        "%s(): unable to register DVB bus %d\n",
                        __func__, num);
@@ -771,10 +771,9 @@ static int netup_unidvb_initdev(struct pci_dev *pci_dev,
 
        /* allocate device context */
        ndev = kzalloc(sizeof(*ndev), GFP_KERNEL);
-
        if (!ndev)
                goto dev_alloc_err;
-       memset(ndev, 0, sizeof(*ndev));
+
        ndev->old_fw = old_firmware;
        ndev->wq = create_singlethread_workqueue(NETUP_UNIDVB_NAME);
        if (!ndev->wq) {
index 039bed3..4e783a6 100644 (file)
@@ -57,7 +57,7 @@ static int tuner_attach_stv6110(struct ngene_channel *chan)
                chan->dev->card_info->fe_config[chan->number];
        struct stv6110x_config *tunerconf = (struct stv6110x_config *)
                chan->dev->card_info->tuner_config[chan->number];
-       struct stv6110x_devctl *ctl;
+       const struct stv6110x_devctl *ctl;
 
        /* tuner 1+2: i2c adapter #0, tuner 3+4: i2c adapter #1 */
        if (chan->number < 2)
index 29d2094..9a2fdc7 100644 (file)
 #include "xc5000.h"
 #include "s5h1411.h"
 
-/* commly used strings */
-static char name_mute[]    = "mute";
-static char name_radio[]   = "Radio";
-static char name_tv[]      = "Television";
-static char name_tv_mono[] = "TV (mono only)";
-static char name_comp[]    = "Composite";
-static char name_comp1[]   = "Composite1";
-static char name_comp2[]   = "Composite2";
-static char name_comp3[]   = "Composite3";
-static char name_comp4[]   = "Composite4";
-static char name_svideo[]  = "S-Video";
+/* Input names */
+const char * const saa7134_input_name[] = {
+       [SAA7134_INPUT_MUTE]       = "mute",
+       [SAA7134_INPUT_RADIO]      = "Radio",
+       [SAA7134_INPUT_TV]         = "Television",
+       [SAA7134_INPUT_TV_MONO]    = "TV (mono only)",
+       [SAA7134_INPUT_COMPOSITE]  = "Composite",
+       [SAA7134_INPUT_COMPOSITE0] = "Composite0",
+       [SAA7134_INPUT_COMPOSITE1] = "Composite1",
+       [SAA7134_INPUT_COMPOSITE2] = "Composite2",
+       [SAA7134_INPUT_COMPOSITE3] = "Composite3",
+       [SAA7134_INPUT_COMPOSITE4] = "Composite4",
+       [SAA7134_INPUT_SVIDEO]     = "S-Video",
+       [SAA7134_INPUT_SVIDEO0]    = "S-Video0",
+       [SAA7134_INPUT_SVIDEO1]    = "S-Video1",
+       [SAA7134_INPUT_COMPOSITE_OVER_SVIDEO] = "Composite over S-Video",
+};
 
 /* ------------------------------------------------------------------ */
 /* board config info                                                  */
@@ -69,7 +75,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
 
                .inputs         = {{
-                       .name = "default",
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 0,
                        .amux = LINE1,
                }},
@@ -84,22 +90,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
 
                .inputs         = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -114,40 +118,38 @@ struct saa7134_board saa7134_boards[] = {
 
                .gpiomask       = 0xe000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
                        .gpio = 0x8000,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x0000,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                        .gpio = 0x4000,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                        .gpio = 0x4000,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                        .gpio = 0x4000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x2000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x8000,
                },
@@ -163,34 +165,33 @@ struct saa7134_board saa7134_boards[] = {
 
                .gpiomask       = 0xe000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x0000,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                        .gpio = 0x4000,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                        .gpio = 0x4000,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                        .gpio = 0x4000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x2000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE2,
                        .gpio = 0x8000,
                },
@@ -205,20 +206,19 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
 
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,     /* Composite signal on S-Video input */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,     /* Composite input */
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
@@ -235,40 +235,38 @@ struct saa7134_board saa7134_boards[] = {
 
                .gpiomask       = 0x1E000,      /* Set GP16 and unused 15,14,13 to Output */
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
                        .gpio = 0x10000,        /* GP16=1 selects TV input */
-                       .tv   = 1,
                },{
-/*                     .name = name_tv_mono,
+/*                     .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x0000,
-                       .tv   = 1,
                },{
-*/                     .name = name_comp1,     /* Composite signal on S-Video input */
+*/                     .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE2,
 /*                     .gpio = 0x4000,         */
                },{
-                       .name = name_comp2,     /* Composite input */
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 3,
                        .amux = LINE2,
 /*                     .gpio = 0x4000,         */
                },{
-                       .name = name_svideo,    /* S-Video signal on S-Video input */
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
 /*                     .gpio = 0x4000,         */
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x00000,        /* GP16=0 selects FM radio antenna */
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x10000,
                },
@@ -285,40 +283,38 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0xe000,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
                        .gpio = 0x8000,
-                       .tv   = 1,
                }, {
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x0000,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                        .gpio = 0x4000,
                }, {
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                        .gpio = 0x4000,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                        .gpio = 0x4000,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x2000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x8000,
                },
@@ -334,21 +330,20 @@ struct saa7134_board saa7134_boards[] = {
                .empress_addr   = 0x20,
 
                .inputs         = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
                .mpeg      = SAA7134_MPEG_EMPRESS,
@@ -364,21 +359,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
 
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -390,35 +384,33 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
                        /* workaround for problems with normal TV sound */
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
               .mute = {
-                      .name = name_mute,
+                      .type = SAA7134_INPUT_MUTE,
                       .amux = TV,
               },
        },
@@ -432,32 +424,30 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux   = LINE2,
-                       .tv   = 1,
                },{
 
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
 
-                       .name = "CVid over SVid",
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -472,24 +462,23 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x820000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x20000,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x20000,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x20000,
                }},
                .radio          = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x20000,
                },
@@ -504,20 +493,19 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 4,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp2, /* CVideo over SVideo Connector */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE1,
                }}
@@ -531,31 +519,29 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
                        /* workaround for problems with normal TV sound */
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -567,18 +553,17 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
        },
        [SAA7134_BOARD_CINERGY600] = {
@@ -590,25 +575,24 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 4,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp2, /* CVideo over SVideo Connector */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -622,25 +606,24 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = LINE2,
               },
               .mute = {
-                      .name = name_mute,
+                      .type = SAA7134_INPUT_MUTE,
                       .amux = TV,
                },
        },
@@ -655,21 +638,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = LINE2,
                },
        },
@@ -681,18 +663,17 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 4,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
        },
        [SAA7134_BOARD_ELSA_500TV] = {
@@ -703,19 +684,17 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 7,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 8,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 8,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
        },
        [SAA7134_BOARD_ELSA_700TV] = {
@@ -726,21 +705,20 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 4,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 6,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 7,
                        .amux = LINE1,
                }},
                .mute           = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                },
        },
@@ -753,21 +731,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 4,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE1,
                },
        },
@@ -780,29 +757,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x200000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
                        .gpio = 0x0000,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 4,
                        .amux = LINE2,
                        .gpio = 0x0000,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE2,
                        .gpio = 0x0000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x200000,
                },
                .mute  = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .gpio = 0x0000,
                },
 
@@ -815,18 +791,17 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
        },
        [SAA7134_BOARD_10MOONSTVMASTER] = {
@@ -839,34 +814,33 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0xe000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x0000,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                        .gpio = 0x4000,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                        .gpio = 0x4000,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                        .gpio = 0x4000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x2000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE2,
                        .gpio = 0x8000,
                },
@@ -881,23 +855,23 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .empress_addr   = 0x20,
                .inputs         = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 4,
                        .amux = LINE1,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_comp3,
+                       .type = SAA7134_INPUT_COMPOSITE3,
                        .vmux = 0,
                        .amux = LINE1,
                },{
-                       .name = name_comp4,
+                       .type = SAA7134_INPUT_COMPOSITE4,
                        .vmux = 1,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
@@ -912,18 +886,17 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
        },
        [SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS] = {
@@ -935,21 +908,20 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x06c00012,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x0ac20012,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x08c20012,
-                       .tv   = 1,
                }},                             /* radio and probably mute is missing */
        },
        [SAA7134_BOARD_CRONOS_PLUS] = {
@@ -968,23 +940,23 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0xcf00,
                .inputs         = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .gpio = 2 << 14,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 0,
                        .gpio = 1 << 14,
                },{
-                       .name = name_comp3,
+                       .type = SAA7134_INPUT_COMPOSITE3,
                        .vmux = 0,
                        .gpio = 0 << 14,
                },{
-                       .name = name_comp4,
+                       .type = SAA7134_INPUT_COMPOSITE4,
                        .vmux = 0,
                        .gpio = 3 << 14,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .gpio = 2 << 14,
                }},
@@ -999,34 +971,33 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x03,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x00,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x02,
                }, {
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 0,
                        .amux = LINE1,
                        .gpio = 0x02,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x02,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE1,
                        .gpio = 0x01,
                },
                .mute  = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x00,
                },
@@ -1041,18 +1012,17 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .empress_addr   = 0x20,
                .inputs         = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }},
                .mpeg      = SAA7134_MPEG_EMPRESS,
                .video_out = CCIR656,
@@ -1068,22 +1038,21 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
 
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 4,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE1,
                },
        },
@@ -1096,20 +1065,19 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_INACTIVE,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 1,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
@@ -1123,21 +1091,20 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -1150,21 +1117,20 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
        },
@@ -1177,16 +1143,15 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
@@ -1199,30 +1164,28 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux   = 1,
                        .amux   = LINE2,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                },{
-                       .name   = "CVid over SVid",
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux   = 0,
                        .amux   = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = LINE2,
                },
        },
@@ -1234,30 +1197,28 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux   = 1,
                        .amux   = LINE2,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                },{
-                       .name   = "CVid over SVid",
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux   = 0,
                        .amux   = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = LINE2,
                },
        },
@@ -1270,30 +1231,28 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux   = 1,
                        .amux   = LINE2,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                },{
-                       .name   = "CVid over SVid",
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux   = 0,
                        .amux   = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = LINE2,
                },
        },
@@ -1306,30 +1265,28 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x200000,
                },
@@ -1343,10 +1300,10 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                }},
        },
@@ -1360,10 +1317,9 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                 .mpeg           = SAA7134_MPEG_DVB,
                 .inputs         = {{
-                        .name = name_tv,
+                        .type = SAA7134_INPUT_TV,
                         .vmux = 1,
                         .amux = TV,
-                        .tv   = 1,
                 } },
        },
        [SAA7134_BOARD_NOVAC_PRIMETV7133] = {
@@ -1375,15 +1331,14 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                }},
        },
@@ -1396,29 +1351,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
        },
@@ -1432,29 +1386,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                }, {
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
        },
@@ -1467,12 +1420,11 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 7,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 7,
                        .amux = LINE1,
                }},
@@ -1486,21 +1438,20 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -1512,25 +1463,24 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 4,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp2, /* CVideo over SVideo Connector */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE1,
                }},
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE2,
                },
        },
@@ -1544,29 +1494,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x808c0080,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x00080,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x00080,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2_LEFT,
-                       .tv   = 1,
                        .gpio = 0x00080,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x80000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE2,
                        .gpio = 0x40000,
                },
@@ -1580,21 +1529,20 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = LINE2,
                },
        },
@@ -1607,18 +1555,17 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
        },
        [SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE] = {
@@ -1631,29 +1578,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x4000,
                .inputs         = {{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x8000,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x8000,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE1,
                        .gpio = 0x8000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE1,
                        .gpio = 0x8000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio =0x8000,
                }
@@ -1672,29 +1618,28 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x03,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x00,
                },{
-                       .name = name_comp,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x02,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x02,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE1,
                        .gpio = 0x01,
                },
                .mute  = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                        .gpio = 0x00,
                },
@@ -1709,29 +1654,28 @@ struct saa7134_board saa7134_boards[] = {
                .gpiomask       = 0x00300003,
                /* .gpiomask       = 0x8c240003, */
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x01,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                        .gpio = 0x02,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE1,
                        .gpio = 0x02,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x00300001,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x01,
                },
@@ -1745,21 +1689,20 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE1,
                },
        },
@@ -1774,24 +1717,23 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x08000000,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x08000000,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x08000000,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x08000000,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x00000000,
                },
@@ -1805,21 +1747,19 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
@@ -1834,25 +1774,24 @@ struct saa7134_board saa7134_boards[] = {
                .rds_addr       = 0x10,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 4,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp2, /* CVideo over SVideo Connector */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -1866,29 +1805,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x1ce780,
                .inputs         = {{
-                       .name = name_svideo,
-                       .vmux = 0,              /* CVideo over SVideo Connector - ok? */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
+                       .vmux = 0,
                        .amux = LINE1,
                        .gpio = 0x008080,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x008080,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x008080,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x80000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE2,
                        .gpio = 0x0c8000,
                },
@@ -1903,20 +1841,19 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_INACTIVE,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 1,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
@@ -1931,22 +1868,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -1961,25 +1896,24 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
        },
@@ -1995,26 +1929,25 @@ struct saa7134_board saa7134_boards[] = {
                .gpiomask       = 0x00200000,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
                        .gpio = 0x200000,       /* GPIO21=High for TV input */
-                       .tv   = 1,
                },{
-                       .name = name_comp1,     /* Composite signal on S-Video input */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,     /* Composite input */
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,    /* S-Video signal on S-Video input */
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x000000,       /* GPIO21=Low for FM radio antenna */
                },
@@ -2028,11 +1961,11 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                }},
@@ -2049,20 +1982,19 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
@@ -2075,16 +2007,15 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
@@ -2098,29 +2029,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x0700,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                        .gpio   = 0x000,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                        .gpio   = 0x200,                /* gpio by DScaler */
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 0,
                        .amux   = LINE1,
                        .gpio   = 0x200,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = LINE1,
                        .gpio   = 0x100,
                },
                .mute  = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x000,
                },
@@ -2135,26 +2065,25 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x00200000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
                        .gpio = 0x200000,       /* GPIO21=High for TV input */
-                       .tv   = 1,
                },{
-                       .name = name_svideo,    /* S-Video signal on S-Video input */
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                },{
-                       .name = name_comp1,     /* Composite signal on S-Video input */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,     /* Composite input */
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x000000,       /* GPIO21=Low for FM radio antenna */
                },
@@ -2168,29 +2097,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = 0x60,
                .gpiomask       = 0x8c1880,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 0,
                        .amux = LINE1,
                        .gpio = 0x800800,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x801000,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x800000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x880000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE2,
                        .gpio = 0x840000,
                },
@@ -2213,29 +2141,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = 0x60,
                .gpiomask       = 0x0700,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                        .gpio   = 0x000,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                        .gpio   = 0x200,                /* gpio by DScaler */
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 0,
                        .amux   = LINE1,
                        .gpio   = 0x200,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = LINE1,
                        .gpio   = 0x100,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x000,
                },
@@ -2248,30 +2175,28 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,             /* radio unconfirmed */
+                       .type = SAA7134_INPUT_RADIO,            /* radio unconfirmed */
                        .amux = LINE2,
                },
        },
@@ -2286,24 +2211,23 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 1 << 21,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
                        .gpio = 0x0000000,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,     /* Composite input */
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                        .gpio = 0x0000000,
                },{
-                       .name = name_svideo,    /* S-Video input */
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                        .gpio = 0x0000000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x0200000,
                },
@@ -2322,29 +2246,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr= ADDR_UNSET,
                .gpiomask       = 0x00010003,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x01,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                        .gpio = 0x02,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE2,
                        .gpio = 0x02,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE1,
                        .gpio = 0x00010003,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x01,
                },
@@ -2362,21 +2285,20 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                         .name = name_tv,
+                         .type = SAA7134_INPUT_TV,
                          .vmux = 3,
                          .amux = TV,
-                         .tv   = 1,
                },{
-                         .name = name_comp1,
+                         .type = SAA7134_INPUT_COMPOSITE1,
                          .vmux = 1,
                          .amux = LINE1,
                },{
-                         .name = name_svideo,
+                         .type = SAA7134_INPUT_SVIDEO,
                          .vmux = 8,
                          .amux = LINE1,
                }},
                .radio = {
-                         .name = name_radio,
+                         .type = SAA7134_INPUT_RADIO,
                          .amux = LINE2,
                },
        },
@@ -2392,34 +2314,33 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf    = TDA9887_PRESENT,
                .gpiomask        = 0x00200003,
                .inputs          = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x00200003,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x00200003,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x00200003,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x00200003,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x00200003,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x00200003,
                },
@@ -2434,16 +2355,15 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 3,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE2,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE2,
                }},
@@ -2458,16 +2378,15 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 3,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE2,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE2,
                }},
@@ -2481,11 +2400,11 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                }},
@@ -2499,27 +2418,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .empress_addr   = 0x21,
                .inputs         = {{
-                       .name   = "Composite 0",
+                       .type = SAA7134_INPUT_COMPOSITE0,
                        .vmux   = 0,
                        .amux   = LINE1,
                },{
-                       .name   = "Composite 1",
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE2,
                },{
-                       .name   = "Composite 2",
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux   = 2,
                        .amux   = LINE1,
                },{
-                       .name   = "Composite 3",
+                       .type = SAA7134_INPUT_COMPOSITE3,
                        .vmux   = 3,
                        .amux   = LINE2,
                },{
-                       .name   = "S-Video 0",
+                       .type = SAA7134_INPUT_SVIDEO0,
+
                        .vmux   = 8,
                        .amux   = LINE1,
                },{
-                       .name   = "S-Video 1",
+                       .type = SAA7134_INPUT_SVIDEO1,
                        .vmux   = 9,
                        .amux   = LINE2,
                }},
@@ -2538,27 +2458,27 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name   = "Composite 0",
+                       .type = SAA7134_INPUT_COMPOSITE0,
                        .vmux   = 0,
                        .amux   = LINE1,
                },{
-                       .name   = "Composite 1",
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE2,
                },{
-                       .name   = "Composite 2",
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux   = 2,
                        .amux   = LINE1,
                },{
-                       .name   = "Composite 3",
+                       .type = SAA7134_INPUT_COMPOSITE3,
                        .vmux   = 3,
                        .amux   = LINE2,
                },{
-                       .name   = "S-Video 0",
+                       .type = SAA7134_INPUT_SVIDEO0,
                        .vmux   = 8,
                        .amux   = LINE1,
                },{
-                       .name   = "S-Video 1",
+                       .type = SAA7134_INPUT_SVIDEO1,
                        .vmux   = 9,
                        .amux   = LINE2,
                }},
@@ -2572,20 +2492,19 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
 
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,     /* Composite signal on S-Video input */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,     /* Composite input */
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
@@ -2604,11 +2523,11 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
@@ -2622,16 +2541,15 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
 
                .inputs         = {{
-                         .name = name_tv,
+                         .type = SAA7134_INPUT_TV,
                          .vmux = 1,
                          .amux = TV,
-                         .tv   = 1,
                },{
-                         .name = name_comp1,
+                         .type = SAA7134_INPUT_COMPOSITE1,
                          .vmux = 3,
                          .amux = LINE1,
                },{
-                         .name = name_svideo,
+                         .type = SAA7134_INPUT_SVIDEO,
                          .vmux = 6,
                          .amux = LINE1,
                }},
@@ -2645,25 +2563,24 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x080200000,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 4,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE2,
                }, {
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 0,
                        .amux = LINE2,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x0200000,
                },
@@ -2678,29 +2595,28 @@ struct saa7134_board saa7134_boards[] = {
                .gpiomask       = 1 << 21,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x0000000,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                        .gpio = 0x0200000,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 0,
                        .amux = LINE2,
                        .gpio = 0x0200000,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                        .gpio = 0x0200000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x0200000,
                },
@@ -2717,21 +2633,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0xe880c0,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -2745,16 +2660,15 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
@@ -2770,21 +2684,20 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0200000,
                },
@@ -2798,25 +2711,24 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 1 << 21,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux   = 3,
                        .amux   = LINE2,        /* unconfirmed, taken from Philips driver */
                },{
-                       .name   = name_comp2,
-                       .vmux   = 0,            /* untested, Composite over S-Video */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
+                       .vmux   = 0,            /* untested */
                        .amux   = LINE2,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE2,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0200000,
                },
@@ -2834,17 +2746,16 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x80200000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_svideo,  /* NOT tested */
+                       .type = SAA7134_INPUT_SVIDEO,  /* NOT tested */
                        .vmux = 8,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0200000,
                },
@@ -2861,26 +2772,25 @@ struct saa7134_board saa7134_boards[] = {
                .gpiomask       = 0x00200000,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,        /* Analog broadcast/cable TV */
+                       .type = SAA7134_INPUT_TV,       /* Analog broadcast/cable TV */
                        .vmux = 1,
                        .amux = TV,
                        .gpio = 0x200000,       /* GPIO21=High for TV input */
-                       .tv   = 1,
                },{
-                       .name = name_svideo,    /* S-Video signal on S-Video input */
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                },{
-                       .name = name_comp1,     /* Composite signal on S-Video input */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,     /* Composite input */
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x000000,       /* GPIO21=Low for FM radio antenna */
                },
@@ -2894,11 +2804,11 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                }},
@@ -2914,11 +2824,11 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_comp1,     /* Composite input */
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,    /* S-Video signal on S-Video input */
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
@@ -2933,10 +2843,9 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x00600000, /* Bit 21 0=Radio, Bit 22 0=TV */
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                        .gpio   = 0x00200000,
                }},
        },
@@ -2950,25 +2859,24 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 1 << 21,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                },{
-                       .name   = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux   = 0,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0200000,
                },
@@ -2983,21 +2891,20 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 1 << 21,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0200000,
                },
@@ -3012,16 +2919,15 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
@@ -3052,17 +2958,16 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0xca60000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 4,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x04a61000,
                },{
-                       .name = name_comp2,  /*  Composite SVIDEO (B/W if signal is carried with SVIDEO) */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 1,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 9,           /* 9 is correct as S-VIDEO1 according to a169.inf! */
                        .amux = LINE1,
                }},
@@ -3086,26 +2991,25 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x00600000, /* Bit 21 0=Radio, Bit 22 0=TV */
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
                        .gpio = 0x200000,       /* GPIO21=High for TV input */
-                       .tv   = 1,
                },{
-                       .name = name_svideo,    /* S-Video signal on S-Video input */
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                },{
-                       .name = name_comp1,     /* Composite signal on S-Video input */
+                       .type = SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,     /* Composite input */
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 3,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x000000,       /* GPIO21=Low for FM radio antenna */
                },
@@ -3121,40 +3025,38 @@ struct saa7134_board saa7134_boards[] = {
 
                .gpiomask       = 0xe000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
                        .gpio = 0x8000,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x0000,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                        .gpio = 0x4000,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                        .gpio = 0x4000,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                        .gpio = 0x4000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x2000,
                },
                        .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x8000,
                },
@@ -3168,16 +3070,15 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                }},
@@ -3193,11 +3094,11 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_comp1,     /* Composite input */
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,    /* S-Video signal on S-Video input */
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
@@ -3211,25 +3112,24 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
        },
@@ -3244,21 +3144,20 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE1,
                },
        },
@@ -3272,21 +3171,20 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT| TDA9887_PORT1_ACTIVE | TDA9887_PORT2_ACTIVE,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 3,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 4,
                        .amux   = LINE2,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE2,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = LINE1,
                },
        },
@@ -3301,25 +3199,24 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x000200000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 4,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE2,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0200000,
                },
@@ -3335,34 +3232,33 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x03,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x00,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                        .gpio = 0x00,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                        .gpio = 0x00,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                        .gpio = 0x00,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x01,
                },
                .mute  = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                        .gpio = 0x00,
                },
@@ -3378,16 +3274,15 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 3,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE2,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE2,
                }},
@@ -3405,22 +3300,21 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200100,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x0000100,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x0200100,
                },
@@ -3438,22 +3332,21 @@ struct saa7134_board saa7134_boards[] = {
                .ts_force_val   = 1,
                .gpiomask       = 0x0800100, /* GPIO 21 is an INPUT */
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x0000100,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x0800100, /* GPIO 23 HI for FM */
                },
@@ -3470,22 +3363,21 @@ struct saa7134_board saa7134_boards[] = {
                .ts_type        = SAA7134_MPEG_TS_SERIAL,
                .gpiomask       = 0x0800100, /* GPIO 21 is an INPUT */
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x0000100,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x0800100, /* GPIO 23 HI for FM */
                },
@@ -3499,16 +3391,15 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 6,
                        .amux   = LINE1,
                }},
@@ -3523,33 +3414,31 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = 3,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 7,
                        .amux = 4,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = 2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 0,
                        .amux = 2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
 /*                     .gpio = 0x00300001,*/
                        .gpio = 0x20000,
 
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = 0,
                },
        },
@@ -3562,32 +3451,30 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = 3,
-                       .tv   = 1,
                },{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 7,
                        .amux = 4,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = 2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 0,
                        .amux = 2,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x20000,
 
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = 0,
                },
        },
@@ -3600,29 +3487,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x7000,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = 1,
-                       .tv   = 1,
                        .gpio = 0x50000,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = 2,
                        .gpio = 0x2000,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = 2,
                        .gpio = 0x2000,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .vmux = 1,
                        .amux = 1,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .gpio = 0xf000,
                        .amux = 0,
                },
@@ -3635,26 +3521,25 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = 0x61,
                .radio_addr     = 0x60,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .vmux = 1,
                        .amux = LINE1,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                        .gpio = 0x43000,
                },
@@ -3668,16 +3553,15 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 6,
                        .amux   = LINE1,
                }},
@@ -3693,21 +3577,20 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                },{
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                }},
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0200000,
                },
@@ -3721,16 +3604,15 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 1<<21,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE2,
                }},
@@ -3746,10 +3628,9 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                        .gpio   = 0x0200000,
                }},
        },
@@ -3764,29 +3645,28 @@ struct saa7134_board saa7134_boards[] = {
                .gpiomask       = 1 << 21,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x0000000,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                        .gpio = 0x0200000,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 0,
                        .amux = LINE2,
                        .gpio = 0x0200000,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                        .gpio = 0x0200000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x0200000,
                },
@@ -3800,26 +3680,25 @@ struct saa7134_board saa7134_boards[] = {
               .radio_addr     = ADDR_UNSET,
               .gpiomask       = 1 << 21,
               .inputs         = {{
-                      .name = name_tv,
+                      .type = SAA7134_INPUT_TV,
                       .vmux = 1,
                       .amux = TV,
-                      .tv   = 1,
                       .gpio = 0x0000000,
               }, {
-                      .name = name_comp1,
+                      .type = SAA7134_INPUT_COMPOSITE1,
                       .vmux = 3,
                       .amux = LINE2,
               }, {
-                      .name = name_comp2,
+                      .type = SAA7134_INPUT_COMPOSITE2,
                       .vmux = 0,
                       .amux = LINE2,
               }, {
-                      .name = name_svideo,
+                      .type = SAA7134_INPUT_SVIDEO,
                       .vmux = 8,
                       .amux = LINE2,
               } },
               .radio = {
-                      .name = name_radio,
+                      .type = SAA7134_INPUT_RADIO,
                       .amux = TV,
                       .gpio = 0x0200000,
               },
@@ -3832,25 +3711,24 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 0,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                },
        },
@@ -3864,24 +3742,23 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x7000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x0000,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x2000,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x2000,
                }},
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE2,
                        .gpio = 0x3000,
                },
@@ -3896,10 +3773,9 @@ struct saa7134_board saa7134_boards[] = {
                .tda829x_conf   = { .lna_cfg = TDA8290_LNA_OFF },
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv, /* FIXME: analog tv untested */
+                       .type = SAA7134_INPUT_TV, /* FIXME: analog tv untested */
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                }},
        },
        [SAA7134_BOARD_AVERMEDIA_M135A] = {
@@ -3912,26 +3788,25 @@ struct saa7134_board saa7134_boards[] = {
                .tda829x_conf   = { .lna_cfg = TDA8290_LNA_GP0_HIGH_OFF },
                .gpiomask       = 0x020200000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x00200000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x01,
                },
@@ -3946,26 +3821,25 @@ struct saa7134_board saa7134_boards[] = {
                .tda829x_conf   = { .lna_cfg = TDA8290_LNA_OFF },
                .gpiomask       = 0x020200000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x00200000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x01,
                },
@@ -3981,21 +3855,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
        },
@@ -4010,18 +3883,17 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
        },
        [SAA7134_BOARD_BEHOLD_403FM] = {
@@ -4035,21 +3907,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4065,18 +3936,17 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
        },
        [SAA7134_BOARD_BEHOLD_405FM] = {
@@ -4092,21 +3962,20 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4122,20 +3991,19 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0xc0c000,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                        .gpio = 0xc0c000,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv = 1,
                        .gpio = 0xc0c000,
                }},
        },
@@ -4151,24 +4019,23 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs = {{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0xc0c000,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                        .gpio = 0xc0c000,
                },{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv = 1,
                        .gpio = 0xc0c000,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0xc0c000,
                },
@@ -4185,16 +4052,15 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
@@ -4211,25 +4077,24 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4246,25 +4111,24 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4280,21 +4144,20 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
                        .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4311,21 +4174,20 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                        .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4342,21 +4204,20 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                        .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4372,24 +4233,23 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x000A8004,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x000A8004,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                        .gpio = 0x000A8000,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x000A8000,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x000A8000,
                },
@@ -4404,21 +4264,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4432,21 +4291,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4460,21 +4318,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4488,21 +4345,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4517,21 +4373,20 @@ struct saa7134_board saa7134_boards[] = {
                .rds_addr       = 0x10,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4546,21 +4401,20 @@ struct saa7134_board saa7134_boards[] = {
                .rds_addr       = 0x10,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4575,21 +4429,20 @@ struct saa7134_board saa7134_boards[] = {
                .rds_addr       = 0x10,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4604,21 +4457,20 @@ struct saa7134_board saa7134_boards[] = {
                .rds_addr       = 0x10,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                },{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                },{
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }},
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -4636,21 +4488,20 @@ struct saa7134_board saa7134_boards[] = {
                .empress_addr   = 0x20,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
                .mpeg  = SAA7134_MPEG_EMPRESS,
@@ -4673,21 +4524,20 @@ struct saa7134_board saa7134_boards[] = {
                .empress_addr   = 0x20,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
                .mpeg  = SAA7134_MPEG_EMPRESS,
@@ -4712,21 +4562,20 @@ struct saa7134_board saa7134_boards[] = {
                .empress_addr   = 0x20,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
                .mpeg  = SAA7134_MPEG_EMPRESS,
@@ -4747,21 +4596,20 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                }, {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,            /* untested */
                        .amux   = LINE1,
                } },
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0200000,
                },
@@ -4776,30 +4624,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0xf000,
                .inputs         = {{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE2,
                        .gpio = 0x0000,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x2000,
-                       .tv = 1
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x2000,
        } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x1000,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE2,
                        .gpio = 0x6000,
                },
@@ -4813,11 +4659,11 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                } },
@@ -4832,16 +4678,15 @@ struct saa7134_board saa7134_boards[] = {
                .tda829x_conf = { .lna_cfg = TDA8290_LNA_OFF },
                .mpeg         = SAA7134_MPEG_DVB,
                .inputs       = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
@@ -4857,21 +4702,20 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = { {
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                }, {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                } },
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0200000,
                },
@@ -4885,21 +4729,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                 .mpeg           = SAA7134_MPEG_DVB,
                 .inputs         = {{
-                        .name = name_tv,
+                        .type = SAA7134_INPUT_TV,
                         .vmux = 1,
                         .amux = TV,
-                        .tv   = 1,
                 }, {
-                        .name = name_comp1,
+                        .type = SAA7134_INPUT_COMPOSITE1,
                         .vmux = 3,
                         .amux = LINE1,
                 }, {
-                        .name = name_svideo,
+                        .type = SAA7134_INPUT_SVIDEO,
                         .vmux = 8,
                         .amux = LINE2,
                 } },
                 .radio = {
-                        .name = name_radio,
+                        .type = SAA7134_INPUT_RADIO,
                         .amux = TV,
                 },
        },
@@ -4912,21 +4755,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                }, {
-                       .name = name_comp,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 0,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                },
        },
@@ -4938,16 +4780,15 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                } },
@@ -4962,21 +4803,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 3,
                        .amux   = TV,
-                       .tv     = 1,
                }, {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE2,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE2,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                }
        },
@@ -4990,11 +4830,11 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = { {
-                       .name = name_comp,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE1,
                } },
@@ -5009,21 +4849,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = { {
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 4,
                        .amux   = TV,
-                       .tv     = 1,
                }, {
-                       .name = name_comp,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                },
        },
@@ -5038,21 +4877,20 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -5067,21 +4905,20 @@ struct saa7134_board saa7134_boards[] = {
                .gpiomask       = 1 << 21,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 0,
                        .amux = LINE2,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x0200000,
                },
@@ -5097,21 +4934,20 @@ struct saa7134_board saa7134_boards[] = {
                .gpiomask       = 1 << 21,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 0,
                        .amux = LINE2,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x0200000,
                },
@@ -5125,29 +4961,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x801a8087,
                .inputs = { {
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 3,
                        .amux   = LINE2,
-                       .tv     = 1,
                        .gpio   = 0x624000,
                }, {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 1,
                        .amux   = LINE1,
                        .gpio   = 0x624000,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 1,
                        .amux   = LINE1,
                        .gpio   = 0x624000,
                } },
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = LINE2,
                        .gpio   = 0x624001,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                },
        },
@@ -5161,16 +4996,15 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 4,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
@@ -5186,25 +5020,24 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .gpiomask       = 0x0200000,
                .inputs = { {
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                }, {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE2,
                }, {
-                       .name   = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux   = 0,
                        .amux   = LINE2,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE2,
                } },
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0200000,
                },
@@ -5218,30 +5051,29 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = 0x60,
                .gpiomask       = 0x80000700,
                .inputs = { {
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = LINE2,
-                       .tv     = 1,
                        .gpio   = 0x100,
                }, {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                        .gpio   = 0x200,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                        .gpio   = 0x200,
                } },
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .vmux   = 1,
                        .amux   = LINE1,
                        .gpio   = 0x100,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .vmux = 8,
                        .amux = 2,
                },
@@ -5257,18 +5089,17 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .ts_type        = SAA7134_MPEG_TS_PARALLEL,
                .inputs = { {
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
 #if 0  /* FIXME */
                }, {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                        .gpio   = 0x200,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                        .gpio   = 0x200,
@@ -5276,14 +5107,14 @@ struct saa7134_board saa7134_boards[] = {
                } },
 #if 0
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .vmux   = 1,
                        .amux   = LINE1,
                        .gpio   = 0x100,
                },
 #endif
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .vmux = 0,
                        .amux = TV,
                },
@@ -5298,24 +5129,23 @@ struct saa7134_board saa7134_boards[] = {
                .gpiomask       = 0x00300003,
                /* .gpiomask       = 0x8c240003, */
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x01,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                        .amux = LINE1,
                        .gpio = 0x02,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x00300001,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                        .gpio = 0x01,
                },
@@ -5331,29 +5161,28 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x03,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                        .gpio = 0x00,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x00,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                        .gpio = 0x00,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                        .gpio = 0x01,
                },
                .mute  = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                        .gpio = 0x00,
                },
@@ -5368,11 +5197,11 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = { {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE1,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8, /* Not tested */
                        .amux   = LINE1
                } },
@@ -5387,21 +5216,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 2,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 9,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                },
        },
@@ -5416,13 +5244,12 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .ts_type        = SAA7134_MPEG_TS_PARALLEL,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                } },
                .radio = {      /* untested */
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                },
        },
@@ -5436,16 +5263,15 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = { {
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 3,
                        .amux   = TV,
-                       .tv     = 1,
                }, {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 4,
                        .amux   = LINE2,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE2,
                } },
@@ -5459,10 +5285,10 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = { {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                } },
        },
@@ -5479,25 +5305,24 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT,
                .gpiomask       = 0x00008000,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE2,
                },
        },
@@ -5512,7 +5337,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr   = ADDR_UNSET,
                .gpiomask      = 0x389c00,
                .inputs       = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x01fc00,
@@ -5529,21 +5354,20 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .ts_type        = SAA7134_MPEG_TS_PARALLEL,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 2,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 9,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                },
        },
@@ -5556,21 +5380,20 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 2,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 9,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                },
        },
@@ -5584,16 +5407,15 @@ struct saa7134_board saa7134_boards[] = {
                .tda9887_conf   = TDA9887_PRESENT | TDA9887_PORT1_ACTIVE,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs = {{
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 3,
                        .amux   = TV,
-                       .tv     = 1,
                }, {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE2,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE2,
                } },
@@ -5607,25 +5429,24 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = 0x60,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE1,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = TV,
                },
        },
@@ -5642,29 +5463,28 @@ struct saa7134_board saa7134_boards[] = {
                .mpeg           = SAA7134_MPEG_DVB,
                .ts_type        = SAA7134_MPEG_TS_PARALLEL,
                .inputs         = { {
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                        .gpio   = 0x00050000,
                }, {
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 3,
                        .amux   = LINE1,
                        .gpio   = 0x00050000,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                        .gpio   = 0x00050000,
                } },
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x00050000,
                },
                .mute = {
-                       .name   = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .vmux   = 0,
                        .amux   = TV,
                        .gpio   = 0x00050000,
@@ -5681,21 +5501,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x00008000,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
        },
@@ -5710,21 +5529,20 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x00008000,
                .inputs         = { {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = LINE2,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 1,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
        },
@@ -5736,15 +5554,15 @@ struct saa7134_board saa7134_boards[] = {
                .tuner_addr     = ADDR_UNSET,
                .radio_addr     = ADDR_UNSET,
                .inputs         = {{
-                       .name   = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux   = 0,
                        .amux   = LINE1,
                }, {
-                       .name   = name_comp3,
+                       .type = SAA7134_INPUT_COMPOSITE3,
                        .vmux   = 2,
                        .amux   = LINE1,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE1,
                } },
@@ -5760,21 +5578,20 @@ struct saa7134_board saa7134_boards[] = {
                .gpiomask       = 1 << 21,
                .ts_type        = SAA7134_MPEG_TS_PARALLEL,
                .inputs = { {
-                       .name   = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux   = 1,
                        .amux   = TV,
-                       .tv     = 1,
                }, {
-                       .name   = name_comp,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux   = 3,
                        .amux   = LINE1,
                }, {
-                       .name   = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux   = 8,
                        .amux   = LINE2,
                } },
                .radio = {
-                       .name   = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux   = TV,
                        .gpio   = 0x0000000,
                },
@@ -5790,7 +5607,7 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr   = ADDR_UNSET,
                .gpiomask      = 0x618E700,
                .inputs       = {{
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE1,
                        .gpio = 0x6010000,
@@ -5809,21 +5626,20 @@ struct saa7134_board saa7134_boards[] = {
                .gpiomask       = 1 << 11,
                .mpeg           = SAA7134_MPEG_DVB,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_comp,
+                       .type = SAA7134_INPUT_COMPOSITE,
                        .vmux = 4,
                        .amux = LINE1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE1,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = TV,
                        .gpio = 0x0000800,
                },
@@ -5837,16 +5653,15 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .mpeg           = SAA7134_MPEG_GO7007,
                .inputs         = { {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                }, {
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 3,
                        .amux = TV,
-                       .tv   = 1,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 6,
                .amux = LINE1,
                } },
@@ -5862,25 +5677,24 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .tda9887_conf   = TDA9887_PRESENT,
                .inputs         = {{
-                       .name = name_tv,
+                       .type = SAA7134_INPUT_TV,
                        .vmux = 1,
                        .amux = LINE2,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 0,
                        .amux = LINE2,
                }, {
-                       .name = name_comp2,
+                       .type = SAA7134_INPUT_COMPOSITE2,
                        .vmux = 3,
                        .amux = LINE2,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                } },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                },
        },
@@ -5893,29 +5707,28 @@ struct saa7134_board saa7134_boards[] = {
                .radio_addr     = ADDR_UNSET,
                .gpiomask       = 0x0d,
                .inputs         = {{
-                       .name = name_tv_mono,
+                       .type = SAA7134_INPUT_TV_MONO,
                        .vmux = 1,
                        .amux = LINE1,
                        .gpio = 0x00,
-                       .tv   = 1,
                }, {
-                       .name = name_comp1,
+                       .type = SAA7134_INPUT_COMPOSITE1,
                        .vmux = 3,
                        .amux = LINE2,
                        .gpio = 0x08,
                }, {
-                       .name = name_svideo,
+                       .type = SAA7134_INPUT_SVIDEO,
                        .vmux = 8,
                        .amux = LINE2,
                        .gpio = 0x08,
                } },
                .radio = {
-                       .name = name_radio,
+                       .type = SAA7134_INPUT_RADIO,
                        .amux = LINE1,
                        .gpio = 0x04,
                },
                .mute = {
-                       .name = name_mute,
+                       .type = SAA7134_INPUT_MUTE,
                        .amux = LINE1,
                        .gpio = 0x08,
                },
index e227b02..42bc417 100644 (file)
@@ -112,7 +112,7 @@ int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
                printk(KERN_DEBUG pr_fmt("irq: " fmt), ## arg); \
        } while (0)
 
-void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
+void saa7134_track_gpio(struct saa7134_dev *dev, const char *msg)
 {
        unsigned long mode,status;
 
@@ -806,6 +806,153 @@ static void must_configure_manually(int has_eeprom)
        }
 }
 
+static void saa7134_unregister_media_device(struct saa7134_dev *dev)
+{
+
+#ifdef CONFIG_MEDIA_CONTROLLER
+       if (!dev->media_dev)
+               return;
+       media_device_unregister(dev->media_dev);
+       media_device_cleanup(dev->media_dev);
+       kfree(dev->media_dev);
+       dev->media_dev = NULL;
+#endif
+}
+
+static void saa7134_media_release(struct saa7134_dev *dev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+       int i;
+
+       for (i = 0; i < SAA7134_INPUT_MAX + 1; i++)
+               media_device_unregister_entity(&dev->input_ent[i]);
+#endif
+}
+
+static void saa7134_create_entities(struct saa7134_dev *dev)
+{
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       int ret, i;
+       struct media_entity *entity;
+       struct media_entity *decoder = NULL;
+
+       /* Check if it is using an external analog TV demod */
+       media_device_for_each_entity(entity, dev->media_dev) {
+               if (entity->function == MEDIA_ENT_F_ATV_DECODER)
+                       decoder = entity;
+                       break;
+       }
+
+       /*
+        * saa713x is not using an external ATV demod.
+        * Register the internal one
+        */
+       if (!decoder) {
+               dev->demod.name = "saa713x";
+               dev->demod_pad[DEMOD_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
+               dev->demod_pad[DEMOD_PAD_VID_OUT].flags = MEDIA_PAD_FL_SOURCE;
+               dev->demod_pad[DEMOD_PAD_VBI_OUT].flags = MEDIA_PAD_FL_SOURCE;
+               dev->demod.function = MEDIA_ENT_F_ATV_DECODER;
+
+               ret = media_entity_pads_init(&dev->demod, DEMOD_NUM_PADS,
+                                            dev->demod_pad);
+               if (ret < 0)
+                       pr_err("failed to initialize demod pad!\n");
+
+               ret = media_device_register_entity(dev->media_dev, &dev->demod);
+               if (ret < 0)
+                       pr_err("failed to register demod entity!\n");
+
+               dev->decoder = &dev->demod;
+       } else {
+               dev->decoder = decoder;
+       }
+
+       /* Initialize Video, VBI and Radio pads */
+       dev->video_pad.flags = MEDIA_PAD_FL_SINK;
+       ret = media_entity_pads_init(&dev->video_dev->entity, 1,
+                                    &dev->video_pad);
+       if (ret < 0)
+               pr_err("failed to initialize video media entity!\n");
+
+       dev->vbi_pad.flags = MEDIA_PAD_FL_SINK;
+       ret = media_entity_pads_init(&dev->vbi_dev->entity, 1,
+                                       &dev->vbi_pad);
+       if (ret < 0)
+               pr_err("failed to initialize vbi media entity!\n");
+
+       /* Create entities for each input connector */
+       for (i = 0; i < SAA7134_INPUT_MAX; i++) {
+               struct media_entity *ent = &dev->input_ent[i];
+               struct saa7134_input *in = &card_in(dev, i);
+
+               if (in->type == SAA7134_NO_INPUT)
+                       break;
+
+               /* This input uses the S-Video connector */
+               if (in->type == SAA7134_INPUT_COMPOSITE_OVER_SVIDEO)
+                       continue;
+
+               ent->name = saa7134_input_name[in->type];
+               ent->flags = MEDIA_ENT_FL_CONNECTOR;
+               dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
+
+               switch (in->type) {
+               case SAA7134_INPUT_COMPOSITE:
+               case SAA7134_INPUT_COMPOSITE0:
+               case SAA7134_INPUT_COMPOSITE1:
+               case SAA7134_INPUT_COMPOSITE2:
+               case SAA7134_INPUT_COMPOSITE3:
+               case SAA7134_INPUT_COMPOSITE4:
+                       ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
+                       break;
+               case SAA7134_INPUT_SVIDEO:
+               case SAA7134_INPUT_SVIDEO0:
+               case SAA7134_INPUT_SVIDEO1:
+                       ent->function = MEDIA_ENT_F_CONN_SVIDEO;
+                       break;
+               default:
+                       /*
+                        * SAA7134_INPUT_TV and SAA7134_INPUT_TV_MONO.
+                        *
+                        * Please notice that neither SAA7134_INPUT_MUTE or
+                        * SAA7134_INPUT_RADIO are defined at
+                        * saa7134_board.input.
+                        */
+                       ent->function = MEDIA_ENT_F_CONN_RF;
+                       break;
+               }
+
+               ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
+               if (ret < 0)
+                       pr_err("failed to initialize input pad[%d]!\n", i);
+
+               ret = media_device_register_entity(dev->media_dev, ent);
+               if (ret < 0)
+                       pr_err("failed to register input entity %d!\n", i);
+       }
+
+       /* Create input for Radio RF connector */
+       if (card_has_radio(dev)) {
+               struct saa7134_input *in = &saa7134_boards[dev->board].radio;
+               struct media_entity *ent = &dev->input_ent[i];
+
+               ent->name = saa7134_input_name[in->type];
+               ent->flags = MEDIA_ENT_FL_CONNECTOR;
+               dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
+               ent->function = MEDIA_ENT_F_CONN_RF;
+
+               ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
+               if (ret < 0)
+                       pr_err("failed to initialize input pad[%d]!\n", i);
+
+               ret = media_device_register_entity(dev->media_dev, ent);
+               if (ret < 0)
+                       pr_err("failed to register input entity %d!\n", i);
+       }
+#endif
+}
+
 static struct video_device *vdev_init(struct saa7134_dev *dev,
                                      struct video_device *template,
                                      char *type)
@@ -826,6 +973,8 @@ static struct video_device *vdev_init(struct saa7134_dev *dev,
 
 static void saa7134_unregister_video(struct saa7134_dev *dev)
 {
+       saa7134_media_release(dev);
+
        if (dev->video_dev) {
                if (video_is_registered(dev->video_dev))
                        video_unregister_device(dev->video_dev);
@@ -889,6 +1038,18 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
        if (NULL == dev)
                return -ENOMEM;
 
+       dev->nr = saa7134_devcount;
+       sprintf(dev->name, "saa%x[%d]", pci_dev->device, dev->nr);
+
+#ifdef CONFIG_MEDIA_CONTROLLER
+       dev->media_dev = v4l2_mc_pci_media_device_init(pci_dev, dev->name);
+       if (!dev->media_dev) {
+               err = -ENOMEM;
+               goto fail0;
+       }
+       dev->v4l2_dev.mdev = dev->media_dev;
+#endif
+
        err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev);
        if (err)
                goto fail0;
@@ -900,9 +1061,6 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
                goto fail1;
        }
 
-       dev->nr = saa7134_devcount;
-       sprintf(dev->name,"saa%x[%d]",pci_dev->device,dev->nr);
-
        /* pci quirks */
        if (pci_pci_problems) {
                if (pci_pci_problems & PCIPCI_TRITON)
@@ -1102,6 +1260,15 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
                       dev->name, video_device_node_name(dev->radio_dev));
        }
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+       saa7134_create_entities(dev);
+
+       err = v4l2_mc_create_media_graph(dev->media_dev);
+       if (err) {
+               pr_err("failed to create media graph\n");
+               goto fail5;
+       }
+#endif
        /* everything worked */
        saa7134_devcount++;
 
@@ -1109,6 +1276,18 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
                saa7134_dmasound_init(dev);
 
        request_submodules(dev);
+
+       /*
+        * Do it at the end, to reduce dynamic configuration changes during
+        * the device init. Yet, as request_modules() can be async, the
+        * topology will likely change after load the saa7134 subdrivers.
+        */
+#ifdef CONFIG_MEDIA_CONTROLLER
+       err = media_device_register(dev->media_dev);
+       if (err)
+               goto fail5;
+#endif
+
        return 0;
 
  fail5:
@@ -1126,6 +1305,9 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
  fail1:
        v4l2_device_unregister(&dev->v4l2_dev);
  fail0:
+#ifdef CONFIG_MEDIA_CONTROLLER
+       kfree(dev->media_dev);
+#endif
        kfree(dev);
        return err;
 }
@@ -1188,9 +1370,10 @@ static void saa7134_finidev(struct pci_dev *pci_dev)
        release_mem_region(pci_resource_start(pci_dev,0),
                           pci_resource_len(pci_dev,0));
 
-
        v4l2_device_unregister(&dev->v4l2_dev);
 
+       saa7134_unregister_media_device(dev);
+
        /* free memory */
        kfree(dev);
 }
index 101ba87..db987e5 100644 (file)
@@ -1883,8 +1883,15 @@ static int dvb_init(struct saa7134_dev *dev)
        fe0->dvb.frontend->callback = saa7134_tuner_callback;
 
        /* register everything else */
+#ifndef CONFIG_MEDIA_CONTROLLER_DVB
        ret = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
-                                       &dev->pci->dev, adapter_nr, 0);
+                                  &dev->pci->dev, NULL,
+                                  adapter_nr, 0);
+#else
+       ret = vb2_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
+                                  &dev->pci->dev, dev->media_dev,
+                                  adapter_nr, 0);
+#endif
 
        /* this sequence is necessary to make the tda1004x load its firmware
         * and to enter analog mode of hybrid boards
index 56b932c..ca417a4 100644 (file)
@@ -189,6 +189,7 @@ static const struct v4l2_ioctl_ops ts_ioctl_ops = {
        .vidioc_querybuf                = vb2_ioctl_querybuf,
        .vidioc_qbuf                    = vb2_ioctl_qbuf,
        .vidioc_dqbuf                   = vb2_ioctl_dqbuf,
+       .vidioc_expbuf                  = vb2_ioctl_expbuf,
        .vidioc_streamon                = vb2_ioctl_streamon,
        .vidioc_streamoff               = vb2_ioctl_streamoff,
        .vidioc_g_frequency             = saa7134_g_frequency,
@@ -286,7 +287,7 @@ static int empress_init(struct saa7134_dev *dev)
         * transfers that do not start at the beginning of a page. A USERPTR
         * can start anywhere in a page, so USERPTR support is a no-go.
         */
-       q->io_modes = VB2_MMAP | VB2_READ;
+       q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
        q->drv_priv = &dev->ts_q;
        q->ops = &saa7134_empress_qops;
        q->gfp_flags = GFP_DMA32;
index 8a2abb3..2799538 100644 (file)
@@ -378,7 +378,7 @@ static int saa7134_go7007_send_firmware(struct go7007 *go, u8 *data, int len)
        return 0;
 }
 
-static struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
+static const struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
        .interface_reset        = saa7134_go7007_interface_reset,
        .write_interrupt        = saa7134_go7007_write_interrupt,
        .read_interrupt         = saa7134_go7007_read_interrupt,
index 21a5793..38f94b7 100644 (file)
@@ -192,7 +192,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
        in   = dev->input;
        mute = (dev->ctl_mute ||
                (dev->automute  &&  (&card(dev).radio) != in));
-       if (card(dev).mute.name) {
+       if (card(dev).mute.type) {
                /*
                 * 7130 - we'll mute using some unconnected audio input
                 * 7134 - we'll probably should switch external mux with gpio
@@ -204,13 +204,14 @@ static void mute_input_7134(struct saa7134_dev *dev)
        if (dev->hw_mute  == mute &&
                dev->hw_input == in && !dev->insuspend) {
                audio_dbg(1, "mute/input: nothing to do [mute=%d,input=%s]\n",
-                         mute, in->name);
+                         mute, saa7134_input_name[in->type]);
                return;
        }
 
        audio_dbg(1, "ctl_mute=%d automute=%d input=%s  =>  mute=%d input=%s\n",
                  dev->ctl_mute, dev->automute,
-                 dev->input->name, mute, in->name);
+                 saa7134_input_name[dev->input->type], mute,
+                 saa7134_input_name[in->type]);
        dev->hw_mute  = mute;
        dev->hw_input = in;
 
@@ -245,7 +246,7 @@ static void mute_input_7134(struct saa7134_dev *dev)
        mask = card(dev).gpiomask;
        saa_andorl(SAA7134_GPIO_GPMODE0 >> 2,   mask, mask);
        saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio);
-       saa7134_track_gpio(dev,in->name);
+       saa7134_track_gpio(dev, saa7134_input_name[in->type]);
 }
 
 static void tvaudio_setmode(struct saa7134_dev *dev,
@@ -756,14 +757,14 @@ static int mute_input_7133(struct saa7134_dev *dev)
        if (0 != card(dev).gpiomask) {
                mask = card(dev).gpiomask;
 
-               if (card(dev).mute.name && dev->ctl_mute)
+               if (card(dev).mute.type && dev->ctl_mute)
                        in = &card(dev).mute;
                else
                        in = dev->input;
 
                saa_andorl(SAA7134_GPIO_GPMODE0 >> 2,   mask, mask);
                saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, in->gpio);
-               saa7134_track_gpio(dev,in->name);
+               saa7134_track_gpio(dev, saa7134_input_name[in->type]);
        }
 
        return 0;
index a63c136..ffa3954 100644 (file)
@@ -409,7 +409,8 @@ static void set_tvnorm(struct saa7134_dev *dev, struct saa7134_tvnorm *norm)
 
 static void video_mux(struct saa7134_dev *dev, int input)
 {
-       video_dbg("video input = %d [%s]\n", input, card_in(dev, input).name);
+       video_dbg("video input = %d [%s]\n",
+                 input, saa7134_input_name[card_in(dev, input).type]);
        dev->ctl_input = input;
        set_tvnorm(dev, dev->tvnorm);
        saa7134_tvaudio_setinput(dev, &card_in(dev, input));
@@ -478,8 +479,7 @@ void saa7134_set_tvnorm_hw(struct saa7134_dev *dev)
 {
        saa7134_set_decoder(dev);
 
-       if (card_in(dev, dev->ctl_input).tv)
-               saa_call_all(dev, video, s_std, dev->tvnorm->id);
+       saa_call_all(dev, video, s_std, dev->tvnorm->id);
        /* Set the correct norm for the saa6752hs. This function
           does nothing if there is no saa6752hs. */
        saa_call_empress(dev, video, s_std, dev->tvnorm->id);
@@ -785,6 +785,63 @@ static int stop_preview(struct saa7134_dev *dev)
        return 0;
 }
 
+/*
+ * Media Controller helper functions
+ */
+
+static int saa7134_enable_analog_tuner(struct saa7134_dev *dev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct media_device *mdev = dev->media_dev;
+       struct media_entity *source;
+       struct media_link *link, *found_link = NULL;
+       int ret, active_links = 0;
+
+       if (!mdev || !dev->decoder)
+               return 0;
+
+       /*
+        * This will find the tuner that is connected into the decoder.
+        * Technically, this is not 100% correct, as the device may be
+        * using an analog input instead of the tuner. However, as we can't
+        * do DVB streaming while the DMA engine is being used for V4L2,
+        * this should be enough for the actual needs.
+        */
+       list_for_each_entry(link, &dev->decoder->links, list) {
+               if (link->sink->entity == dev->decoder) {
+                       found_link = link;
+                       if (link->flags & MEDIA_LNK_FL_ENABLED)
+                               active_links++;
+                       break;
+               }
+       }
+
+       if (active_links == 1 || !found_link)
+               return 0;
+
+       source = found_link->source->entity;
+       list_for_each_entry(link, &source->links, list) {
+               struct media_entity *sink;
+               int flags = 0;
+
+               sink = link->sink->entity;
+
+               if (sink == dev->decoder)
+                       flags = MEDIA_LNK_FL_ENABLED;
+
+               ret = media_entity_setup_link(link, flags);
+               if (ret) {
+                       pr_err("Couldn't change link %s->%s to %s. Error %d\n",
+                              source->name, sink->name,
+                              flags ? "enabled" : "disabled",
+                              ret);
+                       return ret;
+               }
+       }
+#endif
+       return 0;
+}
+
 /* ------------------------------------------------------------------ */
 
 static int buffer_activate(struct saa7134_dev *dev,
@@ -924,6 +981,9 @@ static int queue_setup(struct vb2_queue *q,
        *nplanes = 1;
        sizes[0] = size;
        alloc_ctxs[0] = dev->alloc_ctx;
+
+       saa7134_enable_analog_tuner(dev);
+
        return 0;
 }
 
@@ -1219,10 +1279,13 @@ static int saa7134_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.height       = dev->height;
        f->fmt.pix.field        = dev->field;
        f->fmt.pix.pixelformat  = dev->fmt->fourcc;
-       f->fmt.pix.bytesperline =
-               (f->fmt.pix.width * dev->fmt->depth) >> 3;
+       if (dev->fmt->planar)
+               f->fmt.pix.bytesperline = f->fmt.pix.width;
+       else
+               f->fmt.pix.bytesperline =
+                       (f->fmt.pix.width * dev->fmt->depth) / 8;
        f->fmt.pix.sizeimage =
-               f->fmt.pix.height * f->fmt.pix.bytesperline;
+               (f->fmt.pix.height * f->fmt.pix.width * dev->fmt->depth) / 8;
        f->fmt.pix.colorspace   = V4L2_COLORSPACE_SMPTE170M;
        return 0;
 }
@@ -1298,10 +1361,13 @@ static int saa7134_try_fmt_vid_cap(struct file *file, void *priv,
        if (f->fmt.pix.height > maxh)
                f->fmt.pix.height = maxh;
        f->fmt.pix.width &= ~0x03;
-       f->fmt.pix.bytesperline =
-               (f->fmt.pix.width * fmt->depth) >> 3;
+       if (fmt->planar)
+               f->fmt.pix.bytesperline = f->fmt.pix.width;
+       else
+               f->fmt.pix.bytesperline =
+                       (f->fmt.pix.width * fmt->depth) / 8;
        f->fmt.pix.sizeimage =
-               f->fmt.pix.height * f->fmt.pix.bytesperline;
+               (f->fmt.pix.height * f->fmt.pix.width * fmt->depth) / 8;
        f->fmt.pix.colorspace   = V4L2_COLORSPACE_SMPTE170M;
 
        return 0;
@@ -1381,13 +1447,19 @@ int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i)
        n = i->index;
        if (n >= SAA7134_INPUT_MAX)
                return -EINVAL;
-       if (NULL == card_in(dev, i->index).name)
+       if (card_in(dev, i->index).type == SAA7134_NO_INPUT)
                return -EINVAL;
        i->index = n;
-       i->type  = V4L2_INPUT_TYPE_CAMERA;
-       strcpy(i->name, card_in(dev, n).name);
-       if (card_in(dev, n).tv)
+       strcpy(i->name, saa7134_input_name[card_in(dev, n).type]);
+       switch (card_in(dev, n).type) {
+       case SAA7134_INPUT_TV:
+       case SAA7134_INPUT_TV_MONO:
                i->type = V4L2_INPUT_TYPE_TUNER;
+               break;
+       default:
+               i->type  = V4L2_INPUT_TYPE_CAMERA;
+               break;
+       }
        if (n == dev->ctl_input) {
                int v1 = saa_readb(SAA7134_STATUS_VIDEO1);
                int v2 = saa_readb(SAA7134_STATUS_VIDEO2);
@@ -1419,7 +1491,7 @@ int saa7134_s_input(struct file *file, void *priv, unsigned int i)
 
        if (i >= SAA7134_INPUT_MAX)
                return -EINVAL;
-       if (NULL == card_in(dev, i).name)
+       if (card_in(dev, i).type == SAA7134_NO_INPUT)
                return -EINVAL;
        video_mux(dev, i);
        return 0;
@@ -1656,12 +1728,13 @@ int saa7134_g_tuner(struct file *file, void *priv,
                return -EINVAL;
        memset(t, 0, sizeof(*t));
        for (n = 0; n < SAA7134_INPUT_MAX; n++) {
-               if (card_in(dev, n).tv)
+               if (card_in(dev, n).type == SAA7134_INPUT_TV ||
+                   card_in(dev, n).type == SAA7134_INPUT_TV_MONO)
                        break;
        }
        if (n == SAA7134_INPUT_MAX)
                return -EINVAL;
-       if (NULL != card_in(dev, n).name) {
+       if (card_in(dev, n).type != SAA7134_NO_INPUT) {
                strcpy(t->name, "Television");
                t->type = V4L2_TUNER_ANALOG_TV;
                saa_call_all(dev, tuner, g_tuner, t);
@@ -1906,6 +1979,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
        .vidioc_querybuf                = vb2_ioctl_querybuf,
        .vidioc_qbuf                    = vb2_ioctl_qbuf,
        .vidioc_dqbuf                   = vb2_ioctl_dqbuf,
+       .vidioc_expbuf                  = vb2_ioctl_expbuf,
        .vidioc_s_std                   = saa7134_s_std,
        .vidioc_g_std                   = saa7134_g_std,
        .vidioc_querystd                = saa7134_querystd,
@@ -2089,7 +2163,7 @@ int saa7134_video_init1(struct saa7134_dev *dev)
         * USERPTR support is a no-go unless the application knows about these
         * limitations and has special support for this.
         */
-       q->io_modes = VB2_MMAP | VB2_READ;
+       q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
        if (saa7134_userptr)
                q->io_modes |= VB2_USERPTR;
        q->drv_priv = &dev->video_q;
index 5938bc7..8936568 100644 (file)
@@ -361,12 +361,29 @@ struct saa7134_card_ir {
 #define SET_CLOCK_INVERTED                     (1 << 2)
 #define SET_VSYNC_OFF                          (1 << 3)
 
+enum saa7134_input_types {
+       SAA7134_NO_INPUT = 0,
+       SAA7134_INPUT_MUTE,
+       SAA7134_INPUT_RADIO,
+       SAA7134_INPUT_TV,
+       SAA7134_INPUT_TV_MONO,
+       SAA7134_INPUT_COMPOSITE,
+       SAA7134_INPUT_COMPOSITE0,
+       SAA7134_INPUT_COMPOSITE1,
+       SAA7134_INPUT_COMPOSITE2,
+       SAA7134_INPUT_COMPOSITE3,
+       SAA7134_INPUT_COMPOSITE4,
+       SAA7134_INPUT_SVIDEO,
+       SAA7134_INPUT_SVIDEO0,
+       SAA7134_INPUT_SVIDEO1,
+       SAA7134_INPUT_COMPOSITE_OVER_SVIDEO,
+};
+
 struct saa7134_input {
-       char                    *name;
-       unsigned int            vmux;
-       enum saa7134_audio_in   amux;
-       unsigned int            gpio;
-       unsigned int            tv:1;
+       enum saa7134_input_types type;
+       unsigned int             vmux;
+       enum saa7134_audio_in    amux;
+       unsigned int             gpio;
 };
 
 enum saa7134_mpeg_type {
@@ -410,7 +427,7 @@ struct saa7134_board {
        unsigned int            ts_force_val:1;
 };
 
-#define card_has_radio(dev)   (NULL != saa7134_boards[dev->board].radio.name)
+#define card_has_radio(dev)   (SAA7134_NO_INPUT != saa7134_boards[dev->board].radio.type)
 #define card_is_empress(dev)  (SAA7134_MPEG_EMPRESS == saa7134_boards[dev->board].mpeg)
 #define card_is_dvb(dev)      (SAA7134_MPEG_DVB     == saa7134_boards[dev->board].mpeg)
 #define card_is_go7007(dev)   (SAA7134_MPEG_GO7007  == saa7134_boards[dev->board].mpeg)
@@ -654,6 +671,19 @@ struct saa7134_dev {
        /* I2C keyboard data */
        struct IR_i2c_init_data    init_data;
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct media_device *media_dev;
+
+       struct media_entity input_ent[SAA7134_INPUT_MAX + 1];
+       struct media_pad input_pad[SAA7134_INPUT_MAX + 1];
+
+       struct media_entity demod;
+       struct media_pad demod_pad[DEMOD_NUM_PADS];
+
+       struct media_pad video_pad, vbi_pad;
+       struct media_entity *decoder;
+#endif
+
 #if IS_ENABLED(CONFIG_VIDEO_SAA7134_DVB)
        /* SAA7134_MPEG_DVB only */
        struct vb2_dvb_frontends frontends;
@@ -727,7 +757,7 @@ extern struct mutex saa7134_devlist_lock;
 extern int saa7134_no_overlay;
 extern bool saa7134_userptr;
 
-void saa7134_track_gpio(struct saa7134_dev *dev, char *msg);
+void saa7134_track_gpio(struct saa7134_dev *dev, const char *msg);
 void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value);
 
 #define SAA7134_PGTABLE_SIZE 4096
@@ -760,6 +790,7 @@ extern int (*saa7134_dmasound_exit)(struct saa7134_dev *dev);
 /* saa7134-cards.c                                             */
 
 extern struct saa7134_board saa7134_boards[];
+extern const char * const saa7134_input_name[];
 extern const unsigned int saa7134_bcount;
 extern struct pci_device_id saa7134_pci_tbl[];
 
index a69dc6a..18d229f 100644 (file)
@@ -1739,7 +1739,7 @@ static int alps_tdlb7_request_firmware(struct dvb_frontend* fe, const struct fir
 #endif
 }
 
-static struct sp8870_config alps_tdlb7_config = {
+static const struct sp8870_config alps_tdlb7_config = {
 
        .demod_address = 0x71,
        .request_firmware = alps_tdlb7_request_firmware,
index de54310..9f48100 100644 (file)
@@ -644,7 +644,7 @@ static void frontend_init(struct budget *budget)
                }
 
        case 0x101c: { /* TT S2-1600 */
-                       struct stv6110x_devctl *ctl;
+                       const struct stv6110x_devctl *ctl;
                        saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
                        msleep(50);
                        saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
@@ -697,7 +697,7 @@ static void frontend_init(struct budget *budget)
                break;
 
        case 0x1020: { /* Omicom S2 */
-                       struct stv6110x_devctl *ctl;
+                       const struct stv6110x_devctl *ctl;
                        saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTLO);
                        msleep(50);
                        saa7146_setgpio(budget->dev, 2, SAA7146_GPIO_OUTHI);
index 8b89ebe..201f5c2 100644 (file)
@@ -54,15 +54,6 @@ config VIDEO_VIU
          Say Y here if you want to enable VIU device on MPC5121e Rev2+.
          In doubt, say N.
 
-config VIDEO_TIMBERDALE
-       tristate "Support for timberdale Video In/LogiWIN"
-       depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && HAS_DMA
-       depends on (MFD_TIMBERDALE && TIMB_DMA) || COMPILE_TEST
-       select VIDEO_ADV7180
-       select VIDEOBUF_DMA_CONTIG
-       ---help---
-         Add support for the Video In peripherial of the timberdale FPGA.
-
 config VIDEO_M32R_AR
        tristate "AR devices"
        depends on VIDEO_V4L2
@@ -120,6 +111,19 @@ source "drivers/media/platform/s5p-tv/Kconfig"
 source "drivers/media/platform/am437x/Kconfig"
 source "drivers/media/platform/xilinx/Kconfig"
 
+config VIDEO_TI_CAL
+       tristate "TI CAL (Camera Adaptation Layer) driver"
+       depends on VIDEO_DEV && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+       depends on SOC_DRA7XX || COMPILE_TEST
+       depends on HAS_DMA
+       select VIDEOBUF2_DMA_CONTIG
+       default n
+       ---help---
+         Support for the TI CAL (Camera Adaptation Layer) block
+         found on DRA72X SoC.
+         In TI Technical Reference Manual this module is referred as
+         Camera Interface Subsystem (CAMSS).
+
 endif # V4L_PLATFORM_DRIVERS
 
 menuconfig V4L_MEM2MEM_DRIVERS
index efa0295..bbb7bd1 100644 (file)
@@ -2,7 +2,6 @@
 # Makefile for the video capture/playback device drivers.
 #
 
-obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o
 obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
 
 obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o
@@ -18,6 +17,8 @@ obj-$(CONFIG_VIDEO_VIM2M)             += vim2m.o
 
 obj-$(CONFIG_VIDEO_TI_VPE)             += ti-vpe/
 
+obj-$(CONFIG_VIDEO_TI_CAL)             += ti-vpe/
+
 obj-$(CONFIG_VIDEO_MX2_EMMAPRP)                += mx2_emmaprp.o
 obj-$(CONFIG_VIDEO_CODA)               += coda/
 
index 7d28899..6efe9d0 100644 (file)
@@ -1342,7 +1342,7 @@ static void coda_finish_encode(struct coda_ctx *ctx)
 
        /* Calculate bytesused field */
        if (dst_buf->sequence == 0) {
-               vb2_set_plane_payload(&dst_buf->vb2_buf, 0,
+               vb2_set_plane_payload(&dst_buf->vb2_buf, 0, wr_ptr - start_ptr +
                                        ctx->vpu_header_size[0] +
                                        ctx->vpu_header_size[1] +
                                        ctx->vpu_header_size[2]);
index ffbefdf..6fba32b 100644 (file)
@@ -261,7 +261,7 @@ static int ccdc_update_raw_params(struct ccdc_config_params_raw *raw_params)
         */
        if (raw_params->fault_pxl.fp_num != config_params->fault_pxl.fp_num) {
                if (fpc_physaddr != NULL) {
-                       free_pages((unsigned long)fpc_physaddr,
+                       free_pages((unsigned long)fpc_virtaddr,
                                   get_order
                                   (config_params->fault_pxl.fp_num *
                                   FP_NUM_BYTES));
index 93782f1..a600e32 100644 (file)
@@ -700,7 +700,7 @@ static unsigned int gsc_m2m_poll(struct file *file,
 {
        struct gsc_ctx *ctx = fh_to_ctx(file->private_data);
        struct gsc_dev *gsc = ctx->gsc_dev;
-       int ret;
+       unsigned int ret;
 
        if (mutex_lock_interruptible(&gsc->lock))
                return -ERESTARTSYS;
index e79ddbb..feb521f 100644 (file)
@@ -389,13 +389,19 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
        struct fimc_source_info *pd = &fmd->sensor[index].pdata;
        struct device_node *rem, *ep, *np;
        struct v4l2_of_endpoint endpoint;
+       int ret;
 
        /* Assume here a port node can have only one endpoint node. */
        ep = of_get_next_child(port, NULL);
        if (!ep)
                return 0;
 
-       v4l2_of_parse_endpoint(ep, &endpoint);
+       ret = v4l2_of_parse_endpoint(ep, &endpoint);
+       if (ret) {
+               of_node_put(ep);
+               return ret;
+       }
+
        if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
                return -EINVAL;
 
@@ -486,8 +492,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
                        continue;
 
                ret = fimc_md_parse_port_node(fmd, port, index);
-               if (ret < 0)
+               if (ret < 0) {
+                       of_node_put(node);
                        goto rpm_put;
+               }
                index++;
        }
 
@@ -498,8 +506,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
 
        for_each_child_of_node(ports, node) {
                ret = fimc_md_parse_port_node(fmd, node, index);
-               if (ret < 0)
+               if (ret < 0) {
+                       of_node_put(node);
                        break;
+               }
                index++;
        }
 rpm_put:
@@ -707,8 +717,10 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd,
                        ret = fimc_md_register_platform_entity(fmd, pdev,
                                                        plat_entity);
                put_device(&pdev->dev);
-               if (ret < 0)
+               if (ret < 0) {
+                       of_node_put(node);
                        break;
+               }
        }
 
        return ret;
index ac5e50e..bd5c46c 100644 (file)
@@ -736,6 +736,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 {
        struct device_node *node = pdev->dev.of_node;
        struct v4l2_of_endpoint endpoint;
+       int ret;
 
        if (of_property_read_u32(node, "clock-frequency",
                                 &state->clk_frequency))
@@ -751,7 +752,9 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
                return -EINVAL;
        }
        /* Get port node and validate MIPI-CSI channel id. */
-       v4l2_of_parse_endpoint(node, &endpoint);
+       ret = v4l2_of_parse_endpoint(node, &endpoint);
+       if (ret)
+               goto err;
 
        state->index = endpoint.base.port - FIMC_INPUT_MIPI_CSI2_0;
        if (state->index >= CSIS_MAX_ENTITIES)
@@ -764,9 +767,10 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
                                        "samsung,csis-wclk");
 
        state->num_lanes = endpoint.bus.mipi_csi2.num_data_lanes;
-       of_node_put(node);
 
-       return 0;
+err:
+       of_node_put(node);
+       return ret;
 }
 
 static int s5pcsis_pm_resume(struct device *dev, bool runtime);
index 0bcfa55..f9e5245 100644 (file)
@@ -449,7 +449,7 @@ void omap3isp_configure_bridge(struct isp_device *isp,
        case CCDC_INPUT_PARALLEL:
                ispctrl_val |= ISPCTRL_PAR_SER_CLK_SEL_PARALLEL;
                ispctrl_val |= parcfg->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT;
-               shift += parcfg->data_lane_shift * 2;
+               shift += parcfg->data_lane_shift;
                break;
 
        case CCDC_INPUT_CSI2A:
@@ -2235,8 +2235,11 @@ static int isp_of_parse_node(struct device *dev, struct device_node *node,
        struct isp_bus_cfg *buscfg = &isd->bus;
        struct v4l2_of_endpoint vep;
        unsigned int i;
+       int ret;
 
-       v4l2_of_parse_endpoint(node, &vep);
+       ret = v4l2_of_parse_endpoint(node, &vep);
+       if (ret)
+               return ret;
 
        dev_dbg(dev, "parsing endpoint %s, interface %u\n", node->full_name,
                vep.base.port);
@@ -2528,12 +2531,13 @@ static int isp_probe(struct platform_device *pdev)
        }
 
        /* Interrupt */
-       isp->irq_num = platform_get_irq(pdev, 0);
-       if (isp->irq_num <= 0) {
+       ret = platform_get_irq(pdev, 0);
+       if (ret <= 0) {
                dev_err(isp->dev, "No IRQ resource\n");
                ret = -ENODEV;
                goto error_iommu;
        }
+       isp->irq_num = ret;
 
        if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED,
                             "OMAP3 ISP", isp)) {
@@ -2599,6 +2603,7 @@ static const struct of_device_id omap3isp_of_table[] = {
        { .compatible = "ti,omap3-isp" },
        { },
 };
+MODULE_DEVICE_TABLE(of, omap3isp_of_table);
 
 static struct platform_driver omap3isp_driver = {
        .probe = isp_probe,
index bb3974c..882310e 100644 (file)
@@ -2421,7 +2421,7 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,
                        &((struct isp_bus_cfg *)
                          media_entity_to_v4l2_subdev(link->source->entity)
                          ->host_priv)->bus.parallel;
-               parallel_shift = parcfg->data_lane_shift * 2;
+               parallel_shift = parcfg->data_lane_shift;
        } else {
                parallel_shift = 0;
        }
index 84a9667..ac30a0f 100644 (file)
@@ -1480,13 +1480,6 @@ static void preview_isr_buffer(struct isp_prev_device *prev)
        struct isp_buffer *buffer;
        int restart = 0;
 
-       if (prev->input == PREVIEW_INPUT_MEMORY) {
-               buffer = omap3isp_video_buffer_next(&prev->video_in);
-               if (buffer != NULL)
-                       preview_set_inaddr(prev, buffer->dma);
-               pipe->state |= ISP_PIPELINE_IDLE_INPUT;
-       }
-
        if (prev->output & PREVIEW_OUTPUT_MEMORY) {
                buffer = omap3isp_video_buffer_next(&prev->video_out);
                if (buffer != NULL) {
@@ -1496,6 +1489,13 @@ static void preview_isr_buffer(struct isp_prev_device *prev)
                pipe->state |= ISP_PIPELINE_IDLE_OUTPUT;
        }
 
+       if (prev->input == PREVIEW_INPUT_MEMORY) {
+               buffer = omap3isp_video_buffer_next(&prev->video_in);
+               if (buffer != NULL)
+                       preview_set_inaddr(prev, buffer->dma);
+               pipe->state |= ISP_PIPELINE_IDLE_INPUT;
+       }
+
        switch (prev->state) {
        case ISP_PIPELINE_STREAM_SINGLESHOT:
                if (isp_pipeline_ready(pipe))
index 994dfc0..2aff755 100644 (file)
@@ -434,10 +434,68 @@ static void isp_video_buffer_queue(struct vb2_buffer *buf)
        }
 }
 
+/*
+ * omap3isp_video_return_buffers - Return all queued buffers to videobuf2
+ * @video: ISP video object
+ * @state: new state for the returned buffers
+ *
+ * Return all buffers queued on the video node to videobuf2 in the given state.
+ * The buffer state should be VB2_BUF_STATE_QUEUED if called due to an error
+ * when starting the stream, or VB2_BUF_STATE_ERROR otherwise.
+ *
+ * The function must be called with the video irqlock held.
+ */
+static void omap3isp_video_return_buffers(struct isp_video *video,
+                                         enum vb2_buffer_state state)
+{
+       while (!list_empty(&video->dmaqueue)) {
+               struct isp_buffer *buf;
+
+               buf = list_first_entry(&video->dmaqueue,
+                                      struct isp_buffer, irqlist);
+               list_del(&buf->irqlist);
+               vb2_buffer_done(&buf->vb.vb2_buf, state);
+       }
+}
+
+static int isp_video_start_streaming(struct vb2_queue *queue,
+                                    unsigned int count)
+{
+       struct isp_video_fh *vfh = vb2_get_drv_priv(queue);
+       struct isp_video *video = vfh->video;
+       struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
+       unsigned long flags;
+       int ret;
+
+       /* In sensor-to-memory mode, the stream can be started synchronously
+        * to the stream on command. In memory-to-memory mode, it will be
+        * started when buffers are queued on both the input and output.
+        */
+       if (pipe->input)
+               return 0;
+
+       ret = omap3isp_pipeline_set_stream(pipe,
+                                          ISP_PIPELINE_STREAM_CONTINUOUS);
+       if (ret < 0) {
+               spin_lock_irqsave(&video->irqlock, flags);
+               omap3isp_video_return_buffers(video, VB2_BUF_STATE_QUEUED);
+               spin_unlock_irqrestore(&video->irqlock, flags);
+               return ret;
+       }
+
+       spin_lock_irqsave(&video->irqlock, flags);
+       if (list_empty(&video->dmaqueue))
+               video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN;
+       spin_unlock_irqrestore(&video->irqlock, flags);
+
+       return 0;
+}
+
 static const struct vb2_ops isp_video_queue_ops = {
        .queue_setup = isp_video_queue_setup,
        .buf_prepare = isp_video_buffer_prepare,
        .buf_queue = isp_video_buffer_queue,
+       .start_streaming = isp_video_start_streaming,
 };
 
 /*
@@ -459,7 +517,7 @@ static const struct vb2_ops isp_video_queue_ops = {
 struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
 {
        struct isp_pipeline *pipe = to_isp_pipeline(&video->video.entity);
-       enum isp_pipeline_state state;
+       enum vb2_buffer_state vb_state;
        struct isp_buffer *buf;
        unsigned long flags;
 
@@ -495,17 +553,19 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
 
        /* Report pipeline errors to userspace on the capture device side. */
        if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && pipe->error) {
-               state = VB2_BUF_STATE_ERROR;
+               vb_state = VB2_BUF_STATE_ERROR;
                pipe->error = false;
        } else {
-               state = VB2_BUF_STATE_DONE;
+               vb_state = VB2_BUF_STATE_DONE;
        }
 
-       vb2_buffer_done(&buf->vb.vb2_buf, state);
+       vb2_buffer_done(&buf->vb.vb2_buf, vb_state);
 
        spin_lock_irqsave(&video->irqlock, flags);
 
        if (list_empty(&video->dmaqueue)) {
+               enum isp_pipeline_state state;
+
                spin_unlock_irqrestore(&video->irqlock, flags);
 
                if (video->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -541,26 +601,16 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video)
  * omap3isp_video_cancel_stream - Cancel stream on a video node
  * @video: ISP video object
  *
- * Cancelling a stream mark all buffers on the video node as erroneous and makes
- * sure no new buffer can be queued.
+ * Cancelling a stream returns all buffers queued on the video node to videobuf2
+ * in the erroneous state and makes sure no new buffer can be queued.
  */
 void omap3isp_video_cancel_stream(struct isp_video *video)
 {
        unsigned long flags;
 
        spin_lock_irqsave(&video->irqlock, flags);
-
-       while (!list_empty(&video->dmaqueue)) {
-               struct isp_buffer *buf;
-
-               buf = list_first_entry(&video->dmaqueue,
-                                      struct isp_buffer, irqlist);
-               list_del(&buf->irqlist);
-               vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
-       }
-
+       omap3isp_video_return_buffers(video, VB2_BUF_STATE_ERROR);
        video->error = true;
-
        spin_unlock_irqrestore(&video->irqlock, flags);
 }
 
@@ -1087,29 +1137,10 @@ isp_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
        if (ret < 0)
                goto err_check_format;
 
-       /* In sensor-to-memory mode, the stream can be started synchronously
-        * to the stream on command. In memory-to-memory mode, it will be
-        * started when buffers are queued on both the input and output.
-        */
-       if (pipe->input == NULL) {
-               ret = omap3isp_pipeline_set_stream(pipe,
-                                             ISP_PIPELINE_STREAM_CONTINUOUS);
-               if (ret < 0)
-                       goto err_set_stream;
-               spin_lock_irqsave(&video->irqlock, flags);
-               if (list_empty(&video->dmaqueue))
-                       video->dmaqueue_flags |= ISP_VIDEO_DMAQUEUE_UNDERRUN;
-               spin_unlock_irqrestore(&video->irqlock, flags);
-       }
-
        mutex_unlock(&video->stream_lock);
 
        return 0;
 
-err_set_stream:
-       mutex_lock(&video->queue_lock);
-       vb2_streamoff(&vfh->queue, type);
-       mutex_unlock(&video->queue_lock);
 err_check_format:
        media_entity_pipeline_stop(&video->video.entity);
 err_pipeline_start:
index 190e259..443e8f7 100644 (file)
@@ -33,9 +33,9 @@ enum isp_interface_type {
  * struct isp_parallel_cfg - Parallel interface configuration
  * @data_lane_shift: Data lane shifter
  *             0 - CAMEXT[13:0] -> CAM[13:0]
- *             1 - CAMEXT[13:2] -> CAM[11:0]
- *             2 - CAMEXT[13:4] -> CAM[9:0]
- *             3 - CAMEXT[13:6] -> CAM[7:0]
+ *             2 - CAMEXT[13:2] -> CAM[11:0]
+ *             4 - CAMEXT[13:4] -> CAM[9:0]
+ *             6 - CAMEXT[13:6] -> CAM[7:0]
  * @clk_pol: Pixel clock polarity
  *             0 - Sample on rising edge, 1 - Sample on falling edge
  * @hs_pol: Horizontal synchronization polarity
@@ -48,7 +48,7 @@ enum isp_interface_type {
  *             0 - Normal, 1 - One's complement
  */
 struct isp_parallel_cfg {
-       unsigned int data_lane_shift:2;
+       unsigned int data_lane_shift:3;
        unsigned int clk_pol:1;
        unsigned int hs_pol:1;
        unsigned int vs_pol:1;
index 485f525..552789a 100644 (file)
@@ -1613,6 +1613,7 @@ static const struct of_device_id jpu_dt_ids[] = {
        { .compatible = "renesas,jpu-r8a7791" }, /* M2-W */
        { .compatible = "renesas,jpu-r8a7792" }, /* V2H */
        { .compatible = "renesas,jpu-r8a7793" }, /* M2-N */
+       { .compatible = "renesas,rcar-gen2-jpu" },
        { },
 };
 MODULE_DEVICE_TABLE(of, jpu_dt_ids);
index 0434f02..034b5c1 100644 (file)
@@ -212,6 +212,14 @@ static struct mfc_control controls[] = {
                .menu_skip_mask = 0,
        },
        {
+               .id = V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME,
+               .type = V4L2_CTRL_TYPE_BUTTON,
+               .minimum = 0,
+               .maximum = 0,
+               .step = 0,
+               .default_value = 0,
+       },
+       {
                .id = V4L2_CID_MPEG_VIDEO_VBV_SIZE,
                .type = V4L2_CTRL_TYPE_INTEGER,
                .minimum = 0,
@@ -1423,6 +1431,10 @@ static int s5p_mfc_enc_s_ctrl(struct v4l2_ctrl *ctrl)
        case V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE:
                ctx->force_frame_type = ctrl->val;
                break;
+       case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
+               ctx->force_frame_type =
+                       V4L2_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE_I_FRAME;
+               break;
        case V4L2_CID_MPEG_VIDEO_VBV_SIZE:
                p->vbv_size = ctrl->val;
                break;
index b7fd695..dc75a80 100644 (file)
 #define RCAR_VIN_BT656                 (1 << 3)
 
 enum chip_id {
+       RCAR_GEN3,
        RCAR_GEN2,
        RCAR_H1,
        RCAR_M1,
@@ -1818,6 +1819,7 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
 
 #ifdef CONFIG_OF
 static const struct of_device_id rcar_vin_of_table[] = {
+       { .compatible = "renesas,vin-r8a7795", .data = (void *)RCAR_GEN3 },
        { .compatible = "renesas,vin-r8a7794", .data = (void *)RCAR_GEN2 },
        { .compatible = "renesas,vin-r8a7793", .data = (void *)RCAR_GEN2 },
        { .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
index 90c87f2..b9f369c 100644 (file)
@@ -213,8 +213,7 @@ static int sh_mobile_ceu_videobuf_setup(struct vb2_queue *vq,
                        unsigned int *count, unsigned int *num_planes,
                        unsigned int sizes[], void *alloc_ctxs[])
 {
-       struct soc_camera_device *icd = container_of(vq,
-                       struct soc_camera_device, vb2_vidq);
+       struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
        struct sh_mobile_ceu_dev *pcdev = ici->priv;
 
@@ -361,8 +360,7 @@ static int sh_mobile_ceu_videobuf_prepare(struct vb2_buffer *vb)
 static void sh_mobile_ceu_videobuf_queue(struct vb2_buffer *vb)
 {
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
-       struct soc_camera_device *icd = container_of(vb->vb2_queue,
-                       struct soc_camera_device, vb2_vidq);
+       struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
        struct sh_mobile_ceu_dev *pcdev = ici->priv;
        struct sh_mobile_ceu_buffer *buf = to_ceu_vb(vbuf);
@@ -413,8 +411,7 @@ error:
 static void sh_mobile_ceu_videobuf_release(struct vb2_buffer *vb)
 {
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
-       struct soc_camera_device *icd = container_of(vb->vb2_queue,
-                       struct soc_camera_device, vb2_vidq);
+       struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
        struct sh_mobile_ceu_buffer *buf = to_ceu_vb(vbuf);
        struct sh_mobile_ceu_dev *pcdev = ici->priv;
@@ -444,8 +441,7 @@ static void sh_mobile_ceu_videobuf_release(struct vb2_buffer *vb)
 static int sh_mobile_ceu_videobuf_init(struct vb2_buffer *vb)
 {
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
-       struct soc_camera_device *icd = container_of(vb->vb2_queue,
-                       struct soc_camera_device, vb2_vidq);
+       struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue);
        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
        struct sh_mobile_ceu_dev *pcdev = ici->priv;
 
@@ -460,7 +456,7 @@ static int sh_mobile_ceu_videobuf_init(struct vb2_buffer *vb)
 
 static void sh_mobile_ceu_stop_streaming(struct vb2_queue *q)
 {
-       struct soc_camera_device *icd = container_of(q, struct soc_camera_device, vb2_vidq);
+       struct soc_camera_device *icd = soc_camera_from_vb2q(q);
        struct soc_camera_host *ici = to_soc_camera_host(icd->parent);
        struct sh_mobile_ceu_dev *pcdev = ici->priv;
        struct list_head *buf_head, *tmp;
index 69d7fe4..2c0015b 100644 (file)
@@ -118,7 +118,7 @@ int c8sectpfe_frontend_attach(struct dvb_frontend **fe,
                struct channel_info *tsin, int chan_num)
 {
        struct tda18212_config *tda18212;
-       struct stv6110x_devctl *fe2;
+       const struct stv6110x_devctl *fe2;
        struct i2c_client *client;
        struct i2c_board_info tda18212_info = {
                .type = "tda18212",
index be680f8..e236059 100644 (file)
@@ -3,3 +3,7 @@ obj-$(CONFIG_VIDEO_TI_VPE) += ti-vpe.o
 ti-vpe-y := vpe.o sc.o csc.o vpdma.o
 
 ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG
+
+obj-$(CONFIG_VIDEO_TI_CAL) += ti-cal.o
+
+ti-cal-y := cal.o
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
new file mode 100644 (file)
index 0000000..35fa107
--- /dev/null
@@ -0,0 +1,1971 @@
+/*
+ * TI CAL camera interface driver
+ *
+ * Copyright (c) 2015 Texas Instruments Inc.
+ * Benoit Parrot, <bparrot@ti.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/interrupt.h>
+#include <linux/io.h>
+#include <linux/ioctl.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/pm_runtime.h>
+#include <linux/slab.h>
+#include <linux/videodev2.h>
+#include <linux/of_device.h>
+#include <linux/of_graph.h>
+
+#include <media/v4l2-of.h>
+#include <media/v4l2-async.h>
+#include <media/v4l2-common.h>
+#include <media/v4l2-ctrls.h>
+#include <media/v4l2-device.h>
+#include <media/v4l2-event.h>
+#include <media/v4l2-ioctl.h>
+#include <media/v4l2-ctrls.h>
+#include <media/v4l2-fh.h>
+#include <media/v4l2-event.h>
+#include <media/v4l2-common.h>
+#include <media/videobuf2-core.h>
+#include <media/videobuf2-dma-contig.h>
+#include "cal_regs.h"
+
+#define CAL_MODULE_NAME "cal"
+
+#define MAX_WIDTH 1920
+#define MAX_HEIGHT 1200
+
+#define CAL_VERSION "0.1.0"
+
+MODULE_DESCRIPTION("TI CAL driver");
+MODULE_AUTHOR("Benoit Parrot, <bparrot@ti.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_VERSION(CAL_VERSION);
+
+static unsigned video_nr = -1;
+module_param(video_nr, uint, 0644);
+MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect");
+
+static unsigned debug;
+module_param(debug, uint, 0644);
+MODULE_PARM_DESC(debug, "activates debug info");
+
+/* timeperframe: min/max and default */
+static const struct v4l2_fract
+       tpf_default = {.numerator = 1001,       .denominator = 30000};
+
+#define cal_dbg(level, caldev, fmt, arg...)    \
+               v4l2_dbg(level, debug, &caldev->v4l2_dev, fmt, ##arg)
+#define cal_info(caldev, fmt, arg...)  \
+               v4l2_info(&caldev->v4l2_dev, fmt, ##arg)
+#define cal_err(caldev, fmt, arg...)   \
+               v4l2_err(&caldev->v4l2_dev, fmt, ##arg)
+
+#define ctx_dbg(level, ctx, fmt, arg...)       \
+               v4l2_dbg(level, debug, &ctx->v4l2_dev, fmt, ##arg)
+#define ctx_info(ctx, fmt, arg...)     \
+               v4l2_info(&ctx->v4l2_dev, fmt, ##arg)
+#define ctx_err(ctx, fmt, arg...)      \
+               v4l2_err(&ctx->v4l2_dev, fmt, ##arg)
+
+#define CAL_NUM_INPUT 1
+#define CAL_NUM_CONTEXT 2
+
+#define bytes_per_line(pixel, bpp) (ALIGN(pixel * bpp, 16))
+
+#define reg_read(dev, offset) ioread32(dev->base + offset)
+#define reg_write(dev, offset, val) iowrite32(val, dev->base + offset)
+
+#define reg_read_field(dev, offset, mask) get_field(reg_read(dev, offset), \
+                                                   mask)
+#define reg_write_field(dev, offset, field, mask) { \
+       u32 val = reg_read(dev, offset); \
+       set_field(&val, field, mask); \
+       reg_write(dev, offset, val); }
+
+/* ------------------------------------------------------------------
+ *     Basic structures
+ * ------------------------------------------------------------------
+ */
+
+struct cal_fmt {
+       u32     fourcc;
+       u32     code;
+       u8      depth;
+};
+
+static struct cal_fmt cal_formats[] = {
+       {
+               .fourcc         = V4L2_PIX_FMT_YUYV,
+               .code           = MEDIA_BUS_FMT_YUYV8_2X8,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_UYVY,
+               .code           = MEDIA_BUS_FMT_UYVY8_2X8,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_YVYU,
+               .code           = MEDIA_BUS_FMT_YVYU8_2X8,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_VYUY,
+               .code           = MEDIA_BUS_FMT_VYUY8_2X8,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_RGB565, /* gggbbbbb rrrrrggg */
+               .code           = MEDIA_BUS_FMT_RGB565_2X8_LE,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_RGB565X, /* rrrrrggg gggbbbbb */
+               .code           = MEDIA_BUS_FMT_RGB565_2X8_BE,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_RGB555, /* gggbbbbb arrrrrgg */
+               .code           = MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_RGB555X, /* arrrrrgg gggbbbbb */
+               .code           = MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_RGB24, /* rgb */
+               .code           = MEDIA_BUS_FMT_RGB888_2X12_LE,
+               .depth          = 24,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_BGR24, /* bgr */
+               .code           = MEDIA_BUS_FMT_RGB888_2X12_BE,
+               .depth          = 24,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_RGB32, /* argb */
+               .code           = MEDIA_BUS_FMT_ARGB8888_1X32,
+               .depth          = 32,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SBGGR8,
+               .code           = MEDIA_BUS_FMT_SBGGR8_1X8,
+               .depth          = 8,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SGBRG8,
+               .code           = MEDIA_BUS_FMT_SGBRG8_1X8,
+               .depth          = 8,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SGRBG8,
+               .code           = MEDIA_BUS_FMT_SGRBG8_1X8,
+               .depth          = 8,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SRGGB8,
+               .code           = MEDIA_BUS_FMT_SRGGB8_1X8,
+               .depth          = 8,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SBGGR10,
+               .code           = MEDIA_BUS_FMT_SBGGR10_1X10,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SGBRG10,
+               .code           = MEDIA_BUS_FMT_SGBRG10_1X10,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SGRBG10,
+               .code           = MEDIA_BUS_FMT_SGRBG10_1X10,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SRGGB10,
+               .code           = MEDIA_BUS_FMT_SRGGB10_1X10,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SBGGR12,
+               .code           = MEDIA_BUS_FMT_SBGGR12_1X12,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SGBRG12,
+               .code           = MEDIA_BUS_FMT_SGBRG12_1X12,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SGRBG12,
+               .code           = MEDIA_BUS_FMT_SGRBG12_1X12,
+               .depth          = 16,
+       }, {
+               .fourcc         = V4L2_PIX_FMT_SRGGB12,
+               .code           = MEDIA_BUS_FMT_SRGGB12_1X12,
+               .depth          = 16,
+       },
+};
+
+/*  Print Four-character-code (FOURCC) */
+static char *fourcc_to_str(u32 fmt)
+{
+       static char code[5];
+
+       code[0] = (unsigned char)(fmt & 0xff);
+       code[1] = (unsigned char)((fmt >> 8) & 0xff);
+       code[2] = (unsigned char)((fmt >> 16) & 0xff);
+       code[3] = (unsigned char)((fmt >> 24) & 0xff);
+       code[4] = '\0';
+
+       return code;
+}
+
+/* buffer for one video frame */
+struct cal_buffer {
+       /* common v4l buffer stuff -- must be first */
+       struct vb2_v4l2_buffer  vb;
+       struct list_head        list;
+       const struct cal_fmt    *fmt;
+};
+
+struct cal_dmaqueue {
+       struct list_head        active;
+
+       /* Counters to control fps rate */
+       int                     frame;
+       int                     ini_jiffies;
+};
+
+struct cm_data {
+       void __iomem            *base;
+       struct resource         *res;
+
+       unsigned int            camerrx_control;
+
+       struct platform_device *pdev;
+};
+
+struct cc_data {
+       void __iomem            *base;
+       struct resource         *res;
+
+       struct platform_device *pdev;
+};
+
+/*
+ * there is one cal_dev structure in the driver, it is shared by
+ * all instances.
+ */
+struct cal_dev {
+       int                     irq;
+       void __iomem            *base;
+       struct resource         *res;
+       struct platform_device  *pdev;
+       struct v4l2_device      v4l2_dev;
+
+       /* Control Module handle */
+       struct cm_data          *cm;
+       /* Camera Core Module handle */
+       struct cc_data          *cc[CAL_NUM_CSI2_PORTS];
+
+       struct cal_ctx          *ctx[CAL_NUM_CONTEXT];
+};
+
+/*
+ * There is one cal_ctx structure for each camera core context.
+ */
+struct cal_ctx {
+       struct v4l2_device      v4l2_dev;
+       struct v4l2_ctrl_handler ctrl_handler;
+       struct video_device     vdev;
+       struct v4l2_async_notifier notifier;
+       struct v4l2_subdev      *sensor;
+       struct v4l2_of_endpoint endpoint;
+
+       struct v4l2_async_subdev asd;
+       struct v4l2_async_subdev *asd_list[1];
+
+       struct v4l2_fh          fh;
+       struct cal_dev          *dev;
+       struct cc_data          *cc;
+
+       /* v4l2_ioctl mutex */
+       struct mutex            mutex;
+       /* v4l2 buffers lock */
+       spinlock_t              slock;
+
+       /* Several counters */
+       unsigned long           jiffies;
+
+       struct vb2_alloc_ctx    *alloc_ctx;
+       struct cal_dmaqueue     vidq;
+
+       /* Input Number */
+       int                     input;
+
+       /* video capture */
+       const struct cal_fmt    *fmt;
+       /* Used to store current pixel format */
+       struct v4l2_format              v_fmt;
+       /* Used to store current mbus frame format */
+       struct v4l2_mbus_framefmt       m_fmt;
+
+       /* Current subdev enumerated format */
+       struct cal_fmt          *active_fmt[ARRAY_SIZE(cal_formats)];
+       int                     num_active_fmt;
+
+       struct v4l2_fract       timeperframe;
+       unsigned int            sequence;
+       unsigned int            external_rate;
+       struct vb2_queue        vb_vidq;
+       unsigned int            seq_count;
+       unsigned int            csi2_port;
+       unsigned int            virtual_channel;
+
+       /* Pointer pointing to current v4l2_buffer */
+       struct cal_buffer       *cur_frm;
+       /* Pointer pointing to next v4l2_buffer */
+       struct cal_buffer       *next_frm;
+};
+
+static const struct cal_fmt *find_format_by_pix(struct cal_ctx *ctx,
+                                               u32 pixelformat)
+{
+       const struct cal_fmt *fmt;
+       unsigned int k;
+
+       for (k = 0; k < ctx->num_active_fmt; k++) {
+               fmt = ctx->active_fmt[k];
+               if (fmt->fourcc == pixelformat)
+                       return fmt;
+       }
+
+       return NULL;
+}
+
+static const struct cal_fmt *find_format_by_code(struct cal_ctx *ctx,
+                                                u32 code)
+{
+       const struct cal_fmt *fmt;
+       unsigned int k;
+
+       for (k = 0; k < ctx->num_active_fmt; k++) {
+               fmt = ctx->active_fmt[k];
+               if (fmt->code == code)
+                       return fmt;
+       }
+
+       return NULL;
+}
+
+static inline struct cal_ctx *notifier_to_ctx(struct v4l2_async_notifier *n)
+{
+       return container_of(n, struct cal_ctx, notifier);
+}
+
+static inline int get_field(u32 value, u32 mask)
+{
+       return (value & mask) >> __ffs(mask);
+}
+
+static inline void set_field(u32 *valp, u32 field, u32 mask)
+{
+       u32 val = *valp;
+
+       val &= ~mask;
+       val |= (field << __ffs(mask)) & mask;
+       *valp = val;
+}
+
+/*
+ * Control Module block access
+ */
+static struct cm_data *cm_create(struct cal_dev *dev)
+{
+       struct platform_device *pdev = dev->pdev;
+       struct cm_data *cm;
+
+       cm = devm_kzalloc(&pdev->dev, sizeof(*cm), GFP_KERNEL);
+       if (!cm)
+               return ERR_PTR(-ENOMEM);
+
+       cm->res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+                                               "camerrx_control");
+       cm->base = devm_ioremap_resource(&pdev->dev, cm->res);
+       if (IS_ERR(cm->base)) {
+               cal_err(dev, "failed to ioremap\n");
+               return ERR_CAST(cm->base);
+       }
+
+       cal_dbg(1, dev, "ioresource %s at %pa - %pa\n",
+               cm->res->name, &cm->res->start, &cm->res->end);
+
+       return cm;
+}
+
+static void camerarx_phy_enable(struct cal_ctx *ctx)
+{
+       u32 val;
+
+       if (!ctx->dev->cm->base) {
+               ctx_err(ctx, "cm not mapped\n");
+               return;
+       }
+
+       val = reg_read(ctx->dev->cm, CM_CTRL_CORE_CAMERRX_CONTROL);
+       if (ctx->csi2_port == 1) {
+               set_field(&val, 1, CM_CAMERRX_CTRL_CSI0_CTRLCLKEN_MASK);
+               set_field(&val, 0, CM_CAMERRX_CTRL_CSI0_CAMMODE_MASK);
+               /* enable all lanes by default */
+               set_field(&val, 0xf, CM_CAMERRX_CTRL_CSI0_LANEENABLE_MASK);
+               set_field(&val, 1, CM_CAMERRX_CTRL_CSI0_MODE_MASK);
+       } else if (ctx->csi2_port == 2) {
+               set_field(&val, 1, CM_CAMERRX_CTRL_CSI1_CTRLCLKEN_MASK);
+               set_field(&val, 0, CM_CAMERRX_CTRL_CSI1_CAMMODE_MASK);
+               /* enable all lanes by default */
+               set_field(&val, 0x3, CM_CAMERRX_CTRL_CSI1_LANEENABLE_MASK);
+               set_field(&val, 1, CM_CAMERRX_CTRL_CSI1_MODE_MASK);
+       }
+       reg_write(ctx->dev->cm, CM_CTRL_CORE_CAMERRX_CONTROL, val);
+}
+
+static void camerarx_phy_disable(struct cal_ctx *ctx)
+{
+       u32 val;
+
+       if (!ctx->dev->cm->base) {
+               ctx_err(ctx, "cm not mapped\n");
+               return;
+       }
+
+       val = reg_read(ctx->dev->cm, CM_CTRL_CORE_CAMERRX_CONTROL);
+       if (ctx->csi2_port == 1)
+               set_field(&val, 0x0, CM_CAMERRX_CTRL_CSI0_CTRLCLKEN_MASK);
+       else if (ctx->csi2_port == 2)
+               set_field(&val, 0x0, CM_CAMERRX_CTRL_CSI1_CTRLCLKEN_MASK);
+       reg_write(ctx->dev->cm, CM_CTRL_CORE_CAMERRX_CONTROL, val);
+}
+
+/*
+ * Camera Instance access block
+ */
+static struct cc_data *cc_create(struct cal_dev *dev, unsigned int core)
+{
+       struct platform_device *pdev = dev->pdev;
+       struct cc_data *cc;
+
+       cc = devm_kzalloc(&pdev->dev, sizeof(*cc), GFP_KERNEL);
+       if (!cc)
+               return ERR_PTR(-ENOMEM);
+
+       cc->res = platform_get_resource_byname(pdev,
+                                              IORESOURCE_MEM,
+                                              (core == 0) ?
+                                               "cal_rx_core0" :
+                                               "cal_rx_core1");
+       cc->base = devm_ioremap_resource(&pdev->dev, cc->res);
+       if (IS_ERR(cc->base)) {
+               cal_err(dev, "failed to ioremap\n");
+               return ERR_CAST(cc->base);
+       }
+
+       cal_dbg(1, dev, "ioresource %s at %pa - %pa\n",
+               cc->res->name, &cc->res->start, &cc->res->end);
+
+       return cc;
+}
+
+/*
+ * Get Revision and HW info
+ */
+static void cal_get_hwinfo(struct cal_dev *dev)
+{
+       u32 revision = 0;
+       u32 hwinfo = 0;
+
+       revision = reg_read(dev, CAL_HL_REVISION);
+       cal_dbg(3, dev, "CAL_HL_REVISION = 0x%08x (expecting 0x40000200)\n",
+               revision);
+
+       hwinfo = reg_read(dev, CAL_HL_HWINFO);
+       cal_dbg(3, dev, "CAL_HL_HWINFO = 0x%08x (expecting 0xA3C90469)\n",
+               hwinfo);
+}
+
+static inline int cal_runtime_get(struct cal_dev *dev)
+{
+       int r;
+
+       r = pm_runtime_get_sync(&dev->pdev->dev);
+
+       return r;
+}
+
+static inline void cal_runtime_put(struct cal_dev *dev)
+{
+       pm_runtime_put_sync(&dev->pdev->dev);
+}
+
+static void cal_quickdump_regs(struct cal_dev *dev)
+{
+       cal_info(dev, "CAL Registers @ 0x%pa:\n", &dev->res->start);
+       print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 4,
+                      (__force const void *)dev->base,
+                      resource_size(dev->res), false);
+
+       if (dev->ctx[0]) {
+               cal_info(dev, "CSI2 Core 0 Registers @ %pa:\n",
+                        &dev->ctx[0]->cc->res->start);
+               print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 4,
+                              (__force const void *)dev->ctx[0]->cc->base,
+                              resource_size(dev->ctx[0]->cc->res),
+                              false);
+       }
+
+       if (dev->ctx[1]) {
+               cal_info(dev, "CSI2 Core 1 Registers @ %pa:\n",
+                        &dev->ctx[1]->cc->res->start);
+               print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 4,
+                              (__force const void *)dev->ctx[1]->cc->base,
+                              resource_size(dev->ctx[1]->cc->res),
+                              false);
+       }
+
+       cal_info(dev, "CAMERRX_Control Registers @ %pa:\n",
+                &dev->cm->res->start);
+       print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 4,
+                      (__force const void *)dev->cm->base,
+                      resource_size(dev->cm->res), false);
+}
+
+/*
+ * Enable the expected IRQ sources
+ */
+static void enable_irqs(struct cal_ctx *ctx)
+{
+       /* Enable IRQ_WDMA_END 0/1 */
+       reg_write_field(ctx->dev,
+                       CAL_HL_IRQENABLE_SET(2),
+                       CAL_HL_IRQ_ENABLE,
+                       CAL_HL_IRQ_MASK(ctx->csi2_port));
+       /* Enable IRQ_WDMA_START 0/1 */
+       reg_write_field(ctx->dev,
+                       CAL_HL_IRQENABLE_SET(3),
+                       CAL_HL_IRQ_ENABLE,
+                       CAL_HL_IRQ_MASK(ctx->csi2_port));
+       /* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */
+       reg_write(ctx->dev, CAL_CSI2_VC_IRQENABLE(1), 0xFF000000);
+}
+
+static void disable_irqs(struct cal_ctx *ctx)
+{
+       /* Disable IRQ_WDMA_END 0/1 */
+       reg_write_field(ctx->dev,
+                       CAL_HL_IRQENABLE_CLR(2),
+                       CAL_HL_IRQ_CLEAR,
+                       CAL_HL_IRQ_MASK(ctx->csi2_port));
+       /* Disable IRQ_WDMA_START 0/1 */
+       reg_write_field(ctx->dev,
+                       CAL_HL_IRQENABLE_CLR(3),
+                       CAL_HL_IRQ_CLEAR,
+                       CAL_HL_IRQ_MASK(ctx->csi2_port));
+       /* Todo: Add VC_IRQ and CSI2_COMPLEXIO_IRQ handling */
+       reg_write(ctx->dev, CAL_CSI2_VC_IRQENABLE(1), 0);
+}
+
+static void csi2_init(struct cal_ctx *ctx)
+{
+       int i;
+       u32 val;
+
+       val = reg_read(ctx->dev, CAL_CSI2_TIMING(ctx->csi2_port));
+       set_field(&val, CAL_GEN_ENABLE,
+                 CAL_CSI2_TIMING_FORCE_RX_MODE_IO1_MASK);
+       set_field(&val, CAL_GEN_ENABLE,
+                 CAL_CSI2_TIMING_STOP_STATE_X16_IO1_MASK);
+       set_field(&val, CAL_GEN_DISABLE,
+                 CAL_CSI2_TIMING_STOP_STATE_X4_IO1_MASK);
+       set_field(&val, 407, CAL_CSI2_TIMING_STOP_STATE_COUNTER_IO1_MASK);
+       reg_write(ctx->dev, CAL_CSI2_TIMING(ctx->csi2_port), val);
+       ctx_dbg(3, ctx, "CAL_CSI2_TIMING(%d) = 0x%08x\n", ctx->csi2_port,
+               reg_read(ctx->dev, CAL_CSI2_TIMING(ctx->csi2_port)));
+
+       val = reg_read(ctx->dev, CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port));
+       set_field(&val, CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL_OPERATIONAL,
+                 CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL_MASK);
+       set_field(&val, CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_STATE_ON,
+                 CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_MASK);
+       reg_write(ctx->dev, CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port), val);
+       for (i = 0; i < 10; i++) {
+               if (reg_read_field(ctx->dev,
+                                  CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port),
+                                  CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_MASK) ==
+                   CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_STATE_ON)
+                       break;
+               usleep_range(1000, 1100);
+       }
+       ctx_dbg(3, ctx, "CAL_CSI2_COMPLEXIO_CFG(%d) = 0x%08x\n", ctx->csi2_port,
+               reg_read(ctx->dev, CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port)));
+
+       val = reg_read(ctx->dev, CAL_CTRL);
+       set_field(&val, CAL_CTRL_BURSTSIZE_BURST128, CAL_CTRL_BURSTSIZE_MASK);
+       set_field(&val, 0xF, CAL_CTRL_TAGCNT_MASK);
+       set_field(&val, CAL_CTRL_POSTED_WRITES_NONPOSTED,
+                 CAL_CTRL_POSTED_WRITES_MASK);
+       set_field(&val, 0xFF, CAL_CTRL_MFLAGL_MASK);
+       set_field(&val, 0xFF, CAL_CTRL_MFLAGH_MASK);
+       reg_write(ctx->dev, CAL_CTRL, val);
+       ctx_dbg(3, ctx, "CAL_CTRL = 0x%08x\n", reg_read(ctx->dev, CAL_CTRL));
+}
+
+static void csi2_lane_config(struct cal_ctx *ctx)
+{
+       u32 val = reg_read(ctx->dev, CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port));
+       u32 lane_mask = CAL_CSI2_COMPLEXIO_CFG_CLOCK_POSITION_MASK;
+       u32 polarity_mask = CAL_CSI2_COMPLEXIO_CFG_CLOCK_POL_MASK;
+       struct v4l2_of_bus_mipi_csi2 *mipi_csi2 = &ctx->endpoint.bus.mipi_csi2;
+       int lane;
+
+       set_field(&val, mipi_csi2->clock_lane + 1, lane_mask);
+       set_field(&val, mipi_csi2->lane_polarities[0], polarity_mask);
+       for (lane = 0; lane < mipi_csi2->num_data_lanes; lane++) {
+               /*
+                * Every lane are one nibble apart starting with the
+                * clock followed by the data lanes so shift masks by 4.
+                */
+               lane_mask <<= 4;
+               polarity_mask <<= 4;
+               set_field(&val, mipi_csi2->data_lanes[lane] + 1, lane_mask);
+               set_field(&val, mipi_csi2->lane_polarities[lane + 1],
+                         polarity_mask);
+       }
+
+       reg_write(ctx->dev, CAL_CSI2_COMPLEXIO_CFG(ctx->csi2_port), val);
+       ctx_dbg(3, ctx, "CAL_CSI2_COMPLEXIO_CFG(%d) = 0x%08x\n",
+               ctx->csi2_port, val);
+}
+
+static void csi2_ppi_enable(struct cal_ctx *ctx)
+{
+       reg_write_field(ctx->dev, CAL_CSI2_PPI_CTRL(ctx->csi2_port),
+                       CAL_GEN_ENABLE, CAL_CSI2_PPI_CTRL_IF_EN_MASK);
+}
+
+static void csi2_ppi_disable(struct cal_ctx *ctx)
+{
+       reg_write_field(ctx->dev, CAL_CSI2_PPI_CTRL(ctx->csi2_port),
+                       CAL_GEN_DISABLE, CAL_CSI2_PPI_CTRL_IF_EN_MASK);
+}
+
+static void csi2_ctx_config(struct cal_ctx *ctx)
+{
+       u32 val;
+
+       val = reg_read(ctx->dev, CAL_CSI2_CTX0(ctx->csi2_port));
+       set_field(&val, ctx->csi2_port, CAL_CSI2_CTX_CPORT_MASK);
+       /*
+        * DT type: MIPI CSI-2 Specs
+        *   0x1: All - DT filter is disabled
+        *  0x24: RGB888 1 pixel  = 3 bytes
+        *  0x2B: RAW10  4 pixels = 5 bytes
+        *  0x2A: RAW8   1 pixel  = 1 byte
+        *  0x1E: YUV422 2 pixels = 4 bytes
+        */
+       set_field(&val, 0x1, CAL_CSI2_CTX_DT_MASK);
+       /* Virtual Channel from the CSI2 sensor usually 0! */
+       set_field(&val, ctx->virtual_channel, CAL_CSI2_CTX_VC_MASK);
+       /* NUM_LINES_PER_FRAME => 0 means auto detect */
+       set_field(&val, 0, CAL_CSI2_CTX_LINES_MASK);
+       set_field(&val, CAL_CSI2_CTX_ATT_PIX, CAL_CSI2_CTX_ATT_MASK);
+       set_field(&val, CAL_CSI2_CTX_PACK_MODE_LINE,
+                 CAL_CSI2_CTX_PACK_MODE_MASK);
+       reg_write(ctx->dev, CAL_CSI2_CTX0(ctx->csi2_port), val);
+       ctx_dbg(3, ctx, "CAL_CSI2_CTX0(%d) = 0x%08x\n", ctx->csi2_port,
+               reg_read(ctx->dev, CAL_CSI2_CTX0(ctx->csi2_port)));
+}
+
+static void pix_proc_config(struct cal_ctx *ctx)
+{
+       u32 val;
+
+       val = reg_read(ctx->dev, CAL_PIX_PROC(ctx->csi2_port));
+       set_field(&val, CAL_PIX_PROC_EXTRACT_B8, CAL_PIX_PROC_EXTRACT_MASK);
+       set_field(&val, CAL_PIX_PROC_DPCMD_BYPASS, CAL_PIX_PROC_DPCMD_MASK);
+       set_field(&val, CAL_PIX_PROC_DPCME_BYPASS, CAL_PIX_PROC_DPCME_MASK);
+       set_field(&val, CAL_PIX_PROC_PACK_B8, CAL_PIX_PROC_PACK_MASK);
+       set_field(&val, ctx->csi2_port, CAL_PIX_PROC_CPORT_MASK);
+       set_field(&val, CAL_GEN_ENABLE, CAL_PIX_PROC_EN_MASK);
+       reg_write(ctx->dev, CAL_PIX_PROC(ctx->csi2_port), val);
+       ctx_dbg(3, ctx, "CAL_PIX_PROC(%d) = 0x%08x\n", ctx->csi2_port,
+               reg_read(ctx->dev, CAL_PIX_PROC(ctx->csi2_port)));
+}
+
+static void cal_wr_dma_config(struct cal_ctx *ctx,
+                             unsigned int width)
+{
+       u32 val;
+
+       val = reg_read(ctx->dev, CAL_WR_DMA_CTRL(ctx->csi2_port));
+       set_field(&val, ctx->csi2_port, CAL_WR_DMA_CTRL_CPORT_MASK);
+       set_field(&val, CAL_WR_DMA_CTRL_DTAG_PIX_DAT,
+                 CAL_WR_DMA_CTRL_DTAG_MASK);
+       set_field(&val, CAL_WR_DMA_CTRL_MODE_CONST,
+                 CAL_WR_DMA_CTRL_MODE_MASK);
+       set_field(&val, CAL_WR_DMA_CTRL_PATTERN_LINEAR,
+                 CAL_WR_DMA_CTRL_PATTERN_MASK);
+       set_field(&val, CAL_GEN_ENABLE, CAL_WR_DMA_CTRL_STALL_RD_MASK);
+       reg_write(ctx->dev, CAL_WR_DMA_CTRL(ctx->csi2_port), val);
+       ctx_dbg(3, ctx, "CAL_WR_DMA_CTRL(%d) = 0x%08x\n", ctx->csi2_port,
+               reg_read(ctx->dev, CAL_WR_DMA_CTRL(ctx->csi2_port)));
+
+       /*
+        * width/16 not sure but giving it a whirl.
+        * zero does not work right
+        */
+       reg_write_field(ctx->dev,
+                       CAL_WR_DMA_OFST(ctx->csi2_port),
+                       (width / 16),
+                       CAL_WR_DMA_OFST_MASK);
+       ctx_dbg(3, ctx, "CAL_WR_DMA_OFST(%d) = 0x%08x\n", ctx->csi2_port,
+               reg_read(ctx->dev, CAL_WR_DMA_OFST(ctx->csi2_port)));
+
+       val = reg_read(ctx->dev, CAL_WR_DMA_XSIZE(ctx->csi2_port));
+       /* 64 bit word means no skipping */
+       set_field(&val, 0, CAL_WR_DMA_XSIZE_XSKIP_MASK);
+       /*
+        * (width*8)/64 this should be size of an entire line
+        * in 64bit word but 0 means all data until the end
+        * is detected automagically
+        */
+       set_field(&val, (width / 8), CAL_WR_DMA_XSIZE_MASK);
+       reg_write(ctx->dev, CAL_WR_DMA_XSIZE(ctx->csi2_port), val);
+       ctx_dbg(3, ctx, "CAL_WR_DMA_XSIZE(%d) = 0x%08x\n", ctx->csi2_port,
+               reg_read(ctx->dev, CAL_WR_DMA_XSIZE(ctx->csi2_port)));
+}
+
+static void cal_wr_dma_addr(struct cal_ctx *ctx, unsigned int dmaaddr)
+{
+       reg_write(ctx->dev, CAL_WR_DMA_ADDR(ctx->csi2_port), dmaaddr);
+}
+
+/*
+ * TCLK values are OK at their reset values
+ */
+#define TCLK_TERM      0
+#define TCLK_MISS      1
+#define TCLK_SETTLE    14
+#define THS_SETTLE     15
+
+static void csi2_phy_config(struct cal_ctx *ctx)
+{
+       unsigned int reg0, reg1;
+       unsigned int ths_term, ths_settle;
+       unsigned int ddrclkperiod_us;
+
+       /*
+        * THS_TERM: Programmed value = floor(20 ns/DDRClk period) - 2.
+        */
+       ddrclkperiod_us = ctx->external_rate / 2000000;
+       ddrclkperiod_us = 1000000 / ddrclkperiod_us;
+       ctx_dbg(1, ctx, "ddrclkperiod_us: %d\n", ddrclkperiod_us);
+
+       ths_term = 20000 / ddrclkperiod_us;
+       ths_term = (ths_term >= 2) ? ths_term - 2 : ths_term;
+       ctx_dbg(1, ctx, "ths_term: %d (0x%02x)\n", ths_term, ths_term);
+
+       /*
+        * THS_SETTLE: Programmed value = floor(176.3 ns/CtrlClk period) - 1.
+        *      Since CtrlClk is fixed at 96Mhz then we get
+        *      ths_settle = floor(176.3 / 10.416) - 1 = 15
+        * If we ever switch to a dynamic clock then this code might be useful
+        *
+        * unsigned int ctrlclkperiod_us;
+        * ctrlclkperiod_us = 96000000 / 1000000;
+        * ctrlclkperiod_us = 1000000 / ctrlclkperiod_us;
+        * ctx_dbg(1, ctx, "ctrlclkperiod_us: %d\n", ctrlclkperiod_us);
+
+        * ths_settle = 176300  / ctrlclkperiod_us;
+        * ths_settle = (ths_settle > 1) ? ths_settle - 1 : ths_settle;
+        */
+
+       ths_settle = THS_SETTLE;
+       ctx_dbg(1, ctx, "ths_settle: %d (0x%02x)\n", ths_settle, ths_settle);
+
+       reg0 = reg_read(ctx->cc, CAL_CSI2_PHY_REG0);
+       set_field(&reg0, CAL_CSI2_PHY_REG0_HSCLOCKCONFIG_DISABLE,
+                 CAL_CSI2_PHY_REG0_HSCLOCKCONFIG_MASK);
+       set_field(&reg0, ths_term, CAL_CSI2_PHY_REG0_THS_TERM_MASK);
+       set_field(&reg0, ths_settle, CAL_CSI2_PHY_REG0_THS_SETTLE_MASK);
+
+       ctx_dbg(1, ctx, "CSI2_%d_REG0 = 0x%08x\n", (ctx->csi2_port - 1), reg0);
+       reg_write(ctx->cc, CAL_CSI2_PHY_REG0, reg0);
+
+       reg1 = reg_read(ctx->cc, CAL_CSI2_PHY_REG1);
+       set_field(&reg1, TCLK_TERM, CAL_CSI2_PHY_REG1_TCLK_TERM_MASK);
+       set_field(&reg1, 0xb8, CAL_CSI2_PHY_REG1_DPHY_HS_SYNC_PATTERN_MASK);
+       set_field(&reg1, TCLK_MISS, CAL_CSI2_PHY_REG1_CTRLCLK_DIV_FACTOR_MASK);
+       set_field(&reg1, TCLK_SETTLE, CAL_CSI2_PHY_REG1_TCLK_SETTLE_MASK);
+
+       ctx_dbg(1, ctx, "CSI2_%d_REG1 = 0x%08x\n", (ctx->csi2_port - 1), reg1);
+       reg_write(ctx->cc, CAL_CSI2_PHY_REG1, reg1);
+}
+
+static int cal_get_external_info(struct cal_ctx *ctx)
+{
+       struct v4l2_ctrl *ctrl;
+
+       ctrl = v4l2_ctrl_find(ctx->sensor->ctrl_handler, V4L2_CID_PIXEL_RATE);
+       if (!ctrl) {
+               ctx_err(ctx, "no pixel rate control in subdev: %s\n",
+                       ctx->sensor->name);
+               return -EPIPE;
+       }
+
+       ctx->external_rate = v4l2_ctrl_g_ctrl_int64(ctrl);
+       ctx_dbg(3, ctx, "sensor Pixel Rate: %d\n", ctx->external_rate);
+
+       return 0;
+}
+
+static inline void cal_schedule_next_buffer(struct cal_ctx *ctx)
+{
+       struct cal_dmaqueue *dma_q = &ctx->vidq;
+       struct cal_buffer *buf;
+       unsigned long addr;
+
+       buf = list_entry(dma_q->active.next, struct cal_buffer, list);
+       ctx->next_frm = buf;
+       list_del(&buf->list);
+
+       addr = vb2_dma_contig_plane_dma_addr(&buf->vb.vb2_buf, 0);
+       cal_wr_dma_addr(ctx, addr);
+}
+
+static inline void cal_process_buffer_complete(struct cal_ctx *ctx)
+{
+       ctx->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
+       ctx->cur_frm->vb.field = ctx->m_fmt.field;
+       ctx->cur_frm->vb.sequence = ctx->sequence++;
+
+       vb2_buffer_done(&ctx->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
+       ctx->cur_frm = ctx->next_frm;
+}
+
+#define isvcirqset(irq, vc, ff) (irq & \
+       (CAL_CSI2_VC_IRQENABLE_ ##ff ##_IRQ_##vc ##_MASK))
+
+#define isportirqset(irq, port) (irq & CAL_HL_IRQ_MASK(port))
+
+static irqreturn_t cal_irq(int irq_cal, void *data)
+{
+       struct cal_dev *dev = (struct cal_dev *)data;
+       struct cal_ctx *ctx;
+       struct cal_dmaqueue *dma_q;
+       u32 irqst2, irqst3;
+
+       /* Check which DMA just finished */
+       irqst2 = reg_read(dev, CAL_HL_IRQSTATUS(2));
+       if (irqst2) {
+               /* Clear Interrupt status */
+               reg_write(dev, CAL_HL_IRQSTATUS(2), irqst2);
+
+               /* Need to check both port */
+               if (isportirqset(irqst2, 1)) {
+                       ctx = dev->ctx[0];
+
+                       if (ctx->cur_frm != ctx->next_frm)
+                               cal_process_buffer_complete(ctx);
+               }
+
+               if (isportirqset(irqst2, 2)) {
+                       ctx = dev->ctx[1];
+
+                       if (ctx->cur_frm != ctx->next_frm)
+                               cal_process_buffer_complete(ctx);
+               }
+       }
+
+       /* Check which DMA just started */
+       irqst3 = reg_read(dev, CAL_HL_IRQSTATUS(3));
+       if (irqst3) {
+               /* Clear Interrupt status */
+               reg_write(dev, CAL_HL_IRQSTATUS(3), irqst3);
+
+               /* Need to check both port */
+               if (isportirqset(irqst3, 1)) {
+                       ctx = dev->ctx[0];
+                       dma_q = &ctx->vidq;
+
+                       spin_lock(&ctx->slock);
+                       if (!list_empty(&dma_q->active) &&
+                           ctx->cur_frm == ctx->next_frm)
+                               cal_schedule_next_buffer(ctx);
+                       spin_unlock(&ctx->slock);
+               }
+
+               if (isportirqset(irqst3, 2)) {
+                       ctx = dev->ctx[1];
+                       dma_q = &ctx->vidq;
+
+                       spin_lock(&ctx->slock);
+                       if (!list_empty(&dma_q->active) &&
+                           ctx->cur_frm == ctx->next_frm)
+                               cal_schedule_next_buffer(ctx);
+                       spin_unlock(&ctx->slock);
+               }
+       }
+
+       return IRQ_HANDLED;
+}
+
+/*
+ * video ioctls
+ */
+static int cal_querycap(struct file *file, void *priv,
+                       struct v4l2_capability *cap)
+{
+       struct cal_ctx *ctx = video_drvdata(file);
+
+       strlcpy(cap->driver, CAL_MODULE_NAME, sizeof(cap->driver));
+       strlcpy(cap->card, CAL_MODULE_NAME, sizeof(cap->card));
+
+       snprintf(cap->bus_info, sizeof(cap->bus_info),
+                "platform:%s", ctx->v4l2_dev.name);
+       cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING |
+                           V4L2_CAP_READWRITE;
+       cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
+       return 0;
+}
+
+static int cal_enum_fmt_vid_cap(struct file *file, void  *priv,
+                               struct v4l2_fmtdesc *f)
+{
+       struct cal_ctx *ctx = video_drvdata(file);
+       const struct cal_fmt *fmt = NULL;
+
+       if (f->index >= ctx->num_active_fmt)
+               return -EINVAL;
+
+       fmt = ctx->active_fmt[f->index];
+
+       f->pixelformat = fmt->fourcc;
+       f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       return 0;
+}
+
+static int __subdev_get_format(struct cal_ctx *ctx,
+                              struct v4l2_mbus_framefmt *fmt)
+{
+       struct v4l2_subdev_format sd_fmt;
+       struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format;
+       int ret;
+
+       if (!ctx->sensor)
+               return -EINVAL;
+
+       sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+       sd_fmt.pad = 0;
+
+       ret = v4l2_subdev_call(ctx->sensor, pad, get_fmt, NULL, &sd_fmt);
+       if (ret)
+               return ret;
+
+       *fmt = *mbus_fmt;
+
+       ctx_dbg(1, ctx, "%s %dx%d code:%04X\n", __func__,
+               fmt->width, fmt->height, fmt->code);
+
+       return 0;
+}
+
+static int __subdev_set_format(struct cal_ctx *ctx,
+                              struct v4l2_mbus_framefmt *fmt)
+{
+       struct v4l2_subdev_format sd_fmt;
+       struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format;
+       int ret;
+
+       if (!ctx->sensor)
+               return -EINVAL;
+
+       sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+       sd_fmt.pad = 0;
+       *mbus_fmt = *fmt;
+
+       ret = v4l2_subdev_call(ctx->sensor, pad, set_fmt, NULL, &sd_fmt);
+       if (ret)
+               return ret;
+
+       ctx_dbg(1, ctx, "%s %dx%d code:%04X\n", __func__,
+               fmt->width, fmt->height, fmt->code);
+
+       return 0;
+}
+
+static int cal_calc_format_size(struct cal_ctx *ctx,
+                               const struct cal_fmt *fmt,
+                               struct v4l2_format *f)
+{
+       if (!fmt) {
+               ctx_dbg(3, ctx, "No cal_fmt provided!\n");
+               return -EINVAL;
+       }
+
+       v4l_bound_align_image(&f->fmt.pix.width, 48, MAX_WIDTH, 2,
+                             &f->fmt.pix.height, 32, MAX_HEIGHT, 0, 0);
+       f->fmt.pix.bytesperline = bytes_per_line(f->fmt.pix.width,
+                                                fmt->depth >> 3);
+       f->fmt.pix.sizeimage = f->fmt.pix.height *
+                              f->fmt.pix.bytesperline;
+
+       ctx_dbg(3, ctx, "%s: fourcc: %s size: %dx%d bpl:%d img_size:%d\n",
+               __func__, fourcc_to_str(f->fmt.pix.pixelformat),
+               f->fmt.pix.width, f->fmt.pix.height,
+               f->fmt.pix.bytesperline, f->fmt.pix.sizeimage);
+
+       return 0;
+}
+
+static int cal_g_fmt_vid_cap(struct file *file, void *priv,
+                            struct v4l2_format *f)
+{
+       struct cal_ctx *ctx = video_drvdata(file);
+
+       *f = ctx->v_fmt;
+
+       return 0;
+}
+
+static int cal_try_fmt_vid_cap(struct file *file, void *priv,
+                              struct v4l2_format *f)
+{
+       struct cal_ctx *ctx = video_drvdata(file);
+       const struct cal_fmt *fmt;
+       struct v4l2_subdev_frame_size_enum fse;
+       int ret, found;
+
+       fmt = find_format_by_pix(ctx, f->fmt.pix.pixelformat);
+       if (!fmt) {
+               ctx_dbg(3, ctx, "Fourcc format (0x%08x) not found.\n",
+                       f->fmt.pix.pixelformat);
+
+               /* Just get the first one enumerated */
+               fmt = ctx->active_fmt[0];
+               f->fmt.pix.pixelformat = fmt->fourcc;
+       }
+
+       f->fmt.pix.field = ctx->v_fmt.fmt.pix.field;
+
+       /* check for/find a valid width/height */
+       ret = 0;
+       found = false;
+       fse.pad = 0;
+       fse.code = fmt->code;
+       fse.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+       for (fse.index = 0; ; fse.index++) {
+               ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size,
+                                      NULL, &fse);
+               if (ret)
+                       break;
+
+               if ((f->fmt.pix.width == fse.max_width) &&
+                   (f->fmt.pix.height == fse.max_height)) {
+                       found = true;
+                       break;
+               } else if ((f->fmt.pix.width >= fse.min_width) &&
+                        (f->fmt.pix.width <= fse.max_width) &&
+                        (f->fmt.pix.height >= fse.min_height) &&
+                        (f->fmt.pix.height <= fse.max_height)) {
+                       found = true;
+                       break;
+               }
+       }
+
+       if (!found) {
+               /* use existing values as default */
+               f->fmt.pix.width = ctx->v_fmt.fmt.pix.width;
+               f->fmt.pix.height =  ctx->v_fmt.fmt.pix.height;
+       }
+
+       /*
+        * Use current colorspace for now, it will get
+        * updated properly during s_fmt
+        */
+       f->fmt.pix.colorspace = ctx->v_fmt.fmt.pix.colorspace;
+       return cal_calc_format_size(ctx, fmt, f);
+}
+
+static int cal_s_fmt_vid_cap(struct file *file, void *priv,
+                            struct v4l2_format *f)
+{
+       struct cal_ctx *ctx = video_drvdata(file);
+       struct vb2_queue *q = &ctx->vb_vidq;
+       const struct cal_fmt *fmt;
+       struct v4l2_mbus_framefmt mbus_fmt;
+       int ret;
+
+       if (vb2_is_busy(q)) {
+               ctx_dbg(3, ctx, "%s device busy\n", __func__);
+               return -EBUSY;
+       }
+
+       ret = cal_try_fmt_vid_cap(file, priv, f);
+       if (ret < 0)
+               return ret;
+
+       fmt = find_format_by_pix(ctx, f->fmt.pix.pixelformat);
+
+       v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, fmt->code);
+
+       ret = __subdev_set_format(ctx, &mbus_fmt);
+       if (ret)
+               return ret;
+
+       /* Just double check nothing has gone wrong */
+       if (mbus_fmt.code != fmt->code) {
+               ctx_dbg(3, ctx,
+                       "%s subdev changed format on us, this should not happen\n",
+                       __func__);
+               return -EINVAL;
+       }
+
+       v4l2_fill_pix_format(&ctx->v_fmt.fmt.pix, &mbus_fmt);
+       ctx->v_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       ctx->v_fmt.fmt.pix.pixelformat  = fmt->fourcc;
+       cal_calc_format_size(ctx, fmt, &ctx->v_fmt);
+       ctx->fmt = fmt;
+       ctx->m_fmt = mbus_fmt;
+       *f = ctx->v_fmt;
+
+       return 0;
+}
+
+static int cal_enum_framesizes(struct file *file, void *fh,
+                              struct v4l2_frmsizeenum *fsize)
+{
+       struct cal_ctx *ctx = video_drvdata(file);
+       const struct cal_fmt *fmt;
+       struct v4l2_subdev_frame_size_enum fse;
+       int ret;
+
+       /* check for valid format */
+       fmt = find_format_by_pix(ctx, fsize->pixel_format);
+       if (!fmt) {
+               ctx_dbg(3, ctx, "Invalid pixel code: %x\n",
+                       fsize->pixel_format);
+               return -EINVAL;
+       }
+
+       fse.index = fsize->index;
+       fse.pad = 0;
+       fse.code = fmt->code;
+
+       ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size, NULL, &fse);
+       if (ret)
+               return -EINVAL;
+
+       ctx_dbg(1, ctx, "%s: index: %d code: %x W:[%d,%d] H:[%d,%d]\n",
+               __func__, fse.index, fse.code, fse.min_width, fse.max_width,
+               fse.min_height, fse.max_height);
+
+       fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
+       fsize->discrete.width = fse.max_width;
+       fsize->discrete.height = fse.max_height;
+
+       return 0;
+}
+
+static int cal_enum_input(struct file *file, void *priv,
+                         struct v4l2_input *inp)
+{
+       if (inp->index >= CAL_NUM_INPUT)
+               return -EINVAL;
+
+       inp->type = V4L2_INPUT_TYPE_CAMERA;
+       sprintf(inp->name, "Camera %u", inp->index);
+       return 0;
+}
+
+static int cal_g_input(struct file *file, void *priv, unsigned int *i)
+{
+       struct cal_ctx *ctx = video_drvdata(file);
+
+       *i = ctx->input;
+       return 0;
+}
+
+static int cal_s_input(struct file *file, void *priv, unsigned int i)
+{
+       struct cal_ctx *ctx = video_drvdata(file);
+
+       if (i >= CAL_NUM_INPUT)
+               return -EINVAL;
+
+       ctx->input = i;
+       return 0;
+}
+
+/* timeperframe is arbitrary and continuous */
+static int cal_enum_frameintervals(struct file *file, void *priv,
+                                  struct v4l2_frmivalenum *fival)
+{
+       struct cal_ctx *ctx = video_drvdata(file);
+       const struct cal_fmt *fmt;
+       struct v4l2_subdev_frame_size_enum fse;
+       int ret;
+
+       if (fival->index)
+               return -EINVAL;
+
+       fmt = find_format_by_pix(ctx, fival->pixel_format);
+       if (!fmt)
+               return -EINVAL;
+
+       /* check for valid width/height */
+       ret = 0;
+       fse.pad = 0;
+       fse.code = fmt->code;
+       fse.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+       for (fse.index = 0; ; fse.index++) {
+               ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size,
+                                      NULL, &fse);
+               if (ret)
+                       return -EINVAL;
+
+               if ((fival->width == fse.max_width) &&
+                   (fival->height == fse.max_height))
+                       break;
+               else if ((fival->width >= fse.min_width) &&
+                        (fival->width <= fse.max_width) &&
+                        (fival->height >= fse.min_height) &&
+                        (fival->height <= fse.max_height))
+                       break;
+
+               return -EINVAL;
+       }
+
+       fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+       fival->discrete.numerator = 1;
+       fival->discrete.denominator = 30;
+
+       return 0;
+}
+
+/*
+ * Videobuf operations
+ */
+static int cal_queue_setup(struct vb2_queue *vq,
+                          unsigned int *nbuffers, unsigned int *nplanes,
+                          unsigned int sizes[], void *alloc_ctxs[])
+{
+       struct cal_ctx *ctx = vb2_get_drv_priv(vq);
+       unsigned size = ctx->v_fmt.fmt.pix.sizeimage;
+
+       if (vq->num_buffers + *nbuffers < 3)
+               *nbuffers = 3 - vq->num_buffers;
+       alloc_ctxs[0] = ctx->alloc_ctx;
+
+       if (*nplanes) {
+               if (sizes[0] < size)
+                       return -EINVAL;
+               size = sizes[0];
+       }
+
+       *nplanes = 1;
+       sizes[0] = size;
+
+       ctx_dbg(3, ctx, "nbuffers=%d, size=%d\n", *nbuffers, sizes[0]);
+
+       return 0;
+}
+
+static int cal_buffer_prepare(struct vb2_buffer *vb)
+{
+       struct cal_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
+       struct cal_buffer *buf = container_of(vb, struct cal_buffer,
+                                             vb.vb2_buf);
+       unsigned long size;
+
+       if (WARN_ON(!ctx->fmt))
+               return -EINVAL;
+
+       size = ctx->v_fmt.fmt.pix.sizeimage;
+       if (vb2_plane_size(vb, 0) < size) {
+               ctx_err(ctx,
+                       "data will not fit into plane (%lu < %lu)\n",
+                       vb2_plane_size(vb, 0), size);
+               return -EINVAL;
+       }
+
+       vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size);
+       return 0;
+}
+
+static void cal_buffer_queue(struct vb2_buffer *vb)
+{
+       struct cal_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
+       struct cal_buffer *buf = container_of(vb, struct cal_buffer,
+                                             vb.vb2_buf);
+       struct cal_dmaqueue *vidq = &ctx->vidq;
+       unsigned long flags = 0;
+
+       /* recheck locking */
+       spin_lock_irqsave(&ctx->slock, flags);
+       list_add_tail(&buf->list, &vidq->active);
+       spin_unlock_irqrestore(&ctx->slock, flags);
+}
+
+static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
+{
+       struct cal_ctx *ctx = vb2_get_drv_priv(vq);
+       struct cal_dmaqueue *dma_q = &ctx->vidq;
+       struct cal_buffer *buf, *tmp;
+       unsigned long addr = 0;
+       unsigned long flags;
+       int ret;
+
+       spin_lock_irqsave(&ctx->slock, flags);
+       if (list_empty(&dma_q->active)) {
+               spin_unlock_irqrestore(&ctx->slock, flags);
+               ctx_dbg(3, ctx, "buffer queue is empty\n");
+               return -EIO;
+       }
+
+       buf = list_entry(dma_q->active.next, struct cal_buffer, list);
+       ctx->cur_frm = buf;
+       ctx->next_frm = buf;
+       list_del(&buf->list);
+       spin_unlock_irqrestore(&ctx->slock, flags);
+
+       addr = vb2_dma_contig_plane_dma_addr(&ctx->cur_frm->vb.vb2_buf, 0);
+       ctx->sequence = 0;
+
+       ret = cal_get_external_info(ctx);
+       if (ret < 0)
+               goto err;
+
+       cal_runtime_get(ctx->dev);
+
+       enable_irqs(ctx);
+       camerarx_phy_enable(ctx);
+       csi2_init(ctx);
+       csi2_phy_config(ctx);
+       csi2_lane_config(ctx);
+       csi2_ctx_config(ctx);
+       pix_proc_config(ctx);
+       cal_wr_dma_config(ctx, ctx->v_fmt.fmt.pix.bytesperline);
+       cal_wr_dma_addr(ctx, addr);
+       csi2_ppi_enable(ctx);
+
+       if (ctx->sensor) {
+               if (v4l2_subdev_call(ctx->sensor, video, s_stream, 1)) {
+                       ctx_err(ctx, "stream on failed in subdev\n");
+                       cal_runtime_put(ctx->dev);
+                       ret = -EINVAL;
+                       goto err;
+               }
+       }
+
+       if (debug >= 4)
+               cal_quickdump_regs(ctx->dev);
+
+       return 0;
+
+err:
+       list_for_each_entry_safe(buf, tmp, &dma_q->active, list) {
+               list_del(&buf->list);
+               vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED);
+       }
+       return ret;
+}
+
+static void cal_stop_streaming(struct vb2_queue *vq)
+{
+       struct cal_ctx *ctx = vb2_get_drv_priv(vq);
+       struct cal_dmaqueue *dma_q = &ctx->vidq;
+       struct cal_buffer *buf, *tmp;
+       unsigned long flags;
+
+       if (ctx->sensor) {
+               if (v4l2_subdev_call(ctx->sensor, video, s_stream, 0))
+                       ctx_err(ctx, "stream off failed in subdev\n");
+       }
+
+       csi2_ppi_disable(ctx);
+       disable_irqs(ctx);
+
+       /* Release all active buffers */
+       spin_lock_irqsave(&ctx->slock, flags);
+       list_for_each_entry_safe(buf, tmp, &dma_q->active, list) {
+               list_del(&buf->list);
+               vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
+       }
+
+       if (ctx->cur_frm == ctx->next_frm) {
+               vb2_buffer_done(&ctx->cur_frm->vb.vb2_buf, VB2_BUF_STATE_ERROR);
+       } else {
+               vb2_buffer_done(&ctx->cur_frm->vb.vb2_buf, VB2_BUF_STATE_ERROR);
+               vb2_buffer_done(&ctx->next_frm->vb.vb2_buf,
+                               VB2_BUF_STATE_ERROR);
+       }
+       ctx->cur_frm = NULL;
+       ctx->next_frm = NULL;
+       spin_unlock_irqrestore(&ctx->slock, flags);
+
+       cal_runtime_put(ctx->dev);
+}
+
+static struct vb2_ops cal_video_qops = {
+       .queue_setup            = cal_queue_setup,
+       .buf_prepare            = cal_buffer_prepare,
+       .buf_queue              = cal_buffer_queue,
+       .start_streaming        = cal_start_streaming,
+       .stop_streaming         = cal_stop_streaming,
+       .wait_prepare           = vb2_ops_wait_prepare,
+       .wait_finish            = vb2_ops_wait_finish,
+};
+
+static const struct v4l2_file_operations cal_fops = {
+       .owner          = THIS_MODULE,
+       .open           = v4l2_fh_open,
+       .release        = vb2_fop_release,
+       .read           = vb2_fop_read,
+       .poll           = vb2_fop_poll,
+       .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */
+       .mmap           = vb2_fop_mmap,
+};
+
+static const struct v4l2_ioctl_ops cal_ioctl_ops = {
+       .vidioc_querycap      = cal_querycap,
+       .vidioc_enum_fmt_vid_cap  = cal_enum_fmt_vid_cap,
+       .vidioc_g_fmt_vid_cap     = cal_g_fmt_vid_cap,
+       .vidioc_try_fmt_vid_cap   = cal_try_fmt_vid_cap,
+       .vidioc_s_fmt_vid_cap     = cal_s_fmt_vid_cap,
+       .vidioc_enum_framesizes   = cal_enum_framesizes,
+       .vidioc_reqbufs       = vb2_ioctl_reqbufs,
+       .vidioc_create_bufs   = vb2_ioctl_create_bufs,
+       .vidioc_prepare_buf   = vb2_ioctl_prepare_buf,
+       .vidioc_querybuf      = vb2_ioctl_querybuf,
+       .vidioc_qbuf          = vb2_ioctl_qbuf,
+       .vidioc_dqbuf         = vb2_ioctl_dqbuf,
+       .vidioc_enum_input    = cal_enum_input,
+       .vidioc_g_input       = cal_g_input,
+       .vidioc_s_input       = cal_s_input,
+       .vidioc_enum_frameintervals = cal_enum_frameintervals,
+       .vidioc_streamon      = vb2_ioctl_streamon,
+       .vidioc_streamoff     = vb2_ioctl_streamoff,
+       .vidioc_log_status    = v4l2_ctrl_log_status,
+       .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
+       .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
+};
+
+static struct video_device cal_videodev = {
+       .name           = CAL_MODULE_NAME,
+       .fops           = &cal_fops,
+       .ioctl_ops      = &cal_ioctl_ops,
+       .minor          = -1,
+       .release        = video_device_release_empty,
+};
+
+/* -----------------------------------------------------------------
+ *     Initialization and module stuff
+ * ------------------------------------------------------------------
+ */
+static int cal_complete_ctx(struct cal_ctx *ctx);
+
+static int cal_async_bound(struct v4l2_async_notifier *notifier,
+                          struct v4l2_subdev *subdev,
+                          struct v4l2_async_subdev *asd)
+{
+       struct cal_ctx *ctx = notifier_to_ctx(notifier);
+       struct v4l2_subdev_mbus_code_enum mbus_code;
+       int ret = 0;
+       int i, j, k;
+
+       if (ctx->sensor) {
+               ctx_info(ctx, "Rejecting subdev %s (Already set!!)",
+                        subdev->name);
+               return 0;
+       }
+
+       ctx->sensor = subdev;
+       ctx_dbg(1, ctx, "Using sensor %s for capture\n", subdev->name);
+
+       /* Enumerate sub device formats and enable all matching local formats */
+       ctx->num_active_fmt = 0;
+       for (j = 0, i = 0; ret != -EINVAL; ++j) {
+               struct cal_fmt *fmt;
+
+               memset(&mbus_code, 0, sizeof(mbus_code));
+               mbus_code.index = j;
+               ret = v4l2_subdev_call(subdev, pad, enum_mbus_code,
+                                      NULL, &mbus_code);
+               if (ret)
+                       continue;
+
+               ctx_dbg(2, ctx,
+                       "subdev %s: code: %04x idx: %d\n",
+                       subdev->name, mbus_code.code, j);
+
+               for (k = 0; k < ARRAY_SIZE(cal_formats); k++) {
+                       fmt = &cal_formats[k];
+
+                       if (mbus_code.code == fmt->code) {
+                               ctx->active_fmt[i] = fmt;
+                               ctx_dbg(2, ctx,
+                                       "matched fourcc: %s: code: %04x idx: %d\n",
+                                       fourcc_to_str(fmt->fourcc),
+                                       fmt->code, i);
+                               ctx->num_active_fmt = ++i;
+                       }
+               }
+       }
+
+       if (i == 0) {
+               ctx_err(ctx, "No suitable format reported by subdev %s\n",
+                       subdev->name);
+               return -EINVAL;
+       }
+
+       cal_complete_ctx(ctx);
+
+       return 0;
+}
+
+static int cal_async_complete(struct v4l2_async_notifier *notifier)
+{
+       struct cal_ctx *ctx = notifier_to_ctx(notifier);
+       const struct cal_fmt *fmt;
+       struct v4l2_mbus_framefmt mbus_fmt;
+       int ret;
+
+       ret = __subdev_get_format(ctx, &mbus_fmt);
+       if (ret)
+               return ret;
+
+       fmt = find_format_by_code(ctx, mbus_fmt.code);
+       if (!fmt) {
+               ctx_dbg(3, ctx, "mbus code format (0x%08x) not found.\n",
+                       mbus_fmt.code);
+               return -EINVAL;
+       }
+
+       /* Save current subdev format */
+       v4l2_fill_pix_format(&ctx->v_fmt.fmt.pix, &mbus_fmt);
+       ctx->v_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       ctx->v_fmt.fmt.pix.pixelformat  = fmt->fourcc;
+       cal_calc_format_size(ctx, fmt, &ctx->v_fmt);
+       ctx->fmt = fmt;
+       ctx->m_fmt = mbus_fmt;
+
+       return 0;
+}
+
+static int cal_complete_ctx(struct cal_ctx *ctx)
+{
+       struct video_device *vfd;
+       struct vb2_queue *q;
+       int ret;
+
+       ctx->timeperframe = tpf_default;
+       ctx->external_rate = 192000000;
+
+       /* initialize locks */
+       spin_lock_init(&ctx->slock);
+       mutex_init(&ctx->mutex);
+
+       /* initialize queue */
+       q = &ctx->vb_vidq;
+       q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+       q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
+       q->drv_priv = ctx;
+       q->buf_struct_size = sizeof(struct cal_buffer);
+       q->ops = &cal_video_qops;
+       q->mem_ops = &vb2_dma_contig_memops;
+       q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+       q->lock = &ctx->mutex;
+       q->min_buffers_needed = 3;
+
+       ret = vb2_queue_init(q);
+       if (ret)
+               return ret;
+
+       /* init video dma queues */
+       INIT_LIST_HEAD(&ctx->vidq.active);
+
+       vfd = &ctx->vdev;
+       *vfd = cal_videodev;
+       vfd->v4l2_dev = &ctx->v4l2_dev;
+       vfd->queue = q;
+
+       /*
+        * Provide a mutex to v4l2 core. It will be used to protect
+        * all fops and v4l2 ioctls.
+        */
+       vfd->lock = &ctx->mutex;
+       video_set_drvdata(vfd, ctx);
+
+       ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);
+       if (ret < 0)
+               return ret;
+
+       v4l2_info(&ctx->v4l2_dev, "V4L2 device registered as %s\n",
+                 video_device_node_name(vfd));
+
+       ctx->alloc_ctx = vb2_dma_contig_init_ctx(vfd->v4l2_dev->dev);
+       if (IS_ERR(ctx->alloc_ctx)) {
+               ctx_err(ctx, "Failed to alloc vb2 context\n");
+               ret = PTR_ERR(ctx->alloc_ctx);
+               goto vdev_unreg;
+       }
+
+       return 0;
+
+vdev_unreg:
+       video_unregister_device(vfd);
+       return ret;
+}
+
+static struct device_node *
+of_get_next_port(const struct device_node *parent,
+                struct device_node *prev)
+{
+       struct device_node *port = NULL;
+
+       if (!parent)
+               return NULL;
+
+       if (!prev) {
+               struct device_node *ports;
+               /*
+                * It's the first call, we have to find a port subnode
+                * within this node or within an optional 'ports' node.
+                */
+               ports = of_get_child_by_name(parent, "ports");
+               if (ports)
+                       parent = ports;
+
+               port = of_get_child_by_name(parent, "port");
+
+               /* release the 'ports' node */
+               of_node_put(ports);
+       } else {
+               struct device_node *ports;
+
+               ports = of_get_parent(prev);
+               if (!ports)
+                       return NULL;
+
+               do {
+                       port = of_get_next_child(ports, prev);
+                       if (!port) {
+                               of_node_put(ports);
+                               return NULL;
+                       }
+                       prev = port;
+               } while (of_node_cmp(port->name, "port") != 0);
+       }
+
+       return port;
+}
+
+static struct device_node *
+of_get_next_endpoint(const struct device_node *parent,
+                    struct device_node *prev)
+{
+       struct device_node *ep = NULL;
+
+       if (!parent)
+               return NULL;
+
+       do {
+               ep = of_get_next_child(parent, prev);
+               if (!ep)
+                       return NULL;
+               prev = ep;
+       } while (of_node_cmp(ep->name, "endpoint") != 0);
+
+       return ep;
+}
+
+static int of_cal_create_instance(struct cal_ctx *ctx, int inst)
+{
+       struct platform_device *pdev = ctx->dev->pdev;
+       struct device_node *ep_node, *port, *remote_ep,
+                       *sensor_node, *parent;
+       struct v4l2_of_endpoint *endpoint;
+       struct v4l2_async_subdev *asd;
+       u32 regval = 0;
+       int ret, index, found_port = 0, lane;
+
+       parent = pdev->dev.of_node;
+
+       asd = &ctx->asd;
+       endpoint = &ctx->endpoint;
+
+       ep_node = NULL;
+       port = NULL;
+       remote_ep = NULL;
+       sensor_node = NULL;
+       ret = -EINVAL;
+
+       ctx_dbg(3, ctx, "Scanning Port node for csi2 port: %d\n", inst);
+       for (index = 0; index < CAL_NUM_CSI2_PORTS; index++) {
+               port = of_get_next_port(parent, port);
+               if (!port) {
+                       ctx_dbg(1, ctx, "No port node found for csi2 port:%d\n",
+                               index);
+                       goto cleanup_exit;
+               }
+
+               /* Match the slice number with <REG> */
+               of_property_read_u32(port, "reg", &regval);
+               ctx_dbg(3, ctx, "port:%d inst:%d <reg>:%d\n",
+                       index, inst, regval);
+               if ((regval == inst) && (index == inst)) {
+                       found_port = 1;
+                       break;
+               }
+       }
+
+       if (!found_port) {
+               ctx_dbg(1, ctx, "No port node matches csi2 port:%d\n",
+                       inst);
+               goto cleanup_exit;
+       }
+
+       ctx_dbg(3, ctx, "Scanning sub-device for csi2 port: %d\n",
+               inst);
+
+       ep_node = of_get_next_endpoint(port, ep_node);
+       if (!ep_node) {
+               ctx_dbg(3, ctx, "can't get next endpoint\n");
+               goto cleanup_exit;
+       }
+
+       sensor_node = of_graph_get_remote_port_parent(ep_node);
+       if (!sensor_node) {
+               ctx_dbg(3, ctx, "can't get remote parent\n");
+               goto cleanup_exit;
+       }
+       asd->match_type = V4L2_ASYNC_MATCH_OF;
+       asd->match.of.node = sensor_node;
+
+       remote_ep = of_parse_phandle(ep_node, "remote-endpoint", 0);
+       if (!remote_ep) {
+               ctx_dbg(3, ctx, "can't get remote-endpoint\n");
+               goto cleanup_exit;
+       }
+       v4l2_of_parse_endpoint(remote_ep, endpoint);
+
+       if (endpoint->bus_type != V4L2_MBUS_CSI2) {
+               ctx_err(ctx, "Port:%d sub-device %s is not a CSI2 device\n",
+                       inst, sensor_node->name);
+               goto cleanup_exit;
+       }
+
+       /* Store Virtual Channel number */
+       ctx->virtual_channel = endpoint->base.id;
+
+       ctx_dbg(3, ctx, "Port:%d v4l2-endpoint: CSI2\n", inst);
+       ctx_dbg(3, ctx, "Virtual Channel=%d\n", ctx->virtual_channel);
+       ctx_dbg(3, ctx, "flags=0x%08x\n", endpoint->bus.mipi_csi2.flags);
+       ctx_dbg(3, ctx, "clock_lane=%d\n", endpoint->bus.mipi_csi2.clock_lane);
+       ctx_dbg(3, ctx, "num_data_lanes=%d\n",
+               endpoint->bus.mipi_csi2.num_data_lanes);
+       ctx_dbg(3, ctx, "data_lanes= <\n");
+       for (lane = 0; lane < endpoint->bus.mipi_csi2.num_data_lanes; lane++)
+               ctx_dbg(3, ctx, "\t%d\n",
+                       endpoint->bus.mipi_csi2.data_lanes[lane]);
+       ctx_dbg(3, ctx, "\t>\n");
+
+       ctx_dbg(1, ctx, "Port: %d found sub-device %s\n",
+               inst, sensor_node->name);
+
+       ctx->asd_list[0] = asd;
+       ctx->notifier.subdevs = ctx->asd_list;
+       ctx->notifier.num_subdevs = 1;
+       ctx->notifier.bound = cal_async_bound;
+       ctx->notifier.complete = cal_async_complete;
+       ret = v4l2_async_notifier_register(&ctx->v4l2_dev,
+                                          &ctx->notifier);
+       if (ret) {
+               ctx_err(ctx, "Error registering async notifier\n");
+               ret = -EINVAL;
+       }
+
+cleanup_exit:
+       if (!remote_ep)
+               of_node_put(remote_ep);
+       if (!sensor_node)
+               of_node_put(sensor_node);
+       if (!ep_node)
+               of_node_put(ep_node);
+       if (!port)
+               of_node_put(port);
+
+       return ret;
+}
+
+static struct cal_ctx *cal_create_instance(struct cal_dev *dev, int inst)
+{
+       struct cal_ctx *ctx;
+       struct v4l2_ctrl_handler *hdl;
+       int ret;
+
+       ctx = devm_kzalloc(&dev->pdev->dev, sizeof(*ctx), GFP_KERNEL);
+       if (!ctx)
+               return NULL;
+
+       /* save the cal_dev * for future ref */
+       ctx->dev = dev;
+
+       snprintf(ctx->v4l2_dev.name, sizeof(ctx->v4l2_dev.name),
+                "%s-%03d", CAL_MODULE_NAME, inst);
+       ret = v4l2_device_register(&dev->pdev->dev, &ctx->v4l2_dev);
+       if (ret)
+               goto err_exit;
+
+       hdl = &ctx->ctrl_handler;
+       ret = v4l2_ctrl_handler_init(hdl, 11);
+       if (ret) {
+               ctx_err(ctx, "Failed to init ctrl handler\n");
+               goto unreg_dev;
+       }
+       ctx->v4l2_dev.ctrl_handler = hdl;
+
+       /* Make sure Camera Core H/W register area is available */
+       ctx->cc = dev->cc[inst];
+
+       /* Store the instance id */
+       ctx->csi2_port = inst + 1;
+
+       ret = of_cal_create_instance(ctx, inst);
+       if (ret) {
+               ret = -EINVAL;
+               goto free_hdl;
+       }
+       return ctx;
+
+free_hdl:
+       v4l2_ctrl_handler_free(hdl);
+unreg_dev:
+       v4l2_device_unregister(&ctx->v4l2_dev);
+err_exit:
+       return NULL;
+}
+
+static int cal_probe(struct platform_device *pdev)
+{
+       struct cal_dev *dev;
+       int ret;
+       int irq;
+
+       dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
+       if (!dev)
+               return -ENOMEM;
+
+       /* set pseudo v4l2 device name so we can use v4l2_printk */
+       strlcpy(dev->v4l2_dev.name, CAL_MODULE_NAME,
+               sizeof(dev->v4l2_dev.name));
+
+       /* save pdev pointer */
+       dev->pdev = pdev;
+
+       dev->res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+                                               "cal_top");
+       dev->base = devm_ioremap_resource(&pdev->dev, dev->res);
+       if (IS_ERR(dev->base))
+               return PTR_ERR(dev->base);
+
+       cal_dbg(1, dev, "ioresource %s at %pa - %pa\n",
+               dev->res->name, &dev->res->start, &dev->res->end);
+
+       irq = platform_get_irq(pdev, 0);
+       cal_dbg(1, dev, "got irq# %d\n", irq);
+       ret = devm_request_irq(&pdev->dev, irq, cal_irq, 0, CAL_MODULE_NAME,
+                              dev);
+       if (ret)
+               return ret;
+
+       platform_set_drvdata(pdev, dev);
+
+       dev->cm = cm_create(dev);
+       if (IS_ERR(dev->cm))
+               return PTR_ERR(dev->cm);
+
+       dev->cc[0] = cc_create(dev, 0);
+       if (IS_ERR(dev->cc[0]))
+               return PTR_ERR(dev->cc[0]);
+
+       dev->cc[1] = cc_create(dev, 1);
+       if (IS_ERR(dev->cc[1]))
+               return PTR_ERR(dev->cc[1]);
+
+       dev->ctx[0] = NULL;
+       dev->ctx[1] = NULL;
+
+       dev->ctx[0] = cal_create_instance(dev, 0);
+       dev->ctx[1] = cal_create_instance(dev, 1);
+       if (!dev->ctx[0] && !dev->ctx[1]) {
+               cal_err(dev, "Neither port is configured, no point in staying up\n");
+               return -ENODEV;
+       }
+
+       pm_runtime_enable(&pdev->dev);
+
+       ret = cal_runtime_get(dev);
+       if (ret)
+               goto runtime_disable;
+
+       /* Just check we can actually access the module */
+       cal_get_hwinfo(dev);
+
+       cal_runtime_put(dev);
+
+       return 0;
+
+runtime_disable:
+       pm_runtime_disable(&pdev->dev);
+       return ret;
+}
+
+static int cal_remove(struct platform_device *pdev)
+{
+       struct cal_dev *dev =
+               (struct cal_dev *)platform_get_drvdata(pdev);
+       struct cal_ctx *ctx;
+       int i;
+
+       cal_dbg(1, dev, "Removing %s\n", CAL_MODULE_NAME);
+
+       cal_runtime_get(dev);
+
+       for (i = 0; i < CAL_NUM_CONTEXT; i++) {
+               ctx = dev->ctx[i];
+               if (ctx) {
+                       ctx_dbg(1, ctx, "unregistering %s\n",
+                               video_device_node_name(&ctx->vdev));
+                       camerarx_phy_disable(ctx);
+                       v4l2_async_notifier_unregister(&ctx->notifier);
+                       vb2_dma_contig_cleanup_ctx(ctx->alloc_ctx);
+                       v4l2_ctrl_handler_free(&ctx->ctrl_handler);
+                       v4l2_device_unregister(&ctx->v4l2_dev);
+                       video_unregister_device(&ctx->vdev);
+               }
+       }
+
+       cal_runtime_put(dev);
+       pm_runtime_disable(&pdev->dev);
+
+       return 0;
+}
+
+#if defined(CONFIG_OF)
+static const struct of_device_id cal_of_match[] = {
+       { .compatible = "ti,dra72-cal", },
+       {},
+};
+MODULE_DEVICE_TABLE(of, cal_of_match);
+#endif
+
+static struct platform_driver cal_pdrv = {
+       .probe          = cal_probe,
+       .remove         = cal_remove,
+       .driver         = {
+               .name   = CAL_MODULE_NAME,
+               .of_match_table = of_match_ptr(cal_of_match),
+       },
+};
+
+module_platform_driver(cal_pdrv);
diff --git a/drivers/media/platform/ti-vpe/cal_regs.h b/drivers/media/platform/ti-vpe/cal_regs.h
new file mode 100644 (file)
index 0000000..82b3dcf
--- /dev/null
@@ -0,0 +1,479 @@
+/*
+ * TI CAL camera interface driver
+ *
+ * Copyright (c) 2015 Texas Instruments Inc.
+ *
+ * Benoit Parrot, <bparrot@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#ifndef __TI_CAL_REGS_H
+#define __TI_CAL_REGS_H
+
+#define CAL_NUM_CSI2_PORTS             2
+
+/* CAL register offsets */
+
+#define CAL_HL_REVISION                        0x0000
+#define CAL_HL_HWINFO                  0x0004
+#define CAL_HL_SYSCONFIG               0x0010
+#define CAL_HL_IRQ_EOI                 0x001c
+#define CAL_HL_IRQSTATUS_RAW(m)                (0x20U + ((m-1) * 0x10U))
+#define CAL_HL_IRQSTATUS(m)            (0x24U + ((m-1) * 0x10U))
+#define CAL_HL_IRQENABLE_SET(m)                (0x28U + ((m-1) * 0x10U))
+#define CAL_HL_IRQENABLE_CLR(m)                (0x2cU + ((m-1) * 0x10U))
+#define CAL_PIX_PROC(m)                        (0xc0U + ((m-1) * 0x4U))
+#define CAL_CTRL                       0x100
+#define CAL_CTRL1                      0x104
+#define CAL_LINE_NUMBER_EVT            0x108
+#define CAL_VPORT_CTRL1                        0x120
+#define CAL_VPORT_CTRL2                        0x124
+#define CAL_BYS_CTRL1                  0x130
+#define CAL_BYS_CTRL2                  0x134
+#define CAL_RD_DMA_CTRL                        0x140
+#define CAL_RD_DMA_PIX_ADDR            0x144
+#define CAL_RD_DMA_PIX_OFST            0x148
+#define CAL_RD_DMA_XSIZE               0x14c
+#define CAL_RD_DMA_YSIZE               0x150
+#define CAL_RD_DMA_INIT_ADDR           0x154
+#define CAL_RD_DMA_INIT_OFST           0x168
+#define CAL_RD_DMA_CTRL2               0x16c
+#define CAL_WR_DMA_CTRL(m)             (0x200U + ((m-1) * 0x10U))
+#define CAL_WR_DMA_ADDR(m)             (0x204U + ((m-1) * 0x10U))
+#define CAL_WR_DMA_OFST(m)             (0x208U + ((m-1) * 0x10U))
+#define CAL_WR_DMA_XSIZE(m)            (0x20cU + ((m-1) * 0x10U))
+#define CAL_CSI2_PPI_CTRL(m)           (0x300U + ((m-1) * 0x80U))
+#define CAL_CSI2_COMPLEXIO_CFG(m)      (0x304U + ((m-1) * 0x80U))
+#define CAL_CSI2_COMPLEXIO_IRQSTATUS(m)        (0x308U + ((m-1) * 0x80U))
+#define CAL_CSI2_SHORT_PACKET(m)       (0x30cU + ((m-1) * 0x80U))
+#define CAL_CSI2_COMPLEXIO_IRQENABLE(m)        (0x310U + ((m-1) * 0x80U))
+#define CAL_CSI2_TIMING(m)             (0x314U + ((m-1) * 0x80U))
+#define CAL_CSI2_VC_IRQENABLE(m)       (0x318U + ((m-1) * 0x80U))
+#define CAL_CSI2_VC_IRQSTATUS(m)       (0x328U + ((m-1) * 0x80U))
+#define CAL_CSI2_CTX0(m)               (0x330U + ((m-1) * 0x80U))
+#define CAL_CSI2_CTX1(m)               (0x334U + ((m-1) * 0x80U))
+#define CAL_CSI2_CTX2(m)               (0x338U + ((m-1) * 0x80U))
+#define CAL_CSI2_CTX3(m)               (0x33cU + ((m-1) * 0x80U))
+#define CAL_CSI2_CTX4(m)               (0x340U + ((m-1) * 0x80U))
+#define CAL_CSI2_CTX5(m)               (0x344U + ((m-1) * 0x80U))
+#define CAL_CSI2_CTX6(m)               (0x348U + ((m-1) * 0x80U))
+#define CAL_CSI2_CTX7(m)               (0x34cU + ((m-1) * 0x80U))
+#define CAL_CSI2_STATUS0(m)            (0x350U + ((m-1) * 0x80U))
+#define CAL_CSI2_STATUS1(m)            (0x354U + ((m-1) * 0x80U))
+#define CAL_CSI2_STATUS2(m)            (0x358U + ((m-1) * 0x80U))
+#define CAL_CSI2_STATUS3(m)            (0x35cU + ((m-1) * 0x80U))
+#define CAL_CSI2_STATUS4(m)            (0x360U + ((m-1) * 0x80U))
+#define CAL_CSI2_STATUS5(m)            (0x364U + ((m-1) * 0x80U))
+#define CAL_CSI2_STATUS6(m)            (0x368U + ((m-1) * 0x80U))
+#define CAL_CSI2_STATUS7(m)            (0x36cU + ((m-1) * 0x80U))
+
+/* CAL CSI2 PHY register offsets */
+#define CAL_CSI2_PHY_REG0              0x000
+#define CAL_CSI2_PHY_REG1              0x004
+#define CAL_CSI2_PHY_REG2              0x008
+
+/* CAL Control Module Core Camerrx Control register offsets */
+#define CM_CTRL_CORE_CAMERRX_CONTROL   0x000
+
+/*********************************************************************
+* Generic value used in various field below
+*********************************************************************/
+
+#define CAL_GEN_DISABLE                        0
+#define CAL_GEN_ENABLE                 1
+#define CAL_GEN_FALSE                  0
+#define CAL_GEN_TRUE                   1
+
+/*********************************************************************
+* Field Definition Macros
+*********************************************************************/
+
+#define CAL_HL_REVISION_MINOR_MASK             GENMASK(5, 0)
+#define CAL_HL_REVISION_CUSTOM_MASK            GENMASK(7, 6)
+#define CAL_HL_REVISION_MAJOR_MASK             GENMASK(10, 8)
+#define CAL_HL_REVISION_RTL_MASK               GENMASK(15, 11)
+#define CAL_HL_REVISION_FUNC_MASK              GENMASK(27, 16)
+#define CAL_HL_REVISION_SCHEME_MASK            GENMASK(31, 30)
+#define CAL_HL_REVISION_SCHEME_H08                     1
+#define CAL_HL_REVISION_SCHEME_LEGACY                  0
+
+#define CAL_HL_HWINFO_WFIFO_MASK               GENMASK(3, 0)
+#define CAL_HL_HWINFO_RFIFO_MASK               GENMASK(7, 4)
+#define CAL_HL_HWINFO_PCTX_MASK                        GENMASK(12, 8)
+#define CAL_HL_HWINFO_WCTX_MASK                        GENMASK(18, 13)
+#define CAL_HL_HWINFO_VFIFO_MASK               GENMASK(22, 19)
+#define CAL_HL_HWINFO_NCPORT_MASK              GENMASK(27, 23)
+#define CAL_HL_HWINFO_NPPI_CTXS0_MASK          GENMASK(29, 28)
+#define CAL_HL_HWINFO_NPPI_CTXS1_MASK          GENMASK(31, 30)
+#define CAL_HL_HWINFO_NPPI_CONTEXTS_ZERO               0
+#define CAL_HL_HWINFO_NPPI_CONTEXTS_FOUR               1
+#define CAL_HL_HWINFO_NPPI_CONTEXTS_EIGHT              2
+#define CAL_HL_HWINFO_NPPI_CONTEXTS_RESERVED           3
+
+#define CAL_HL_SYSCONFIG_SOFTRESET_MASK                BIT_MASK(0)
+#define CAL_HL_SYSCONFIG_SOFTRESET_DONE                        0x0
+#define CAL_HL_SYSCONFIG_SOFTRESET_PENDING             0x1
+#define CAL_HL_SYSCONFIG_SOFTRESET_NOACTION            0x0
+#define CAL_HL_SYSCONFIG_SOFTRESET_RESET               0x1
+#define CAL_HL_SYSCONFIG_IDLE_MASK             GENMASK(3, 2)
+#define CAL_HL_SYSCONFIG_IDLEMODE_FORCE                        0
+#define CAL_HL_SYSCONFIG_IDLEMODE_NO                   1
+#define CAL_HL_SYSCONFIG_IDLEMODE_SMART1               2
+#define CAL_HL_SYSCONFIG_IDLEMODE_SMART2               3
+
+#define CAL_HL_IRQ_EOI_LINE_NUMBER_MASK                BIT_MASK(0)
+#define CAL_HL_IRQ_EOI_LINE_NUMBER_READ0               0
+#define CAL_HL_IRQ_EOI_LINE_NUMBER_EOI0                        0
+
+#define CAL_HL_IRQ_MASK(m)                     BIT_MASK(m-1)
+#define CAL_HL_IRQ_NOACTION                            0x0
+#define CAL_HL_IRQ_ENABLE                              0x1
+#define CAL_HL_IRQ_CLEAR                               0x1
+#define CAL_HL_IRQ_DISABLED                            0x0
+#define CAL_HL_IRQ_ENABLED                             0x1
+#define CAL_HL_IRQ_PENDING                             0x1
+
+#define CAL_PIX_PROC_EN_MASK                   BIT_MASK(0)
+#define CAL_PIX_PROC_EXTRACT_MASK              GENMASK(4, 1)
+#define CAL_PIX_PROC_EXTRACT_B6                                0x0
+#define CAL_PIX_PROC_EXTRACT_B7                                0x1
+#define CAL_PIX_PROC_EXTRACT_B8                                0x2
+#define CAL_PIX_PROC_EXTRACT_B10                       0x3
+#define CAL_PIX_PROC_EXTRACT_B10_MIPI                  0x4
+#define CAL_PIX_PROC_EXTRACT_B12                       0x5
+#define CAL_PIX_PROC_EXTRACT_B12_MIPI                  0x6
+#define CAL_PIX_PROC_EXTRACT_B14                       0x7
+#define CAL_PIX_PROC_EXTRACT_B14_MIPI                  0x8
+#define CAL_PIX_PROC_EXTRACT_B16_BE                    0x9
+#define CAL_PIX_PROC_EXTRACT_B16_LE                    0xa
+#define CAL_PIX_PROC_DPCMD_MASK                        GENMASK(9, 5)
+#define CAL_PIX_PROC_DPCMD_BYPASS                      0x0
+#define CAL_PIX_PROC_DPCMD_DPCM_10_8_1                 0x2
+#define CAL_PIX_PROC_DPCMD_DPCM_12_8_1                 0x8
+#define CAL_PIX_PROC_DPCMD_DPCM_10_7_1                 0x4
+#define CAL_PIX_PROC_DPCMD_DPCM_10_7_2                 0x5
+#define CAL_PIX_PROC_DPCMD_DPCM_10_6_1                 0x6
+#define CAL_PIX_PROC_DPCMD_DPCM_10_6_2                 0x7
+#define CAL_PIX_PROC_DPCMD_DPCM_12_7_1                 0xa
+#define CAL_PIX_PROC_DPCMD_DPCM_12_6_1                 0xc
+#define CAL_PIX_PROC_DPCMD_DPCM_14_10                  0xe
+#define CAL_PIX_PROC_DPCMD_DPCM_14_8_1                 0x10
+#define CAL_PIX_PROC_DPCMD_DPCM_16_12_1                        0x12
+#define CAL_PIX_PROC_DPCMD_DPCM_16_10_1                        0x14
+#define CAL_PIX_PROC_DPCMD_DPCM_16_8_1                 0x16
+#define CAL_PIX_PROC_DPCME_MASK                        GENMASK(15, 11)
+#define CAL_PIX_PROC_DPCME_BYPASS                      0x0
+#define CAL_PIX_PROC_DPCME_DPCM_10_8_1                 0x2
+#define CAL_PIX_PROC_DPCME_DPCM_12_8_1                 0x8
+#define CAL_PIX_PROC_DPCME_DPCM_14_10                  0xe
+#define CAL_PIX_PROC_DPCME_DPCM_14_8_1                 0x10
+#define CAL_PIX_PROC_DPCME_DPCM_16_12_1                        0x12
+#define CAL_PIX_PROC_DPCME_DPCM_16_10_1                        0x14
+#define CAL_PIX_PROC_DPCME_DPCM_16_8_1                 0x16
+#define CAL_PIX_PROC_PACK_MASK                 GENMASK(18, 16)
+#define CAL_PIX_PROC_PACK_B8                           0x0
+#define CAL_PIX_PROC_PACK_B10_MIPI                     0x2
+#define CAL_PIX_PROC_PACK_B12                          0x3
+#define CAL_PIX_PROC_PACK_B12_MIPI                     0x4
+#define CAL_PIX_PROC_PACK_B16                          0x5
+#define CAL_PIX_PROC_PACK_ARGB                         0x6
+#define CAL_PIX_PROC_CPORT_MASK                        GENMASK(23, 19)
+
+#define CAL_CTRL_POSTED_WRITES_MASK            BIT_MASK(0)
+#define CAL_CTRL_POSTED_WRITES_NONPOSTED               0
+#define CAL_CTRL_POSTED_WRITES                         1
+#define CAL_CTRL_TAGCNT_MASK                   GENMASK(4, 1)
+#define CAL_CTRL_BURSTSIZE_MASK                        GENMASK(6, 5)
+#define CAL_CTRL_BURSTSIZE_BURST16                     0x0
+#define CAL_CTRL_BURSTSIZE_BURST32                     0x1
+#define CAL_CTRL_BURSTSIZE_BURST64                     0x2
+#define CAL_CTRL_BURSTSIZE_BURST128                    0x3
+#define CAL_CTRL_LL_FORCE_STATE_MASK           GENMASK(12, 7)
+#define CAL_CTRL_MFLAGL_MASK                   GENMASK(20, 13)
+#define CAL_CTRL_PWRSCPCLK_MASK                        BIT_MASK(21)
+#define CAL_CTRL_PWRSCPCLK_AUTO                                0
+#define CAL_CTRL_PWRSCPCLK_FORCE                       1
+#define CAL_CTRL_RD_DMA_STALL_MASK             BIT_MASK(22)
+#define CAL_CTRL_MFLAGH_MASK                   GENMASK(31, 24)
+
+#define CAL_CTRL1_PPI_GROUPING_MASK            GENMASK(1, 0)
+#define CAL_CTRL1_PPI_GROUPING_DISABLED                        0
+#define CAL_CTRL1_PPI_GROUPING_RESERVED                        1
+#define CAL_CTRL1_PPI_GROUPING_0                       2
+#define CAL_CTRL1_PPI_GROUPING_1                       3
+#define CAL_CTRL1_INTERLEAVE01_MASK            GENMASK(3, 2)
+#define CAL_CTRL1_INTERLEAVE01_DISABLED                        0
+#define CAL_CTRL1_INTERLEAVE01_PIX1                    1
+#define CAL_CTRL1_INTERLEAVE01_PIX4                    2
+#define CAL_CTRL1_INTERLEAVE01_RESERVED                        3
+#define CAL_CTRL1_INTERLEAVE23_MASK            GENMASK(5, 4)
+#define CAL_CTRL1_INTERLEAVE23_DISABLED                        0
+#define CAL_CTRL1_INTERLEAVE23_PIX1                    1
+#define CAL_CTRL1_INTERLEAVE23_PIX4                    2
+#define CAL_CTRL1_INTERLEAVE23_RESERVED                        3
+
+#define CAL_LINE_NUMBER_EVT_CPORT_MASK         GENMASK(4, 0)
+#define CAL_LINE_NUMBER_EVT_MASK               GENMASK(29, 16)
+
+#define CAL_VPORT_CTRL1_PCLK_MASK              GENMASK(16, 0)
+#define CAL_VPORT_CTRL1_XBLK_MASK              GENMASK(24, 17)
+#define CAL_VPORT_CTRL1_YBLK_MASK              GENMASK(30, 25)
+#define CAL_VPORT_CTRL1_WIDTH_MASK             BIT_MASK(31)
+#define CAL_VPORT_CTRL1_WIDTH_ONE                      0
+#define CAL_VPORT_CTRL1_WIDTH_TWO                      1
+
+#define CAL_VPORT_CTRL2_CPORT_MASK             GENMASK(4, 0)
+#define CAL_VPORT_CTRL2_FREERUNNING_MASK       BIT_MASK(15)
+#define CAL_VPORT_CTRL2_FREERUNNING_GATED              0
+#define CAL_VPORT_CTRL2_FREERUNNING_FREE               1
+#define CAL_VPORT_CTRL2_FS_RESETS_MASK         BIT_MASK(16)
+#define CAL_VPORT_CTRL2_FS_RESETS_NO                   0
+#define CAL_VPORT_CTRL2_FS_RESETS_YES                  1
+#define CAL_VPORT_CTRL2_FSM_RESET_MASK         BIT_MASK(17)
+#define CAL_VPORT_CTRL2_FSM_RESET_NOEFFECT             0
+#define CAL_VPORT_CTRL2_FSM_RESET                      1
+#define CAL_VPORT_CTRL2_RDY_THR_MASK           GENMASK(31, 18)
+
+#define CAL_BYS_CTRL1_PCLK_MASK                        GENMASK(16, 0)
+#define CAL_BYS_CTRL1_XBLK_MASK                        GENMASK(24, 17)
+#define CAL_BYS_CTRL1_YBLK_MASK                        GENMASK(30, 25)
+#define CAL_BYS_CTRL1_BYSINEN_MASK             BIT_MASK(31)
+
+#define CAL_BYS_CTRL2_CPORTIN_MASK             GENMASK(4, 0)
+#define CAL_BYS_CTRL2_CPORTOUT_MASK            GENMASK(9, 5)
+#define CAL_BYS_CTRL2_DUPLICATEDDATA_MASK      BIT_MASK(10)
+#define CAL_BYS_CTRL2_DUPLICATEDDATA_NO                        0
+#define CAL_BYS_CTRL2_DUPLICATEDDATA_YES               1
+#define CAL_BYS_CTRL2_FREERUNNING_MASK         BIT_MASK(11)
+#define CAL_BYS_CTRL2_FREERUNNING_NO                   0
+#define CAL_BYS_CTRL2_FREERUNNING_YES                  1
+
+#define CAL_RD_DMA_CTRL_GO_MASK                        BIT_MASK(0)
+#define CAL_RD_DMA_CTRL_GO_DIS                         0
+#define CAL_RD_DMA_CTRL_GO_EN                          1
+#define CAL_RD_DMA_CTRL_GO_IDLE                                0
+#define CAL_RD_DMA_CTRL_GO_BUSY                                1
+#define CAL_RD_DMA_CTRL_INIT_MASK              BIT_MASK(1)
+#define CAL_RD_DMA_CTRL_BW_LIMITER_MASK                GENMASK(10, 2)
+#define CAL_RD_DMA_CTRL_OCP_TAG_CNT_MASK       GENMASK(14, 11)
+#define CAL_RD_DMA_CTRL_PCLK_MASK              GENMASK(31, 15)
+
+#define CAL_RD_DMA_PIX_ADDR_MASK               GENMASK(31, 3)
+
+#define CAL_RD_DMA_PIX_OFST_MASK               GENMASK(31, 4)
+
+#define CAL_RD_DMA_XSIZE_MASK                  GENMASK(31, 19)
+
+#define CAL_RD_DMA_YSIZE_MASK                  GENMASK(29, 16)
+
+#define CAL_RD_DMA_INIT_ADDR_MASK              GENMASK(31, 3)
+
+#define CAL_RD_DMA_INIT_OFST_MASK              GENMASK(31, 3)
+
+#define CAL_RD_DMA_CTRL2_CIRC_MODE_MASK                GENMASK(2, 0)
+#define CAL_RD_DMA_CTRL2_CIRC_MODE_DIS                 0
+#define CAL_RD_DMA_CTRL2_CIRC_MODE_ONE                 1
+#define CAL_RD_DMA_CTRL2_CIRC_MODE_FOUR                        2
+#define CAL_RD_DMA_CTRL2_CIRC_MODE_SIXTEEN             3
+#define CAL_RD_DMA_CTRL2_CIRC_MODE_SIXTYFOUR           4
+#define CAL_RD_DMA_CTRL2_CIRC_MODE_RESERVED            5
+#define CAL_RD_DMA_CTRL2_ICM_CSTART_MASK       BIT_MASK(3)
+#define CAL_RD_DMA_CTRL2_PATTERN_MASK          GENMASK(5, 4)
+#define CAL_RD_DMA_CTRL2_PATTERN_LINEAR                        0
+#define CAL_RD_DMA_CTRL2_PATTERN_YUV420                        1
+#define CAL_RD_DMA_CTRL2_PATTERN_RD2SKIP2              2
+#define CAL_RD_DMA_CTRL2_PATTERN_RD2SKIP4              3
+#define CAL_RD_DMA_CTRL2_BYSOUT_LE_WAIT_MASK   BIT_MASK(6)
+#define CAL_RD_DMA_CTRL2_BYSOUT_LE_WAIT_FREERUNNING    0
+#define CAL_RD_DMA_CTRL2_BYSOUT_LE_WAIT_WAITFORBYSOUT  1
+#define CAL_RD_DMA_CTRL2_CIRC_SIZE_MASK                GENMASK(29, 16)
+
+#define CAL_WR_DMA_CTRL_MODE_MASK              GENMASK(2, 0)
+#define CAL_WR_DMA_CTRL_MODE_DIS                       0
+#define CAL_WR_DMA_CTRL_MODE_SHD                       1
+#define CAL_WR_DMA_CTRL_MODE_CNT                       2
+#define CAL_WR_DMA_CTRL_MODE_CNT_INIT                  3
+#define CAL_WR_DMA_CTRL_MODE_CONST                     4
+#define CAL_WR_DMA_CTRL_MODE_RESERVED                  5
+#define CAL_WR_DMA_CTRL_PATTERN_MASK           GENMASK(4, 3)
+#define CAL_WR_DMA_CTRL_PATTERN_LINEAR                 0
+#define CAL_WR_DMA_CTRL_PATTERN_WR2SKIP2               2
+#define CAL_WR_DMA_CTRL_PATTERN_WR2SKIP4               3
+#define CAL_WR_DMA_CTRL_PATTERN_RESERVED               1
+#define CAL_WR_DMA_CTRL_ICM_PSTART_MASK                BIT_MASK(5)
+#define CAL_WR_DMA_CTRL_DTAG_MASK              GENMASK(8, 6)
+#define CAL_WR_DMA_CTRL_DTAG_ATT_HDR                   0
+#define CAL_WR_DMA_CTRL_DTAG_ATT_DAT                   1
+#define CAL_WR_DMA_CTRL_DTAG                           2
+#define CAL_WR_DMA_CTRL_DTAG_PIX_HDR                   3
+#define CAL_WR_DMA_CTRL_DTAG_PIX_DAT                   4
+#define CAL_WR_DMA_CTRL_DTAG_D5                                5
+#define CAL_WR_DMA_CTRL_DTAG_D6                                6
+#define CAL_WR_DMA_CTRL_DTAG_D7                                7
+#define CAL_WR_DMA_CTRL_CPORT_MASK             GENMASK(13, 9)
+#define CAL_WR_DMA_CTRL_STALL_RD_MASK          BIT_MASK(14)
+#define CAL_WR_DMA_CTRL_YSIZE_MASK             GENMASK(31, 18)
+
+#define CAL_WR_DMA_ADDR_MASK                   GENMASK(31, 4)
+
+#define CAL_WR_DMA_OFST_MASK                   GENMASK(18, 4)
+#define CAL_WR_DMA_OFST_CIRC_MODE_MASK         GENMASK(23, 22)
+#define CAL_WR_DMA_OFST_CIRC_MODE_ONE                  1
+#define CAL_WR_DMA_OFST_CIRC_MODE_FOUR                 2
+#define CAL_WR_DMA_OFST_CIRC_MODE_SIXTYFOUR            3
+#define CAL_WR_DMA_OFST_CIRC_MODE_DISABLED             0
+#define CAL_WR_DMA_OFST_CIRC_SIZE_MASK         GENMASK(31, 24)
+
+#define CAL_WR_DMA_XSIZE_XSKIP_MASK            GENMASK(15, 3)
+#define CAL_WR_DMA_XSIZE_MASK                  GENMASK(31, 19)
+
+#define CAL_CSI2_PPI_CTRL_IF_EN_MASK           BIT_MASK(0)
+#define CAL_CSI2_PPI_CTRL_ECC_EN_MASK          BIT_MASK(2)
+#define CAL_CSI2_PPI_CTRL_FRAME_MASK           BIT_MASK(3)
+#define CAL_CSI2_PPI_CTRL_FRAME_IMMEDIATE              0
+#define CAL_CSI2_PPI_CTRL_FRAME                                1
+
+#define CAL_CSI2_COMPLEXIO_CFG_CLOCK_POSITION_MASK     GENMASK(2, 0)
+#define CAL_CSI2_COMPLEXIO_CFG_POSITION_5                      5
+#define CAL_CSI2_COMPLEXIO_CFG_POSITION_4                      4
+#define CAL_CSI2_COMPLEXIO_CFG_POSITION_3                      3
+#define CAL_CSI2_COMPLEXIO_CFG_POSITION_2                      2
+#define CAL_CSI2_COMPLEXIO_CFG_POSITION_1                      1
+#define CAL_CSI2_COMPLEXIO_CFG_POSITION_NOT_USED               0
+#define CAL_CSI2_COMPLEXIO_CFG_CLOCK_POL_MASK          BIT_MASK(3)
+#define CAL_CSI2_COMPLEXIO_CFG_POL_PLUSMINUS                   0
+#define CAL_CSI2_COMPLEXIO_CFG_POL_MINUSPLUS                   1
+#define CAL_CSI2_COMPLEXIO_CFG_DATA1_POSITION_MASK     GENMASK(6, 4)
+#define CAL_CSI2_COMPLEXIO_CFG_DATA1_POL_MASK          BIT_MASK(7)
+#define CAL_CSI2_COMPLEXIO_CFG_DATA2_POSITION_MASK     GENMASK(10, 8)
+#define CAL_CSI2_COMPLEXIO_CFG_DATA2_POL_MASK          BIT_MASK(11)
+#define CAL_CSI2_COMPLEXIO_CFG_DATA3_POSITION_MASK     GENMASK(14, 12)
+#define CAL_CSI2_COMPLEXIO_CFG_DATA3_POL_MASK          BIT_MASK(15)
+#define CAL_CSI2_COMPLEXIO_CFG_DATA4_POSITION_MASK     GENMASK(18, 16)
+#define CAL_CSI2_COMPLEXIO_CFG_DATA4_POL_MASK          BIT_MASK(19)
+#define CAL_CSI2_COMPLEXIO_CFG_PWR_AUTO_MASK           BIT_MASK(24)
+#define CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_MASK         GENMASK(26, 25)
+#define CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_STATE_OFF            0
+#define CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_STATE_ON             1
+#define CAL_CSI2_COMPLEXIO_CFG_PWR_STATUS_STATE_ULP            2
+#define CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_MASK            GENMASK(28, 27)
+#define CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_STATE_OFF               0
+#define CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_STATE_ON                        1
+#define CAL_CSI2_COMPLEXIO_CFG_PWR_CMD_STATE_ULP               2
+#define CAL_CSI2_COMPLEXIO_CFG_RESET_DONE_MASK         BIT_MASK(29)
+#define CAL_CSI2_COMPLEXIO_CFG_RESET_DONE_RESETCOMPLETED       1
+#define CAL_CSI2_COMPLEXIO_CFG_RESET_DONE_RESETONGOING         0
+#define CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL_MASK         BIT_MASK(30)
+#define CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL                      0
+#define CAL_CSI2_COMPLEXIO_CFG_RESET_CTRL_OPERATIONAL          1
+
+#define CAL_CSI2_SHORT_PACKET_MASK     GENMASK(23, 0)
+
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTHS1_MASK          BIT_MASK(0)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTHS2_MASK          BIT_MASK(1)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTHS3_MASK          BIT_MASK(2)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTHS4_MASK          BIT_MASK(3)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTHS5_MASK          BIT_MASK(4)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS1_MASK      BIT_MASK(5)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS2_MASK      BIT_MASK(6)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS3_MASK      BIT_MASK(7)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS4_MASK      BIT_MASK(8)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRSOTSYNCHS5_MASK      BIT_MASK(9)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRESC1_MASK            BIT_MASK(10)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRESC2_MASK            BIT_MASK(11)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRESC3_MASK            BIT_MASK(12)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRESC4_MASK            BIT_MASK(13)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRESC5_MASK            BIT_MASK(14)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL1_MASK                BIT_MASK(15)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL2_MASK                BIT_MASK(16)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL3_MASK                BIT_MASK(17)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL4_MASK                BIT_MASK(18)
+#define CAL_CSI2_COMPLEXIO_IRQ_ERRCONTROL5_MASK                BIT_MASK(19)
+#define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM1_MASK         BIT_MASK(20)
+#define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM2_MASK         BIT_MASK(21)
+#define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM3_MASK         BIT_MASK(22)
+#define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM4_MASK         BIT_MASK(23)
+#define CAL_CSI2_COMPLEXIO_IRQ_STATEULPM5_MASK         BIT_MASK(24)
+#define CAL_CSI2_COMPLEXIO_IRQ_STATEALLULPMENTER_MASK  BIT_MASK(25)
+#define CAL_CSI2_COMPLEXIO_IRQ_STATEALLULPMEXIT_MASK   BIT_MASK(26)
+#define CAL_CSI2_COMPLEXIO_IRQ_FIFO_OVR_MASK           BIT_MASK(27)
+#define CAL_CSI2_COMPLEXIO_IRQ_SHORT_PACKET_MASK       BIT_MASK(28)
+#define CAL_CSI2_COMPLEXIO_IRQ_ECC_NO_CORRECTION_MASK  BIT_MASK(30)
+
+#define CAL_CSI2_TIMING_STOP_STATE_COUNTER_IO1_MASK    GENMASK(12, 0)
+#define CAL_CSI2_TIMING_STOP_STATE_X4_IO1_MASK         BIT_MASK(13)
+#define CAL_CSI2_TIMING_STOP_STATE_X16_IO1_MASK                BIT_MASK(14)
+#define CAL_CSI2_TIMING_FORCE_RX_MODE_IO1_MASK         BIT_MASK(15)
+
+#define CAL_CSI2_VC_IRQ_FS_IRQ_0_MASK                  BIT_MASK(0)
+#define CAL_CSI2_VC_IRQ_FE_IRQ_0_MASK                  BIT_MASK(1)
+#define CAL_CSI2_VC_IRQ_LS_IRQ_0_MASK                  BIT_MASK(2)
+#define CAL_CSI2_VC_IRQ_LE_IRQ_0_MASK                  BIT_MASK(3)
+#define CAL_CSI2_VC_IRQ_CS_IRQ_0_MASK                  BIT_MASK(4)
+#define CAL_CSI2_VC_IRQ_ECC_CORRECTION0_IRQ_0_MASK     BIT_MASK(5)
+#define CAL_CSI2_VC_IRQ_FS_IRQ_1_MASK                  BIT_MASK(8)
+#define CAL_CSI2_VC_IRQ_FE_IRQ_1_MASK                  BIT_MASK(9)
+#define CAL_CSI2_VC_IRQ_LS_IRQ_1_MASK                  BIT_MASK(10)
+#define CAL_CSI2_VC_IRQ_LE_IRQ_1_MASK                  BIT_MASK(11)
+#define CAL_CSI2_VC_IRQ_CS_IRQ_1_MASK                  BIT_MASK(12)
+#define CAL_CSI2_VC_IRQ_ECC_CORRECTION0_IRQ_1_MASK     BIT_MASK(13)
+#define CAL_CSI2_VC_IRQ_FS_IRQ_2_MASK                  BIT_MASK(16)
+#define CAL_CSI2_VC_IRQ_FE_IRQ_2_MASK                  BIT_MASK(17)
+#define CAL_CSI2_VC_IRQ_LS_IRQ_2_MASK                  BIT_MASK(18)
+#define CAL_CSI2_VC_IRQ_LE_IRQ_2_MASK                  BIT_MASK(19)
+#define CAL_CSI2_VC_IRQ_CS_IRQ_2_MASK                  BIT_MASK(20)
+#define CAL_CSI2_VC_IRQ_ECC_CORRECTION0_IRQ_2_MASK     BIT_MASK(21)
+#define CAL_CSI2_VC_IRQ_FS_IRQ_3_MASK                  BIT_MASK(24)
+#define CAL_CSI2_VC_IRQ_FE_IRQ_3_MASK                  BIT_MASK(25)
+#define CAL_CSI2_VC_IRQ_LS_IRQ_3_MASK                  BIT_MASK(26)
+#define CAL_CSI2_VC_IRQ_LE_IRQ_3_MASK                  BIT_MASK(27)
+#define CAL_CSI2_VC_IRQ_CS_IRQ_3_MASK                  BIT_MASK(28)
+#define CAL_CSI2_VC_IRQ_ECC_CORRECTION0_IRQ_3_MASK     BIT_MASK(29)
+
+#define CAL_CSI2_CTX_DT_MASK           GENMASK(5, 0)
+#define CAL_CSI2_CTX_VC_MASK           GENMASK(7, 6)
+#define CAL_CSI2_CTX_CPORT_MASK                GENMASK(12, 8)
+#define CAL_CSI2_CTX_ATT_MASK          BIT_MASK(13)
+#define CAL_CSI2_CTX_ATT_PIX                   0
+#define CAL_CSI2_CTX_ATT                       1
+#define CAL_CSI2_CTX_PACK_MODE_MASK    BIT_MASK(14)
+#define CAL_CSI2_CTX_PACK_MODE_LINE            0
+#define CAL_CSI2_CTX_PACK_MODE_FRAME           1
+#define CAL_CSI2_CTX_LINES_MASK                GENMASK(29, 16)
+
+#define CAL_CSI2_STATUS_FRAME_MASK     GENMASK(15, 0)
+
+#define CAL_CSI2_PHY_REG0_THS_SETTLE_MASK      GENMASK(7, 0)
+#define CAL_CSI2_PHY_REG0_THS_TERM_MASK                GENMASK(15, 8)
+#define CAL_CSI2_PHY_REG0_HSCLOCKCONFIG_MASK   BIT_MASK(24)
+#define CAL_CSI2_PHY_REG0_HSCLOCKCONFIG_DISABLE                1
+#define CAL_CSI2_PHY_REG0_HSCLOCKCONFIG_ENABLE         0
+
+#define CAL_CSI2_PHY_REG1_TCLK_SETTLE_MASK                     GENMASK(7, 0)
+#define CAL_CSI2_PHY_REG1_CTRLCLK_DIV_FACTOR_MASK              GENMASK(9, 8)
+#define CAL_CSI2_PHY_REG1_DPHY_HS_SYNC_PATTERN_MASK            GENMASK(17, 10)
+#define CAL_CSI2_PHY_REG1_TCLK_TERM_MASK                       GENMASK(24, 18)
+#define CAL_CSI2_PHY_REG1_CLOCK_MISS_DETECTOR_STATUS_MASK      BIT_MASK(25)
+#define CAL_CSI2_PHY_REG1_CLOCK_MISS_DETECTOR_STATUS_ERROR             1
+#define CAL_CSI2_PHY_REG1_CLOCK_MISS_DETECTOR_STATUS_SUCCESS           0
+#define CAL_CSI2_PHY_REG1_RESET_DONE_STATUS_MASK               GENMASK(29, 28)
+
+#define CAL_CSI2_PHY_REG2_CCP2_SYNC_PATTERN_MASK               GENMASK(23, 0)
+#define CAL_CSI2_PHY_REG2_TRIGGER_CMD_RXTRIGESC3_MASK          GENMASK(25, 24)
+#define CAL_CSI2_PHY_REG2_TRIGGER_CMD_RXTRIGESC2_MASK          GENMASK(27, 26)
+#define CAL_CSI2_PHY_REG2_TRIGGER_CMD_RXTRIGESC1_MASK          GENMASK(29, 28)
+#define CAL_CSI2_PHY_REG2_TRIGGER_CMD_RXTRIGESC0_MASK          GENMASK(31, 30)
+
+#define CM_CAMERRX_CTRL_CSI1_CTRLCLKEN_MASK                    BIT_MASK(0)
+#define CM_CAMERRX_CTRL_CSI1_CAMMODE_MASK                      GENMASK(2, 1)
+#define CM_CAMERRX_CTRL_CSI1_LANEENABLE_MASK                   GENMASK(4, 3)
+#define CM_CAMERRX_CTRL_CSI1_MODE_MASK                         BIT_MASK(5)
+#define CM_CAMERRX_CTRL_CSI0_CTRLCLKEN_MASK                    BIT_MASK(10)
+#define CM_CAMERRX_CTRL_CSI0_CAMMODE_MASK                      GENMASK(12, 11)
+#define CM_CAMERRX_CTRL_CSI0_LANEENABLE_MASK                   GENMASK(16, 13)
+#define CM_CAMERRX_CTRL_CSI0_MODE_MASK                         BIT_MASK(17)
+
+#endif
index 418113c..c4b5fab 100644 (file)
@@ -1074,7 +1074,7 @@ static int __init vim2m_init(void)
        if (ret)
                platform_device_unregister(&vim2m_pdev);
 
-       return 0;
+       return ret;
 }
 
 module_init(vim2m_init);
index e15eef6..bdc380b 100644 (file)
@@ -360,7 +360,7 @@ void vivid_fb_release_buffers(struct vivid_dev *dev)
 
        /* Release pseudo palette */
        kfree(dev->fb_info.pseudo_palette);
-       kfree((void *)dev->video_vbase);
+       kfree(dev->video_vbase);
 }
 
 /* Initialize the specified card */
index 9baed6a..93fbaee 100644 (file)
@@ -418,6 +418,8 @@ static inline void tpg_s_bytesperline(struct tpg_data *tpg, unsigned plane, unsi
 
                tpg->bytesperline[p] = plane_w / tpg->hdownsampling[p];
        }
+       if (tpg_g_interleaved(tpg))
+               tpg->bytesperline[1] = tpg->bytesperline[0];
 }
 
 
index 6a93f92..95b3ac2 100644 (file)
@@ -1,4 +1,5 @@
-vsp1-y                                 := vsp1_drv.o vsp1_entity.o vsp1_video.o
+vsp1-y                                 := vsp1_drv.o vsp1_entity.o vsp1_pipe.o
+vsp1-y                                 += vsp1_dl.o vsp1_drm.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_bru.o vsp1_sru.o vsp1_uds.o
index 989e96f..910d6b8 100644 (file)
@@ -26,6 +26,9 @@
 struct clk;
 struct device;
 
+struct vsp1_dl;
+struct vsp1_drm;
+struct vsp1_entity;
 struct vsp1_platform_data;
 struct vsp1_bru;
 struct vsp1_hsit;
@@ -42,17 +45,21 @@ struct vsp1_uds;
 #define VSP1_HAS_LIF           (1 << 0)
 #define VSP1_HAS_LUT           (1 << 1)
 #define VSP1_HAS_SRU           (1 << 2)
+#define VSP1_HAS_BRU           (1 << 3)
 
-struct vsp1_platform_data {
+struct vsp1_device_info {
+       u32 version;
        unsigned int features;
        unsigned int rpf_count;
        unsigned int uds_count;
        unsigned int wpf_count;
+       unsigned int num_bru_inputs;
+       bool uapi;
 };
 
 struct vsp1_device {
        struct device *dev;
-       struct vsp1_platform_data pdata;
+       const struct vsp1_device_info *info;
 
        void __iomem *mmio;
        struct clk *clock;
@@ -71,14 +78,22 @@ struct vsp1_device {
        struct vsp1_rwpf *wpf[VSP1_MAX_WPF];
 
        struct list_head entities;
+       struct list_head videos;
 
        struct v4l2_device v4l2_dev;
        struct media_device media_dev;
+       struct media_entity_operations media_ops;
+
+       struct vsp1_drm *drm;
+
+       bool use_dl;
 };
 
 int vsp1_device_get(struct vsp1_device *vsp1);
 void vsp1_device_put(struct vsp1_device *vsp1);
 
+int vsp1_reset_wpf(struct vsp1_device *vsp1, unsigned int index);
+
 static inline u32 vsp1_read(struct vsp1_device *vsp1, u32 reg)
 {
        return ioread32(vsp1->mmio + reg);
@@ -89,4 +104,14 @@ static inline void vsp1_write(struct vsp1_device *vsp1, u32 reg, u32 data)
        iowrite32(data, vsp1->mmio + reg);
 }
 
+#include "vsp1_dl.h"
+
+static inline void vsp1_mod_write(struct vsp1_entity *e, u32 reg, u32 data)
+{
+       if (e->vsp1->use_dl)
+               vsp1_dl_add(e, reg, data);
+       else
+               vsp1_write(e->vsp1, reg, data);
+}
+
 #endif /* __VSP1_H__ */
index 7dd7633..cb0dbc1 100644 (file)
@@ -19,6 +19,7 @@
 #include "vsp1.h"
 #include "vsp1_bru.h"
 #include "vsp1_rwpf.h"
+#include "vsp1_video.h"
 
 #define BRU_MIN_SIZE                           1U
 #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);
+       vsp1_mod_write(&bru->entity, reg, data);
 }
 
 /* -----------------------------------------------------------------------------
@@ -83,7 +79,7 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
        if (!enable)
                return 0;
 
-       format = &bru->entity.formats[BRU_PAD_SOURCE];
+       format = &bru->entity.formats[bru->entity.source_pad];
 
        /* 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
@@ -94,7 +90,7 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
        /* 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;
+       flags = pipe->output ? pipe->output->format.flags : 0;
        vsp1_bru_write(bru, VI6_BRU_INCTRL,
                       flags & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA ?
                       0 : VI6_BRU_INCTRL_NRM);
@@ -113,7 +109,7 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
                       VI6_BRU_ROP_CROP(VI6_ROP_NOP) |
                       VI6_BRU_ROP_AROP(VI6_ROP_NOP));
 
-       for (i = 0; i < 4; ++i) {
+       for (i = 0; i < bru->entity.source_pad; ++i) {
                bool premultiplied = false;
                u32 ctrl = 0;
 
@@ -125,7 +121,7 @@ static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
                if (bru->inputs[i].rpf) {
                        ctrl |= VI6_BRU_CTRL_RBC;
 
-                       premultiplied = bru->inputs[i].rpf->video.format.flags
+                       premultiplied = bru->inputs[i].rpf->format.flags
                                      & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA;
                } else {
                        ctrl |= VI6_BRU_CTRL_CROP(VI6_ROP_NOP)
@@ -295,7 +291,7 @@ static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_con
        *format = fmt->format;
 
        /* Reset the compose rectangle */
-       if (fmt->pad != BRU_PAD_SOURCE) {
+       if (fmt->pad != bru->entity.source_pad) {
                struct v4l2_rect *compose;
 
                compose = bru_get_compose(bru, cfg, fmt->pad, fmt->which);
@@ -309,7 +305,7 @@ static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_con
        if (fmt->pad == BRU_PAD_SINK(0)) {
                unsigned int i;
 
-               for (i = 0; i <= BRU_PAD_SOURCE; ++i) {
+               for (i = 0; i <= bru->entity.source_pad; ++i) {
                        format = vsp1_entity_get_pad_format(&bru->entity, cfg,
                                                            i, fmt->which);
                        format->code = fmt->format.code;
@@ -325,7 +321,7 @@ static int bru_get_selection(struct v4l2_subdev *subdev,
 {
        struct vsp1_bru *bru = to_bru(subdev);
 
-       if (sel->pad == BRU_PAD_SOURCE)
+       if (sel->pad == bru->entity.source_pad)
                return -EINVAL;
 
        switch (sel->target) {
@@ -353,7 +349,7 @@ static int bru_set_selection(struct v4l2_subdev *subdev,
        struct v4l2_mbus_framefmt *format;
        struct v4l2_rect *compose;
 
-       if (sel->pad == BRU_PAD_SOURCE)
+       if (sel->pad == bru->entity.source_pad)
                return -EINVAL;
 
        if (sel->target != V4L2_SEL_TGT_COMPOSE)
@@ -362,8 +358,8 @@ static int bru_set_selection(struct v4l2_subdev *subdev,
        /* The compose rectangle top left corner must be inside the output
         * frame.
         */
-       format = vsp1_entity_get_pad_format(&bru->entity, cfg, BRU_PAD_SOURCE,
-                                           sel->which);
+       format = vsp1_entity_get_pad_format(&bru->entity, cfg,
+                                           bru->entity.source_pad, 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);
 
@@ -419,7 +415,8 @@ struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1)
 
        bru->entity.type = VSP1_ENTITY_BRU;
 
-       ret = vsp1_entity_init(vsp1, &bru->entity, 5);
+       ret = vsp1_entity_init(vsp1, &bru->entity,
+                              vsp1->info->num_bru_inputs + 1);
        if (ret < 0)
                return ERR_PTR(ret);
 
@@ -427,7 +424,7 @@ struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1)
        subdev = &bru->entity.subdev;
        v4l2_subdev_init(subdev, &bru_ops);
 
-       subdev->entity.ops = &vsp1_media_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));
index 16b1c65..dbac968 100644 (file)
@@ -23,7 +23,6 @@ struct vsp1_device;
 struct vsp1_rwpf;
 
 #define BRU_PAD_SINK(n)                                (n)
-#define BRU_PAD_SOURCE                         4
 
 struct vsp1_bru {
        struct vsp1_entity entity;
@@ -33,7 +32,7 @@ struct vsp1_bru {
        struct {
                struct vsp1_rwpf *rpf;
                struct v4l2_rect compose;
-       } inputs[4];
+       } inputs[VSP1_MAX_RPF];
 };
 
 static inline struct vsp1_bru *to_bru(struct v4l2_subdev *subdev)
diff --git a/drivers/media/platform/vsp1/vsp1_dl.c b/drivers/media/platform/vsp1/vsp1_dl.c
new file mode 100644 (file)
index 0000000..7dc27ac
--- /dev/null
@@ -0,0 +1,305 @@
+/*
+ * vsp1_dl.h  --  R-Car VSP1 Display List
+ *
+ * Copyright (C) 2015 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/dma-mapping.h>
+#include <linux/gfp.h>
+#include <linux/slab.h>
+
+#include "vsp1.h"
+#include "vsp1_dl.h"
+#include "vsp1_pipe.h"
+
+/*
+ * Global resources
+ *
+ * - Display-related interrupts (can be used for vblank evasion ?)
+ * - Display-list enable
+ * - Header-less for WPF0
+ * - DL swap
+ */
+
+#define VSP1_DL_BODY_SIZE              (2 * 4 * 256)
+#define VSP1_DL_NUM_LISTS              3
+
+struct vsp1_dl_entry {
+       u32 addr;
+       u32 data;
+} __attribute__((__packed__));
+
+struct vsp1_dl_list {
+       size_t size;
+       int reg_count;
+
+       bool in_use;
+
+       struct vsp1_dl_entry *body;
+       dma_addr_t dma;
+};
+
+/**
+ * struct vsp1_dl - Display List manager
+ * @vsp1: the VSP1 device
+ * @lock: protects the active, queued and pending lists
+ * @lists.all: array of all allocate display lists
+ * @lists.active: list currently being processed (loaded) by hardware
+ * @lists.queued: list queued to the hardware (written to the DL registers)
+ * @lists.pending: list waiting to be queued to the hardware
+ * @lists.write: list being written to by software
+ */
+struct vsp1_dl {
+       struct vsp1_device *vsp1;
+
+       spinlock_t lock;
+
+       size_t size;
+       dma_addr_t dma;
+       void *mem;
+
+       struct {
+               struct vsp1_dl_list all[VSP1_DL_NUM_LISTS];
+
+               struct vsp1_dl_list *active;
+               struct vsp1_dl_list *queued;
+               struct vsp1_dl_list *pending;
+               struct vsp1_dl_list *write;
+       } lists;
+};
+
+/* -----------------------------------------------------------------------------
+ * Display List Transaction Management
+ */
+
+static void vsp1_dl_free_list(struct vsp1_dl_list *list)
+{
+       if (!list)
+               return;
+
+       list->in_use = false;
+}
+
+void vsp1_dl_reset(struct vsp1_dl *dl)
+{
+       unsigned int i;
+
+       dl->lists.active = NULL;
+       dl->lists.queued = NULL;
+       dl->lists.pending = NULL;
+       dl->lists.write = NULL;
+
+       for (i = 0; i < ARRAY_SIZE(dl->lists.all); ++i)
+               dl->lists.all[i].in_use = false;
+}
+
+void vsp1_dl_begin(struct vsp1_dl *dl)
+{
+       struct vsp1_dl_list *list = NULL;
+       unsigned long flags;
+       unsigned int i;
+
+       spin_lock_irqsave(&dl->lock, flags);
+
+       for (i = 0; i < ARRAY_SIZE(dl->lists.all); ++i) {
+               if (!dl->lists.all[i].in_use) {
+                       list = &dl->lists.all[i];
+                       break;
+               }
+       }
+
+       if (!list) {
+               list = dl->lists.pending;
+               dl->lists.pending = NULL;
+       }
+
+       spin_unlock_irqrestore(&dl->lock, flags);
+
+       dl->lists.write = list;
+
+       list->in_use = true;
+       list->reg_count = 0;
+}
+
+void vsp1_dl_add(struct vsp1_entity *e, u32 reg, u32 data)
+{
+       struct vsp1_pipeline *pipe = to_vsp1_pipeline(&e->subdev.entity);
+       struct vsp1_dl *dl = pipe->dl;
+       struct vsp1_dl_list *list = dl->lists.write;
+
+       list->body[list->reg_count].addr = reg;
+       list->body[list->reg_count].data = data;
+       list->reg_count++;
+}
+
+void vsp1_dl_commit(struct vsp1_dl *dl)
+{
+       struct vsp1_device *vsp1 = dl->vsp1;
+       struct vsp1_dl_list *list;
+       unsigned long flags;
+       bool update;
+
+       list = dl->lists.write;
+       dl->lists.write = NULL;
+
+       spin_lock_irqsave(&dl->lock, flags);
+
+       /* Once the UPD bit has been set the hardware can start processing the
+        * display list at any time and we can't touch the address and size
+        * registers. In that case mark the update as pending, it will be
+        * queued up to the hardware by the frame end interrupt handler.
+        */
+       update = !!(vsp1_read(vsp1, VI6_DL_BODY_SIZE) & VI6_DL_BODY_SIZE_UPD);
+       if (update) {
+               vsp1_dl_free_list(dl->lists.pending);
+               dl->lists.pending = list;
+               goto done;
+       }
+
+       /* Program the hardware with the display list body address and size.
+        * The UPD bit will be cleared by the device when the display list is
+        * processed.
+        */
+       vsp1_write(vsp1, VI6_DL_HDR_ADDR(0), list->dma);
+       vsp1_write(vsp1, VI6_DL_BODY_SIZE, VI6_DL_BODY_SIZE_UPD |
+                  (list->reg_count * 8));
+
+       vsp1_dl_free_list(dl->lists.queued);
+       dl->lists.queued = list;
+
+done:
+       spin_unlock_irqrestore(&dl->lock, flags);
+}
+
+/* -----------------------------------------------------------------------------
+ * Interrupt Handling
+ */
+
+void vsp1_dl_irq_display_start(struct vsp1_dl *dl)
+{
+       spin_lock(&dl->lock);
+
+       /* The display start interrupt signals the end of the display list
+        * processing by the device. The active display list, if any, won't be
+        * accessed anymore and can be reused.
+        */
+       if (dl->lists.active) {
+               vsp1_dl_free_list(dl->lists.active);
+               dl->lists.active = NULL;
+       }
+
+       spin_unlock(&dl->lock);
+}
+
+void vsp1_dl_irq_frame_end(struct vsp1_dl *dl)
+{
+       struct vsp1_device *vsp1 = dl->vsp1;
+
+       spin_lock(&dl->lock);
+
+       /* The UPD bit set indicates that the commit operation raced with the
+        * interrupt and occurred after the frame end event and UPD clear but
+        * before interrupt processing. The hardware hasn't taken the update
+        * into account yet, we'll thus skip one frame and retry.
+        */
+       if (vsp1_read(vsp1, VI6_DL_BODY_SIZE) & VI6_DL_BODY_SIZE_UPD)
+               goto done;
+
+       /* The device starts processing the queued display list right after the
+        * frame end interrupt. The display list thus becomes active.
+        */
+       if (dl->lists.queued) {
+               WARN_ON(dl->lists.active);
+               dl->lists.active = dl->lists.queued;
+               dl->lists.queued = NULL;
+       }
+
+       /* Now that the UPD bit has been cleared we can queue the next display
+        * list to the hardware if one has been prepared.
+        */
+       if (dl->lists.pending) {
+               struct vsp1_dl_list *list = dl->lists.pending;
+
+               vsp1_write(vsp1, VI6_DL_HDR_ADDR(0), list->dma);
+               vsp1_write(vsp1, VI6_DL_BODY_SIZE, VI6_DL_BODY_SIZE_UPD |
+                          (list->reg_count * 8));
+
+               dl->lists.queued = list;
+               dl->lists.pending = NULL;
+       }
+
+done:
+       spin_unlock(&dl->lock);
+}
+
+/* -----------------------------------------------------------------------------
+ * Hardware Setup
+ */
+
+void vsp1_dl_setup(struct vsp1_device *vsp1)
+{
+       u32 ctrl = (256 << VI6_DL_CTRL_AR_WAIT_SHIFT)
+                | VI6_DL_CTRL_DC2 | VI6_DL_CTRL_DC1 | VI6_DL_CTRL_DC0
+                | VI6_DL_CTRL_DLE;
+
+       /* The DRM pipeline operates with header-less display lists in
+        * Continuous Frame Mode.
+        */
+       if (vsp1->drm)
+               ctrl |= VI6_DL_CTRL_CFM0 | VI6_DL_CTRL_NH0;
+
+       vsp1_write(vsp1, VI6_DL_CTRL, ctrl);
+       vsp1_write(vsp1, VI6_DL_SWAP, VI6_DL_SWAP_LWS);
+}
+
+/* -----------------------------------------------------------------------------
+ * Initialization and Cleanup
+ */
+
+struct vsp1_dl *vsp1_dl_create(struct vsp1_device *vsp1)
+{
+       struct vsp1_dl *dl;
+       unsigned int i;
+
+       dl = kzalloc(sizeof(*dl), GFP_KERNEL);
+       if (!dl)
+               return NULL;
+
+       spin_lock_init(&dl->lock);
+
+       dl->vsp1 = vsp1;
+       dl->size = VSP1_DL_BODY_SIZE * ARRAY_SIZE(dl->lists.all);
+
+       dl->mem = dma_alloc_writecombine(vsp1->dev, dl->size, &dl->dma,
+                                        GFP_KERNEL);
+       if (!dl->mem) {
+               kfree(dl);
+               return NULL;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(dl->lists.all); ++i) {
+               struct vsp1_dl_list *list = &dl->lists.all[i];
+
+               list->size = VSP1_DL_BODY_SIZE;
+               list->reg_count = 0;
+               list->in_use = false;
+               list->dma = dl->dma + VSP1_DL_BODY_SIZE * i;
+               list->body = dl->mem + VSP1_DL_BODY_SIZE * i;
+       }
+
+       return dl;
+}
+
+void vsp1_dl_destroy(struct vsp1_dl *dl)
+{
+       dma_free_writecombine(dl->vsp1->dev, dl->size, dl->mem, dl->dma);
+       kfree(dl);
+}
diff --git a/drivers/media/platform/vsp1/vsp1_dl.h b/drivers/media/platform/vsp1/vsp1_dl.h
new file mode 100644 (file)
index 0000000..448c425
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * vsp1_dl.h  --  R-Car VSP1 Display List
+ *
+ * Copyright (C) 2015 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_DL_H__
+#define __VSP1_DL_H__
+
+#include "vsp1_entity.h"
+
+struct vsp1_device;
+struct vsp1_dl;
+
+struct vsp1_dl *vsp1_dl_create(struct vsp1_device *vsp1);
+void vsp1_dl_destroy(struct vsp1_dl *dl);
+
+void vsp1_dl_setup(struct vsp1_device *vsp1);
+
+void vsp1_dl_reset(struct vsp1_dl *dl);
+void vsp1_dl_begin(struct vsp1_dl *dl);
+void vsp1_dl_add(struct vsp1_entity *e, u32 reg, u32 data);
+void vsp1_dl_commit(struct vsp1_dl *dl);
+
+void vsp1_dl_irq_display_start(struct vsp1_dl *dl);
+void vsp1_dl_irq_frame_end(struct vsp1_dl *dl);
+
+static inline void vsp1_dl_mod_write(struct vsp1_entity *e, u32 reg, u32 data)
+{
+       if (e->vsp1->use_dl)
+               vsp1_dl_add(e, reg, data);
+       else
+               vsp1_write(e->vsp1, reg, data);
+}
+
+#endif /* __VSP1_DL_H__ */
diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
new file mode 100644 (file)
index 0000000..021fe57
--- /dev/null
@@ -0,0 +1,597 @@
+/*
+ * vsp1_drm.c  --  R-Car VSP1 DRM API
+ *
+ * Copyright (C) 2015 Renesas Electronics 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/slab.h>
+#include <linux/vsp1.h>
+
+#include <media/media-entity.h>
+#include <media/v4l2-subdev.h>
+
+#include "vsp1.h"
+#include "vsp1_bru.h"
+#include "vsp1_dl.h"
+#include "vsp1_drm.h"
+#include "vsp1_lif.h"
+#include "vsp1_pipe.h"
+#include "vsp1_rwpf.h"
+
+/* -----------------------------------------------------------------------------
+ * Runtime Handling
+ */
+
+static void vsp1_drm_pipeline_frame_end(struct vsp1_pipeline *pipe)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&pipe->irqlock, flags);
+       if (pipe->num_inputs)
+               vsp1_pipeline_run(pipe);
+       spin_unlock_irqrestore(&pipe->irqlock, flags);
+}
+
+/* -----------------------------------------------------------------------------
+ * DU Driver API
+ */
+
+int vsp1_du_init(struct device *dev)
+{
+       struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+
+       if (!vsp1)
+               return -EPROBE_DEFER;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(vsp1_du_init);
+
+/**
+ * vsp1_du_setup_lif - Setup the output part of the VSP pipeline
+ * @dev: the VSP device
+ * @width: output frame width in pixels
+ * @height: output frame height in pixels
+ *
+ * Configure the output part of VSP DRM pipeline for the given frame @width and
+ * @height. This sets up formats on the BRU source pad, the WPF0 sink and source
+ * pads, and the LIF sink pad.
+ *
+ * As the media bus code on the BRU source pad is conditioned by the
+ * configuration of the BRU sink 0 pad, we also set up the formats on all BRU
+ * sinks, even if the configuration will be overwritten later by
+ * vsp1_du_setup_rpf(). This ensures that the BRU configuration is set to a well
+ * defined state.
+ *
+ * Return 0 on success or a negative error code on failure.
+ */
+int vsp1_du_setup_lif(struct device *dev, unsigned int width,
+                     unsigned int height)
+{
+       struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+       struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
+       struct vsp1_bru *bru = vsp1->bru;
+       struct v4l2_subdev_format format;
+       unsigned int i;
+       int ret;
+
+       dev_dbg(vsp1->dev, "%s: configuring LIF with format %ux%u\n",
+               __func__, width, height);
+
+       if (width == 0 || height == 0) {
+               /* Zero width or height means the CRTC is being disabled, stop
+                * the pipeline and turn the light off.
+                */
+               ret = vsp1_pipeline_stop(pipe);
+               if (ret == -ETIMEDOUT)
+                       dev_err(vsp1->dev, "DRM pipeline stop timeout\n");
+
+               media_entity_pipeline_stop(&pipe->output->entity.subdev.entity);
+
+               for (i = 0; i < bru->entity.source_pad; ++i) {
+                       bru->inputs[i].rpf = NULL;
+                       pipe->inputs[i] = NULL;
+               }
+
+               pipe->num_inputs = 0;
+
+               vsp1_device_put(vsp1);
+
+               dev_dbg(vsp1->dev, "%s: pipeline disabled\n", __func__);
+
+               return 0;
+       }
+
+       vsp1_dl_reset(vsp1->drm->dl);
+
+       /* Configure the format at the BRU sinks and propagate it through the
+        * pipeline.
+        */
+       memset(&format, 0, sizeof(format));
+       format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+
+       for (i = 0; i < bru->entity.source_pad; ++i) {
+               format.pad = i;
+
+               format.format.width = width;
+               format.format.height = height;
+               format.format.code = MEDIA_BUS_FMT_ARGB8888_1X32;
+               format.format.field = V4L2_FIELD_NONE;
+
+               ret = v4l2_subdev_call(&bru->entity.subdev, pad,
+                                      set_fmt, NULL, &format);
+               if (ret < 0)
+                       return ret;
+
+               dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on BRU pad %u\n",
+                       __func__, format.format.width, format.format.height,
+                       format.format.code, i);
+       }
+
+       format.pad = bru->entity.source_pad;
+       format.format.width = width;
+       format.format.height = height;
+       format.format.code = MEDIA_BUS_FMT_ARGB8888_1X32;
+       format.format.field = V4L2_FIELD_NONE;
+
+       ret = v4l2_subdev_call(&bru->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on BRU pad %u\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code, i);
+
+       format.pad = RWPF_PAD_SINK;
+       ret = v4l2_subdev_call(&vsp1->wpf[0]->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on WPF0 sink\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code);
+
+       format.pad = RWPF_PAD_SOURCE;
+       ret = v4l2_subdev_call(&vsp1->wpf[0]->entity.subdev, pad, get_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev, "%s: got format %ux%u (%x) on WPF0 source\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code);
+
+       format.pad = LIF_PAD_SINK;
+       ret = v4l2_subdev_call(&vsp1->lif->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on LIF sink\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code);
+
+       /* Verify that the format at the output of the pipeline matches the
+        * requested frame size and media bus code.
+        */
+       if (format.format.width != width || format.format.height != height ||
+           format.format.code != MEDIA_BUS_FMT_ARGB8888_1X32) {
+               dev_dbg(vsp1->dev, "%s: format mismatch\n", __func__);
+               return -EPIPE;
+       }
+
+       /* Mark the pipeline as streaming and enable the VSP1. This will store
+        * the pipeline pointer in all entities, which the s_stream handlers
+        * will need. We don't start the entities themselves right at this point
+        * as there's no plane configured yet, so we can't start processing
+        * buffers.
+        */
+       ret = vsp1_device_get(vsp1);
+       if (ret < 0)
+               return ret;
+
+       ret = media_entity_pipeline_start(&pipe->output->entity.subdev.entity,
+                                         &pipe->pipe);
+       if (ret < 0) {
+               dev_dbg(vsp1->dev, "%s: pipeline start failed\n", __func__);
+               vsp1_device_put(vsp1);
+               return ret;
+       }
+
+       dev_dbg(vsp1->dev, "%s: pipeline enabled\n", __func__);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(vsp1_du_setup_lif);
+
+/**
+ * vsp1_du_atomic_begin - Prepare for an atomic update
+ * @dev: the VSP device
+ */
+void vsp1_du_atomic_begin(struct device *dev)
+{
+       struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+       struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
+       unsigned long flags;
+
+       spin_lock_irqsave(&pipe->irqlock, flags);
+
+       vsp1->drm->num_inputs = pipe->num_inputs;
+
+       spin_unlock_irqrestore(&pipe->irqlock, flags);
+
+       /* Prepare the display list. */
+       vsp1_dl_begin(vsp1->drm->dl);
+}
+EXPORT_SYMBOL_GPL(vsp1_du_atomic_begin);
+
+/**
+ * vsp1_du_atomic_update - Setup one RPF input of the VSP pipeline
+ * @dev: the VSP device
+ * @rpf_index: index of the RPF to setup (0-based)
+ * @pixelformat: V4L2 pixel format for the RPF memory input
+ * @pitch: number of bytes per line in the image stored in memory
+ * @mem: DMA addresses of the memory buffers (one per plane)
+ * @src: the source crop rectangle for the RPF
+ * @dst: the destination compose rectangle for the BRU input
+ *
+ * Configure the VSP to perform composition of the image referenced by @mem
+ * through RPF @rpf_index, using the @src crop rectangle and the @dst
+ * composition rectangle. The Z-order is fixed with RPF 0 at the bottom.
+ *
+ * Image format as stored in memory is expressed as a V4L2 @pixelformat value.
+ * As a special case, setting the pixel format to 0 will disable the RPF. The
+ * @pitch, @mem, @src and @dst parameters are ignored in that case. Calling the
+ * function on a disabled RPF is allowed.
+ *
+ * The memory pitch is configurable to allow for padding at end of lines, or
+ * simple for images that extend beyond the crop rectangle boundaries. The
+ * @pitch value is expressed in bytes and applies to all planes for multiplanar
+ * formats.
+ *
+ * The source memory buffer is referenced by the DMA address of its planes in
+ * the @mem array. Up to two planes are supported. The second plane DMA address
+ * is ignored for formats using a single plane.
+ *
+ * This function isn't reentrant, the caller needs to serialize calls.
+ *
+ * TODO: Implement Z-order control by decoupling the RPF index from the BRU
+ * input index.
+ *
+ * Return 0 on success or a negative error code on failure.
+ */
+int vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
+                         u32 pixelformat, unsigned int pitch,
+                         dma_addr_t mem[2], const struct v4l2_rect *src,
+                         const struct v4l2_rect *dst)
+{
+       struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+       struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
+       const struct vsp1_format_info *fmtinfo;
+       struct v4l2_subdev_selection sel;
+       struct v4l2_subdev_format format;
+       struct vsp1_rwpf_memory memory;
+       struct vsp1_rwpf *rpf;
+       unsigned long flags;
+       int ret;
+
+       if (rpf_index >= vsp1->info->rpf_count)
+               return -EINVAL;
+
+       rpf = vsp1->rpf[rpf_index];
+
+       if (pixelformat == 0) {
+               dev_dbg(vsp1->dev, "%s: RPF%u: disable requested\n", __func__,
+                       rpf_index);
+
+               spin_lock_irqsave(&pipe->irqlock, flags);
+
+               if (pipe->inputs[rpf_index]) {
+                       /* Remove the RPF from the pipeline if it was previously
+                        * enabled.
+                        */
+                       vsp1->bru->inputs[rpf_index].rpf = NULL;
+                       pipe->inputs[rpf_index] = NULL;
+
+                       pipe->num_inputs--;
+               }
+
+               spin_unlock_irqrestore(&pipe->irqlock, flags);
+
+               return 0;
+       }
+
+       dev_dbg(vsp1->dev,
+               "%s: RPF%u: (%u,%u)/%ux%u -> (%u,%u)/%ux%u (%08x), pitch %u dma { %pad, %pad }\n",
+               __func__, rpf_index,
+               src->left, src->top, src->width, src->height,
+               dst->left, dst->top, dst->width, dst->height,
+               pixelformat, pitch, &mem[0], &mem[1]);
+
+       /* Set the stride at the RPF input. */
+       fmtinfo = vsp1_get_format_info(pixelformat);
+       if (!fmtinfo) {
+               dev_dbg(vsp1->dev, "Unsupport pixel format %08x for RPF\n",
+                       pixelformat);
+               return -EINVAL;
+       }
+
+       rpf->fmtinfo = fmtinfo;
+       rpf->format.num_planes = fmtinfo->planes;
+       rpf->format.plane_fmt[0].bytesperline = pitch;
+       rpf->format.plane_fmt[1].bytesperline = pitch;
+
+       /* Configure the format on the RPF sink pad and propagate it up to the
+        * BRU sink pad.
+        */
+       memset(&format, 0, sizeof(format));
+       format.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+       format.pad = RWPF_PAD_SINK;
+       format.format.width = src->width + src->left;
+       format.format.height = src->height + src->top;
+       format.format.code = fmtinfo->mbus;
+       format.format.field = V4L2_FIELD_NONE;
+
+       ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev,
+               "%s: set format %ux%u (%x) on RPF%u sink\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code, rpf->entity.index);
+
+       memset(&sel, 0, sizeof(sel));
+       sel.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+       sel.pad = RWPF_PAD_SINK;
+       sel.target = V4L2_SEL_TGT_CROP;
+       sel.r = *src;
+
+       ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_selection, NULL,
+                              &sel);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev,
+               "%s: set selection (%u,%u)/%ux%u on RPF%u sink\n",
+               __func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height,
+               rpf->entity.index);
+
+       /* RPF source, hardcode the format to ARGB8888 to turn on format
+        * conversion if needed.
+        */
+       format.pad = RWPF_PAD_SOURCE;
+
+       ret = v4l2_subdev_call(&rpf->entity.subdev, pad, get_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev,
+               "%s: got format %ux%u (%x) on RPF%u source\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code, rpf->entity.index);
+
+       format.format.code = MEDIA_BUS_FMT_ARGB8888_1X32;
+
+       ret = v4l2_subdev_call(&rpf->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       /* BRU sink, propagate the format from the RPF source. */
+       format.pad = rpf->entity.index;
+
+       ret = v4l2_subdev_call(&vsp1->bru->entity.subdev, pad, set_fmt, NULL,
+                              &format);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on BRU pad %u\n",
+               __func__, format.format.width, format.format.height,
+               format.format.code, format.pad);
+
+       sel.pad = rpf->entity.index;
+       sel.target = V4L2_SEL_TGT_COMPOSE;
+       sel.r = *dst;
+
+       ret = v4l2_subdev_call(&vsp1->bru->entity.subdev, pad, set_selection,
+                              NULL, &sel);
+       if (ret < 0)
+               return ret;
+
+       dev_dbg(vsp1->dev,
+               "%s: set selection (%u,%u)/%ux%u on BRU pad %u\n",
+               __func__, sel.r.left, sel.r.top, sel.r.width, sel.r.height,
+               sel.pad);
+
+       /* Store the compose rectangle coordinates in the RPF. */
+       rpf->location.left = dst->left;
+       rpf->location.top = dst->top;
+
+       /* Set the memory buffer address. */
+       memory.num_planes = fmtinfo->planes;
+       memory.addr[0] = mem[0];
+       memory.addr[1] = mem[1];
+
+       rpf->ops->set_memory(rpf, &memory);
+
+       spin_lock_irqsave(&pipe->irqlock, flags);
+
+       /* If the RPF was previously stopped set the BRU input to the RPF and
+        * store the RPF in the pipeline inputs array.
+        */
+       if (!pipe->inputs[rpf->entity.index]) {
+               vsp1->bru->inputs[rpf_index].rpf = rpf;
+               pipe->inputs[rpf->entity.index] = rpf;
+               pipe->num_inputs++;
+       }
+
+       spin_unlock_irqrestore(&pipe->irqlock, flags);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(vsp1_du_atomic_update);
+
+/**
+ * vsp1_du_atomic_flush - Commit an atomic update
+ * @dev: the VSP device
+ */
+void vsp1_du_atomic_flush(struct device *dev)
+{
+       struct vsp1_device *vsp1 = dev_get_drvdata(dev);
+       struct vsp1_pipeline *pipe = &vsp1->drm->pipe;
+       struct vsp1_entity *entity;
+       unsigned long flags;
+       bool stop = false;
+       int ret;
+
+       list_for_each_entry(entity, &pipe->entities, list_pipe) {
+               /* Disconnect unused RPFs from the pipeline. */
+               if (entity->type == VSP1_ENTITY_RPF) {
+                       struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev);
+
+                       if (!pipe->inputs[rpf->entity.index]) {
+                               vsp1_mod_write(entity, entity->route->reg,
+                                          VI6_DPR_NODE_UNUSED);
+                               continue;
+                       }
+               }
+
+               vsp1_entity_route_setup(entity);
+
+               ret = v4l2_subdev_call(&entity->subdev, video,
+                                      s_stream, 1);
+               if (ret < 0) {
+                       dev_err(vsp1->dev,
+                               "DRM pipeline start failure on entity %s\n",
+                               entity->subdev.name);
+                       return;
+               }
+       }
+
+       vsp1_dl_commit(vsp1->drm->dl);
+
+       spin_lock_irqsave(&pipe->irqlock, flags);
+
+       /* Start or stop the pipeline if needed. */
+       if (!vsp1->drm->num_inputs && pipe->num_inputs) {
+               vsp1_write(vsp1, VI6_DISP_IRQ_STA, 0);
+               vsp1_write(vsp1, VI6_DISP_IRQ_ENB, VI6_DISP_IRQ_ENB_DSTE);
+               vsp1_pipeline_run(pipe);
+       } else if (vsp1->drm->num_inputs && !pipe->num_inputs) {
+               stop = true;
+       }
+
+       spin_unlock_irqrestore(&pipe->irqlock, flags);
+
+       if (stop) {
+               vsp1_write(vsp1, VI6_DISP_IRQ_ENB, 0);
+               vsp1_pipeline_stop(pipe);
+       }
+}
+EXPORT_SYMBOL_GPL(vsp1_du_atomic_flush);
+
+/* -----------------------------------------------------------------------------
+ * Initialization
+ */
+
+int vsp1_drm_create_links(struct vsp1_device *vsp1)
+{
+       const u32 flags = MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE;
+       unsigned int i;
+       int ret;
+
+       /* VSPD instances require a BRU to perform composition and a LIF to
+        * output to the DU.
+        */
+       if (!vsp1->bru || !vsp1->lif)
+               return -ENXIO;
+
+       for (i = 0; i < vsp1->info->rpf_count; ++i) {
+               struct vsp1_rwpf *rpf = vsp1->rpf[i];
+
+               ret = media_create_pad_link(&rpf->entity.subdev.entity,
+                                           RWPF_PAD_SOURCE,
+                                           &vsp1->bru->entity.subdev.entity,
+                                           i, flags);
+               if (ret < 0)
+                       return ret;
+
+               rpf->entity.sink = &vsp1->bru->entity.subdev.entity;
+               rpf->entity.sink_pad = i;
+       }
+
+       ret = media_create_pad_link(&vsp1->bru->entity.subdev.entity,
+                                   vsp1->bru->entity.source_pad,
+                                   &vsp1->wpf[0]->entity.subdev.entity,
+                                   RWPF_PAD_SINK, flags);
+       if (ret < 0)
+               return ret;
+
+       vsp1->bru->entity.sink = &vsp1->wpf[0]->entity.subdev.entity;
+       vsp1->bru->entity.sink_pad = RWPF_PAD_SINK;
+
+       ret = media_create_pad_link(&vsp1->wpf[0]->entity.subdev.entity,
+                                   RWPF_PAD_SOURCE,
+                                   &vsp1->lif->entity.subdev.entity,
+                                   LIF_PAD_SINK, flags);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+int vsp1_drm_init(struct vsp1_device *vsp1)
+{
+       struct vsp1_pipeline *pipe;
+       unsigned int i;
+
+       vsp1->drm = devm_kzalloc(vsp1->dev, sizeof(*vsp1->drm), GFP_KERNEL);
+       if (!vsp1->drm)
+               return -ENOMEM;
+
+       vsp1->drm->dl = vsp1_dl_create(vsp1);
+       if (!vsp1->drm->dl)
+               return -ENOMEM;
+
+       pipe = &vsp1->drm->pipe;
+
+       vsp1_pipeline_init(pipe);
+       pipe->frame_end = vsp1_drm_pipeline_frame_end;
+
+       /* The DRM pipeline is static, add entities manually. */
+       for (i = 0; i < vsp1->info->rpf_count; ++i) {
+               struct vsp1_rwpf *input = vsp1->rpf[i];
+
+               list_add_tail(&input->entity.list_pipe, &pipe->entities);
+       }
+
+       list_add_tail(&vsp1->bru->entity.list_pipe, &pipe->entities);
+       list_add_tail(&vsp1->wpf[0]->entity.list_pipe, &pipe->entities);
+       list_add_tail(&vsp1->lif->entity.list_pipe, &pipe->entities);
+
+       pipe->bru = &vsp1->bru->entity;
+       pipe->lif = &vsp1->lif->entity;
+       pipe->output = vsp1->wpf[0];
+
+       pipe->dl = vsp1->drm->dl;
+
+       return 0;
+}
+
+void vsp1_drm_cleanup(struct vsp1_device *vsp1)
+{
+       vsp1_dl_destroy(vsp1->drm->dl);
+}
diff --git a/drivers/media/platform/vsp1/vsp1_drm.h b/drivers/media/platform/vsp1/vsp1_drm.h
new file mode 100644 (file)
index 0000000..f680568
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * vsp1_drm.h  --  R-Car VSP1 DRM/KMS Interface
+ *
+ * Copyright (C) 2015 Renesas Electronics 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_DRM_H__
+#define __VSP1_DRM_H__
+
+#include "vsp1_pipe.h"
+
+struct vsp1_dl;
+
+/**
+ * vsp1_drm - State for the API exposed to the DRM driver
+ * @dl: display list for DRM pipeline operation
+ * @pipe: the VSP1 pipeline used for display
+ * @num_inputs: number of active pipeline inputs at the beginning of an update
+ * @update: the pipeline configuration has been updated
+ */
+struct vsp1_drm {
+       struct vsp1_dl *dl;
+       struct vsp1_pipeline pipe;
+       unsigned int num_inputs;
+       bool update;
+};
+
+int vsp1_drm_init(struct vsp1_device *vsp1);
+void vsp1_drm_cleanup(struct vsp1_device *vsp1);
+int vsp1_drm_create_links(struct vsp1_device *vsp1);
+
+int vsp1_du_init(struct device *dev);
+int vsp1_du_setup_lif(struct device *dev, unsigned int width,
+                     unsigned int height);
+void vsp1_du_atomic_begin(struct device *dev);
+int vsp1_du_atomic_update(struct device *dev, unsigned int rpf_index,
+                         u32 pixelformat, unsigned int pitch,
+                         dma_addr_t mem[2], const struct v4l2_rect *src,
+                         const struct v4l2_rect *dst);
+void vsp1_du_atomic_flush(struct device *dev);
+
+
+#endif /* __VSP1_DRM_H__ */
index 533bc79..25750a0 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/videodev2.h>
 
+#include <media/v4l2-subdev.h>
+
 #include "vsp1.h"
 #include "vsp1_bru.h"
+#include "vsp1_dl.h"
+#include "vsp1_drm.h"
 #include "vsp1_hsit.h"
 #include "vsp1_lif.h"
 #include "vsp1_lut.h"
 #include "vsp1_rwpf.h"
 #include "vsp1_sru.h"
 #include "vsp1_uds.h"
+#include "vsp1_video.h"
 
 /* -----------------------------------------------------------------------------
  * Interrupt Handling
@@ -39,11 +45,11 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
        struct vsp1_device *vsp1 = data;
        irqreturn_t ret = IRQ_NONE;
        unsigned int i;
+       u32 status;
 
-       for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
+       for (i = 0; i < vsp1->info->wpf_count; ++i) {
                struct vsp1_rwpf *wpf = vsp1->wpf[i];
                struct vsp1_pipeline *pipe;
-               u32 status;
 
                if (wpf == NULL)
                        continue;
@@ -58,6 +64,21 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
                }
        }
 
+       status = vsp1_read(vsp1, VI6_DISP_IRQ_STA);
+       vsp1_write(vsp1, VI6_DISP_IRQ_STA, ~status & VI6_DISP_IRQ_STA_DST);
+
+       if (status & VI6_DISP_IRQ_STA_DST) {
+               struct vsp1_rwpf *wpf = vsp1->wpf[0];
+               struct vsp1_pipeline *pipe;
+
+               if (wpf) {
+                       pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
+                       vsp1_pipeline_display_start(pipe);
+               }
+
+               ret = IRQ_HANDLED;
+       }
+
        return ret;
 }
 
@@ -66,7 +87,7 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
  */
 
 /*
- * vsp1_create_links - Create links from all sources to the given sink
+ * vsp1_create_sink_links - Create links from all sources to the given sink
  *
  * This function creates media links from all valid sources to the given sink
  * pad. Links that would be invalid according to the VSP1 hardware capabilities
@@ -75,7 +96,8 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
  * - from a UDS to a UDS (UDS entities can't be chained)
  * - from an entity to itself (no loops are allowed)
  */
-static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)
+static int vsp1_create_sink_links(struct vsp1_device *vsp1,
+                                 struct vsp1_entity *sink)
 {
        struct media_entity *entity = &sink->subdev.entity;
        struct vsp1_entity *source;
@@ -115,19 +137,86 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)
        return 0;
 }
 
-static void vsp1_destroy_entities(struct vsp1_device *vsp1)
+static int vsp1_uapi_create_links(struct vsp1_device *vsp1)
 {
        struct vsp1_entity *entity;
-       struct vsp1_entity *next;
+       unsigned int i;
+       int ret;
+
+       list_for_each_entry(entity, &vsp1->entities, list_dev) {
+               if (entity->type == VSP1_ENTITY_LIF ||
+                   entity->type == VSP1_ENTITY_RPF)
+                       continue;
+
+               ret = vsp1_create_sink_links(vsp1, entity);
+               if (ret < 0)
+                       return ret;
+       }
+
+       if (vsp1->info->features & VSP1_HAS_LIF) {
+               ret = media_create_pad_link(&vsp1->wpf[0]->entity.subdev.entity,
+                                           RWPF_PAD_SOURCE,
+                                           &vsp1->lif->entity.subdev.entity,
+                                           LIF_PAD_SINK, 0);
+               if (ret < 0)
+                       return ret;
+       }
+
+       for (i = 0; i < vsp1->info->rpf_count; ++i) {
+               struct vsp1_rwpf *rpf = vsp1->rpf[i];
 
-       list_for_each_entry_safe(entity, next, &vsp1->entities, list_dev) {
+               ret = media_create_pad_link(&rpf->video->video.entity, 0,
+                                           &rpf->entity.subdev.entity,
+                                           RWPF_PAD_SINK,
+                                           MEDIA_LNK_FL_ENABLED |
+                                           MEDIA_LNK_FL_IMMUTABLE);
+               if (ret < 0)
+                       return ret;
+       }
+
+       for (i = 0; i < vsp1->info->wpf_count; ++i) {
+               /* Connect the video device to the WPF. All connections are
+                * immutable except for the WPF0 source link if a LIF is
+                * present.
+                */
+               struct vsp1_rwpf *wpf = vsp1->wpf[i];
+               unsigned int flags = MEDIA_LNK_FL_ENABLED;
+
+               if (!(vsp1->info->features & VSP1_HAS_LIF) || i != 0)
+                       flags |= MEDIA_LNK_FL_IMMUTABLE;
+
+               ret = media_create_pad_link(&wpf->entity.subdev.entity,
+                                           RWPF_PAD_SOURCE,
+                                           &wpf->video->video.entity, 0,
+                                           flags);
+               if (ret < 0)
+                       return ret;
+       }
+
+       return 0;
+}
+
+static void vsp1_destroy_entities(struct vsp1_device *vsp1)
+{
+       struct vsp1_entity *entity, *_entity;
+       struct vsp1_video *video, *_video;
+
+       list_for_each_entry_safe(entity, _entity, &vsp1->entities, list_dev) {
                list_del(&entity->list_dev);
                vsp1_entity_destroy(entity);
        }
 
+       list_for_each_entry_safe(video, _video, &vsp1->videos, list) {
+               list_del(&video->list);
+               vsp1_video_cleanup(video);
+       }
+
        v4l2_device_unregister(&vsp1->v4l2_dev);
        media_device_unregister(&vsp1->media_dev);
        media_device_cleanup(&vsp1->media_dev);
+
+       if (!vsp1->info->uapi)
+               vsp1_drm_cleanup(vsp1);
 }
 
 static int vsp1_create_entities(struct vsp1_device *vsp1)
@@ -144,6 +233,14 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
                 dev_name(mdev->dev));
        media_device_init(mdev);
 
+       vsp1->media_ops.link_setup = vsp1_entity_link_setup;
+       /* Don't perform link validation when the userspace API is disabled as
+        * the pipeline is configured internally by the driver in that case, and
+        * its configuration can thus be trusted.
+        */
+       if (vsp1->info->uapi)
+               vsp1->media_ops.link_validate = v4l2_subdev_link_validate;
+
        vdev->mdev = mdev;
        ret = v4l2_device_register(vsp1->dev, vdev);
        if (ret < 0) {
@@ -153,13 +250,15 @@ 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;
-       }
+       if (vsp1->info->features & VSP1_HAS_BRU) {
+               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);
+               list_add_tail(&vsp1->bru->entity.list_dev, &vsp1->entities);
+       }
 
        vsp1->hsi = vsp1_hsit_create(vsp1, true);
        if (IS_ERR(vsp1->hsi)) {
@@ -177,7 +276,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
 
        list_add_tail(&vsp1->hst->entity.list_dev, &vsp1->entities);
 
-       if (vsp1->pdata.features & VSP1_HAS_LIF) {
+       if (vsp1->info->features & VSP1_HAS_LIF) {
                vsp1->lif = vsp1_lif_create(vsp1);
                if (IS_ERR(vsp1->lif)) {
                        ret = PTR_ERR(vsp1->lif);
@@ -187,7 +286,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
                list_add_tail(&vsp1->lif->entity.list_dev, &vsp1->entities);
        }
 
-       if (vsp1->pdata.features & VSP1_HAS_LUT) {
+       if (vsp1->info->features & VSP1_HAS_LUT) {
                vsp1->lut = vsp1_lut_create(vsp1);
                if (IS_ERR(vsp1->lut)) {
                        ret = PTR_ERR(vsp1->lut);
@@ -197,7 +296,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
                list_add_tail(&vsp1->lut->entity.list_dev, &vsp1->entities);
        }
 
-       for (i = 0; i < vsp1->pdata.rpf_count; ++i) {
+       for (i = 0; i < vsp1->info->rpf_count; ++i) {
                struct vsp1_rwpf *rpf;
 
                rpf = vsp1_rpf_create(vsp1, i);
@@ -208,9 +307,20 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
 
                vsp1->rpf[i] = rpf;
                list_add_tail(&rpf->entity.list_dev, &vsp1->entities);
+
+               if (vsp1->info->uapi) {
+                       struct vsp1_video *video = vsp1_video_create(vsp1, rpf);
+
+                       if (IS_ERR(video)) {
+                               ret = PTR_ERR(video);
+                               goto done;
+                       }
+
+                       list_add_tail(&video->list, &vsp1->videos);
+               }
        }
 
-       if (vsp1->pdata.features & VSP1_HAS_SRU) {
+       if (vsp1->info->features & VSP1_HAS_SRU) {
                vsp1->sru = vsp1_sru_create(vsp1);
                if (IS_ERR(vsp1->sru)) {
                        ret = PTR_ERR(vsp1->sru);
@@ -220,7 +330,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
                list_add_tail(&vsp1->sru->entity.list_dev, &vsp1->entities);
        }
 
-       for (i = 0; i < vsp1->pdata.uds_count; ++i) {
+       for (i = 0; i < vsp1->info->uds_count; ++i) {
                struct vsp1_uds *uds;
 
                uds = vsp1_uds_create(vsp1, i);
@@ -233,7 +343,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
                list_add_tail(&uds->entity.list_dev, &vsp1->entities);
        }
 
-       for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
+       for (i = 0; i < vsp1->info->wpf_count; ++i) {
                struct vsp1_rwpf *wpf;
 
                wpf = vsp1_wpf_create(vsp1, i);
@@ -244,6 +354,18 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
 
                vsp1->wpf[i] = wpf;
                list_add_tail(&wpf->entity.list_dev, &vsp1->entities);
+
+               if (vsp1->info->uapi) {
+                       struct vsp1_video *video = vsp1_video_create(vsp1, wpf);
+
+                       if (IS_ERR(video)) {
+                               ret = PTR_ERR(video);
+                               goto done;
+                       }
+
+                       list_add_tail(&video->list, &vsp1->videos);
+                       wpf->entity.sink = &video->video.entity;
+               }
        }
 
        /* Register all subdevs. */
@@ -255,34 +377,23 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
        }
 
        /* Create links. */
-       list_for_each_entry(entity, &vsp1->entities, list_dev) {
-               if (entity->type == VSP1_ENTITY_WPF) {
-                       ret = vsp1_wpf_create_links(vsp1, entity);
-                       if (ret < 0)
-                               goto done;
-               } else if (entity->type == VSP1_ENTITY_RPF) {
-                       ret = vsp1_rpf_create_links(vsp1, entity);
-                       if (ret < 0)
-                               goto done;
-               }
-
-               if (entity->type != VSP1_ENTITY_LIF &&
-                   entity->type != VSP1_ENTITY_RPF) {
-                       ret = vsp1_create_links(vsp1, entity);
-                       if (ret < 0)
-                               goto done;
-               }
-       }
+       if (vsp1->info->uapi)
+               ret = vsp1_uapi_create_links(vsp1);
+       else
+               ret = vsp1_drm_create_links(vsp1);
+       if (ret < 0)
+               goto done;
 
-       if (vsp1->pdata.features & VSP1_HAS_LIF) {
-               ret = media_create_pad_link(
-                       &vsp1->wpf[0]->entity.subdev.entity, RWPF_PAD_SOURCE,
-                       &vsp1->lif->entity.subdev.entity, LIF_PAD_SINK, 0);
-               if (ret < 0)
-                       return ret;
+       /* Register subdev nodes if the userspace API is enabled or initialize
+        * the DRM pipeline otherwise.
+        */
+       if (vsp1->info->uapi) {
+               vsp1->use_dl = false;
+               ret = v4l2_device_register_subdev_nodes(&vsp1->v4l2_dev);
+       } else {
+               vsp1->use_dl = true;
+               ret = vsp1_drm_init(vsp1);
        }
-
-       ret = v4l2_device_register_subdev_nodes(&vsp1->v4l2_dev);
        if (ret < 0)
                goto done;
 
@@ -295,42 +406,51 @@ done:
        return ret;
 }
 
-static int vsp1_device_init(struct vsp1_device *vsp1)
+int vsp1_reset_wpf(struct vsp1_device *vsp1, unsigned int index)
 {
-       unsigned int i;
+       unsigned int timeout;
        u32 status;
 
-       /* Reset any channel that might be running. */
        status = vsp1_read(vsp1, VI6_STATUS);
+       if (!(status & VI6_STATUS_SYS_ACT(index)))
+               return 0;
 
-       for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
-               unsigned int timeout;
+       vsp1_write(vsp1, VI6_SRESET, VI6_SRESET_SRTS(index));
+       for (timeout = 10; timeout > 0; --timeout) {
+               status = vsp1_read(vsp1, VI6_STATUS);
+               if (!(status & VI6_STATUS_SYS_ACT(index)))
+                       break;
 
-               if (!(status & VI6_STATUS_SYS_ACT(i)))
-                       continue;
+               usleep_range(1000, 2000);
+       }
 
-               vsp1_write(vsp1, VI6_SRESET, VI6_SRESET_SRTS(i));
-               for (timeout = 10; timeout > 0; --timeout) {
-                       status = vsp1_read(vsp1, VI6_STATUS);
-                       if (!(status & VI6_STATUS_SYS_ACT(i)))
-                               break;
+       if (!timeout) {
+               dev_err(vsp1->dev, "failed to reset wpf.%u\n", index);
+               return -ETIMEDOUT;
+       }
 
-                       usleep_range(1000, 2000);
-               }
+       return 0;
+}
 
-               if (!timeout) {
-                       dev_err(vsp1->dev, "failed to reset wpf.%u\n", i);
-                       return -ETIMEDOUT;
-               }
+static int vsp1_device_init(struct vsp1_device *vsp1)
+{
+       unsigned int i;
+       int ret;
+
+       /* Reset any channel that might be running. */
+       for (i = 0; i < vsp1->info->wpf_count; ++i) {
+               ret = vsp1_reset_wpf(vsp1, i);
+               if (ret < 0)
+                       return ret;
        }
 
        vsp1_write(vsp1, VI6_CLK_DCSWT, (8 << VI6_CLK_DCSWT_CSTPW_SHIFT) |
                   (8 << VI6_CLK_DCSWT_CSTRW_SHIFT));
 
-       for (i = 0; i < vsp1->pdata.rpf_count; ++i)
+       for (i = 0; i < vsp1->info->rpf_count; ++i)
                vsp1_write(vsp1, VI6_DPR_RPF_ROUTE(i), VI6_DPR_NODE_UNUSED);
 
-       for (i = 0; i < vsp1->pdata.uds_count; ++i)
+       for (i = 0; i < vsp1->info->uds_count; ++i)
                vsp1_write(vsp1, VI6_DPR_UDS_ROUTE(i), VI6_DPR_NODE_UNUSED);
 
        vsp1_write(vsp1, VI6_DPR_SRU_ROUTE, VI6_DPR_NODE_UNUSED);
@@ -345,6 +465,9 @@ static int vsp1_device_init(struct vsp1_device *vsp1)
        vsp1_write(vsp1, VI6_DPR_HGT_SMPPT, (7 << VI6_DPR_SMPPT_TGW_SHIFT) |
                   (VI6_DPR_NODE_UNUSED << VI6_DPR_SMPPT_PT_SHIFT));
 
+       if (vsp1->use_dl)
+               vsp1_dl_setup(vsp1);
+
        return 0;
 }
 
@@ -444,48 +567,76 @@ static const struct dev_pm_ops vsp1_pm_ops = {
  * Platform Driver
  */
 
-static int vsp1_parse_dt(struct vsp1_device *vsp1)
-{
-       struct device_node *np = vsp1->dev->of_node;
-       struct vsp1_platform_data *pdata = &vsp1->pdata;
-
-       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);
-
-       if (pdata->rpf_count <= 0 || pdata->rpf_count > VSP1_MAX_RPF) {
-               dev_err(vsp1->dev, "invalid number of RPF (%u)\n",
-                       pdata->rpf_count);
-               return -EINVAL;
-       }
-
-       if (pdata->uds_count <= 0 || pdata->uds_count > VSP1_MAX_UDS) {
-               dev_err(vsp1->dev, "invalid number of UDS (%u)\n",
-                       pdata->uds_count);
-               return -EINVAL;
-       }
-
-       if (pdata->wpf_count <= 0 || pdata->wpf_count > VSP1_MAX_WPF) {
-               dev_err(vsp1->dev, "invalid number of WPF (%u)\n",
-                       pdata->wpf_count);
-               return -EINVAL;
-       }
-
-       return 0;
-}
+static const struct vsp1_device_info vsp1_device_infos[] = {
+       {
+               .version = VI6_IP_VERSION_MODEL_VSPS_H2,
+               .features = VSP1_HAS_BRU | VSP1_HAS_LUT | VSP1_HAS_SRU,
+               .rpf_count = 5,
+               .uds_count = 3,
+               .wpf_count = 4,
+               .num_bru_inputs = 4,
+               .uapi = true,
+       }, {
+               .version = VI6_IP_VERSION_MODEL_VSPR_H2,
+               .features = VSP1_HAS_BRU | VSP1_HAS_SRU,
+               .rpf_count = 5,
+               .uds_count = 1,
+               .wpf_count = 4,
+               .num_bru_inputs = 4,
+               .uapi = true,
+       }, {
+               .version = VI6_IP_VERSION_MODEL_VSPD_GEN2,
+               .features = VSP1_HAS_BRU | VSP1_HAS_LIF | VSP1_HAS_LUT,
+               .rpf_count = 4,
+               .uds_count = 1,
+               .wpf_count = 4,
+               .num_bru_inputs = 4,
+               .uapi = true,
+       }, {
+               .version = VI6_IP_VERSION_MODEL_VSPS_M2,
+               .features = VSP1_HAS_BRU | VSP1_HAS_LUT | VSP1_HAS_SRU,
+               .rpf_count = 5,
+               .uds_count = 3,
+               .wpf_count = 4,
+               .num_bru_inputs = 4,
+               .uapi = true,
+       }, {
+               .version = VI6_IP_VERSION_MODEL_VSPI_GEN3,
+               .features = VSP1_HAS_LUT | VSP1_HAS_SRU,
+               .rpf_count = 1,
+               .uds_count = 1,
+               .wpf_count = 1,
+               .uapi = true,
+       }, {
+               .version = VI6_IP_VERSION_MODEL_VSPBD_GEN3,
+               .features = VSP1_HAS_BRU,
+               .rpf_count = 5,
+               .wpf_count = 1,
+               .num_bru_inputs = 5,
+               .uapi = true,
+       }, {
+               .version = VI6_IP_VERSION_MODEL_VSPBC_GEN3,
+               .features = VSP1_HAS_BRU | VSP1_HAS_LUT,
+               .rpf_count = 5,
+               .wpf_count = 1,
+               .num_bru_inputs = 5,
+               .uapi = true,
+       }, {
+               .version = VI6_IP_VERSION_MODEL_VSPD_GEN3,
+               .features = VSP1_HAS_BRU | VSP1_HAS_LIF | VSP1_HAS_LUT,
+               .rpf_count = 5,
+               .wpf_count = 2,
+               .num_bru_inputs = 5,
+       },
+};
 
 static int vsp1_probe(struct platform_device *pdev)
 {
        struct vsp1_device *vsp1;
        struct resource *irq;
        struct resource *io;
+       unsigned int i;
+       u32 version;
        int ret;
 
        vsp1 = devm_kzalloc(&pdev->dev, sizeof(*vsp1), GFP_KERNEL);
@@ -495,10 +646,7 @@ static int vsp1_probe(struct platform_device *pdev)
        vsp1->dev = &pdev->dev;
        mutex_init(&vsp1->lock);
        INIT_LIST_HEAD(&vsp1->entities);
-
-       ret = vsp1_parse_dt(vsp1);
-       if (ret < 0)
-               return ret;
+       INIT_LIST_HEAD(&vsp1->videos);
 
        /* I/O, IRQ and clock resources */
        io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -525,6 +673,29 @@ static int vsp1_probe(struct platform_device *pdev)
                return ret;
        }
 
+       /* Configure device parameters based on the version register. */
+       ret = clk_prepare_enable(vsp1->clock);
+       if (ret < 0)
+               return ret;
+
+       version = vsp1_read(vsp1, VI6_IP_VERSION);
+       clk_disable_unprepare(vsp1->clock);
+
+       for (i = 0; i < ARRAY_SIZE(vsp1_device_infos); ++i) {
+               if ((version & VI6_IP_VERSION_MODEL_MASK) ==
+                   vsp1_device_infos[i].version) {
+                       vsp1->info = &vsp1_device_infos[i];
+                       break;
+               }
+       }
+
+       if (!vsp1->info) {
+               dev_err(&pdev->dev, "unsupported IP version 0x%08x\n", version);
+               return -ENXIO;
+       }
+
+       dev_dbg(&pdev->dev, "IP version 0x%08x\n", version);
+
        /* Instanciate entities */
        ret = vsp1_create_entities(vsp1);
        if (ret < 0) {
@@ -548,6 +719,7 @@ static int vsp1_remove(struct platform_device *pdev)
 
 static const struct of_device_id vsp1_of_match[] = {
        { .compatible = "renesas,vsp1" },
+       { .compatible = "renesas,vsp2" },
        { },
 };
 
index d730853..20a78fb 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "vsp1.h"
 #include "vsp1_entity.h"
-#include "vsp1_video.h"
 
 bool vsp1_entity_is_streaming(struct vsp1_entity *entity)
 {
@@ -46,7 +45,7 @@ int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming)
        if (!streaming)
                return 0;
 
-       if (!entity->subdev.ctrl_handler)
+       if (!entity->vsp1->info->uapi || !entity->subdev.ctrl_handler)
                return 0;
 
        ret = v4l2_ctrl_handler_setup(entity->subdev.ctrl_handler);
@@ -59,6 +58,18 @@ int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming)
        return ret;
 }
 
+void vsp1_entity_route_setup(struct vsp1_entity *source)
+{
+       struct vsp1_entity *sink;
+
+       if (source->route->reg == 0)
+               return;
+
+       sink = container_of(source->sink, struct vsp1_entity, subdev.entity);
+       vsp1_mod_write(source, source->route->reg,
+                      sink->route->inputs[source->sink_pad]);
+}
+
 /* -----------------------------------------------------------------------------
  * V4L2 Subdevice Operations
  */
@@ -120,9 +131,9 @@ const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops = {
  * Media Operations
  */
 
-static int vsp1_entity_link_setup(struct media_entity *entity,
-                                 const struct media_pad *local,
-                                 const struct media_pad *remote, u32 flags)
+int vsp1_entity_link_setup(struct media_entity *entity,
+                          const struct media_pad *local,
+                          const struct media_pad *remote, u32 flags)
 {
        struct vsp1_entity *source;
 
@@ -147,11 +158,6 @@ static int vsp1_entity_link_setup(struct media_entity *entity,
        return 0;
 }
 
-const struct media_entity_operations vsp1_media_ops = {
-       .link_setup = vsp1_entity_link_setup,
-       .link_validate = v4l2_subdev_link_validate,
-};
-
 /* -----------------------------------------------------------------------------
  * Initialization
  */
@@ -159,7 +165,8 @@ const struct media_entity_operations vsp1_media_ops = {
 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), } },
+           VI6_DPR_NODE_BRU_IN(2), VI6_DPR_NODE_BRU_IN(3),
+           VI6_DPR_NODE_BRU_IN(4) } },
        { 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, } },
@@ -225,8 +232,6 @@ 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);
index 8867a57..83570df 100644 (file)
@@ -19,7 +19,6 @@
 #include <media/v4l2-subdev.h>
 
 struct vsp1_device;
-struct vsp1_video;
 
 enum vsp1_entity_type {
        VSP1_ENTITY_BRU,
@@ -33,6 +32,8 @@ enum vsp1_entity_type {
        VSP1_ENTITY_WPF,
 };
 
+#define VSP1_ENTITY_MAX_INPUTS         5       /* For the BRU */
+
 /*
  * struct vsp1_route - Entity routing configuration
  * @type: Entity type this routing entry is associated with
@@ -49,7 +50,7 @@ struct vsp1_route {
        enum vsp1_entity_type type;
        unsigned int index;
        unsigned int reg;
-       unsigned int inputs[4];
+       unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
 };
 
 struct vsp1_entity {
@@ -71,8 +72,6 @@ struct vsp1_entity {
        struct v4l2_subdev subdev;
        struct v4l2_mbus_framefmt *formats;
 
-       struct vsp1_video *video;
-
        spinlock_t lock;                /* Protects the streaming field */
        bool streaming;
 };
@@ -87,7 +86,10 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
 void vsp1_entity_destroy(struct vsp1_entity *entity);
 
 extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
-extern const struct media_entity_operations vsp1_media_ops;
+
+int vsp1_entity_link_setup(struct media_entity *entity,
+                          const struct media_pad *local,
+                          const struct media_pad *remote, u32 flags);
 
 struct v4l2_mbus_framefmt *
 vsp1_entity_get_pad_format(struct vsp1_entity *entity,
@@ -99,4 +101,6 @@ void vsp1_entity_init_formats(struct v4l2_subdev *subdev,
 bool vsp1_entity_is_streaming(struct vsp1_entity *entity);
 int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming);
 
+void vsp1_entity_route_setup(struct vsp1_entity *source);
+
 #endif /* __VSP1_ENTITY_H__ */
index 8ffb817..c1087cf 100644 (file)
@@ -203,7 +203,7 @@ struct vsp1_hsit *vsp1_hsit_create(struct vsp1_device *vsp1, bool inverse)
        subdev = &hsit->entity.subdev;
        v4l2_subdev_init(subdev, &hsit_ops);
 
-       subdev->entity.ops = &vsp1_media_ops;
+       subdev->entity.ops = &vsp1->media_ops;
        subdev->internal_ops = &vsp1_subdev_internal_ops;
        snprintf(subdev->name, sizeof(subdev->name), "%s %s",
                 dev_name(vsp1->dev), inverse ? "hsi" : "hst");
index 39fa5ef..433853c 100644 (file)
  * Device Access
  */
 
-static inline u32 vsp1_lif_read(struct vsp1_lif *lif, u32 reg)
-{
-       return vsp1_read(lif->entity.vsp1, reg);
-}
-
 static inline void vsp1_lif_write(struct vsp1_lif *lif, u32 reg, u32 data)
 {
-       vsp1_write(lif->entity.vsp1, reg, data);
+       vsp1_mod_write(&lif->entity, reg, data);
 }
 
 /* -----------------------------------------------------------------------------
@@ -49,7 +44,7 @@ static int lif_s_stream(struct v4l2_subdev *subdev, int enable)
        unsigned int lbth = 200;
 
        if (!enable) {
-               vsp1_lif_write(lif, VI6_LIF_CTRL, 0);
+               vsp1_write(lif->entity.vsp1, VI6_LIF_CTRL, 0);
                return 0;
        }
 
@@ -228,7 +223,7 @@ struct vsp1_lif *vsp1_lif_create(struct vsp1_device *vsp1)
        subdev = &lif->entity.subdev;
        v4l2_subdev_init(subdev, &lif_ops);
 
-       subdev->entity.ops = &vsp1_media_ops;
+       subdev->entity.ops = &vsp1->media_ops;
        subdev->internal_ops = &vsp1_subdev_internal_ops;
        snprintf(subdev->name, sizeof(subdev->name), "%s lif",
                 dev_name(vsp1->dev));
index 656ec27..4b89095 100644 (file)
  * Device Access
  */
 
-static inline u32 vsp1_lut_read(struct vsp1_lut *lut, u32 reg)
-{
-       return vsp1_read(lut->entity.vsp1, reg);
-}
-
 static inline void vsp1_lut_write(struct vsp1_lut *lut, u32 reg, u32 data)
 {
        vsp1_write(lut->entity.vsp1, reg, data);
@@ -242,7 +237,7 @@ struct vsp1_lut *vsp1_lut_create(struct vsp1_device *vsp1)
        subdev = &lut->entity.subdev;
        v4l2_subdev_init(subdev, &lut_ops);
 
-       subdev->entity.ops = &vsp1_media_ops;
+       subdev->entity.ops = &vsp1->media_ops;
        subdev->internal_ops = &vsp1_subdev_internal_ops;
        snprintf(subdev->name, sizeof(subdev->name), "%s lut",
                 dev_name(vsp1->dev));
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.c b/drivers/media/platform/vsp1/vsp1_pipe.c
new file mode 100644 (file)
index 0000000..6659f06
--- /dev/null
@@ -0,0 +1,426 @@
+/*
+ * vsp1_pipe.c  --  R-Car VSP1 Pipeline
+ *
+ * Copyright (C) 2013-2015 Renesas Electronics 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/delay.h>
+#include <linux/list.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
+
+#include <media/media-entity.h>
+#include <media/v4l2-subdev.h>
+
+#include "vsp1.h"
+#include "vsp1_bru.h"
+#include "vsp1_dl.h"
+#include "vsp1_entity.h"
+#include "vsp1_pipe.h"
+#include "vsp1_rwpf.h"
+#include "vsp1_uds.h"
+
+/* -----------------------------------------------------------------------------
+ * Helper Functions
+ */
+
+static const struct vsp1_format_info vsp1_video_formats[] = {
+       { V4L2_PIX_FMT_RGB332, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_ARGB444, MEDIA_BUS_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, MEDIA_BUS_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, true },
+       { V4L2_PIX_FMT_ARGB555, MEDIA_BUS_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, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_RGB565, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_BGR24, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_RGB24, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_ABGR32, MEDIA_BUS_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, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_ARGB32, MEDIA_BUS_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, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_UYVY, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_VYUY, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_YUYV, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_YVYU, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_NV12M, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_NV21M, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_NV16M, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_NV61M, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_YUV420M, MEDIA_BUS_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, false },
+       { V4L2_PIX_FMT_YVU420M, MEDIA_BUS_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, true, 2, 2, false },
+       { V4L2_PIX_FMT_YUV422M, MEDIA_BUS_FMT_AYUV8_1X32,
+         VI6_FMT_Y_U_V_422, 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, 1, false },
+       { V4L2_PIX_FMT_YVU422M, MEDIA_BUS_FMT_AYUV8_1X32,
+         VI6_FMT_Y_U_V_422, 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, true, 2, 1, false },
+       { V4L2_PIX_FMT_YUV444M, MEDIA_BUS_FMT_AYUV8_1X32,
+         VI6_FMT_Y_U_V_444, 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, 1, 1, false },
+       { V4L2_PIX_FMT_YVU444M, MEDIA_BUS_FMT_AYUV8_1X32,
+         VI6_FMT_Y_U_V_444, 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, true, 1, 1, false },
+};
+
+/*
+ * vsp1_get_format_info - Retrieve format information for a 4CC
+ * @fourcc: the format 4CC
+ *
+ * Return a pointer to the format information structure corresponding to the
+ * given V4L2 format 4CC, or NULL if no corresponding format can be found.
+ */
+const struct vsp1_format_info *vsp1_get_format_info(u32 fourcc)
+{
+       unsigned int i;
+
+       for (i = 0; i < ARRAY_SIZE(vsp1_video_formats); ++i) {
+               const struct vsp1_format_info *info = &vsp1_video_formats[i];
+
+               if (info->fourcc == fourcc)
+                       return info;
+       }
+
+       return NULL;
+}
+
+/* -----------------------------------------------------------------------------
+ * Pipeline Management
+ */
+
+void vsp1_pipeline_reset(struct vsp1_pipeline *pipe)
+{
+       unsigned int i;
+
+       if (pipe->bru) {
+               struct vsp1_bru *bru = to_bru(&pipe->bru->subdev);
+
+               for (i = 0; i < ARRAY_SIZE(bru->inputs); ++i)
+                       bru->inputs[i].rpf = NULL;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(pipe->inputs); ++i)
+               pipe->inputs[i] = NULL;
+
+       INIT_LIST_HEAD(&pipe->entities);
+       pipe->state = VSP1_PIPELINE_STOPPED;
+       pipe->buffers_ready = 0;
+       pipe->num_inputs = 0;
+       pipe->output = NULL;
+       pipe->bru = NULL;
+       pipe->lif = NULL;
+       pipe->uds = NULL;
+}
+
+void vsp1_pipeline_init(struct vsp1_pipeline *pipe)
+{
+       mutex_init(&pipe->lock);
+       spin_lock_init(&pipe->irqlock);
+       init_waitqueue_head(&pipe->wq);
+
+       INIT_LIST_HEAD(&pipe->entities);
+       pipe->state = VSP1_PIPELINE_STOPPED;
+}
+
+void vsp1_pipeline_run(struct vsp1_pipeline *pipe)
+{
+       struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
+
+       if (pipe->state == VSP1_PIPELINE_STOPPED) {
+               vsp1_write(vsp1, VI6_CMD(pipe->output->entity.index),
+                          VI6_CMD_STRCMD);
+               pipe->state = VSP1_PIPELINE_RUNNING;
+       }
+
+       pipe->buffers_ready = 0;
+}
+
+bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe)
+{
+       unsigned long flags;
+       bool stopped;
+
+       spin_lock_irqsave(&pipe->irqlock, flags);
+       stopped = pipe->state == VSP1_PIPELINE_STOPPED;
+       spin_unlock_irqrestore(&pipe->irqlock, flags);
+
+       return stopped;
+}
+
+int vsp1_pipeline_stop(struct vsp1_pipeline *pipe)
+{
+       struct vsp1_entity *entity;
+       unsigned long flags;
+       int ret;
+
+       if (pipe->dl) {
+               /* When using display lists in continuous frame mode the only
+                * way to stop the pipeline is to reset the hardware.
+                */
+               ret = vsp1_reset_wpf(pipe->output->entity.vsp1,
+                                    pipe->output->entity.index);
+               if (ret == 0) {
+                       spin_lock_irqsave(&pipe->irqlock, flags);
+                       pipe->state = VSP1_PIPELINE_STOPPED;
+                       spin_unlock_irqrestore(&pipe->irqlock, flags);
+               }
+       } else {
+               /* Otherwise just request a stop and wait. */
+               spin_lock_irqsave(&pipe->irqlock, flags);
+               if (pipe->state == VSP1_PIPELINE_RUNNING)
+                       pipe->state = VSP1_PIPELINE_STOPPING;
+               spin_unlock_irqrestore(&pipe->irqlock, flags);
+
+               ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe),
+                                        msecs_to_jiffies(500));
+               ret = ret == 0 ? -ETIMEDOUT : 0;
+       }
+
+       list_for_each_entry(entity, &pipe->entities, list_pipe) {
+               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);
+       }
+
+       return ret;
+}
+
+bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe)
+{
+       unsigned int mask;
+
+       mask = ((1 << pipe->num_inputs) - 1) << 1;
+       if (!pipe->lif)
+               mask |= 1 << 0;
+
+       return pipe->buffers_ready == mask;
+}
+
+void vsp1_pipeline_display_start(struct vsp1_pipeline *pipe)
+{
+       if (pipe->dl)
+               vsp1_dl_irq_display_start(pipe->dl);
+}
+
+void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe)
+{
+       enum vsp1_pipeline_state state;
+       unsigned long flags;
+
+       if (pipe == NULL)
+               return;
+
+       if (pipe->dl)
+               vsp1_dl_irq_frame_end(pipe->dl);
+
+       /* Signal frame end to the pipeline handler. */
+       pipe->frame_end(pipe);
+
+       spin_lock_irqsave(&pipe->irqlock, flags);
+
+       state = pipe->state;
+
+       /* When using display lists in continuous frame mode the pipeline is
+        * automatically restarted by the hardware.
+        */
+       if (!pipe->dl)
+               pipe->state = VSP1_PIPELINE_STOPPED;
+
+       /* If a stop has been requested, mark the pipeline as stopped and
+        * return.
+        */
+       if (state == VSP1_PIPELINE_STOPPING) {
+               wake_up(&pipe->wq);
+               goto done;
+       }
+
+       /* Restart the pipeline if ready. */
+       if (vsp1_pipeline_ready(pipe))
+               vsp1_pipeline_run(pipe);
+
+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 (!is_media_entity_v4l2_subdev(pad->entity))
+                       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);
+       }
+}
+
+void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
+{
+       unsigned long flags;
+       unsigned int i;
+       int ret;
+
+       /* To avoid increasing the system suspend time needlessly, loop over the
+        * pipelines twice, first to set them all to the stopping state, and
+        * then to wait for the stop to complete.
+        */
+       for (i = 0; i < vsp1->info->wpf_count; ++i) {
+               struct vsp1_rwpf *wpf = vsp1->wpf[i];
+               struct vsp1_pipeline *pipe;
+
+               if (wpf == NULL)
+                       continue;
+
+               pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
+               if (pipe == NULL)
+                       continue;
+
+               spin_lock_irqsave(&pipe->irqlock, flags);
+               if (pipe->state == VSP1_PIPELINE_RUNNING)
+                       pipe->state = VSP1_PIPELINE_STOPPING;
+               spin_unlock_irqrestore(&pipe->irqlock, flags);
+       }
+
+       for (i = 0; i < vsp1->info->wpf_count; ++i) {
+               struct vsp1_rwpf *wpf = vsp1->wpf[i];
+               struct vsp1_pipeline *pipe;
+
+               if (wpf == NULL)
+                       continue;
+
+               pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
+               if (pipe == NULL)
+                       continue;
+
+               ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe),
+                                        msecs_to_jiffies(500));
+               if (ret == 0)
+                       dev_warn(vsp1->dev, "pipeline %u stop timeout\n",
+                                wpf->entity.index);
+       }
+}
+
+void vsp1_pipelines_resume(struct vsp1_device *vsp1)
+{
+       unsigned int i;
+
+       /* Resume pipeline all running pipelines. */
+       for (i = 0; i < vsp1->info->wpf_count; ++i) {
+               struct vsp1_rwpf *wpf = vsp1->wpf[i];
+               struct vsp1_pipeline *pipe;
+
+               if (wpf == NULL)
+                       continue;
+
+               pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
+               if (pipe == NULL)
+                       continue;
+
+               if (vsp1_pipeline_ready(pipe))
+                       vsp1_pipeline_run(pipe);
+       }
+}
diff --git a/drivers/media/platform/vsp1/vsp1_pipe.h b/drivers/media/platform/vsp1/vsp1_pipe.h
new file mode 100644 (file)
index 0000000..b2f3a8a
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * vsp1_pipe.h  --  R-Car VSP1 Pipeline
+ *
+ * Copyright (C) 2013-2015 Renesas Electronics 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_PIPE_H__
+#define __VSP1_PIPE_H__
+
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/wait.h>
+
+#include <media/media-entity.h>
+
+struct vsp1_dl;
+struct vsp1_rwpf;
+
+/*
+ * struct vsp1_format_info - VSP1 video format description
+ * @mbus: media bus format code
+ * @fourcc: V4L2 pixel format FCC identifier
+ * @planes: number of planes
+ * @bpp: bits per pixel
+ * @hwfmt: VSP1 hardware format
+ * @swap_yc: the Y and C components are swapped (Y comes before C)
+ * @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;
+       unsigned int mbus;
+       unsigned int hwfmt;
+       unsigned int swap;
+       unsigned int planes;
+       unsigned int bpp[3];
+       bool swap_yc;
+       bool swap_uv;
+       unsigned int hsub;
+       unsigned int vsub;
+       bool alpha;
+};
+
+enum vsp1_pipeline_state {
+       VSP1_PIPELINE_STOPPED,
+       VSP1_PIPELINE_RUNNING,
+       VSP1_PIPELINE_STOPPING,
+};
+
+/*
+ * struct vsp1_pipeline - A VSP1 hardware pipeline
+ * @pipe: the media pipeline
+ * @irqlock: protects the pipeline state
+ * @state: current state
+ * @wq: work queue to wait for state change completion
+ * @frame_end: frame end interrupt handler
+ * @lock: protects the pipeline use count and stream count
+ * @use_count: number of video nodes using the pipeline
+ * @stream_count: number of streaming video nodes
+ * @buffers_ready: bitmask of RPFs and WPFs with at least one buffer available
+ * @num_inputs: number of RPFs
+ * @inputs: array of RPFs in the pipeline (indexed by RPF index)
+ * @output: WPF at the output of the pipeline
+ * @bru: BRU entity, if present
+ * @lif: LIF entity, if present
+ * @uds: UDS entity, if present
+ * @uds_input: entity at the input of the UDS, if the UDS is present
+ * @entities: list of entities in the pipeline
+ * @dl: display list associated with the pipeline
+ */
+struct vsp1_pipeline {
+       struct media_pipeline pipe;
+
+       spinlock_t irqlock;
+       enum vsp1_pipeline_state state;
+       wait_queue_head_t wq;
+
+       void (*frame_end)(struct vsp1_pipeline *pipe);
+
+       struct mutex lock;
+       unsigned int use_count;
+       unsigned int stream_count;
+       unsigned int buffers_ready;
+
+       unsigned int num_inputs;
+       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;
+
+       struct vsp1_dl *dl;
+};
+
+static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
+{
+       if (likely(e->pipe))
+               return container_of(e->pipe, struct vsp1_pipeline, pipe);
+       else
+               return NULL;
+}
+
+void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);
+void vsp1_pipeline_init(struct vsp1_pipeline *pipe);
+
+void vsp1_pipeline_run(struct vsp1_pipeline *pipe);
+bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe);
+int vsp1_pipeline_stop(struct vsp1_pipeline *pipe);
+bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe);
+
+void vsp1_pipeline_display_start(struct vsp1_pipeline *pipe);
+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);
+
+void vsp1_pipelines_suspend(struct vsp1_device *vsp1);
+void vsp1_pipelines_resume(struct vsp1_device *vsp1);
+
+const struct vsp1_format_info *vsp1_get_format_info(u32 fourcc);
+
+#endif /* __VSP1_PIPE_H__ */
index 25b4873..069216f 100644 (file)
@@ -46,7 +46,7 @@
 #define VI6_DISP_IRQ_ENB_LNEE(n)       (1 << (n))
 
 #define VI6_DISP_IRQ_STA               0x007c
-#define VI6_DISP_IRQ_STA_DSE           (1 << 8)
+#define VI6_DISP_IRQ_STA_DST           (1 << 8)
 #define VI6_DISP_IRQ_STA_MAE           (1 << 5)
 #define VI6_DISP_IRQ_STA_LNE(n)                (1 << (n))
 
 #define VI6_DPR_NODE_SRU               16
 #define VI6_DPR_NODE_UDS(n)            (17 + (n))
 #define VI6_DPR_NODE_LUT               22
-#define VI6_DPR_NODE_BRU_IN(n)         (23 + (n))
+#define VI6_DPR_NODE_BRU_IN(n)         (((n) <= 3) ? 23 + (n) : 49)
 #define VI6_DPR_NODE_BRU_OUT           27
 #define VI6_DPR_NODE_CLU               29
 #define VI6_DPR_NODE_HST               30
 #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(n)                        (0x2c10 + (n) * 8 + ((n) <= 3 ? 0 : 4))
 #define VI6_BRU_CTRL_RBC               (1 << 31)
-#define VI6_BRU_CTRL_DSTSEL_BRUIN(n)   ((n) << 20)
+#define VI6_BRU_CTRL_DSTSEL_BRUIN(n)   (((n) <= 3 ? (n) : (n)+1) << 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_BRUIN(n)   (((n) <= 3 ? (n) : (n)+1) << 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_AROP(rop)         ((rop) << 0)
 #define VI6_BRU_CTRL_AROP_MASK         (0xf << 0)
 
-#define VI6_BRU_BLD(n)                 (0x2c14 + (n) * 8)
+#define VI6_BRU_BLD(n)                 (0x2c14 + (n) * 8 + ((n) <= 3 ? 0 : 4))
 #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_COEFY_SHIFT                0
 
 #define VI6_BRU_ROP                    0x2c30
-#define VI6_BRU_ROP_DSTSEL_BRUIN(n)    ((n) << 20)
+#define VI6_BRU_ROP_DSTSEL_BRUIN(n)    (((n) <= 3 ? (n) : (n)+1) << 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_SECURITY_CTRL1             0x3d04
 
 /* -----------------------------------------------------------------------------
+ * IP Version Registers
+ */
+
+#define VI6_IP_VERSION                 0x3f00
+#define VI6_IP_VERSION_MODEL_MASK      (0xff << 8)
+#define VI6_IP_VERSION_MODEL_VSPS_H2   (0x09 << 8)
+#define VI6_IP_VERSION_MODEL_VSPR_H2   (0x0a << 8)
+#define VI6_IP_VERSION_MODEL_VSPD_GEN2 (0x0b << 8)
+#define VI6_IP_VERSION_MODEL_VSPS_M2   (0x0c << 8)
+#define VI6_IP_VERSION_MODEL_VSPI_GEN3 (0x14 << 8)
+#define VI6_IP_VERSION_MODEL_VSPBD_GEN3        (0x15 << 8)
+#define VI6_IP_VERSION_MODEL_VSPBC_GEN3        (0x16 << 8)
+#define VI6_IP_VERSION_MODEL_VSPD_GEN3 (0x17 << 8)
+#define VI6_IP_VERSION_SOC_MASK                (0xff << 0)
+#define VI6_IP_VERSION_SOC_H           (0x01 << 0)
+#define VI6_IP_VERSION_SOC_M           (0x02 << 0)
+
+/* -----------------------------------------------------------------------------
  * RPF CLUT Registers
  */
 
index 9245382..5bc1d15 100644 (file)
  * Device Access
  */
 
-static inline u32 vsp1_rpf_read(struct vsp1_rwpf *rpf, u32 reg)
-{
-       return vsp1_read(rpf->entity.vsp1,
-                        reg + rpf->entity.index * VI6_RPF_OFFSET);
-}
-
 static inline void vsp1_rpf_write(struct vsp1_rwpf *rpf, u32 reg, u32 data)
 {
-       vsp1_write(rpf->entity.vsp1,
-                  reg + rpf->entity.index * VI6_RPF_OFFSET, data);
+       vsp1_mod_write(&rpf->entity, reg + rpf->entity.index * VI6_RPF_OFFSET,
+                      data);
 }
 
 /* -----------------------------------------------------------------------------
@@ -74,9 +68,11 @@ static const struct v4l2_ctrl_ops rpf_ctrl_ops = {
 
 static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
 {
+       struct vsp1_pipeline *pipe = to_vsp1_pipeline(&subdev->entity);
        struct vsp1_rwpf *rpf = to_rwpf(subdev);
-       const struct vsp1_format_info *fmtinfo = rpf->video.fmtinfo;
-       const struct v4l2_pix_format_mplane *format = &rpf->video.format;
+       struct vsp1_device *vsp1 = rpf->entity.vsp1;
+       const struct vsp1_format_info *fmtinfo = rpf->fmtinfo;
+       const struct v4l2_pix_format_mplane *format = &rpf->format;
        const struct v4l2_rect *crop = &rpf->crop;
        u32 pstride;
        u32 infmt;
@@ -154,6 +150,15 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
        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));
+
+       if (vsp1->info->uapi)
+               mutex_lock(rpf->ctrls.lock);
+       vsp1_rpf_write(rpf, VI6_RPF_VRTCOL_SET,
+                      rpf->alpha->cur.val << VI6_RPF_VRTCOL_SET_LAYA_SHIFT);
+       vsp1_pipeline_propagate_alpha(pipe, &rpf->entity, rpf->alpha->cur.val);
+       if (vsp1->info->uapi)
+               mutex_unlock(rpf->ctrls.lock);
+
        vsp1_rpf_write(rpf, VI6_RPF_MSK_CTRL, 0);
        vsp1_rpf_write(rpf, VI6_RPF_CKEY_CTRL, 0);
 
@@ -186,30 +191,28 @@ static struct v4l2_subdev_ops rpf_ops = {
  * Video Device Operations
  */
 
-static void rpf_vdev_queue(struct vsp1_video *video,
-                          struct vsp1_video_buffer *buf)
+static void rpf_set_memory(struct vsp1_rwpf *rpf, struct vsp1_rwpf_memory *mem)
 {
-       struct vsp1_rwpf *rpf = container_of(video, struct vsp1_rwpf, video);
        unsigned int i;
 
        for (i = 0; i < 3; ++i)
-               rpf->buf_addr[i] = buf->addr[i];
+               rpf->buf_addr[i] = mem->addr[i];
 
        if (!vsp1_entity_is_streaming(&rpf->entity))
                return;
 
        vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_Y,
-                      buf->addr[0] + rpf->offsets[0]);
-       if (buf->buf.vb2_buf.num_planes > 1)
+                      mem->addr[0] + rpf->offsets[0]);
+       if (mem->num_planes > 1)
                vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_C0,
-                              buf->addr[1] + rpf->offsets[1]);
-       if (buf->buf.vb2_buf.num_planes > 2)
+                              mem->addr[1] + rpf->offsets[1]);
+       if (mem->num_planes > 2)
                vsp1_rpf_write(rpf, VI6_RPF_SRCM_ADDR_C1,
-                              buf->addr[2] + rpf->offsets[1]);
+                              mem->addr[2] + rpf->offsets[1]);
 }
 
-static const struct vsp1_video_operations rpf_vdev_ops = {
-       .queue = rpf_vdev_queue,
+static const struct vsp1_rwpf_operations rpf_vdev_ops = {
+       .set_memory = rpf_set_memory,
 };
 
 /* -----------------------------------------------------------------------------
@@ -219,7 +222,6 @@ static const struct vsp1_video_operations rpf_vdev_ops = {
 struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
 {
        struct v4l2_subdev *subdev;
-       struct vsp1_video *video;
        struct vsp1_rwpf *rpf;
        int ret;
 
@@ -227,6 +229,8 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
        if (rpf == NULL)
                return ERR_PTR(-ENOMEM);
 
+       rpf->ops = &rpf_vdev_ops;
+
        rpf->max_width = RPF_MAX_WIDTH;
        rpf->max_height = RPF_MAX_HEIGHT;
 
@@ -241,7 +245,7 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
        subdev = &rpf->entity.subdev;
        v4l2_subdev_init(subdev, &rpf_ops);
 
-       subdev->entity.ops = &vsp1_media_ops;
+       subdev->entity.ops = &vsp1->media_ops;
        subdev->internal_ops = &vsp1_subdev_internal_ops;
        snprintf(subdev->name, sizeof(subdev->name), "%s rpf.%u",
                 dev_name(vsp1->dev), index);
@@ -252,8 +256,9 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
 
        /* 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->alpha = v4l2_ctrl_new_std(&rpf->ctrls, &rpf_ctrl_ops,
+                                      V4L2_CID_ALPHA_COMPONENT,
+                                      0, 255, 1, 255);
 
        rpf->entity.subdev.ctrl_handler = &rpf->ctrls;
 
@@ -264,42 +269,9 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
                goto error;
        }
 
-       /* Initialize the video device. */
-       video = &rpf->video;
-
-       video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
-       video->vsp1 = vsp1;
-       video->ops = &rpf_vdev_ops;
-
-       ret = vsp1_video_init(video, &rpf->entity);
-       if (ret < 0)
-               goto error;
-
-       rpf->entity.video = video;
-
        return rpf;
 
 error:
        vsp1_entity_destroy(&rpf->entity);
        return ERR_PTR(ret);
 }
-
-/*
- * vsp1_rpf_create_links() - RPF pads links creation
- * @vsp1: Pointer to VSP1 device
- * @entity: Pointer to VSP1 entity
- *
- * return negative error code or zero on success
- */
-int vsp1_rpf_create_links(struct vsp1_device *vsp1,
-                              struct vsp1_entity *entity)
-{
-       struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev);
-
-       /* Connect the video device to the RPF. */
-       return media_create_pad_link(&rpf->video.video.entity, 0,
-                                    &rpf->entity.subdev.entity,
-                                    RWPF_PAD_SINK,
-                                    MEDIA_LNK_FL_ENABLED |
-                                    MEDIA_LNK_FL_IMMUTABLE);
-}
index 731d36e..8e82356 100644 (file)
 
 #include "vsp1.h"
 #include "vsp1_entity.h"
-#include "vsp1_video.h"
 
 #define RWPF_PAD_SINK                          0
 #define RWPF_PAD_SOURCE                                1
 
+struct v4l2_ctrl;
+struct vsp1_rwpf;
+struct vsp1_video;
+
+struct vsp1_rwpf_memory {
+       unsigned int num_planes;
+       dma_addr_t addr[3];
+       unsigned int length[3];
+};
+
+struct vsp1_rwpf_operations {
+       void (*set_memory)(struct vsp1_rwpf *rwpf,
+                          struct vsp1_rwpf_memory *mem);
+};
+
 struct vsp1_rwpf {
        struct vsp1_entity entity;
-       struct vsp1_video video;
        struct v4l2_ctrl_handler ctrls;
+       struct v4l2_ctrl *alpha;
+
+       struct vsp1_video *video;
+
+       const struct vsp1_rwpf_operations *ops;
 
        unsigned int max_width;
        unsigned int max_height;
 
+       struct v4l2_pix_format_mplane format;
+       const struct vsp1_format_info *fmtinfo;
        struct {
                unsigned int left;
                unsigned int top;
@@ -50,11 +70,6 @@ static inline struct vsp1_rwpf *to_rwpf(struct v4l2_subdev *subdev)
 struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index);
 struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index);
 
-int vsp1_rpf_create_links(struct vsp1_device *vsp1,
-                              struct vsp1_entity *entity);
-int vsp1_wpf_create_links(struct vsp1_device *vsp1,
-                              struct vsp1_entity *entity);
-
 int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
                             struct v4l2_subdev_pad_config *cfg,
                             struct v4l2_subdev_mbus_code_enum *code);
index 6310aca..cc09efb 100644 (file)
@@ -151,10 +151,13 @@ static int sru_s_stream(struct v4l2_subdev *subdev, int enable)
        /* 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);
+       if (sru->entity.vsp1->info->uapi)
+               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_CTRL0, ctrl0);
+       if (sru->entity.vsp1->info->uapi)
+               mutex_unlock(sru->ctrls.lock);
 
        vsp1_sru_write(sru, VI6_SRU_CTRL1, VI6_SRU_CTRL1_PARAM5);
 
@@ -360,7 +363,7 @@ struct vsp1_sru *vsp1_sru_create(struct vsp1_device *vsp1)
        subdev = &sru->entity.subdev;
        v4l2_subdev_init(subdev, &sru_ops);
 
-       subdev->entity.ops = &vsp1_media_ops;
+       subdev->entity.ops = &vsp1->media_ops;
        subdev->internal_ops = &vsp1_subdev_internal_ops;
        snprintf(subdev->name, sizeof(subdev->name), "%s sru",
                 dev_name(vsp1->dev));
index ccc8243..bba6777 100644 (file)
  * Device Access
  */
 
-static inline u32 vsp1_uds_read(struct vsp1_uds *uds, u32 reg)
-{
-       return vsp1_read(uds->entity.vsp1,
-                        reg + uds->entity.index * VI6_UDS_OFFSET);
-}
-
 static inline void vsp1_uds_write(struct vsp1_uds *uds, u32 reg, u32 data)
 {
        vsp1_write(uds->entity.vsp1,
@@ -344,7 +338,7 @@ struct vsp1_uds *vsp1_uds_create(struct vsp1_device *vsp1, unsigned int index)
        subdev = &uds->entity.subdev;
        v4l2_subdev_init(subdev, &uds_ops);
 
-       subdev->entity.ops = &vsp1_media_ops;
+       subdev->entity.ops = &vsp1->media_ops;
        subdev->internal_ops = &vsp1_subdev_internal_ops;
        snprintf(subdev->name, sizeof(subdev->name), "%s uds.%u",
                 dev_name(vsp1->dev), index);
index b4dca57..61ee0f9 100644 (file)
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
-#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/v4l2-mediabus.h>
 #include <linux/videodev2.h>
+#include <linux/wait.h>
 
 #include <media/media-entity.h>
 #include <media/v4l2-dev.h>
@@ -30,6 +30,7 @@
 #include "vsp1.h"
 #include "vsp1_bru.h"
 #include "vsp1_entity.h"
+#include "vsp1_pipe.h"
 #include "vsp1_rwpf.h"
 #include "vsp1_uds.h"
 #include "vsp1_video.h"
  * Helper functions
  */
 
-static const struct vsp1_format_info vsp1_video_formats[] = {
-       { V4L2_PIX_FMT_RGB332, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_ARGB444, MEDIA_BUS_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, MEDIA_BUS_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, true },
-       { V4L2_PIX_FMT_ARGB555, MEDIA_BUS_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, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_RGB565, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_BGR24, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_RGB24, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_ABGR32, MEDIA_BUS_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, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_ARGB32, MEDIA_BUS_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, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_UYVY, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_VYUY, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_YUYV, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_YVYU, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_NV12M, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_NV21M, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_NV16M, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_NV61M, MEDIA_BUS_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, false },
-       { V4L2_PIX_FMT_YUV420M, MEDIA_BUS_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, false },
-};
-
-/*
- * vsp1_get_format_info - Retrieve format information for a 4CC
- * @fourcc: the format 4CC
- *
- * Return a pointer to the format information structure corresponding to the
- * given V4L2 format 4CC, or NULL if no corresponding format can be found.
- */
-static const struct vsp1_format_info *vsp1_get_format_info(u32 fourcc)
-{
-       unsigned int i;
-
-       for (i = 0; i < ARRAY_SIZE(vsp1_video_formats); ++i) {
-               const struct vsp1_format_info *info = &vsp1_video_formats[i];
-
-               if (info->fourcc == fourcc)
-                       return info;
-       }
-
-       return NULL;
-}
-
-
 static struct v4l2_subdev *
 vsp1_video_remote_subdev(struct media_pad *local, u32 *pad)
 {
@@ -184,9 +78,9 @@ static int vsp1_video_verify_format(struct vsp1_video *video)
        if (ret < 0)
                return ret == -ENOIOCTLCMD ? -EINVAL : ret;
 
-       if (video->fmtinfo->mbus != fmt.format.code ||
-           video->format.height != fmt.format.height ||
-           video->format.width != fmt.format.width)
+       if (video->rwpf->fmtinfo->mbus != fmt.format.code ||
+           video->rwpf->format.height != fmt.format.height ||
+           video->rwpf->format.width != fmt.format.width)
                return -EINVAL;
 
        return 0;
@@ -277,9 +171,9 @@ static int __vsp1_video_try_format(struct vsp1_video *video,
  * Pipeline Management
  */
 
-static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe,
-                                        struct vsp1_rwpf *input,
-                                        struct vsp1_rwpf *output)
+static int vsp1_video_pipeline_validate_branch(struct vsp1_pipeline *pipe,
+                                              struct vsp1_rwpf *input,
+                                              struct vsp1_rwpf *output)
 {
        struct vsp1_entity *entity;
        struct media_entity_enum ent_enum;
@@ -370,29 +264,8 @@ out:
        return rval;
 }
 
-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)
+static int vsp1_video_pipeline_validate(struct vsp1_pipeline *pipe,
+                                       struct vsp1_video *video)
 {
        struct media_entity_graph graph;
        struct media_entity *entity = &video->video.entity;
@@ -416,10 +289,8 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
                struct vsp1_rwpf *rwpf;
                struct vsp1_entity *e;
 
-               if (is_media_entity_v4l2_io(entity)) {
-                       pipe->num_video++;
+               if (is_media_entity_v4l2_io(entity))
                        continue;
-               }
 
                subdev = media_entity_to_v4l2_subdev(entity);
                e = to_vsp1_entity(subdev);
@@ -427,12 +298,12 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
 
                if (e->type == VSP1_ENTITY_RPF) {
                        rwpf = to_rwpf(subdev);
-                       pipe->inputs[pipe->num_inputs++] = rwpf;
-                       rwpf->video.pipe_index = pipe->num_inputs;
+                       pipe->inputs[rwpf->entity.index] = rwpf;
+                       rwpf->video->pipe_index = ++pipe->num_inputs;
                } else if (e->type == VSP1_ENTITY_WPF) {
                        rwpf = to_rwpf(subdev);
-                       pipe->output = to_rwpf(subdev);
-                       rwpf->video.pipe_index = 0;
+                       pipe->output = rwpf;
+                       rwpf->video->pipe_index = 0;
                } else if (e->type == VSP1_ENTITY_LIF) {
                        pipe->lif = e;
                } else if (e->type == VSP1_ENTITY_BRU) {
@@ -453,9 +324,12 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
        /* Follow links downstream for each input and make sure the graph
         * 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, pipe->inputs[i],
-                                                   pipe->output);
+       for (i = 0; i < video->vsp1->info->rpf_count; ++i) {
+               if (!pipe->inputs[i])
+                       continue;
+
+               ret = vsp1_video_pipeline_validate_branch(pipe, pipe->inputs[i],
+                                                         pipe->output);
                if (ret < 0)
                        goto error;
        }
@@ -463,12 +337,12 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
        return 0;
 
 error:
-       __vsp1_pipeline_cleanup(pipe);
+       vsp1_pipeline_reset(pipe);
        return ret;
 }
 
-static int vsp1_pipeline_init(struct vsp1_pipeline *pipe,
-                             struct vsp1_video *video)
+static int vsp1_video_pipeline_init(struct vsp1_pipeline *pipe,
+                                   struct vsp1_video *video)
 {
        int ret;
 
@@ -476,7 +350,7 @@ static int vsp1_pipeline_init(struct vsp1_pipeline *pipe,
 
        /* If we're the first user validate and initialize the pipeline. */
        if (pipe->use_count == 0) {
-               ret = vsp1_pipeline_validate(pipe, video);
+               ret = vsp1_video_pipeline_validate(pipe, video);
                if (ret < 0)
                        goto done;
        }
@@ -489,75 +363,17 @@ done:
        return ret;
 }
 
-static void vsp1_pipeline_cleanup(struct vsp1_pipeline *pipe)
+static void vsp1_video_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)
-               __vsp1_pipeline_cleanup(pipe);
+               vsp1_pipeline_reset(pipe);
 
        mutex_unlock(&pipe->lock);
 }
 
-static void vsp1_pipeline_run(struct vsp1_pipeline *pipe)
-{
-       struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
-
-       vsp1_write(vsp1, VI6_CMD(pipe->output->entity.index), VI6_CMD_STRCMD);
-       pipe->state = VSP1_PIPELINE_RUNNING;
-       pipe->buffers_ready = 0;
-}
-
-static bool vsp1_pipeline_stopped(struct vsp1_pipeline *pipe)
-{
-       unsigned long flags;
-       bool stopped;
-
-       spin_lock_irqsave(&pipe->irqlock, flags);
-       stopped = pipe->state == VSP1_PIPELINE_STOPPED;
-       spin_unlock_irqrestore(&pipe->irqlock, flags);
-
-       return stopped;
-}
-
-static int vsp1_pipeline_stop(struct vsp1_pipeline *pipe)
-{
-       struct vsp1_entity *entity;
-       unsigned long flags;
-       int ret;
-
-       spin_lock_irqsave(&pipe->irqlock, flags);
-       if (pipe->state == VSP1_PIPELINE_RUNNING)
-               pipe->state = VSP1_PIPELINE_STOPPING;
-       spin_unlock_irqrestore(&pipe->irqlock, flags);
-
-       ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe),
-                                msecs_to_jiffies(500));
-       ret = ret == 0 ? -ETIMEDOUT : 0;
-
-       list_for_each_entry(entity, &pipe->entities, list_pipe) {
-               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);
-       }
-
-       return ret;
-}
-
-static bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe)
-{
-       unsigned int mask;
-
-       mask = ((1 << pipe->num_inputs) - 1) << 1;
-       if (!pipe->lif)
-               mask |= 1 << 0;
-
-       return pipe->buffers_ready == mask;
-}
-
 /*
  * vsp1_video_complete_buffer - Complete the current buffer
  * @video: the video node
@@ -572,12 +388,12 @@ static bool vsp1_pipeline_ready(struct vsp1_pipeline *pipe)
  *
  * Return the next queued buffer or NULL if the queue is empty.
  */
-static struct vsp1_video_buffer *
+static struct vsp1_vb2_buffer *
 vsp1_video_complete_buffer(struct vsp1_video *video)
 {
        struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity);
-       struct vsp1_video_buffer *next = NULL;
-       struct vsp1_video_buffer *done;
+       struct vsp1_vb2_buffer *next = NULL;
+       struct vsp1_vb2_buffer *done;
        unsigned long flags;
        unsigned int i;
 
@@ -589,7 +405,7 @@ vsp1_video_complete_buffer(struct vsp1_video *video)
        }
 
        done = list_first_entry(&video->irqqueue,
-                               struct vsp1_video_buffer, queue);
+                               struct vsp1_vb2_buffer, queue);
 
        /* In DU output mode reuse the buffer if the list is singular. */
        if (pipe->lif && list_is_singular(&video->irqqueue)) {
@@ -601,23 +417,25 @@ vsp1_video_complete_buffer(struct vsp1_video *video)
 
        if (!list_empty(&video->irqqueue))
                next = list_first_entry(&video->irqqueue,
-                                       struct vsp1_video_buffer, queue);
+                                       struct vsp1_vb2_buffer, queue);
 
        spin_unlock_irqrestore(&video->irqlock, flags);
 
        done->buf.sequence = video->sequence++;
        done->buf.vb2_buf.timestamp = ktime_get_ns();
        for (i = 0; i < done->buf.vb2_buf.num_planes; ++i)
-               vb2_set_plane_payload(&done->buf.vb2_buf, i, done->length[i]);
+               vb2_set_plane_payload(&done->buf.vb2_buf, i,
+                                     done->mem.length[i]);
        vb2_buffer_done(&done->buf.vb2_buf, VB2_BUF_STATE_DONE);
 
        return next;
 }
 
 static void vsp1_video_frame_end(struct vsp1_pipeline *pipe,
-                                struct vsp1_video *video)
+                                struct vsp1_rwpf *rwpf)
 {
-       struct vsp1_video_buffer *buf;
+       struct vsp1_video *video = rwpf->video;
+       struct vsp1_vb2_buffer *buf;
        unsigned long flags;
 
        buf = vsp1_video_complete_buffer(video);
@@ -626,155 +444,27 @@ static void vsp1_video_frame_end(struct vsp1_pipeline *pipe,
 
        spin_lock_irqsave(&pipe->irqlock, flags);
 
-       video->ops->queue(video, buf);
+       video->rwpf->ops->set_memory(video->rwpf, &buf->mem);
        pipe->buffers_ready |= 1 << video->pipe_index;
 
        spin_unlock_irqrestore(&pipe->irqlock, flags);
 }
 
-void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe)
+static void vsp1_video_pipeline_frame_end(struct vsp1_pipeline *pipe)
 {
-       enum vsp1_pipeline_state state;
-       unsigned long flags;
+       struct vsp1_device *vsp1 = pipe->output->entity.vsp1;
        unsigned int i;
 
-       if (pipe == NULL)
-               return;
-
        /* Complete buffers on all video nodes. */
-       for (i = 0; i < pipe->num_inputs; ++i)
-               vsp1_video_frame_end(pipe, &pipe->inputs[i]->video);
-
-       if (!pipe->lif)
-               vsp1_video_frame_end(pipe, &pipe->output->video);
-
-       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 (state == VSP1_PIPELINE_STOPPING) {
-               wake_up(&pipe->wq);
-               goto done;
-       }
-
-       /* Restart the pipeline if ready. */
-       if (vsp1_pipeline_ready(pipe))
-               vsp1_pipeline_run(pipe);
-
-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 (!is_media_entity_v4l2_subdev(pad->entity))
-                       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);
-       }
-}
-
-void vsp1_pipelines_suspend(struct vsp1_device *vsp1)
-{
-       unsigned long flags;
-       unsigned int i;
-       int ret;
-
-       /* To avoid increasing the system suspend time needlessly, loop over the
-        * pipelines twice, first to set them all to the stopping state, and then
-        * to wait for the stop to complete.
-        */
-       for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
-               struct vsp1_rwpf *wpf = vsp1->wpf[i];
-               struct vsp1_pipeline *pipe;
-
-               if (wpf == NULL)
-                       continue;
-
-               pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
-               if (pipe == NULL)
-                       continue;
-
-               spin_lock_irqsave(&pipe->irqlock, flags);
-               if (pipe->state == VSP1_PIPELINE_RUNNING)
-                       pipe->state = VSP1_PIPELINE_STOPPING;
-               spin_unlock_irqrestore(&pipe->irqlock, flags);
-       }
-
-       for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
-               struct vsp1_rwpf *wpf = vsp1->wpf[i];
-               struct vsp1_pipeline *pipe;
-
-               if (wpf == NULL)
-                       continue;
-
-               pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
-               if (pipe == NULL)
+       for (i = 0; i < vsp1->info->rpf_count; ++i) {
+               if (!pipe->inputs[i])
                        continue;
 
-               ret = wait_event_timeout(pipe->wq, vsp1_pipeline_stopped(pipe),
-                                        msecs_to_jiffies(500));
-               if (ret == 0)
-                       dev_warn(vsp1->dev, "pipeline %u stop timeout\n",
-                                wpf->entity.index);
+               vsp1_video_frame_end(pipe, pipe->inputs[i]);
        }
-}
-
-void vsp1_pipelines_resume(struct vsp1_device *vsp1)
-{
-       unsigned int i;
-
-       /* Resume pipeline all running pipelines. */
-       for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
-               struct vsp1_rwpf *wpf = vsp1->wpf[i];
-               struct vsp1_pipeline *pipe;
 
-               if (wpf == NULL)
-                       continue;
-
-               pipe = to_vsp1_pipeline(&wpf->entity.subdev.entity);
-               if (pipe == NULL)
-                       continue;
-
-               if (vsp1_pipeline_ready(pipe))
-                       vsp1_pipeline_run(pipe);
-       }
+       if (!pipe->lif)
+               vsp1_video_frame_end(pipe, pipe->output);
 }
 
 /* -----------------------------------------------------------------------------
@@ -787,7 +477,7 @@ vsp1_video_queue_setup(struct vb2_queue *vq,
                     unsigned int sizes[], void *alloc_ctxs[])
 {
        struct vsp1_video *video = vb2_get_drv_priv(vq);
-       const struct v4l2_pix_format_mplane *format = &video->format;
+       const struct v4l2_pix_format_mplane *format = &video->rwpf->format;
        unsigned int i;
 
        if (*nplanes) {
@@ -816,18 +506,20 @@ static int vsp1_video_buffer_prepare(struct vb2_buffer *vb)
 {
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue);
-       struct vsp1_video_buffer *buf = to_vsp1_video_buffer(vbuf);
-       const struct v4l2_pix_format_mplane *format = &video->format;
+       struct vsp1_vb2_buffer *buf = to_vsp1_vb2_buffer(vbuf);
+       const struct v4l2_pix_format_mplane *format = &video->rwpf->format;
        unsigned int i;
 
        if (vb->num_planes < format->num_planes)
                return -EINVAL;
 
+       buf->mem.num_planes = vb->num_planes;
+
        for (i = 0; i < vb->num_planes; ++i) {
-               buf->addr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
-               buf->length[i] = vb2_plane_size(vb, i);
+               buf->mem.addr[i] = vb2_dma_contig_plane_dma_addr(vb, i);
+               buf->mem.length[i] = vb2_plane_size(vb, i);
 
-               if (buf->length[i] < format->plane_fmt[i].sizeimage)
+               if (buf->mem.length[i] < format->plane_fmt[i].sizeimage)
                        return -EINVAL;
        }
 
@@ -839,7 +531,7 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)
        struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
        struct vsp1_video *video = vb2_get_drv_priv(vb->vb2_queue);
        struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity);
-       struct vsp1_video_buffer *buf = to_vsp1_video_buffer(vbuf);
+       struct vsp1_vb2_buffer *buf = to_vsp1_vb2_buffer(vbuf);
        unsigned long flags;
        bool empty;
 
@@ -853,7 +545,7 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)
 
        spin_lock_irqsave(&pipe->irqlock, flags);
 
-       video->ops->queue(video, buf);
+       video->rwpf->ops->set_memory(video->rwpf, &buf->mem);
        pipe->buffers_ready |= 1 << video->pipe_index;
 
        if (vb2_is_streaming(&video->queue) &&
@@ -863,18 +555,6 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)
        spin_unlock_irqrestore(&pipe->irqlock, flags);
 }
 
-static void vsp1_entity_route_setup(struct vsp1_entity *source)
-{
-       struct vsp1_entity *sink;
-
-       if (source->route->reg == 0)
-               return;
-
-       sink = container_of(source->sink, struct vsp1_entity, subdev.entity);
-       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)
 {
        struct vsp1_video *video = vb2_get_drv_priv(vq);
@@ -884,7 +564,7 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
        int ret;
 
        mutex_lock(&pipe->lock);
-       if (pipe->stream_count == pipe->num_video - 1) {
+       if (pipe->stream_count == pipe->num_inputs) {
                if (pipe->uds) {
                        struct vsp1_uds *uds = to_uds(&pipe->uds->subdev);
 
@@ -900,7 +580,7 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
                                struct vsp1_rwpf *rpf =
                                        to_rwpf(&pipe->uds_input->subdev);
 
-                               uds->scale_alpha = rpf->video.fmtinfo->alpha;
+                               uds->scale_alpha = rpf->fmtinfo->alpha;
                        }
                }
 
@@ -931,7 +611,7 @@ static void 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;
+       struct vsp1_vb2_buffer *buffer;
        unsigned long flags;
        int ret;
 
@@ -944,7 +624,7 @@ static void vsp1_video_stop_streaming(struct vb2_queue *vq)
        }
        mutex_unlock(&pipe->lock);
 
-       vsp1_pipeline_cleanup(pipe);
+       vsp1_video_pipeline_cleanup(pipe);
        media_entity_pipeline_stop(&video->video.entity);
 
        /* Remove all buffers from the IRQ queue. */
@@ -1004,7 +684,7 @@ vsp1_video_get_format(struct file *file, void *fh, struct v4l2_format *format)
                return -EINVAL;
 
        mutex_lock(&video->lock);
-       format->fmt.pix_mp = video->format;
+       format->fmt.pix_mp = video->rwpf->format;
        mutex_unlock(&video->lock);
 
        return 0;
@@ -1044,8 +724,8 @@ vsp1_video_set_format(struct file *file, void *fh, struct v4l2_format *format)
                goto done;
        }
 
-       video->format = format->fmt.pix_mp;
-       video->fmtinfo = info;
+       video->rwpf->format = format->fmt.pix_mp;
+       video->rwpf->fmtinfo = info;
 
 done:
        mutex_unlock(&video->lock);
@@ -1085,7 +765,7 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
        if (ret < 0)
                goto err_stop;
 
-       ret = vsp1_pipeline_init(pipe, video);
+       ret = vsp1_video_pipeline_init(pipe, video);
        if (ret < 0)
                goto err_stop;
 
@@ -1097,7 +777,7 @@ vsp1_video_streamon(struct file *file, void *fh, enum v4l2_buf_type type)
        return 0;
 
 err_cleanup:
-       vsp1_pipeline_cleanup(pipe);
+       vsp1_video_pipeline_cleanup(pipe);
 err_stop:
        media_entity_pipeline_stop(&video->video.entity);
        return ret;
@@ -1183,62 +863,64 @@ static struct v4l2_file_operations vsp1_video_fops = {
  * Initialization and Cleanup
  */
 
-int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
+struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1,
+                                    struct vsp1_rwpf *rwpf)
 {
+       struct vsp1_video *video;
        const char *direction;
        int ret;
 
-       switch (video->type) {
-       case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
-               direction = "output";
-               video->pad.flags = MEDIA_PAD_FL_SINK;
-               break;
+       video = devm_kzalloc(vsp1->dev, sizeof(*video), GFP_KERNEL);
+       if (!video)
+               return ERR_PTR(-ENOMEM);
+
+       rwpf->video = video;
+
+       video->vsp1 = vsp1;
+       video->rwpf = rwpf;
 
-       case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
+       if (rwpf->entity.type == VSP1_ENTITY_RPF) {
                direction = "input";
+               video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
                video->pad.flags = MEDIA_PAD_FL_SOURCE;
                video->video.vfl_dir = VFL_DIR_TX;
-               break;
-
-       default:
-               return -EINVAL;
+       } else {
+               direction = "output";
+               video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
+               video->pad.flags = MEDIA_PAD_FL_SINK;
+               video->video.vfl_dir = VFL_DIR_RX;
        }
 
-       video->rwpf = rwpf;
-
        mutex_init(&video->lock);
        spin_lock_init(&video->irqlock);
        INIT_LIST_HEAD(&video->irqqueue);
 
-       mutex_init(&video->pipe.lock);
-       spin_lock_init(&video->pipe.irqlock);
-       INIT_LIST_HEAD(&video->pipe.entities);
-       init_waitqueue_head(&video->pipe.wq);
-       video->pipe.state = VSP1_PIPELINE_STOPPED;
+       vsp1_pipeline_init(&video->pipe);
+       video->pipe.frame_end = vsp1_video_pipeline_frame_end;
 
        /* Initialize the media entity... */
        ret = media_entity_pads_init(&video->video.entity, 1, &video->pad);
        if (ret < 0)
-               return ret;
+               return ERR_PTR(ret);
 
        /* ... and the format ... */
-       video->fmtinfo = vsp1_get_format_info(VSP1_VIDEO_DEF_FORMAT);
-       video->format.pixelformat = video->fmtinfo->fourcc;
-       video->format.colorspace = V4L2_COLORSPACE_SRGB;
-       video->format.field = V4L2_FIELD_NONE;
-       video->format.width = VSP1_VIDEO_DEF_WIDTH;
-       video->format.height = VSP1_VIDEO_DEF_HEIGHT;
-       video->format.num_planes = 1;
-       video->format.plane_fmt[0].bytesperline =
-               video->format.width * video->fmtinfo->bpp[0] / 8;
-       video->format.plane_fmt[0].sizeimage =
-               video->format.plane_fmt[0].bytesperline * video->format.height;
+       rwpf->fmtinfo = vsp1_get_format_info(VSP1_VIDEO_DEF_FORMAT);
+       rwpf->format.pixelformat = rwpf->fmtinfo->fourcc;
+       rwpf->format.colorspace = V4L2_COLORSPACE_SRGB;
+       rwpf->format.field = V4L2_FIELD_NONE;
+       rwpf->format.width = VSP1_VIDEO_DEF_WIDTH;
+       rwpf->format.height = VSP1_VIDEO_DEF_HEIGHT;
+       rwpf->format.num_planes = 1;
+       rwpf->format.plane_fmt[0].bytesperline =
+               rwpf->format.width * rwpf->fmtinfo->bpp[0] / 8;
+       rwpf->format.plane_fmt[0].sizeimage =
+               rwpf->format.plane_fmt[0].bytesperline * rwpf->format.height;
 
        /* ... and the video node... */
        video->video.v4l2_dev = &video->vsp1->v4l2_dev;
        video->video.fops = &vsp1_video_fops;
        snprintf(video->video.name, sizeof(video->video.name), "%s %s",
-                rwpf->subdev.name, direction);
+                rwpf->entity.subdev.name, direction);
        video->video.vfl_type = VFL_TYPE_GRABBER;
        video->video.release = video_device_release_empty;
        video->video.ioctl_ops = &vsp1_video_ioctl_ops;
@@ -1256,7 +938,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
        video->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
        video->queue.lock = &video->lock;
        video->queue.drv_priv = video;
-       video->queue.buf_struct_size = sizeof(struct vsp1_video_buffer);
+       video->queue.buf_struct_size = sizeof(struct vsp1_vb2_buffer);
        video->queue.ops = &vsp1_video_queue_qops;
        video->queue.mem_ops = &vb2_dma_contig_memops;
        video->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
@@ -1274,12 +956,12 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
                goto error;
        }
 
-       return 0;
+       return video;
 
 error:
        vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
        vsp1_video_cleanup(video);
-       return ret;
+       return ERR_PTR(ret);
 }
 
 void vsp1_video_cleanup(struct vsp1_video *video)
index a929aa8..64abd39 100644 (file)
 
 #include <linux/list.h>
 #include <linux/spinlock.h>
-#include <linux/wait.h>
 
-#include <media/media-entity.h>
 #include <media/videobuf2-v4l2.h>
 
-struct vsp1_video;
+#include "vsp1_pipe.h"
+#include "vsp1_rwpf.h"
 
-/*
- * struct vsp1_format_info - VSP1 video format description
- * @mbus: media bus format code
- * @fourcc: V4L2 pixel format FCC identifier
- * @planes: number of planes
- * @bpp: bits per pixel
- * @hwfmt: VSP1 hardware format
- * @swap_yc: the Y and C components are swapped (Y comes before C)
- * @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;
-       unsigned int mbus;
-       unsigned int hwfmt;
-       unsigned int swap;
-       unsigned int planes;
-       unsigned int bpp[3];
-       bool swap_yc;
-       bool swap_uv;
-       unsigned int hsub;
-       unsigned int vsub;
-       bool alpha;
-};
-
-enum vsp1_pipeline_state {
-       VSP1_PIPELINE_STOPPED,
-       VSP1_PIPELINE_RUNNING,
-       VSP1_PIPELINE_STOPPING,
-};
-
-/*
- * struct vsp1_pipeline - A VSP1 hardware pipeline
- * @media: the media pipeline
- * @irqlock: protects the pipeline state
- * @lock: protects the pipeline use count and stream count
- */
-struct vsp1_pipeline {
-       struct media_pipeline pipe;
-
-       spinlock_t irqlock;
-       enum vsp1_pipeline_state state;
-       wait_queue_head_t wq;
-
-       struct mutex lock;
-       unsigned int use_count;
-       unsigned int stream_count;
-       unsigned int buffers_ready;
-
-       unsigned int num_video;
-       unsigned int num_inputs;
-       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;
-};
-
-static inline struct vsp1_pipeline *to_vsp1_pipeline(struct media_entity *e)
-{
-       if (likely(e->pipe))
-               return container_of(e->pipe, struct vsp1_pipeline, pipe);
-       else
-               return NULL;
-}
-
-struct vsp1_video_buffer {
+struct vsp1_vb2_buffer {
        struct vb2_v4l2_buffer buf;
        struct list_head queue;
-
-       dma_addr_t addr[3];
-       unsigned int length[3];
+       struct vsp1_rwpf_memory mem;
 };
 
-static inline struct vsp1_video_buffer *
-to_vsp1_video_buffer(struct vb2_v4l2_buffer *vbuf)
+static inline struct vsp1_vb2_buffer *
+to_vsp1_vb2_buffer(struct vb2_v4l2_buffer *vbuf)
 {
-       return container_of(vbuf, struct vsp1_video_buffer, buf);
+       return container_of(vbuf, struct vsp1_vb2_buffer, buf);
 }
 
-struct vsp1_video_operations {
-       void (*queue)(struct vsp1_video *video, struct vsp1_video_buffer *buf);
-};
-
 struct vsp1_video {
+       struct list_head list;
        struct vsp1_device *vsp1;
-       struct vsp1_entity *rwpf;
-
-       const struct vsp1_video_operations *ops;
+       struct vsp1_rwpf *rwpf;
 
        struct video_device video;
        enum v4l2_buf_type type;
        struct media_pad pad;
 
        struct mutex lock;
-       struct v4l2_pix_format_mplane format;
-       const struct vsp1_format_info *fmtinfo;
 
        struct vsp1_pipeline pipe;
        unsigned int pipe_index;
@@ -140,16 +59,8 @@ static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
        return container_of(vdev, struct vsp1_video, video);
 }
 
-int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf);
+struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1,
+                                    struct vsp1_rwpf *rwpf);
 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);
-
-void vsp1_pipelines_suspend(struct vsp1_device *vsp1);
-void vsp1_pipelines_resume(struct vsp1_device *vsp1);
-
 #endif /* __VSP1_VIDEO_H__ */
index cbf514a..c78d4af 100644 (file)
@@ -34,8 +34,8 @@ static inline u32 vsp1_wpf_read(struct vsp1_rwpf *wpf, u32 reg)
 
 static inline void vsp1_wpf_write(struct vsp1_rwpf *wpf, u32 reg, u32 data)
 {
-       vsp1_write(wpf->entity.vsp1,
-                  reg + wpf->entity.index * VI6_WPF_OFFSET, data);
+       vsp1_mod_write(&wpf->entity,
+                      reg + wpf->entity.index * VI6_WPF_OFFSET, data);
 }
 
 /* -----------------------------------------------------------------------------
@@ -88,7 +88,8 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
 
        if (!enable) {
                vsp1_write(vsp1, VI6_WPF_IRQ_ENB(wpf->entity.index), 0);
-               vsp1_wpf_write(wpf, VI6_WPF_SRCRPF, 0);
+               vsp1_write(vsp1, wpf->entity.index * VI6_WPF_OFFSET +
+                          VI6_WPF_SRCRPF, 0);
                return 0;
        }
 
@@ -97,9 +98,12 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
         * inputs as sub-layers and select the virtual RPF as the master
         * layer.
         */
-       for (i = 0; i < pipe->num_inputs; ++i) {
+       for (i = 0; i < vsp1->info->rpf_count; ++i) {
                struct vsp1_rwpf *input = pipe->inputs[i];
 
+               if (!input)
+                       continue;
+
                srcrpf |= (!pipe->bru && pipe->num_inputs == 1)
                        ? VI6_WPF_SRCRPF_RPF_ACT_MST(input->entity.index)
                        : VI6_WPF_SRCRPF_RPF_ACT_SUB(input->entity.index);
@@ -112,7 +116,7 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
 
        /* Destination stride. */
        if (!pipe->lif) {
-               struct v4l2_pix_format_mplane *format = &wpf->video.format;
+               struct v4l2_pix_format_mplane *format = &wpf->format;
 
                vsp1_wpf_write(wpf, VI6_WPF_DSTM_STRIDE_Y,
                               format->plane_fmt[0].bytesperline);
@@ -130,7 +134,7 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
 
        /* Format */
        if (!pipe->lif) {
-               const struct vsp1_format_info *fmtinfo = wpf->video.fmtinfo;
+               const struct vsp1_format_info *fmtinfo = wpf->fmtinfo;
 
                outfmt = fmtinfo->hwfmt << VI6_WPF_OUTFMT_WRFMT_SHIFT;
 
@@ -151,15 +155,17 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
        /* 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;
+       if (vsp1->info->uapi)
+               mutex_lock(wpf->ctrls.lock);
+       outfmt |= wpf->alpha->cur.val << VI6_WPF_OUTFMT_PDV_SHIFT;
        vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, outfmt);
-       mutex_unlock(wpf->ctrls.lock);
+       if (vsp1->info->uapi)
+               mutex_unlock(wpf->ctrls.lock);
 
-       vsp1_write(vsp1, VI6_DPR_WPF_FPORCH(wpf->entity.index),
-                  VI6_DPR_WPF_FPORCH_FP_WPFN);
+       vsp1_mod_write(&wpf->entity, VI6_DPR_WPF_FPORCH(wpf->entity.index),
+                      VI6_DPR_WPF_FPORCH_FP_WPFN);
 
-       vsp1_write(vsp1, VI6_WPF_WRBCK_CTRL, 0);
+       vsp1_mod_write(&wpf->entity, VI6_WPF_WRBCK_CTRL, 0);
 
        /* Enable interrupts */
        vsp1_write(vsp1, VI6_WPF_IRQ_STA(wpf->entity.index), 0);
@@ -195,20 +201,17 @@ static struct v4l2_subdev_ops wpf_ops = {
  * Video Device Operations
  */
 
-static void wpf_vdev_queue(struct vsp1_video *video,
-                          struct vsp1_video_buffer *buf)
+static void wpf_set_memory(struct vsp1_rwpf *wpf, struct vsp1_rwpf_memory *mem)
 {
-       struct vsp1_rwpf *wpf = container_of(video, struct vsp1_rwpf, video);
-
-       vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_Y, buf->addr[0]);
-       if (buf->buf.vb2_buf.num_planes > 1)
-               vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C0, buf->addr[1]);
-       if (buf->buf.vb2_buf.num_planes > 2)
-               vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C1, buf->addr[2]);
+       vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_Y, mem->addr[0]);
+       if (mem->num_planes > 1)
+               vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C0, mem->addr[1]);
+       if (mem->num_planes > 2)
+               vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C1, mem->addr[2]);
 }
 
-static const struct vsp1_video_operations wpf_vdev_ops = {
-       .queue = wpf_vdev_queue,
+static const struct vsp1_rwpf_operations wpf_vdev_ops = {
+       .set_memory = wpf_set_memory,
 };
 
 /* -----------------------------------------------------------------------------
@@ -218,7 +221,6 @@ static const struct vsp1_video_operations wpf_vdev_ops = {
 struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
 {
        struct v4l2_subdev *subdev;
-       struct vsp1_video *video;
        struct vsp1_rwpf *wpf;
        int ret;
 
@@ -226,6 +228,8 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
        if (wpf == NULL)
                return ERR_PTR(-ENOMEM);
 
+       wpf->ops = &wpf_vdev_ops;
+
        wpf->max_width = WPF_MAX_WIDTH;
        wpf->max_height = WPF_MAX_HEIGHT;
 
@@ -240,7 +244,7 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
        subdev = &wpf->entity.subdev;
        v4l2_subdev_init(subdev, &wpf_ops);
 
-       subdev->entity.ops = &vsp1_media_ops;
+       subdev->entity.ops = &vsp1->media_ops;
        subdev->internal_ops = &vsp1_subdev_internal_ops;
        snprintf(subdev->name, sizeof(subdev->name), "%s wpf.%u",
                 dev_name(vsp1->dev), index);
@@ -251,8 +255,9 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
 
        /* 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->alpha = v4l2_ctrl_new_std(&wpf->ctrls, &wpf_ctrl_ops,
+                                      V4L2_CID_ALPHA_COMPONENT,
+                                      0, 255, 1, 255);
 
        wpf->entity.subdev.ctrl_handler = &wpf->ctrls;
 
@@ -263,48 +268,9 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
                goto error;
        }
 
-       /* Initialize the video device. */
-       video = &wpf->video;
-
-       video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
-       video->vsp1 = vsp1;
-       video->ops = &wpf_vdev_ops;
-
-       ret = vsp1_video_init(video, &wpf->entity);
-       if (ret < 0)
-               goto error;
-
-       wpf->entity.video = video;
-       wpf->entity.sink = &wpf->video.video.entity;
-
        return wpf;
 
 error:
        vsp1_entity_destroy(&wpf->entity);
        return ERR_PTR(ret);
 }
-
-/*
- * vsp1_wpf_create_links() - RPF pads links creation
- * @vsp1: Pointer to VSP1 device
- * @entity: Pointer to VSP1 entity
- *
- * return negative error code or zero on success
- */
-int vsp1_wpf_create_links(struct vsp1_device *vsp1,
-                              struct vsp1_entity *entity)
-{
-       struct vsp1_rwpf *wpf = to_rwpf(&entity->subdev);
-       unsigned int flags;
-
-       /* Connect the video device to the WPF. All connections are immutable
-        * except for the WPF0 source link if a LIF is present.
-        */
-       flags = MEDIA_LNK_FL_ENABLED;
-       if (!(vsp1->pdata.features & VSP1_HAS_LIF) || entity->index != 0)
-               flags |= MEDIA_LNK_FL_IMMUTABLE;
-
-       return media_create_pad_link(&wpf->entity.subdev.entity,
-                                    RWPF_PAD_SOURCE,
-                                    &wpf->video.video.entity, 0, flags);
-}
index 859f0c0..271f725 100644 (file)
@@ -1530,11 +1530,11 @@ static int si476x_radio_probe(struct platform_device *pdev)
        if (si476x_core_has_diversity(radio->core)) {
                si476x_ctrls[SI476X_IDX_DIVERSITY_MODE].def =
                        si476x_phase_diversity_mode_to_idx(radio->core->diversity_mode);
-               si476x_radio_add_new_custom(radio, SI476X_IDX_DIVERSITY_MODE);
+               rval = si476x_radio_add_new_custom(radio, SI476X_IDX_DIVERSITY_MODE);
                if (rval < 0)
                        goto exit;
 
-               si476x_radio_add_new_custom(radio, SI476X_IDX_INTERCHIP_LINK);
+               rval = si476x_radio_add_new_custom(radio, SI476X_IDX_INTERCHIP_LINK);
                if (rval < 0)
                        goto exit;
        }
index 3e08475..4dc2067 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
- *
  */
 
 #include <linux/delay.h>
@@ -226,6 +222,7 @@ void snd_tea575x_set_freq(struct snd_tea575x *tea)
        snd_tea575x_write(tea, tea->val);
        tea->freq = snd_tea575x_val_to_freq(tea, tea->val);
 }
+EXPORT_SYMBOL(snd_tea575x_set_freq);
 
 /*
  * Linux Video interface
@@ -582,25 +579,11 @@ int snd_tea575x_init(struct snd_tea575x *tea, struct module *owner)
 
        return 0;
 }
+EXPORT_SYMBOL(snd_tea575x_init);
 
 void snd_tea575x_exit(struct snd_tea575x *tea)
 {
        video_unregister_device(&tea->vd);
        v4l2_ctrl_handler_free(tea->vd.ctrl_handler);
 }
-
-static int __init alsa_tea575x_module_init(void)
-{
-       return 0;
-}
-
-static void __exit alsa_tea575x_module_exit(void)
-{
-}
-
-module_init(alsa_tea575x_module_init)
-module_exit(alsa_tea575x_module_exit)
-
-EXPORT_SYMBOL(snd_tea575x_init);
 EXPORT_SYMBOL(snd_tea575x_exit);
-EXPORT_SYMBOL(snd_tea575x_set_freq);
index ebc73b0..3f9e6df 100644 (file)
@@ -68,7 +68,7 @@ MODULE_PARM_DESC(default_radio_region, "Region: 0=Europe/US, 1=Japan");
 /* RDS buffer blocks */
 static u32 default_rds_buf = 300;
 module_param(default_rds_buf, uint, 0444);
-MODULE_PARM_DESC(rds_buf, "RDS buffer entries");
+MODULE_PARM_DESC(default_rds_buf, "RDS buffer entries");
 
 /* Radio Nr */
 static u32 radio_nr = -1;
index 18adf58..c96da3a 100644 (file)
@@ -80,17 +80,24 @@ static inline void nvt_clear_reg_bit(struct nvt_dev *nvt, u8 val, u8 reg)
 }
 
 /* enter extended function mode */
-static inline void nvt_efm_enable(struct nvt_dev *nvt)
+static inline int nvt_efm_enable(struct nvt_dev *nvt)
 {
+       if (!request_muxed_region(nvt->cr_efir, 2, NVT_DRIVER_NAME))
+               return -EBUSY;
+
        /* Enabling Extended Function Mode explicitly requires writing 2x */
        outb(EFER_EFM_ENABLE, nvt->cr_efir);
        outb(EFER_EFM_ENABLE, nvt->cr_efir);
+
+       return 0;
 }
 
 /* exit extended function mode */
 static inline void nvt_efm_disable(struct nvt_dev *nvt)
 {
        outb(EFER_EFM_DISABLE, nvt->cr_efir);
+
+       release_region(nvt->cr_efir, 2);
 }
 
 /*
@@ -100,8 +107,25 @@ static inline void nvt_efm_disable(struct nvt_dev *nvt)
  */
 static inline void nvt_select_logical_dev(struct nvt_dev *nvt, u8 ldev)
 {
-       outb(CR_LOGICAL_DEV_SEL, nvt->cr_efir);
-       outb(ldev, nvt->cr_efdr);
+       nvt_cr_write(nvt, ldev, CR_LOGICAL_DEV_SEL);
+}
+
+/* select and enable logical device with setting EFM mode*/
+static inline void nvt_enable_logical_dev(struct nvt_dev *nvt, u8 ldev)
+{
+       nvt_efm_enable(nvt);
+       nvt_select_logical_dev(nvt, ldev);
+       nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
+       nvt_efm_disable(nvt);
+}
+
+/* select and disable logical device with setting EFM mode*/
+static inline void nvt_disable_logical_dev(struct nvt_dev *nvt, u8 ldev)
+{
+       nvt_efm_enable(nvt);
+       nvt_select_logical_dev(nvt, ldev);
+       nvt_cr_write(nvt, LOGICAL_DEV_DISABLE, CR_LOGICAL_DEV_EN);
+       nvt_efm_disable(nvt);
 }
 
 /* write val to cir config register */
@@ -137,6 +161,22 @@ static u8 nvt_cir_wake_reg_read(struct nvt_dev *nvt, u8 offset)
        return val;
 }
 
+/* don't override io address if one is set already */
+static void nvt_set_ioaddr(struct nvt_dev *nvt, unsigned long *ioaddr)
+{
+       unsigned long old_addr;
+
+       old_addr = nvt_cr_read(nvt, CR_CIR_BASE_ADDR_HI) << 8;
+       old_addr |= nvt_cr_read(nvt, CR_CIR_BASE_ADDR_LO);
+
+       if (old_addr)
+               *ioaddr = old_addr;
+       else {
+               nvt_cr_write(nvt, *ioaddr >> 8, CR_CIR_BASE_ADDR_HI);
+               nvt_cr_write(nvt, *ioaddr & 0xff, CR_CIR_BASE_ADDR_LO);
+       }
+}
+
 /* dump current cir register contents */
 static void cir_dump_regs(struct nvt_dev *nvt)
 {
@@ -251,7 +291,7 @@ static inline const char *nvt_find_chip(struct nvt_dev *nvt, int id)
 
 
 /* detect hardware features */
-static void nvt_hw_detect(struct nvt_dev *nvt)
+static int nvt_hw_detect(struct nvt_dev *nvt)
 {
        const char *chip_name;
        int chip_id;
@@ -266,10 +306,17 @@ static void nvt_hw_detect(struct nvt_dev *nvt)
                nvt_efm_enable(nvt);
                nvt->chip_major = nvt_cr_read(nvt, CR_CHIP_ID_HI);
        }
-
        nvt->chip_minor = nvt_cr_read(nvt, CR_CHIP_ID_LO);
 
+       nvt_efm_disable(nvt);
+
        chip_id = nvt->chip_major << 8 | nvt->chip_minor;
+       if (chip_id == NVT_INVALID) {
+               dev_err(&nvt->pdev->dev,
+                       "No device found on either EFM port\n");
+               return -ENODEV;
+       }
+
        chip_name = nvt_find_chip(nvt, chip_id);
 
        /* warn, but still let the driver load, if we don't know this chip */
@@ -282,7 +329,7 @@ static void nvt_hw_detect(struct nvt_dev *nvt)
                         "found %s or compatible: chip id: 0x%02x 0x%02x",
                         chip_name, nvt->chip_major, nvt->chip_minor);
 
-       nvt_efm_disable(nvt);
+       return 0;
 }
 
 static void nvt_cir_ldev_init(struct nvt_dev *nvt)
@@ -305,12 +352,10 @@ static void nvt_cir_ldev_init(struct nvt_dev *nvt)
        val |= psval;
        nvt_cr_write(nvt, val, psreg);
 
-       /* Select CIR logical device and enable */
+       /* Select CIR logical device */
        nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
-       nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
 
-       nvt_cr_write(nvt, nvt->cir_addr >> 8, CR_CIR_BASE_ADDR_HI);
-       nvt_cr_write(nvt, nvt->cir_addr & 0xff, CR_CIR_BASE_ADDR_LO);
+       nvt_set_ioaddr(nvt, &nvt->cir_addr);
 
        nvt_cr_write(nvt, nvt->cir_irq, CR_CIR_IRQ_RSRC);
 
@@ -320,7 +365,7 @@ static void nvt_cir_ldev_init(struct nvt_dev *nvt)
 
 static void nvt_cir_wake_ldev_init(struct nvt_dev *nvt)
 {
-       /* Select ACPI logical device, enable it and CIR Wake */
+       /* Select ACPI logical device and anable it */
        nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI);
        nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
 
@@ -330,12 +375,10 @@ static void nvt_cir_wake_ldev_init(struct nvt_dev *nvt)
        /* enable pme interrupt of cir wakeup event */
        nvt_set_reg_bit(nvt, PME_INTR_CIR_PASS_BIT, CR_ACPI_IRQ_EVENTS2);
 
-       /* Select CIR Wake logical device and enable */
+       /* Select CIR Wake logical device */
        nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE);
-       nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
 
-       nvt_cr_write(nvt, nvt->cir_wake_addr >> 8, CR_CIR_BASE_ADDR_HI);
-       nvt_cr_write(nvt, nvt->cir_wake_addr & 0xff, CR_CIR_BASE_ADDR_LO);
+       nvt_set_ioaddr(nvt, &nvt->cir_wake_addr);
 
        nvt_cr_write(nvt, nvt->cir_wake_irq, CR_CIR_IRQ_RSRC);
 
@@ -355,11 +398,19 @@ static void nvt_clear_cir_fifo(struct nvt_dev *nvt)
 /* clear out the hardware's cir wake rx fifo */
 static void nvt_clear_cir_wake_fifo(struct nvt_dev *nvt)
 {
-       u8 val;
+       u8 val, config;
+
+       config = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRCON);
+
+       /* clearing wake fifo works in learning mode only */
+       nvt_cir_wake_reg_write(nvt, config & ~CIR_WAKE_IRCON_MODE0,
+                              CIR_WAKE_IRCON);
 
        val = nvt_cir_wake_reg_read(nvt, CIR_WAKE_FIFOCON);
        nvt_cir_wake_reg_write(nvt, val | CIR_WAKE_FIFOCON_RXFIFOCLR,
                               CIR_WAKE_FIFOCON);
+
+       nvt_cir_wake_reg_write(nvt, config, CIR_WAKE_IRCON);
 }
 
 /* clear out the hardware's cir tx fifo */
@@ -408,6 +459,9 @@ static void nvt_cir_regs_init(struct nvt_dev *nvt)
 
        /* and finally, enable interrupts */
        nvt_set_cir_iren(nvt);
+
+       /* enable the CIR logical device */
+       nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR);
 }
 
 static void nvt_cir_wake_regs_init(struct nvt_dev *nvt)
@@ -442,10 +496,15 @@ static void nvt_cir_wake_regs_init(struct nvt_dev *nvt)
 
        /* clear any and all stray interrupts */
        nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS);
+
+       /* enable the CIR WAKE logical device */
+       nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR_WAKE);
 }
 
 static void nvt_enable_wake(struct nvt_dev *nvt)
 {
+       unsigned long flags;
+
        nvt_efm_enable(nvt);
 
        nvt_select_logical_dev(nvt, LOGICAL_DEV_ACPI);
@@ -457,12 +516,16 @@ static void nvt_enable_wake(struct nvt_dev *nvt)
 
        nvt_efm_disable(nvt);
 
+       spin_lock_irqsave(&nvt->nvt_lock, flags);
+
        nvt_cir_wake_reg_write(nvt, CIR_WAKE_IRCON_MODE0 | CIR_WAKE_IRCON_RXEN |
                               CIR_WAKE_IRCON_R | CIR_WAKE_IRCON_RXINV |
                               CIR_WAKE_IRCON_SAMPLE_PERIOD_SEL,
                               CIR_WAKE_IRCON);
        nvt_cir_wake_reg_write(nvt, 0xff, CIR_WAKE_IRSTS);
        nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN);
+
+       spin_unlock_irqrestore(&nvt->nvt_lock, flags);
 }
 
 #if 0 /* Currently unused */
@@ -670,7 +733,6 @@ static void nvt_handle_rx_fifo_overrun(struct nvt_dev *nvt)
 /* copy data from hardware rx fifo into driver buffer */
 static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
 {
-       unsigned long flags;
        u8 fifocount, val;
        unsigned int b_idx;
        bool overrun = false;
@@ -689,8 +751,6 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
 
        nvt_dbg("attempting to fetch %u bytes from hw rx fifo", fifocount);
 
-       spin_lock_irqsave(&nvt->nvt_lock, flags);
-
        b_idx = nvt->pkts;
 
        /* This should never happen, but lets check anyway... */
@@ -712,8 +772,6 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt)
 
        if (overrun)
                nvt_handle_rx_fifo_overrun(nvt);
-
-       spin_unlock_irqrestore(&nvt->nvt_lock, flags);
 }
 
 static void nvt_cir_log_irqs(u8 status, u8 iren)
@@ -736,16 +794,13 @@ static void nvt_cir_log_irqs(u8 status, u8 iren)
 static bool nvt_cir_tx_inactive(struct nvt_dev *nvt)
 {
        unsigned long flags;
-       bool tx_inactive;
        u8 tx_state;
 
        spin_lock_irqsave(&nvt->tx.lock, flags);
        tx_state = nvt->tx.tx_state;
        spin_unlock_irqrestore(&nvt->tx.lock, flags);
 
-       tx_inactive = (tx_state == ST_TX_NONE);
-
-       return tx_inactive;
+       return tx_state == ST_TX_NONE;
 }
 
 /* interrupt service routine for incoming and outgoing CIR data */
@@ -757,9 +812,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
 
        nvt_dbg_verbose("%s firing", __func__);
 
-       nvt_efm_enable(nvt);
-       nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
-       nvt_efm_disable(nvt);
+       spin_lock_irqsave(&nvt->nvt_lock, flags);
 
        /*
         * Get IR Status register contents. Write 1 to ack/clear
@@ -775,9 +828,14 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
         *   0: CIR_IRSTS_GH  - Min Length Detected
         */
        status = nvt_cir_reg_read(nvt, CIR_IRSTS);
-       if (!status) {
+       iren = nvt_cir_reg_read(nvt, CIR_IREN);
+
+       /* IRQ may be shared with CIR WAKE, therefore check for each
+        * status bit whether the related interrupt source is enabled
+        */
+       if (!(status & iren)) {
+               spin_unlock_irqrestore(&nvt->nvt_lock, flags);
                nvt_dbg_verbose("%s exiting, IRSTS 0x0", __func__);
-               nvt_cir_reg_write(nvt, 0xff, CIR_IRSTS);
                return IRQ_NONE;
        }
 
@@ -785,13 +843,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
        nvt_cir_reg_write(nvt, status, CIR_IRSTS);
        nvt_cir_reg_write(nvt, 0, CIR_IRSTS);
 
-       /* Interrupt may be shared with CIR Wake, bail if CIR not enabled */
-       iren = nvt_cir_reg_read(nvt, CIR_IREN);
-       if (!iren) {
-               nvt_dbg_verbose("%s exiting, CIR not enabled", __func__);
-               return IRQ_NONE;
-       }
-
        nvt_cir_log_irqs(status, iren);
 
        if (status & CIR_IRSTS_RTR) {
@@ -805,16 +856,14 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)
                if (nvt_cir_tx_inactive(nvt))
                        nvt_get_rx_ir_data(nvt);
 
-               spin_lock_irqsave(&nvt->nvt_lock, flags);
-
                cur_state = nvt->study_state;
 
-               spin_unlock_irqrestore(&nvt->nvt_lock, flags);
-
                if (cur_state == ST_STUDY_NONE)
                        nvt_clear_cir_fifo(nvt);
        }
 
+       spin_unlock_irqrestore(&nvt->nvt_lock, flags);
+
        if (status & CIR_IRSTS_TE)
                nvt_clear_tx_fifo(nvt);
 
@@ -863,9 +912,18 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
 
        nvt_dbg_wake("%s firing", __func__);
 
+       spin_lock_irqsave(&nvt->nvt_lock, flags);
+
        status = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IRSTS);
-       if (!status)
+       iren = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IREN);
+
+       /* IRQ may be shared with CIR, therefore check for each
+        * status bit whether the related interrupt source is enabled
+        */
+       if (!(status & iren)) {
+               spin_unlock_irqrestore(&nvt->nvt_lock, flags);
                return IRQ_NONE;
+       }
 
        if (status & CIR_WAKE_IRSTS_IR_PENDING)
                nvt_clear_cir_wake_fifo(nvt);
@@ -873,13 +931,6 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
        nvt_cir_wake_reg_write(nvt, status, CIR_WAKE_IRSTS);
        nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IRSTS);
 
-       /* Interrupt may be shared with CIR, bail if Wake not enabled */
-       iren = nvt_cir_wake_reg_read(nvt, CIR_WAKE_IREN);
-       if (!iren) {
-               nvt_dbg_wake("%s exiting, wake not enabled", __func__);
-               return IRQ_HANDLED;
-       }
-
        if ((status & CIR_WAKE_IRSTS_PE) &&
            (nvt->wake_state == ST_WAKE_START)) {
                while (nvt_cir_wake_reg_read(nvt, CIR_WAKE_RD_FIFO_ONLY_IDX)) {
@@ -888,39 +939,21 @@ static irqreturn_t nvt_cir_wake_isr(int irq, void *data)
                }
 
                nvt_cir_wake_reg_write(nvt, 0, CIR_WAKE_IREN);
-               spin_lock_irqsave(&nvt->nvt_lock, flags);
                nvt->wake_state = ST_WAKE_FINISH;
-               spin_unlock_irqrestore(&nvt->nvt_lock, flags);
        }
 
+       spin_unlock_irqrestore(&nvt->nvt_lock, flags);
+
        nvt_dbg_wake("%s done", __func__);
        return IRQ_HANDLED;
 }
 
-static void nvt_enable_cir(struct nvt_dev *nvt)
+static void nvt_disable_cir(struct nvt_dev *nvt)
 {
-       /* set function enable flags */
-       nvt_cir_reg_write(nvt, CIR_IRCON_TXEN | CIR_IRCON_RXEN |
-                         CIR_IRCON_RXINV | CIR_IRCON_SAMPLE_PERIOD_SEL,
-                         CIR_IRCON);
-
-       nvt_efm_enable(nvt);
-
-       /* enable the CIR logical device */
-       nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
-       nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
-
-       nvt_efm_disable(nvt);
-
-       /* clear all pending interrupts */
-       nvt_cir_reg_write(nvt, 0xff, CIR_IRSTS);
+       unsigned long flags;
 
-       /* enable interrupts */
-       nvt_set_cir_iren(nvt);
-}
+       spin_lock_irqsave(&nvt->nvt_lock, flags);
 
-static void nvt_disable_cir(struct nvt_dev *nvt)
-{
        /* disable CIR interrupts */
        nvt_cir_reg_write(nvt, 0, CIR_IREN);
 
@@ -934,13 +967,10 @@ static void nvt_disable_cir(struct nvt_dev *nvt)
        nvt_clear_cir_fifo(nvt);
        nvt_clear_tx_fifo(nvt);
 
-       nvt_efm_enable(nvt);
+       spin_unlock_irqrestore(&nvt->nvt_lock, flags);
 
        /* disable the CIR logical device */
-       nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
-       nvt_cr_write(nvt, LOGICAL_DEV_DISABLE, CR_LOGICAL_DEV_EN);
-
-       nvt_efm_disable(nvt);
+       nvt_disable_logical_dev(nvt, LOGICAL_DEV_CIR);
 }
 
 static int nvt_open(struct rc_dev *dev)
@@ -949,20 +979,31 @@ static int nvt_open(struct rc_dev *dev)
        unsigned long flags;
 
        spin_lock_irqsave(&nvt->nvt_lock, flags);
-       nvt_enable_cir(nvt);
+
+       /* set function enable flags */
+       nvt_cir_reg_write(nvt, CIR_IRCON_TXEN | CIR_IRCON_RXEN |
+                         CIR_IRCON_RXINV | CIR_IRCON_SAMPLE_PERIOD_SEL,
+                         CIR_IRCON);
+
+       /* clear all pending interrupts */
+       nvt_cir_reg_write(nvt, 0xff, CIR_IRSTS);
+
+       /* enable interrupts */
+       nvt_set_cir_iren(nvt);
+
        spin_unlock_irqrestore(&nvt->nvt_lock, flags);
 
+       /* enable the CIR logical device */
+       nvt_enable_logical_dev(nvt, LOGICAL_DEV_CIR);
+
        return 0;
 }
 
 static void nvt_close(struct rc_dev *dev)
 {
        struct nvt_dev *nvt = dev->priv;
-       unsigned long flags;
 
-       spin_lock_irqsave(&nvt->nvt_lock, flags);
        nvt_disable_cir(nvt);
-       spin_unlock_irqrestore(&nvt->nvt_lock, flags);
 }
 
 /* Allocate memory, probe hardware, and initialize everything */
@@ -1024,7 +1065,9 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
 
        init_waitqueue_head(&nvt->tx.queue);
 
-       nvt_hw_detect(nvt);
+       ret = nvt_hw_detect(nvt);
+       if (ret)
+               goto exit_free_dev_rdev;
 
        /* Initialize CIR & CIR Wake Logical Devices */
        nvt_efm_enable(nvt);
@@ -1032,7 +1075,10 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
        nvt_cir_wake_ldev_init(nvt);
        nvt_efm_disable(nvt);
 
-       /* Initialize CIR & CIR Wake Config Registers */
+       /*
+        * Initialize CIR & CIR Wake Config Registers
+        * and enable logical devices
+        */
        nvt_cir_regs_init(nvt);
        nvt_cir_wake_regs_init(nvt);
 
@@ -1079,12 +1125,12 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
                goto exit_unregister_device;
 
        if (!devm_request_region(&pdev->dev, nvt->cir_wake_addr,
-                           CIR_IOREG_LENGTH, NVT_DRIVER_NAME))
+                           CIR_IOREG_LENGTH, NVT_DRIVER_NAME "-wake"))
                goto exit_unregister_device;
 
        if (devm_request_irq(&pdev->dev, nvt->cir_wake_irq,
                             nvt_cir_wake_isr, IRQF_SHARED,
-                            NVT_DRIVER_NAME, (void *)nvt))
+                            NVT_DRIVER_NAME "-wake", (void *)nvt))
                goto exit_unregister_device;
 
        device_init_wakeup(&pdev->dev, true);
@@ -1109,15 +1155,11 @@ exit_free_dev_rdev:
 static void nvt_remove(struct pnp_dev *pdev)
 {
        struct nvt_dev *nvt = pnp_get_drvdata(pdev);
-       unsigned long flags;
 
-       spin_lock_irqsave(&nvt->nvt_lock, flags);
-       /* disable CIR */
-       nvt_cir_reg_write(nvt, 0, CIR_IREN);
        nvt_disable_cir(nvt);
+
        /* enable CIR Wake (for IR power-on) */
        nvt_enable_wake(nvt);
-       spin_unlock_irqrestore(&nvt->nvt_lock, flags);
 
        rc_unregister_device(nvt->rdev);
 }
@@ -1129,26 +1171,23 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)
 
        nvt_dbg("%s called", __func__);
 
-       /* zero out misc state tracking */
-       spin_lock_irqsave(&nvt->nvt_lock, flags);
-       nvt->study_state = ST_STUDY_NONE;
-       nvt->wake_state = ST_WAKE_NONE;
-       spin_unlock_irqrestore(&nvt->nvt_lock, flags);
-
        spin_lock_irqsave(&nvt->tx.lock, flags);
        nvt->tx.tx_state = ST_TX_NONE;
        spin_unlock_irqrestore(&nvt->tx.lock, flags);
 
+       spin_lock_irqsave(&nvt->nvt_lock, flags);
+
+       /* zero out misc state tracking */
+       nvt->study_state = ST_STUDY_NONE;
+       nvt->wake_state = ST_WAKE_NONE;
+
        /* disable all CIR interrupts */
        nvt_cir_reg_write(nvt, 0, CIR_IREN);
 
-       nvt_efm_enable(nvt);
+       spin_unlock_irqrestore(&nvt->nvt_lock, flags);
 
        /* disable cir logical dev */
-       nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
-       nvt_cr_write(nvt, LOGICAL_DEV_DISABLE, CR_LOGICAL_DEV_EN);
-
-       nvt_efm_disable(nvt);
+       nvt_disable_logical_dev(nvt, LOGICAL_DEV_CIR);
 
        /* make sure wake is enabled */
        nvt_enable_wake(nvt);
@@ -1162,16 +1201,6 @@ static int nvt_resume(struct pnp_dev *pdev)
 
        nvt_dbg("%s called", __func__);
 
-       /* open interrupt */
-       nvt_set_cir_iren(nvt);
-
-       /* Enable CIR logical device */
-       nvt_efm_enable(nvt);
-       nvt_select_logical_dev(nvt, LOGICAL_DEV_CIR);
-       nvt_cr_write(nvt, LOGICAL_DEV_ENABLE, CR_LOGICAL_DEV_EN);
-
-       nvt_efm_disable(nvt);
-
        nvt_cir_regs_init(nvt);
        nvt_cir_wake_regs_init(nvt);
 
@@ -1181,6 +1210,7 @@ static int nvt_resume(struct pnp_dev *pdev)
 static void nvt_shutdown(struct pnp_dev *pdev)
 {
        struct nvt_dev *nvt = pnp_get_drvdata(pdev);
+
        nvt_enable_wake(nvt);
 }
 
index 0ad15d3..4a5650d 100644 (file)
@@ -68,7 +68,8 @@ enum nvt_chip_ver {
        NVT_W83667HG    = 0xa510,
        NVT_6775F       = 0xb470,
        NVT_6776F       = 0xc330,
-       NVT_6779D       = 0xc560
+       NVT_6779D       = 0xc560,
+       NVT_INVALID     = 0xffff,
 };
 
 struct nvt_chip {
@@ -157,8 +158,8 @@ struct nvt_dev {
 /* total length of CIR and CIR WAKE */
 #define CIR_IOREG_LENGTH       0x0f
 
-/* RX limit length, 8 high bits for SLCH, 8 low bits for SLCL (0x7d0 = 2000) */
-#define CIR_RX_LIMIT_COUNT     0x7d0
+/* RX limit length, 8 high bits for SLCH, 8 low bits for SLCL */
+#define CIR_RX_LIMIT_COUNT  (IR_DEFAULT_TIMEOUT / US_TO_NS(SAMPLE_PERIOD))
 
 /* CIR Regs */
 #define CIR_IRCON      0x00
@@ -292,10 +293,7 @@ struct nvt_dev {
 #define CIR_WAKE_IREN_RTR              0x40
 #define CIR_WAKE_IREN_PE               0x20
 #define CIR_WAKE_IREN_RFO              0x10
-#define CIR_WAKE_IREN_TE               0x08
-#define CIR_WAKE_IREN_TTR              0x04
-#define CIR_WAKE_IREN_TFU              0x02
-#define CIR_WAKE_IREN_GH               0x01
+#define CIR_WAKE_IREN_GH               0x08
 
 /* CIR WAKE FIFOCON settings */
 #define CIR_WAKE_FIFOCON_RXFIFOCLR     0x08
index 7359f3d..585d5e5 100644 (file)
@@ -16,6 +16,9 @@
 #ifndef _RC_CORE_PRIV
 #define _RC_CORE_PRIV
 
+/* Define the max number of pulse/space transitions to buffer */
+#define        MAX_IR_EVENT_SIZE       512
+
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <media/rc-core.h>
@@ -35,7 +38,8 @@ struct ir_raw_event_ctrl {
        struct list_head                list;           /* to keep track of raw clients */
        struct task_struct              *thread;
        spinlock_t                      lock;
-       struct kfifo_rec_ptr_1          kfifo;          /* fifo for the pulse/space durations */
+       /* fifo for the pulse/space durations */
+       DECLARE_KFIFO(kfifo, struct ir_raw_event, MAX_IR_EVENT_SIZE);
        ktime_t                         last_event;     /* when last event occurred */
        enum raw_event_type             last_type;      /* last event type */
        struct rc_dev                   *dev;           /* pointer to the parent rc_dev */
index c69807f..144304c 100644 (file)
@@ -20,9 +20,6 @@
 #include <linux/freezer.h>
 #include "rc-core-priv.h"
 
-/* Define the max number of pulse/space transitions to buffer */
-#define MAX_IR_EVENT_SIZE      512
-
 /* Used to keep track of IR raw clients, protected by ir_raw_handler_lock */
 static LIST_HEAD(ir_raw_client_list);
 
@@ -36,14 +33,12 @@ static int ir_raw_event_thread(void *data)
        struct ir_raw_event ev;
        struct ir_raw_handler *handler;
        struct ir_raw_event_ctrl *raw = (struct ir_raw_event_ctrl *)data;
-       int retval;
 
        while (!kthread_should_stop()) {
 
                spin_lock_irq(&raw->lock);
-               retval = kfifo_len(&raw->kfifo);
 
-               if (retval < sizeof(ev)) {
+               if (!kfifo_len(&raw->kfifo)) {
                        set_current_state(TASK_INTERRUPTIBLE);
 
                        if (kthread_should_stop())
@@ -54,7 +49,8 @@ static int ir_raw_event_thread(void *data)
                        continue;
                }
 
-               retval = kfifo_out(&raw->kfifo, &ev, sizeof(ev));
+               if(!kfifo_out(&raw->kfifo, &ev, 1))
+                       dev_err(&raw->dev->dev, "IR event FIFO is empty!\n");
                spin_unlock_irq(&raw->lock);
 
                mutex_lock(&ir_raw_handler_lock);
@@ -87,8 +83,10 @@ int ir_raw_event_store(struct rc_dev *dev, struct ir_raw_event *ev)
        IR_dprintk(2, "sample: (%05dus %s)\n",
                   TO_US(ev->duration), TO_STR(ev->pulse));
 
-       if (kfifo_in(&dev->raw->kfifo, ev, sizeof(*ev)) != sizeof(*ev))
-               return -ENOMEM;
+       if (!kfifo_put(&dev->raw->kfifo, *ev)) {
+               dev_err(&dev->dev, "IR event FIFO is full!\n");
+               return -ENOSPC;
+       }
 
        return 0;
 }
@@ -273,11 +271,7 @@ int ir_raw_event_register(struct rc_dev *dev)
 
        dev->raw->dev = dev;
        dev->change_protocol = change_protocol;
-       rc = kfifo_alloc(&dev->raw->kfifo,
-                        sizeof(struct ir_raw_event) * MAX_IR_EVENT_SIZE,
-                        GFP_KERNEL);
-       if (rc < 0)
-               goto out;
+       INIT_KFIFO(dev->raw->kfifo);
 
        spin_lock_init(&dev->raw->lock);
        dev->raw->thread = kthread_run(ir_raw_event_thread, dev->raw,
@@ -319,7 +313,6 @@ void ir_raw_event_unregister(struct rc_dev *dev)
                        handler->raw_unregister(dev);
        mutex_unlock(&ir_raw_handler_lock);
 
-       kfifo_free(&dev->raw->kfifo);
        kfree(dev->raw);
        dev->raw = NULL;
 }
index 1042fa3..dcf20d9 100644 (file)
@@ -723,12 +723,18 @@ int rc_open(struct rc_dev *rdev)
                return -EINVAL;
 
        mutex_lock(&rdev->lock);
+       if (!rdev->initialized) {
+               rval = -EINVAL;
+               goto unlock;
+       }
+
        if (!rdev->users++ && rdev->open != NULL)
                rval = rdev->open(rdev);
 
        if (rval)
                rdev->users--;
 
+unlock:
        mutex_unlock(&rdev->lock);
 
        return rval;
@@ -874,6 +880,10 @@ static ssize_t show_protocols(struct device *device,
                return -EINVAL;
 
        mutex_lock(&dev->lock);
+       if (!dev->initialized) {
+               mutex_unlock(&dev->lock);
+               return -EINVAL;
+       }
 
        if (fattr->type == RC_FILTER_NORMAL) {
                enabled = dev->enabled_protocols;
@@ -1074,6 +1084,10 @@ static ssize_t store_protocols(struct device *device,
        }
 
        mutex_lock(&dev->lock);
+       if (!dev->initialized) {
+               rc = -EINVAL;
+               goto out;
+       }
 
        old_protocols = *current_protocols;
        new_protocols = old_protocols;
@@ -1154,12 +1168,17 @@ static ssize_t show_filter(struct device *device,
        if (!dev)
                return -EINVAL;
 
+       mutex_lock(&dev->lock);
+       if (!dev->initialized) {
+               mutex_unlock(&dev->lock);
+               return -EINVAL;
+       }
+
        if (fattr->type == RC_FILTER_NORMAL)
                filter = &dev->scancode_filter;
        else
                filter = &dev->scancode_wakeup_filter;
 
-       mutex_lock(&dev->lock);
        if (fattr->mask)
                val = filter->mask;
        else
@@ -1222,6 +1241,10 @@ static ssize_t store_filter(struct device *device,
                return -EINVAL;
 
        mutex_lock(&dev->lock);
+       if (!dev->initialized) {
+               ret = -EINVAL;
+               goto unlock;
+       }
 
        new_filter = *filter;
        if (fattr->mask)
@@ -1419,14 +1442,6 @@ int rc_register_device(struct rc_dev *dev)
                dev->sysfs_groups[attr++] = &rc_dev_wakeup_protocol_attr_grp;
        dev->sysfs_groups[attr++] = NULL;
 
-       /*
-        * Take the lock here, as the device sysfs node will appear
-        * when device_add() is called, which may trigger an ir-keytable udev
-        * rule, which will in turn call show_protocols and access
-        * dev->enabled_protocols before it has been initialized.
-        */
-       mutex_lock(&dev->lock);
-
        rc = device_add(&dev->dev);
        if (rc)
                goto out_unlock;
@@ -1440,13 +1455,7 @@ int rc_register_device(struct rc_dev *dev)
        dev->input_dev->phys = dev->input_phys;
        dev->input_dev->name = dev->input_name;
 
-       /* input_register_device can call ir_open, so unlock mutex here */
-       mutex_unlock(&dev->lock);
-
        rc = input_register_device(dev->input_dev);
-
-       mutex_lock(&dev->lock);
-
        if (rc)
                goto out_table;
 
@@ -1475,10 +1484,7 @@ int rc_register_device(struct rc_dev *dev)
                        request_module_nowait("ir-lirc-codec");
                        raw_init = true;
                }
-               /* calls ir_register_device so unlock mutex here*/
-               mutex_unlock(&dev->lock);
                rc = ir_raw_event_register(dev);
-               mutex_lock(&dev->lock);
                if (rc < 0)
                        goto out_input;
        }
@@ -1491,6 +1497,8 @@ int rc_register_device(struct rc_dev *dev)
                dev->enabled_protocols = rc_type;
        }
 
+       mutex_lock(&dev->lock);
+       dev->initialized = true;
        mutex_unlock(&dev->lock);
 
        IR_dprintk(1, "Registered rc%u (driver: %s, remote: %s, mode %s)\n",
@@ -1512,7 +1520,6 @@ out_table:
 out_dev:
        device_del(&dev->dev);
 out_unlock:
-       mutex_unlock(&dev->lock);
        ida_simple_remove(&rc_ida, minor);
        return rc;
 }
index 504bfbc..9f3e0fd 100644 (file)
@@ -461,13 +461,12 @@ static int m88rs6000t_sleep(struct dvb_frontend *fe)
        dev_dbg(&dev->client->dev, "%s:\n", __func__);
 
        ret = regmap_write(dev->regmap, 0x07, 0x6d);
-       if (ret)
-               goto err;
-       usleep_range(5000, 10000);
-err:
-       if (ret)
+       if (ret) {
                dev_dbg(&dev->client->dev, "failed=%d\n", ret);
-       return ret;
+               return ret;
+       }
+       usleep_range(5000, 10000);
+       return 0;
 }
 
 static int m88rs6000t_get_frequency(struct dvb_frontend *fe, u32 *frequency)
index a7a8452..6ab35e3 100644 (file)
@@ -1295,7 +1295,7 @@ static int generic_set_freq(struct dvb_frontend *fe,
                            v4l2_std_id std, u32 delsys)
 {
        struct r820t_priv               *priv = fe->tuner_priv;
-       int                             rc = -EINVAL;
+       int                             rc;
        u32                             lo_freq;
 
        tuner_dbg("should set frequency to %d kHz, bw %d MHz\n",
index 0e1ca2b..243ac38 100644 (file)
@@ -364,8 +364,8 @@ static int si2157_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
 static const struct dvb_tuner_ops si2157_ops = {
        .info = {
                .name           = "Silicon Labs Si2146/2147/2148/2157/2158",
-               .frequency_min  = 55000000,
-               .frequency_max  = 862000000,
+               .frequency_min  = 42000000,
+               .frequency_max  = 870000000,
        },
 
        .init = si2157_init,
@@ -403,7 +403,7 @@ err:
 }
 
 static int si2157_probe(struct i2c_client *client,
-               const struct i2c_device_id *id)
+                       const struct i2c_device_id *id)
 {
        struct si2157_config *cfg = client->dev.platform_data;
        struct dvb_frontend *fe = cfg->fe;
@@ -438,6 +438,31 @@ static int si2157_probe(struct i2c_client *client,
        memcpy(&fe->ops.tuner_ops, &si2157_ops, sizeof(struct dvb_tuner_ops));
        fe->tuner_priv = client;
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+       if (cfg->mdev) {
+               dev->mdev = cfg->mdev;
+
+               dev->ent.name = KBUILD_MODNAME;
+               dev->ent.function = MEDIA_ENT_F_TUNER;
+
+               dev->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
+               dev->pad[TUNER_PAD_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
+               dev->pad[TUNER_PAD_AUD_OUT].flags = MEDIA_PAD_FL_SOURCE;
+
+               ret = media_entity_pads_init(&dev->ent, TUNER_NUM_PADS,
+                                            &dev->pad[0]);
+
+               if (ret)
+                       goto err_kfree;
+
+               ret = media_device_register_entity(cfg->mdev, &dev->ent);
+               if (ret) {
+                       media_entity_cleanup(&dev->ent);
+                       goto err_kfree;
+               }
+       }
+#endif
+
        dev_info(&client->dev, "Silicon Labs %s successfully attached\n",
                        dev->chiptype == SI2157_CHIPTYPE_SI2146 ?
                        "Si2146" : "Si2147/2148/2157/2158");
@@ -458,6 +483,14 @@ static int si2157_remove(struct i2c_client *client)
 
        dev_dbg(&client->dev, "\n");
 
+       /* stop statistics polling */
+       cancel_delayed_work_sync(&dev->stat_work);
+
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+       if (dev->mdev)
+               media_device_unregister_entity(&dev->ent);
+#endif
+
        memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops));
        fe->tuner_priv = NULL;
        kfree(dev);
index 4db97ab..5f1a60b 100644 (file)
@@ -18,6 +18,7 @@
 #define SI2157_H
 
 #include <linux/kconfig.h>
+#include <media/media-device.h>
 #include "dvb_frontend.h"
 
 /*
@@ -30,6 +31,10 @@ struct si2157_config {
         */
        struct dvb_frontend *fe;
 
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       struct media_device *mdev;
+#endif
+
        /*
         * Spectral Inversion
         */
index ecc463d..589d558 100644 (file)
@@ -18,6 +18,7 @@
 #define SI2157_PRIV_H
 
 #include <linux/firmware.h>
+#include <media/v4l2-mc.h>
 #include "si2157.h"
 
 /* state struct */
@@ -31,6 +32,13 @@ struct si2157_dev {
        u8 if_port;
        u32 if_frequency;
        struct delayed_work stat_work;
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       struct media_device     *mdev;
+       struct media_entity     ent;
+       struct media_pad        pad[TUNER_NUM_PADS];
+#endif
+
 };
 
 #define SI2157_CHIPTYPE_SI2157 0
index 4e941f0..317ef63 100644 (file)
@@ -1403,11 +1403,14 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)
         * in order to avoid troubles during device release.
         */
        kfree(priv->ctrl.fname);
+       priv->ctrl.fname = NULL;
        memcpy(&priv->ctrl, p, sizeof(priv->ctrl));
        if (p->fname) {
                priv->ctrl.fname = kstrdup(p->fname, GFP_KERNEL);
-               if (priv->ctrl.fname == NULL)
+               if (priv->ctrl.fname == NULL) {
                        rc = -ENOMEM;
+                       goto unlock;
+               }
        }
 
        /*
@@ -1439,6 +1442,7 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg)
                } else
                        priv->state = XC2028_WAITING_FIRMWARE;
        }
+unlock:
        mutex_unlock(&priv->lock);
 
        return rc;
index aee2d76..8def19d 100644 (file)
@@ -52,7 +52,7 @@ struct as10x_bus_adapter_t {
        struct as10x_cmd_t *cmd, *rsp;
 
        /* bus adapter private ops callback */
-       struct as102_priv_ops_t *ops;
+       const struct as102_priv_ops_t *ops;
 };
 
 struct as102_dev_t {
index 3f66906..0e8030c 100644 (file)
@@ -189,7 +189,7 @@ static int as102_read_ep2(struct as10x_bus_adapter_t *bus_adap,
        return actual_len;
 }
 
-static struct as102_priv_ops_t as102_priv_ops = {
+static const struct as102_priv_ops_t as102_priv_ops = {
        .upload_fw_pkt  = as102_send_ep1,
        .xfer_cmd       = as102_usb_xfer_cmd,
        .as102_read_ep2 = as102_read_ep2,
index 9e29e70..7cafe4d 100644 (file)
@@ -143,7 +143,7 @@ static void au0828_unregister_media_device(struct au0828_dev *dev)
 #endif
 }
 
-static void au0828_usb_release(struct au0828_dev *dev)
+void au0828_usb_release(struct au0828_dev *dev)
 {
        au0828_unregister_media_device(dev);
 
@@ -153,33 +153,6 @@ static void au0828_usb_release(struct au0828_dev *dev)
        kfree(dev);
 }
 
-#ifdef CONFIG_VIDEO_AU0828_V4L2
-
-static void au0828_usb_v4l2_media_release(struct au0828_dev *dev)
-{
-#ifdef CONFIG_MEDIA_CONTROLLER
-       int i;
-
-       for (i = 0; i < AU0828_MAX_INPUT; i++) {
-               if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
-                       return;
-               media_device_unregister_entity(&dev->input_ent[i]);
-       }
-#endif
-}
-
-static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
-{
-       struct au0828_dev *dev =
-               container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
-
-       v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
-       v4l2_device_unregister(&dev->v4l2_dev);
-       au0828_usb_v4l2_media_release(dev);
-       au0828_usb_release(dev);
-}
-#endif
-
 static void au0828_usb_disconnect(struct usb_interface *interface)
 {
        struct au0828_dev *dev = usb_get_intfdata(interface);
@@ -202,18 +175,13 @@ static void au0828_usb_disconnect(struct usb_interface *interface)
        mutex_lock(&dev->mutex);
        dev->usbdev = NULL;
        mutex_unlock(&dev->mutex);
-#ifdef CONFIG_VIDEO_AU0828_V4L2
-       if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED) {
-               au0828_analog_unregister(dev);
-               v4l2_device_disconnect(&dev->v4l2_dev);
-               v4l2_device_put(&dev->v4l2_dev);
+       if (au0828_analog_unregister(dev)) {
                /*
                 * No need to call au0828_usb_release() if V4L2 is enabled,
                 * as this is already called via au0828_usb_v4l2_release()
                 */
                return;
        }
-#endif
        au0828_usb_release(dev);
 }
 
@@ -223,23 +191,12 @@ static int au0828_media_device_init(struct au0828_dev *dev,
 #ifdef CONFIG_MEDIA_CONTROLLER
        struct media_device *mdev;
 
-       mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
-       if (!mdev)
-               return -ENOMEM;
-
-       mdev->dev = &udev->dev;
-
        if (!dev->board.name)
-               strlcpy(mdev->model, "unknown au0828", sizeof(mdev->model));
+               mdev = v4l2_mc_usb_media_device_init(udev, "unknown au0828");
        else
-               strlcpy(mdev->model, dev->board.name, sizeof(mdev->model));
-       if (udev->serial)
-               strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
-       strcpy(mdev->bus_info, udev->devpath);
-       mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
-       mdev->driver_version = LINUX_VERSION_CODE;
-
-       media_device_init(mdev);
+               mdev = v4l2_mc_usb_media_device_init(udev, dev->board.name);
+       if (!mdev)
+               return -ENOMEM;
 
        dev->media_dev = mdev;
 #endif
@@ -247,83 +204,6 @@ static int au0828_media_device_init(struct au0828_dev *dev,
 }
 
 
-static int au0828_create_media_graph(struct au0828_dev *dev)
-{
-#ifdef CONFIG_MEDIA_CONTROLLER
-       struct media_device *mdev = dev->media_dev;
-       struct media_entity *entity;
-       struct media_entity *tuner = NULL, *decoder = NULL;
-       int i, ret;
-
-       if (!mdev)
-               return 0;
-
-       media_device_for_each_entity(entity, mdev) {
-               switch (entity->function) {
-               case MEDIA_ENT_F_TUNER:
-                       tuner = entity;
-                       break;
-               case MEDIA_ENT_F_ATV_DECODER:
-                       decoder = entity;
-                       break;
-               }
-       }
-
-       /* Analog setup, using tuner as a link */
-
-       /* Something bad happened! */
-       if (!decoder)
-               return -EINVAL;
-
-       if (tuner) {
-               ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT,
-                                           decoder, 0,
-                                           MEDIA_LNK_FL_ENABLED);
-               if (ret)
-                       return ret;
-       }
-       ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
-                                   MEDIA_LNK_FL_ENABLED);
-       if (ret)
-               return ret;
-       ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
-                                   MEDIA_LNK_FL_ENABLED);
-       if (ret)
-               return ret;
-
-       for (i = 0; i < AU0828_MAX_INPUT; i++) {
-               struct media_entity *ent = &dev->input_ent[i];
-
-               if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
-                       break;
-
-               switch (AUVI_INPUT(i).type) {
-               case AU0828_VMUX_CABLE:
-               case AU0828_VMUX_TELEVISION:
-               case AU0828_VMUX_DVB:
-                       if (!tuner)
-                               break;
-
-                       ret = media_create_pad_link(ent, 0, tuner,
-                                                   TUNER_PAD_RF_INPUT,
-                                                   MEDIA_LNK_FL_ENABLED);
-                       if (ret)
-                               return ret;
-                       break;
-               case AU0828_VMUX_COMPOSITE:
-               case AU0828_VMUX_SVIDEO:
-               default: /* AU0828_VMUX_DEBUG */
-                       /* FIXME: fix the decoder PAD */
-                       ret = media_create_pad_link(ent, 0, decoder, 0, 0);
-                       if (ret)
-                               return ret;
-                       break;
-               }
-       }
-#endif
-       return 0;
-}
-
 static int au0828_usb_probe(struct usb_interface *interface,
        const struct usb_device_id *id)
 {
@@ -378,32 +258,13 @@ static int au0828_usb_probe(struct usb_interface *interface,
                return retval;
        }
 
-#ifdef CONFIG_VIDEO_AU0828_V4L2
-       dev->v4l2_dev.release = au0828_usb_v4l2_release;
-
-       /* Create the v4l2_device */
-#ifdef CONFIG_MEDIA_CONTROLLER
-       dev->v4l2_dev.mdev = dev->media_dev;
-#endif
-       retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
+       retval = au0828_v4l2_device_register(interface, dev);
        if (retval) {
-               pr_err("%s() v4l2_device_register failed\n",
-                      __func__);
+               au0828_usb_v4l2_media_release(dev);
                mutex_unlock(&dev->lock);
                kfree(dev);
                return retval;
        }
-       /* This control handler will inherit the controls from au8522 */
-       retval = v4l2_ctrl_handler_init(&dev->v4l2_ctrl_hdl, 4);
-       if (retval) {
-               pr_err("%s() v4l2_ctrl_handler_init failed\n",
-                      __func__);
-               mutex_unlock(&dev->lock);
-               kfree(dev);
-               return retval;
-       }
-       dev->v4l2_dev.ctrl_handler = &dev->v4l2_ctrl_hdl;
-#endif
 
        /* Power Up the bridge */
        au0828_write(dev, REG_600, 1 << 4);
@@ -417,11 +278,13 @@ static int au0828_usb_probe(struct usb_interface *interface,
        /* Setup */
        au0828_card_setup(dev);
 
-#ifdef CONFIG_VIDEO_AU0828_V4L2
        /* Analog TV */
-       if (AUVI_INPUT(0).type != AU0828_VMUX_UNDEFINED)
-               au0828_analog_register(dev, interface);
-#endif
+       retval = au0828_analog_register(dev, interface);
+       if (retval) {
+               pr_err("%s() au0282_dev_register failed to register on V4L2\n",
+                       __func__);
+               goto done;
+       }
 
        /* Digital TV */
        retval = au0828_dvb_register(dev);
@@ -443,13 +306,6 @@ static int au0828_usb_probe(struct usb_interface *interface,
 
        mutex_unlock(&dev->lock);
 
-       retval = au0828_create_media_graph(dev);
-       if (retval) {
-               pr_err("%s() au0282_dev_register failed to create graph\n",
-                      __func__);
-               goto done;
-       }
-
 #ifdef CONFIG_MEDIA_CONTROLLER
        retval = media_device_register(dev->media_dev);
 #endif
index 94363a3..0e174e8 100644 (file)
@@ -181,7 +181,7 @@ static int stop_urb_transfer(struct au0828_dev *dev)
 static int start_urb_transfer(struct au0828_dev *dev)
 {
        struct urb *purb;
-       int i, ret = -ENOMEM;
+       int i, ret;
 
        dprintk(2, "%s()\n", __func__);
 
@@ -194,7 +194,7 @@ static int start_urb_transfer(struct au0828_dev *dev)
 
                dev->urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
                if (!dev->urbs[i])
-                       goto err;
+                       return -ENOMEM;
 
                purb = dev->urbs[i];
 
@@ -207,9 +207,10 @@ static int start_urb_transfer(struct au0828_dev *dev)
                if (!purb->transfer_buffer) {
                        usb_free_urb(purb);
                        dev->urbs[i] = NULL;
+                       ret = -ENOMEM;
                        pr_err("%s: failed big buffer allocation, err = %d\n",
                               __func__, ret);
-                       goto err;
+                       return ret;
                }
 
                purb->status = -EINPROGRESS;
@@ -235,10 +236,7 @@ static int start_urb_transfer(struct au0828_dev *dev)
        }
 
        dev->urb_streaming = true;
-       ret = 0;
-
-err:
-       return ret;
+       return 0;
 }
 
 static void au0828_start_transport(struct au0828_dev *dev)
index 8c54fd2..2fc2b29 100644 (file)
@@ -638,6 +638,142 @@ static inline int au0828_isoc_copy(struct au0828_dev *dev, struct urb *urb)
        return rc;
 }
 
+void au0828_usb_v4l2_media_release(struct au0828_dev *dev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+       int i;
+
+       for (i = 0; i < AU0828_MAX_INPUT; i++) {
+               if (AUVI_INPUT(i).type == AU0828_VMUX_UNDEFINED)
+                       return;
+               media_device_unregister_entity(&dev->input_ent[i]);
+       }
+#endif
+}
+
+static int au0828_create_media_graph(struct au0828_dev *dev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct media_device *mdev = dev->media_dev;
+       struct media_entity *entity;
+       struct media_entity *tuner = NULL, *decoder = NULL;
+       int i, ret;
+
+       if (!mdev)
+               return 0;
+
+       media_device_for_each_entity(entity, mdev) {
+               switch (entity->function) {
+               case MEDIA_ENT_F_TUNER:
+                       tuner = entity;
+                       break;
+               case MEDIA_ENT_F_ATV_DECODER:
+                       decoder = entity;
+                       break;
+               }
+       }
+
+       /* Analog setup, using tuner as a link */
+
+       /* Something bad happened! */
+       if (!decoder)
+               return -EINVAL;
+
+       if (tuner) {
+               ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
+                                           decoder, 0,
+                                           MEDIA_LNK_FL_ENABLED);
+               if (ret)
+                       return ret;
+       }
+       ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
+                                   MEDIA_LNK_FL_ENABLED);
+       if (ret)
+               return ret;
+       ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
+                                   MEDIA_LNK_FL_ENABLED);
+       if (ret)
+               return ret;
+
+       for (i = 0; i < AU0828_MAX_INPUT; i++) {
+               struct media_entity *ent = &dev->input_ent[i];
+
+               switch (AUVI_INPUT(i).type) {
+               case AU0828_VMUX_UNDEFINED:
+                       break;
+               case AU0828_VMUX_CABLE:
+               case AU0828_VMUX_TELEVISION:
+               case AU0828_VMUX_DVB:
+                       if (!tuner)
+                               break;
+
+                       ret = media_create_pad_link(ent, 0, tuner,
+                                                   TUNER_PAD_RF_INPUT,
+                                                   MEDIA_LNK_FL_ENABLED);
+                       if (ret)
+                               return ret;
+                       break;
+               case AU0828_VMUX_COMPOSITE:
+               case AU0828_VMUX_SVIDEO:
+                       /* FIXME: fix the decoder PAD */
+                       ret = media_create_pad_link(ent, 0, decoder, 0, 0);
+                       if (ret)
+                               return ret;
+                       break;
+               }
+       }
+#endif
+       return 0;
+}
+
+static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
+{
+       struct au0828_dev *dev =
+               container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
+
+       v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
+       v4l2_device_unregister(&dev->v4l2_dev);
+       au0828_usb_v4l2_media_release(dev);
+       au0828_usb_release(dev);
+}
+
+int au0828_v4l2_device_register(struct usb_interface *interface,
+                               struct au0828_dev *dev)
+{
+       int retval;
+
+       if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
+               return 0;
+
+       /* Create the v4l2_device */
+#ifdef CONFIG_MEDIA_CONTROLLER
+       dev->v4l2_dev.mdev = dev->media_dev;
+#endif
+       retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
+       if (retval) {
+               pr_err("%s() v4l2_device_register failed\n",
+                      __func__);
+               mutex_unlock(&dev->lock);
+               kfree(dev);
+               return retval;
+       }
+
+       dev->v4l2_dev.release = au0828_usb_v4l2_release;
+
+       /* This control handler will inherit the controls from au8522 */
+       retval = v4l2_ctrl_handler_init(&dev->v4l2_ctrl_hdl, 4);
+       if (retval) {
+               pr_err("%s() v4l2_ctrl_handler_init failed\n",
+                      __func__);
+               mutex_unlock(&dev->lock);
+               kfree(dev);
+               return retval;
+       }
+       dev->v4l2_dev.ctrl_handler = &dev->v4l2_ctrl_hdl;
+
+       return 0;
+}
+
 static int au0828_enable_analog_tuner(struct au0828_dev *dev)
 {
 #ifdef CONFIG_MEDIA_CONTROLLER
@@ -949,13 +1085,23 @@ static struct vb2_ops au0828_video_qops = {
  * au0828_analog_unregister
  * unregister v4l2 devices
  */
-void au0828_analog_unregister(struct au0828_dev *dev)
+int au0828_analog_unregister(struct au0828_dev *dev)
 {
        dprintk(1, "au0828_analog_unregister called\n");
+
+       /* No analog TV */
+       if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
+               return 0;
+
        mutex_lock(&au0828_sysfs_lock);
        video_unregister_device(&dev->vdev);
        video_unregister_device(&dev->vbi_dev);
        mutex_unlock(&au0828_sysfs_lock);
+
+       v4l2_device_disconnect(&dev->v4l2_dev);
+       v4l2_device_put(&dev->v4l2_dev);
+
+       return 1;
 }
 
 /* This function ensures that video frames continue to be delivered even if
@@ -1312,7 +1458,6 @@ static int vidioc_enum_input(struct file *file, void *priv,
                [AU0828_VMUX_CABLE] = "Cable TV",
                [AU0828_VMUX_TELEVISION] = "Television",
                [AU0828_VMUX_DVB] = "DVB",
-               [AU0828_VMUX_DEBUG] = "tv debug"
        };
 
        dprintk(1, "%s called std_set %d dev_state %d\n", __func__,
@@ -1804,7 +1949,6 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
                [AU0828_VMUX_CABLE] = "Cable TV",
                [AU0828_VMUX_TELEVISION] = "Television",
                [AU0828_VMUX_DVB] = "DVB",
-               [AU0828_VMUX_DEBUG] = "tv debug"
        };
        int ret, i;
 
@@ -1840,11 +1984,9 @@ static void au0828_analog_create_entities(struct au0828_dev *dev)
                case AU0828_VMUX_CABLE:
                case AU0828_VMUX_TELEVISION:
                case AU0828_VMUX_DVB:
+               default: /* Just to shut up a warning */
                        ent->function = MEDIA_ENT_F_CONN_RF;
                        break;
-               default: /* AU0828_VMUX_DEBUG */
-                       ent->function = MEDIA_ENT_F_CONN_TEST;
-                       break;
                }
 
                ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
@@ -1871,6 +2013,10 @@ int au0828_analog_register(struct au0828_dev *dev,
        dprintk(1, "au0828_analog_register called for intf#%d!\n",
                interface->cur_altsetting->desc.bInterfaceNumber);
 
+       /* No analog TV */
+       if (AUVI_INPUT(0).type == AU0828_VMUX_UNDEFINED)
+               return 0;
+
        /* set au0828 usb interface0 to as5 */
        retval = usb_set_interface(dev->usbdev,
                        interface->cur_altsetting->desc.bInterfaceNumber, 5);
@@ -1976,6 +2122,14 @@ int au0828_analog_register(struct au0828_dev *dev,
                ret = -ENODEV;
                goto err_reg_vbi_dev;
        }
+       retval = au0828_create_media_graph(dev);
+       if (retval) {
+               pr_err("%s() au0282_dev_register failed to create graph\n",
+                       __func__);
+               ret = -ENODEV;
+               goto err_reg_vbi_dev;
+       }
+
 
        dprintk(1, "%s completed!\n", __func__);
 
index 8276072..23f869c 100644 (file)
@@ -76,7 +76,6 @@ enum au0828_itype {
        AU0828_VMUX_CABLE,
        AU0828_VMUX_TELEVISION,
        AU0828_VMUX_DVB,
-       AU0828_VMUX_DEBUG
 };
 
 struct au0828_input {
@@ -301,6 +300,7 @@ struct au0828_dev {
 /* au0828-core.c */
 extern u32 au0828_read(struct au0828_dev *dev, u16 reg);
 extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val);
+extern void au0828_usb_release(struct au0828_dev *dev);
 extern int au0828_debug;
 
 /* ----------------------------------------------------------- */
@@ -319,16 +319,29 @@ extern int au0828_i2c_unregister(struct au0828_dev *dev);
 
 /* ----------------------------------------------------------- */
 /* au0828-video.c */
-extern int au0828_analog_register(struct au0828_dev *dev,
-                          struct usb_interface *interface);
-extern void au0828_analog_unregister(struct au0828_dev *dev);
 extern int au0828_start_analog_streaming(struct vb2_queue *vq,
                                                unsigned int count);
 extern void au0828_stop_vbi_streaming(struct vb2_queue *vq);
 #ifdef CONFIG_VIDEO_AU0828_V4L2
+extern int au0828_v4l2_device_register(struct usb_interface *interface,
+                                     struct au0828_dev *dev);
+
+extern int au0828_analog_register(struct au0828_dev *dev,
+                          struct usb_interface *interface);
+extern int au0828_analog_unregister(struct au0828_dev *dev);
+extern void au0828_usb_v4l2_media_release(struct au0828_dev *dev);
 extern void au0828_v4l2_suspend(struct au0828_dev *dev);
 extern void au0828_v4l2_resume(struct au0828_dev *dev);
 #else
+static inline int au0828_v4l2_device_register(struct usb_interface *interface,
+                                             struct au0828_dev *dev)
+{ return 0; };
+static inline int au0828_analog_register(struct au0828_dev *dev,
+                                    struct usb_interface *interface)
+{ return 0; };
+static inline int au0828_analog_unregister(struct au0828_dev *dev)
+{ return 0; };
+static inline void au0828_usb_v4l2_media_release(struct au0828_dev *dev) { };
 static inline void au0828_v4l2_suspend(struct au0828_dev *dev) { };
 static inline void au0828_v4l2_resume(struct au0828_dev *dev) { };
 #endif
index 0bd9690..d4bdba6 100644 (file)
@@ -10,7 +10,7 @@
 /* Version information */
 #define DRIVER_VERSION "0.1"
 #define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV USB Driver"
-#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>"
+#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@posteo.de>"
 
 /* debug */
 #ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
index 187012c..0310fd6 100644 (file)
@@ -923,7 +923,7 @@ static int apply_vp_patch(struct camera_data *cam)
        /* ... followed by the data payload */
        for (i = 2; i < fw->size; i += 64) {
                cmd.start = 0x0C; /* Data */
-               cmd.reg_count = min_t(int, 64, fw->size - i);
+               cmd.reg_count = min_t(uint, 64, fw->size - i);
                memcpy(cmd.buffer.block_data, &fw->data[i], cmd.reg_count);
                cpia2_send_command(cam, &cmd);
        }
index 48643b9..c9320d6 100644 (file)
@@ -1382,6 +1382,8 @@ static int cx231xx_bulk_copy(struct cx231xx *dev, struct urb *urb)
        buffer_size = urb->actual_length;
 
        buffer = kmalloc(buffer_size, GFP_ATOMIC);
+       if (!buffer)
+               return -ENOMEM;
 
        memcpy(buffer, dma_q->ps_head, 3);
        memcpy(buffer+3, p_buffer, buffer_size-3);
index de4ae5e..a6a9508 100644 (file)
@@ -499,6 +499,11 @@ static int snd_cx231xx_pcm_close(struct snd_pcm_substream *substream)
        }
 
        dev->adev.users--;
+       if (substream->runtime->dma_area) {
+               dev_dbg(dev->dev, "freeing\n");
+               vfree(substream->runtime->dma_area);
+               substream->runtime->dma_area = NULL;
+       }
        mutex_unlock(&dev->lock);
 
        if (dev->adev.users == 0 && dev->adev.shutdown == 1) {
index 620b83d..9e3a5d2 100644 (file)
@@ -1212,70 +1212,15 @@ static int cx231xx_media_device_init(struct cx231xx *dev,
 #ifdef CONFIG_MEDIA_CONTROLLER
        struct media_device *mdev;
 
-       mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+       mdev = v4l2_mc_usb_media_device_init(udev, dev->board.name);
        if (!mdev)
                return -ENOMEM;
 
-       mdev->dev = dev->dev;
-       strlcpy(mdev->model, dev->board.name, sizeof(mdev->model));
-       if (udev->serial)
-               strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
-       strcpy(mdev->bus_info, udev->devpath);
-       mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
-       mdev->driver_version = LINUX_VERSION_CODE;
-
-       media_device_init(mdev);
-
        dev->media_dev = mdev;
 #endif
        return 0;
 }
 
-static int cx231xx_create_media_graph(struct cx231xx *dev)
-{
-#ifdef CONFIG_MEDIA_CONTROLLER
-       struct media_device *mdev = dev->media_dev;
-       struct media_entity *entity;
-       struct media_entity *tuner = NULL, *decoder = NULL;
-       int ret;
-
-       if (!mdev)
-               return 0;
-
-       media_device_for_each_entity(entity, mdev) {
-               switch (entity->function) {
-               case MEDIA_ENT_F_TUNER:
-                       tuner = entity;
-                       break;
-               case MEDIA_ENT_F_ATV_DECODER:
-                       decoder = entity;
-                       break;
-               }
-       }
-
-       /* Analog setup, using tuner as a link */
-
-       if (!decoder)
-               return 0;
-
-       if (tuner) {
-               ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
-                                           MEDIA_LNK_FL_ENABLED);
-               if (ret < 0)
-                       return ret;
-       }
-       ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
-                                   MEDIA_LNK_FL_ENABLED);
-       if (ret < 0)
-               return ret;
-       ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
-                                   MEDIA_LNK_FL_ENABLED);
-       if (ret < 0)
-               return ret;
-#endif
-       return 0;
-}
-
 /*
  * cx231xx_init_dev()
  * allocates and inits the device structs, registers i2c bus and v4l device
@@ -1739,15 +1684,14 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
        /* load other modules required */
        request_modules(dev);
 
-       retval = cx231xx_create_media_graph(dev);
-       if (retval < 0)
-               goto done;
-
 #ifdef CONFIG_MEDIA_CONTROLLER
-       retval = media_device_register(dev->media_dev);
-#endif
+       /* Init entities at the Media Controller */
+       cx231xx_v4l2_create_entities(dev);
 
-done:
+       retval = v4l2_mc_create_media_graph(dev->media_dev);
+       if (!retval)
+               retval = media_device_register(dev->media_dev);
+#endif
        if (retval < 0)
                cx231xx_release_resources(dev);
        return retval;
index b8d5b2b..ab2fb9f 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <media/v4l2-common.h>
 #include <media/videobuf-vmalloc.h>
+#include <media/tuner.h>
 
 #include "xc5000.h"
 #include "s5h1432.h"
@@ -551,7 +552,8 @@ static int register_dvb(struct cx231xx_dvb *dvb,
 
        /* register network adapter */
        dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
-       result = dvb_create_media_graph(&dvb->adapter, false);
+       result = dvb_create_media_graph(&dvb->adapter,
+                                       dev->tuner_type == TUNER_ABSENT);
        if (result < 0)
                goto fail_create_graph;
 
@@ -801,6 +803,9 @@ static int dvb_init(struct cx231xx *dev)
                /* attach tuner */
                memset(&si2157_config, 0, sizeof(si2157_config));
                si2157_config.fe = dev->dvb->frontend;
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+               si2157_config.mdev = dev->media_dev;
+#endif
                si2157_config.if_port = 1;
                si2157_config.inversion = true;
                strlcpy(info.type, "si2157", I2C_NAME_SIZE);
@@ -857,6 +862,9 @@ static int dvb_init(struct cx231xx *dev)
                /* attach tuner */
                memset(&si2157_config, 0, sizeof(si2157_config));
                si2157_config.fe = dev->dvb->frontend;
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+               si2157_config.mdev = dev->media_dev;
+#endif
                si2157_config.if_port = 1;
                si2157_config.inversion = true;
                strlcpy(info.type, "si2157", I2C_NAME_SIZE);
index 9b88cd8..6414188 100644 (file)
@@ -1103,9 +1103,54 @@ static const char *iname[] = {
        [CX231XX_VMUX_TELEVISION] = "Television",
        [CX231XX_VMUX_CABLE]      = "Cable TV",
        [CX231XX_VMUX_DVB]        = "DVB",
-       [CX231XX_VMUX_DEBUG]      = "for debug only",
 };
 
+void cx231xx_v4l2_create_entities(struct cx231xx *dev)
+{
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       int ret, i;
+
+       /* Create entities for each input connector */
+       for (i = 0; i < MAX_CX231XX_INPUT; i++) {
+               struct media_entity *ent = &dev->input_ent[i];
+
+               if (!INPUT(i)->type)
+                       break;
+
+               ent->name = iname[INPUT(i)->type];
+               ent->flags = MEDIA_ENT_FL_CONNECTOR;
+               dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
+
+               switch (INPUT(i)->type) {
+               case CX231XX_VMUX_COMPOSITE1:
+                       ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
+                       break;
+               case CX231XX_VMUX_SVIDEO:
+                       ent->function = MEDIA_ENT_F_CONN_SVIDEO;
+                       break;
+               case CX231XX_VMUX_TELEVISION:
+               case CX231XX_VMUX_CABLE:
+               case CX231XX_VMUX_DVB:
+                       /* The DVB core will handle it */
+                       if (dev->tuner_type == TUNER_ABSENT)
+                               continue;
+                       /* fall though */
+               default: /* just to shut up a gcc warning */
+                       ent->function = MEDIA_ENT_F_CONN_RF;
+                       break;
+               }
+
+               ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
+               if (ret < 0)
+                       pr_err("failed to initialize input pad[%d]!\n", i);
+
+               ret = media_device_register_entity(dev->media_dev, ent);
+               if (ret < 0)
+                       pr_err("failed to register input entity %d!\n", i);
+       }
+#endif
+}
+
 int cx231xx_enum_input(struct file *file, void *priv,
                             struct v4l2_input *i)
 {
index ec6d3f5..69f6d20 100644 (file)
@@ -281,7 +281,6 @@ enum cx231xx_itype {
        CX231XX_VMUX_CABLE,
        CX231XX_RADIO,
        CX231XX_VMUX_DVB,
-       CX231XX_VMUX_DEBUG
 };
 
 enum cx231xx_v_input {
@@ -663,6 +662,8 @@ struct cx231xx {
 #if defined(CONFIG_MEDIA_CONTROLLER)
        struct media_device *media_dev;
        struct media_pad video_pad, vbi_pad;
+       struct media_entity input_ent[MAX_CX231XX_INPUT];
+       struct media_pad input_pad[MAX_CX231XX_INPUT];
 #endif
 
        unsigned char eedata[256];
@@ -943,6 +944,7 @@ int cx231xx_register_extension(struct cx231xx_ops *dev);
 void cx231xx_unregister_extension(struct cx231xx_ops *dev);
 void cx231xx_init_extension(struct cx231xx *dev);
 void cx231xx_close_extension(struct cx231xx *dev);
+void cx231xx_v4l2_create_entities(struct cx231xx *dev);
 int cx231xx_querycap(struct file *file, void *priv,
                           struct v4l2_capability *cap);
 int cx231xx_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t);
index 6e02a15..b3c09fe 100644 (file)
@@ -684,7 +684,7 @@ static int af9035_download_firmware(struct dvb_usb_device *d,
        if (ret < 0)
                goto err;
 
-       if (tmp == 1 || tmp == 3) {
+       if (tmp == 1 || tmp == 3 || tmp == 5) {
                /* configure gpioh1, reset & power slave demod */
                ret = af9035_wr_reg_mask(d, 0x00d8b0, 0x01, 0x01);
                if (ret < 0)
@@ -823,7 +823,7 @@ static int af9035_read_config(struct dvb_usb_device *d)
        if (ret < 0)
                goto err;
 
-       if (tmp == 1 || tmp == 3)
+       if (tmp == 1 || tmp == 3 || tmp == 5)
                state->dual_mode = true;
 
        dev_dbg(&d->udev->dev, "%s: ts mode=%d dual mode=%d\n", __func__,
index 416a97f..df22001 100644 (file)
@@ -112,9 +112,10 @@ static const u32 clock_lut_it9135[] = {
  * 0  TS
  * 1  DCA + PIP
  * 3  PIP
+ * 5  DCA + PIP
  * n  DCA
  *
- * Values 0 and 3 are seen to this day. 0 for single TS and 3 for dual TS.
+ * Values 0, 3 and 5 are seen to this day. 0 for single TS and 3/5 for dual TS.
  */
 
 #define EEPROM_BASE_AF9035        0x42fd
index 023d91f..35f27e2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DVB USB framework
  *
- * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@desy.de>
+ * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@posteo.de>
  * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
  *
  *    This program is free software; you can redistribute it and/or modify
index 45f0709..a1622bd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DVB USB framework
  *
- * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@desy.de>
+ * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@posteo.de>
  * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
  *
  *    This program is free software; you can redistribute it and/or modify
index f0565bf..4a87697 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DVB USB framework
  *
- * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@desy.de>
+ * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@posteo.de>
  * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
  *
  *    This program is free software; you can redistribute it and/or modify
@@ -20,6 +20,7 @@
  */
 
 #include "dvb_usb_common.h"
+#include <media/v4l2-mc.h>
 
 static int dvb_usbv2_disable_rc_polling;
 module_param_named(disable_rc_polling, dvb_usbv2_disable_rc_polling, int, 0644);
@@ -407,20 +408,10 @@ static int dvb_usbv2_media_device_init(struct dvb_usb_adapter *adap)
        struct dvb_usb_device *d = adap_to_d(adap);
        struct usb_device *udev = d->udev;
 
-       mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+       mdev = v4l2_mc_usb_media_device_init(udev, d->name);
        if (!mdev)
                return -ENOMEM;
 
-       mdev->dev = &udev->dev;
-       strlcpy(mdev->model, d->name, sizeof(mdev->model));
-       if (udev->serial)
-               strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
-       strcpy(mdev->bus_info, udev->devpath);
-       mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
-       mdev->driver_version = LINUX_VERSION_CODE;
-
-       media_device_init(mdev);
-
        dvb_register_media_controller(&adap->dvb_adap, mdev);
 
        dev_info(&d->udev->dev, "media controller created\n");
@@ -1129,7 +1120,7 @@ int dvb_usbv2_reset_resume(struct usb_interface *intf)
 EXPORT_SYMBOL(dvb_usbv2_reset_resume);
 
 MODULE_VERSION("2.0");
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
 MODULE_DESCRIPTION("DVB USB common");
 MODULE_LICENSE("GPL");
index 22bdce1..5bafeb6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * DVB USB framework
  *
- * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@desy.de>
+ * Copyright (C) 2004-6 Patrick Boettcher <patrick.boettcher@posteo.de>
  * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
  *
  *    This program is free software; you can redistribute it and/or modify
index 1dd9625..02dbc6c 100644 (file)
@@ -847,10 +847,17 @@ static const struct usb_device_id dvbsky_id_table[] = {
                USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI,
                &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI",
                RC_MAP_TT_1500) },
+       { DVB_USB_DEVICE(USB_VID_TECHNOTREND,
+               USB_PID_TECHNOTREND_CONNECT_CT2_4650_CI_2,
+               &dvbsky_t680c_props, "TechnoTrend TT-connect CT2-4650 CI v1.1",
+               RC_MAP_TT_1500) },
        { DVB_USB_DEVICE(USB_VID_TERRATEC,
                USB_PID_TERRATEC_H7_3,
                &dvbsky_t680c_props, "Terratec H7 Rev.4",
                RC_MAP_TT_1500) },
+       { DVB_USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R4,
+               &dvbsky_s960_props, "Terratec Cinergy S2 Rev.4",
+               RC_MAP_DVBSKY) },
        { }
 };
 MODULE_DEVICE_TABLE(usb, dvbsky_id_table);
index 84f6de6..047a32f 100644 (file)
@@ -507,9 +507,9 @@ static int mxl111sf_demod_read_signal_strength(struct dvb_frontend *fe,
        return 0;
 }
 
-static int mxl111sf_demod_get_frontend(struct dvb_frontend *fe)
+static int mxl111sf_demod_get_frontend(struct dvb_frontend *fe,
+                                      struct dtv_frontend_properties *p)
 {
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
        struct mxl111sf_demod_state *state = fe->demodulator_priv;
 
        mxl_dbg("()");
index 444579b..7d16252 100644 (file)
@@ -36,7 +36,7 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able)).");
 struct mxl111sf_tuner_state {
        struct mxl111sf_state *mxl_state;
 
-       struct mxl111sf_tuner_config *cfg;
+       const struct mxl111sf_tuner_config *cfg;
 
        enum mxl_if_freq if_freq;
 
@@ -489,8 +489,8 @@ static struct dvb_tuner_ops mxl111sf_tuner_tuner_ops = {
 };
 
 struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe,
-                                          struct mxl111sf_state *mxl_state,
-                                          struct mxl111sf_tuner_config *cfg)
+                               struct mxl111sf_state *mxl_state,
+                               const struct mxl111sf_tuner_config *cfg)
 {
        struct mxl111sf_tuner_state *state = NULL;
 
index e6caab2..509b550 100644 (file)
@@ -63,13 +63,13 @@ struct mxl111sf_tuner_config {
 #if IS_ENABLED(CONFIG_DVB_USB_MXL111SF)
 extern
 struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe,
-                                          struct mxl111sf_state *mxl_state,
-                                          struct mxl111sf_tuner_config *cfg);
+                               struct mxl111sf_state *mxl_state,
+                               const struct mxl111sf_tuner_config *cfg);
 #else
 static inline
 struct dvb_frontend *mxl111sf_tuner_attach(struct dvb_frontend *fe,
-                                          struct mxl111sf_state *mxl_state,
-                                          struct mxl111sf_tuner_config *cfg)
+                               struct mxl111sf_state *mxl_state,
+                               const struct mxl111sf_tuner_config *cfg)
 {
        printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
        return NULL;
index b669dec..5d676b5 100644 (file)
@@ -856,7 +856,7 @@ static int mxl111sf_ant_hunt(struct dvb_frontend *fe)
        return 0;
 }
 
-static struct mxl111sf_tuner_config mxl_tuner_config = {
+static const struct mxl111sf_tuner_config mxl_tuner_config = {
        .if_freq         = MXL_IF_6_0, /* applies to external IF output, only */
        .invert_spectrum = 0,
        .read_reg        = mxl111sf_read_reg,
@@ -888,7 +888,7 @@ static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap)
        state->tuner.function = MEDIA_ENT_F_TUNER;
        state->tuner.name = "mxl111sf tuner";
        state->tuner_pads[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
-       state->tuner_pads[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
+       state->tuner_pads[TUNER_PAD_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
 
        ret = media_entity_pads_init(&state->tuner,
                                     TUNER_NUM_PADS, state->tuner_pads);
index eb5787a..c4c6e92 100644 (file)
@@ -259,6 +259,10 @@ static int rtl28xxu_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                ret = -EOPNOTSUPP;
        }
 
+       /* Retry failed I2C messages */
+       if (ret == -EPIPE)
+               ret = -EAGAIN;
+
 err_mutex_unlock:
        mutex_unlock(&d->i2c_mutex);
 
@@ -619,6 +623,10 @@ static int rtl28xxu_identify_state(struct dvb_usb_device *d, const char **name)
        }
        dev_dbg(&d->intf->dev, "chip_id=%u\n", dev->chip_id);
 
+       /* Retry failed I2C messages */
+       d->i2c_adap.retries = 1;
+       d->i2c_adap.timeout = msecs_to_jiffies(10);
+
        return WARM;
 err:
        dev_dbg(&d->intf->dev, "failed=%d\n", ret);
index ca8f3c2..55136cd 100644 (file)
@@ -1,6 +1,6 @@
 /* usb-urb.c is part of the DVB USB library.
  *
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * This file keeps functions for initializing and handling the
index 83684ed..7ba975b 100644 (file)
@@ -1,7 +1,7 @@
 /* DVB USB framework compliant Linux driver for the AVerMedia AverTV DVB-T
  * USB2.0 (A800) DVB-T receiver.
  *
- * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * Thanks to
  *   - AVerMedia who kindly provided information and
@@ -185,7 +185,7 @@ static struct usb_driver a800_driver = {
 
 module_usb_driver(a800_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("AVerMedia AverTV DVB-T USB 2.0 (A800)");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL");
index ac97075..09db3d0 100644 (file)
@@ -1227,9 +1227,9 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int af9005_fe_get_frontend(struct dvb_frontend *fe)
+static int af9005_fe_get_frontend(struct dvb_frontend *fe,
+                                 struct dtv_frontend_properties *fep)
 {
-       struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
        struct af9005_fe_state *state = fe->demodulator_priv;
        int ret;
        u8 temp;
index ab71511..907ac01 100644 (file)
@@ -13,7 +13,7 @@
  *
  * TODO: Use the cx25840-driver for the analogue part
  *
- * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
  * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
  * Copyright (C) 2006, 2007 Chris Pascoe (c.pascoe@itee.uq.edu.au)
  *
@@ -2314,7 +2314,7 @@ static struct usb_driver cxusb_driver = {
 
 module_usb_driver(cxusb_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
 MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
 MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
index 0d248ce..c16f999 100644 (file)
@@ -881,7 +881,7 @@ static struct usb_driver dib0700_driver = {
 module_usb_driver(dib0700_driver);
 
 MODULE_FIRMWARE("dvb-usb-dib0700-1.20.fw");
-MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for devices based on DiBcom DiB0700 - USB bridge");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL");
index 7ed4964..ea0391e 100644 (file)
@@ -1736,8 +1736,13 @@ static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
        struct dib0700_adapter_state *st = adap->priv;
        struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
 
-       if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
-               return -ENODEV;
+       if (adap->id == 0) {
+               if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
+                       return -ENODEV;
+       } else {
+               if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
+                       return -ENODEV;
+       }
 
        st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
        adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
@@ -1773,6 +1778,20 @@ static int stk809x_frontend_attach(struct dvb_usb_adapter *adap)
        return adap->fe_adap[0].fe == NULL ?  -ENODEV : 0;
 }
 
+static int stk809x_frontend1_attach(struct dvb_usb_adapter *adap)
+{
+       struct dib0700_adapter_state *state = adap->priv;
+
+       if (!dvb_attach(dib8000_attach, &state->dib8000_ops))
+               return -ENODEV;
+
+       state->dib8000_ops.i2c_enumeration(&adap->dev->i2c_adap, 1, 0x10, 0x82, 0);
+
+       adap->fe_adap[0].fe = state->dib8000_ops.init(&adap->dev->i2c_adap, 0x82, &dib809x_dib8000_config[1]);
+
+       return adap->fe_adap[0].fe == NULL ?  -ENODEV : 0;
+}
+
 static int nim8096md_tuner_attach(struct dvb_usb_adapter *adap)
 {
        struct dib0700_adapter_state *st = adap->priv;
@@ -3794,6 +3813,7 @@ struct usb_device_id dib0700_usb_id_table[] = {
 /* 80 */{ USB_DEVICE(USB_VID_ELGATO,   USB_PID_ELGATO_EYETV_DTT_2) },
        { USB_DEVICE(USB_VID_PCTV,      USB_PID_PCTV_2002E) },
        { USB_DEVICE(USB_VID_PCTV,      USB_PID_PCTV_2002E_SE) },
+       { USB_DEVICE(USB_VID_PCTV,      USB_PID_DIBCOM_STK8096PVR) },
        { 0 }           /* Terminating entry */
 };
 MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table);
@@ -4959,6 +4979,59 @@ struct dvb_usb_device_properties dib0700_devices[] = {
                                            RC_BIT_NEC,
                        .change_protocol  = dib0700_change_protocol,
                },
+       }, { DIB0700_DEFAULT_DEVICE_PROPERTIES,
+               .num_adapters = 2,
+               .adapter = {
+                       {
+                               .num_frontends = 1,
+                               .fe = {{
+                                       .caps  = DVB_USB_ADAP_HAS_PID_FILTER |
+                                               DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
+                                       .pid_filter_count = 32,
+                                       .pid_filter = stk80xx_pid_filter,
+                                       .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
+                                       .frontend_attach  = stk809x_frontend_attach,
+                                       .tuner_attach     = dib809x_tuner_attach,
+
+                                       DIB0700_DEFAULT_STREAMING_CONFIG(0x02),
+                               } },
+                               .size_of_priv =
+                                       sizeof(struct dib0700_adapter_state),
+                       }, {
+                               .num_frontends = 1,
+                               .fe = { {
+                                       .caps  = DVB_USB_ADAP_HAS_PID_FILTER |
+                                               DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
+                                       .pid_filter_count = 32,
+                                       .pid_filter = stk80xx_pid_filter,
+                                       .pid_filter_ctrl = stk80xx_pid_filter_ctrl,
+                                       .frontend_attach  = stk809x_frontend1_attach,
+                                       .tuner_attach     = dib809x_tuner_attach,
+
+                                       DIB0700_DEFAULT_STREAMING_CONFIG(0x03),
+                               } },
+                               .size_of_priv =
+                                       sizeof(struct dib0700_adapter_state),
+                       },
+               },
+               .num_device_descs = 1,
+               .devices = {
+                       {   "DiBcom STK8096-PVR reference design",
+                               { &dib0700_usb_id_table[83], NULL },
+                               { NULL },
+                       },
+               },
+
+               .rc.core = {
+                       .rc_interval      = DEFAULT_RC_INTERVAL,
+                       .rc_codes         = RC_MAP_DIB0700_RC5_TABLE,
+                       .module_name  = "dib0700",
+                       .rc_query         = dib0700_rc_query_old_firmware,
+                       .allowed_protos   = RC_BIT_RC5 |
+                               RC_BIT_RC6_MCE |
+                               RC_BIT_NEC,
+                       .change_protocol  = dib0700_change_protocol,
+               },
        },
 };
 
index ef3a8f7..35de609 100644 (file)
@@ -1,6 +1,6 @@
 /* Common methods for dibusb-based-receivers.
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the Free
index a4ac37e..a005764 100644 (file)
@@ -1,10 +1,10 @@
 /* DVB USB compliant linux driver for mobile DVB-T USB devices based on
  * reference designs made by DiBcom (http://www.dibcom.fr/) (DiB3000M-B)
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * based on GPL code from DiBcom, which has
- * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
+ * Copyright (C) 2004 Amaury Demol for DiBcom
  *
  *     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
@@ -465,7 +465,7 @@ static struct usb_driver dibusb_driver = {
 
 module_usb_driver(dibusb_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for DiBcom USB DVB-T devices (DiB3000M-B based)");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL");
index 9d1a59d..08fb8a3 100644 (file)
@@ -1,10 +1,10 @@
 /* DVB USB compliant linux driver for mobile DVB-T USB devices based on
  * reference designs made by DiBcom (http://www.dibcom.fr/) (DiB3000M-C/P)
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * based on GPL code from DiBcom, which has
- * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
+ * Copyright (C) 2004 Amaury Demol for DiBcom
  *
  *     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
@@ -143,7 +143,7 @@ static struct usb_driver dibusb_mc_driver = {
 
 module_usb_driver(dibusb_mc_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for DiBcom USB2.0 DVB-T (DiB3000M-C/P based) devices");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL");
index 32ab139..3f82163 100644 (file)
@@ -1,6 +1,6 @@
 /* Header file for all dibusb-based-receivers.
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the Free
index 772bde3..6313433 100644 (file)
@@ -1,7 +1,7 @@
 /* DVB USB compliant linux driver for Nebula Electronics uDigiTV DVB-T USB2.0
  * receiver
  *
- * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * partly based on the SDK published by Nebula Electronics
  *
@@ -348,7 +348,7 @@ static struct usb_driver digitv_driver = {
 
 module_usb_driver(digitv_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for Nebula Electronics uDigiTV DVB-T USB2.0");
 MODULE_VERSION("1.0-alpha");
 MODULE_LICENSE("GPL");
index 8637ad1..c09332b 100644 (file)
@@ -1,7 +1,7 @@
 /* Frontend part of the Linux driver for the WideView/ Yakumo/ Hama/
  * Typhoon/ Yuan DVB-T USB2.0 receiver.
  *
- * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de>
+ * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@posteo.de>
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the Free
@@ -140,10 +140,11 @@ static int dtt200u_fe_set_frontend(struct dvb_frontend *fe)
        return 0;
 }
 
-static int dtt200u_fe_get_frontend(struct dvb_frontend* fe)
+static int dtt200u_fe_get_frontend(struct dvb_frontend* fe,
+                                  struct dtv_frontend_properties *fep)
 {
-       struct dtv_frontend_properties *fep = &fe->dtv_property_cache;
        struct dtt200u_fe_state *state = fe->demodulator_priv;
+
        memcpy(fep, &state->fep, sizeof(struct dtv_frontend_properties));
        return 0;
 }
index c357fb3..ca3b69a 100644 (file)
@@ -1,7 +1,7 @@
 /* DVB USB library compliant Linux driver for the WideView/ Yakumo/ Hama/
  * Typhoon/ Yuan/ Miglia DVB-T USB2.0 receiver.
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * Thanks to Steve Chang from WideView for providing support for the WT-220U.
  *
@@ -362,7 +362,7 @@ static struct usb_driver dtt200u_usb_driver = {
 
 module_usb_driver(dtt200u_usb_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon/Club3D/Miglia DVB-T USB2.0 devices");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL");
index 005b0a7..efccc39 100644 (file)
@@ -1,7 +1,7 @@
 /* Common header file of Linux driver for the WideView/ Yakumo/ Hama/
  * Typhoon/ Yuan DVB-T USB2.0 receiver.
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the Free
index 6b7b2a8..7e619d6 100644 (file)
@@ -1,6 +1,6 @@
 /* dvb-usb-common.h is part of the DVB USB library.
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * a header file containing prototypes and types for internal use of the dvb-usb-lib
index 9ddfcab..513b0c1 100644 (file)
@@ -1,12 +1,13 @@
 /* dvb-usb-dvb.c is part of the DVB USB library.
  *
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * This file contains functions for initializing and handling the
  * linux-dvb API.
  */
 #include "dvb-usb-common.h"
+#include <media/v4l2-mc.h>
 
 /* does the complete input transfer handling */
 static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
@@ -102,19 +103,7 @@ static int dvb_usb_media_device_init(struct dvb_usb_adapter *adap)
        struct dvb_usb_device *d = adap->dev;
        struct usb_device *udev = d->udev;
 
-       mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
-       if (!mdev)
-               return -ENOMEM;
-
-       mdev->dev = &udev->dev;
-       strlcpy(mdev->model, d->desc->name, sizeof(mdev->model));
-       if (udev->serial)
-               strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
-       strcpy(mdev->bus_info, udev->devpath);
-       mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
-       mdev->driver_version = LINUX_VERSION_CODE;
-
-       media_device_init(mdev);
+       mdev = v4l2_mc_usb_media_device_init(udev, d->desc->name);
 
        dvb_register_media_controller(&adap->dvb_adap, mdev);
 
index 733a7ff..dd048a7 100644 (file)
@@ -1,6 +1,6 @@
 /* dvb-usb-firmware.c is part of the DVB USB library.
  *
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * This file contains functions for downloading the firmware to Cypress FX 1 and 2 based devices.
index 88e4a62..4f0b0ad 100644 (file)
@@ -1,6 +1,6 @@
 /* dvb-usb-i2c.c is part of the DVB USB library.
  *
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * This file contains functions for (de-)initializing an I2C adapter.
index 1adf325..3896ba9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * dvb-usb-init.c
  *
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the Free
@@ -299,6 +299,6 @@ void dvb_usb_device_exit(struct usb_interface *intf)
 EXPORT_SYMBOL(dvb_usb_device_exit);
 
 MODULE_VERSION("1.0");
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices");
 MODULE_LICENSE("GPL");
index 7b5dae3..c259f9e 100644 (file)
@@ -1,6 +1,6 @@
 /* dvb-usb-remote.c is part of the DVB USB library.
  *
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * This file contains functions for initializing the input-device and for handling remote-control-queries.
index 5c8f651..95f9097 100644 (file)
@@ -1,6 +1,6 @@
 /* dvb-usb-urb.c is part of the DVB USB library.
  *
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * This file keeps functions for initializing and handling the
index ce4c4e3..639c467 100644 (file)
@@ -1,6 +1,6 @@
 /* dvb-usb.h is part of the DVB USB library.
  *
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * the headerfile, all dvb-usb-drivers have to include.
index 14ef25d..dd46d6c 100644 (file)
@@ -1688,6 +1688,7 @@ enum dw2102_table_entry {
        TECHNOTREND_S2_4600,
        TEVII_S482_1,
        TEVII_S482_2,
+       TERRATEC_CINERGY_S2_BOX,
 };
 
 static struct usb_device_id dw2102_table[] = {
@@ -1702,19 +1703,20 @@ static struct usb_device_id dw2102_table[] = {
        [TEVII_S660] = {USB_DEVICE(0x9022, USB_PID_TEVII_S660)},
        [PROF_7500] = {USB_DEVICE(0x3034, 0x7500)},
        [GENIATECH_SU3000] = {USB_DEVICE(0x1f4d, 0x3000)},
-       [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00a8)},
+       [TERRATEC_CINERGY_S2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R1)},
        [TEVII_S480_1] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_1)},
        [TEVII_S480_2] = {USB_DEVICE(0x9022, USB_PID_TEVII_S480_2)},
        [X3M_SPC1400HD] = {USB_DEVICE(0x1f4d, 0x3100)},
        [TEVII_S421] = {USB_DEVICE(0x9022, USB_PID_TEVII_S421)},
        [TEVII_S632] = {USB_DEVICE(0x9022, USB_PID_TEVII_S632)},
-       [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, 0x00b0)},
+       [TERRATEC_CINERGY_S2_R2] = {USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_S2_R2)},
        [GOTVIEW_SAT_HD] = {USB_DEVICE(0x1FE1, USB_PID_GOTVIEW_SAT_HD)},
        [GENIATECH_T220] = {USB_DEVICE(0x1f4d, 0xD220)},
        [TECHNOTREND_S2_4600] = {USB_DEVICE(USB_VID_TECHNOTREND,
                USB_PID_TECHNOTREND_CONNECT_S2_4600)},
        [TEVII_S482_1] = {USB_DEVICE(0x9022, 0xd483)},
        [TEVII_S482_2] = {USB_DEVICE(0x9022, 0xd484)},
+       [TERRATEC_CINERGY_S2_BOX] = {USB_DEVICE(USB_VID_TERRATEC, 0x0105)},
        { }
 };
 
@@ -2232,7 +2234,7 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = {
                } },
                }
        },
-       .num_device_descs = 3,
+       .num_device_descs = 4,
        .devices = {
                { "TechnoTrend TT-connect S2-4600",
                        { &dw2102_table[TECHNOTREND_S2_4600], NULL },
@@ -2246,6 +2248,10 @@ static struct dvb_usb_device_properties tt_s2_4600_properties = {
                        { &dw2102_table[TEVII_S482_2], NULL },
                        { NULL },
                },
+               { "Terratec Cinergy S2 USB BOX",
+                       { &dw2102_table[TERRATEC_CINERGY_S2_BOX], NULL },
+                       { NULL },
+               },
        }
 };
 
index 8ec92fb..979f05b 100644 (file)
@@ -283,20 +283,6 @@ static int jdvbt90502_set_property(struct dvb_frontend *fe,
        return r;
 }
 
-static int jdvbt90502_get_frontend(struct dvb_frontend *fe)
-{
-       struct dtv_frontend_properties *p = &fe->dtv_property_cache;
-       p->inversion = INVERSION_AUTO;
-       p->bandwidth_hz = 6000000;
-       p->code_rate_HP = FEC_AUTO;
-       p->code_rate_LP = FEC_AUTO;
-       p->modulation = QAM_64;
-       p->transmission_mode = TRANSMISSION_MODE_AUTO;
-       p->guard_interval = GUARD_INTERVAL_AUTO;
-       p->hierarchy = HIERARCHY_AUTO;
-       return 0;
-}
-
 static int jdvbt90502_set_frontend(struct dvb_frontend *fe)
 {
        struct dtv_frontend_properties *p = &fe->dtv_property_cache;
@@ -312,8 +298,16 @@ static int jdvbt90502_set_frontend(struct dvb_frontend *fe)
 
        deb_fe("%s: Freq:%d\n", __func__, p->frequency);
 
-       /* for recovery from DTV_CLEAN */
-       fe->dtv_property_cache.delivery_system = SYS_ISDBT;
+       /* This driver only works on auto mode */
+       p->inversion = INVERSION_AUTO;
+       p->bandwidth_hz = 6000000;
+       p->code_rate_HP = FEC_AUTO;
+       p->code_rate_LP = FEC_AUTO;
+       p->modulation = QAM_64;
+       p->transmission_mode = TRANSMISSION_MODE_AUTO;
+       p->guard_interval = GUARD_INTERVAL_AUTO;
+       p->hierarchy = HIERARCHY_AUTO;
+       p->delivery_system = SYS_ISDBT;
 
        ret = jdvbt90502_pll_set_freq(state, p->frequency);
        if (ret) {
@@ -466,7 +460,6 @@ static struct dvb_frontend_ops jdvbt90502_ops = {
        .set_property = jdvbt90502_set_property,
 
        .set_frontend = jdvbt90502_set_frontend,
-       .get_frontend = jdvbt90502_get_frontend,
 
        .read_status = jdvbt90502_read_status,
        .read_signal_strength = jdvbt90502_read_signal_strength,
index 6c55384..fc7569e 100644 (file)
@@ -1,7 +1,7 @@
 /* DVB USB framework compliant Linux driver for the Hauppauge WinTV-NOVA-T usb2
  * DVB-T receiver.
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the Free
@@ -227,7 +227,7 @@ static struct usb_driver nova_t_driver = {
 
 module_usb_driver(nova_t_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Hauppauge WinTV-NOVA-T usb2");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL");
index 6c3c477..51487d2 100644 (file)
@@ -512,7 +512,7 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
                        &a->dev->i2c_adap, STV090x_DEMODULATOR_0);
 
        if (a->fe_adap[0].fe) {
-               struct stv6110x_devctl *ctl;
+               const struct stv6110x_devctl *ctl;
 
                ctl = dvb_attach(stv6110x_attach,
                                a->fe_adap[0].fe,
index f107173..ecc207f 100644 (file)
@@ -820,7 +820,7 @@ static struct usb_driver ttusb2_driver = {
 
 module_usb_driver(ttusb2_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for Pinnacle PCTV 400e DVB-S USB2.0");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL");
index 9b04229..58ad5b4 100644 (file)
@@ -1,7 +1,7 @@
 /* DVB USB framework compliant Linux driver for the HanfTek UMT-010 USB2.0
  * DVB-T receiver.
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the Free
@@ -145,7 +145,7 @@ static struct usb_driver umt_driver = {
 
 module_usb_driver(umt_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for HanfTek UMT 010 USB2.0 DVB-T device");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL");
index d62ee0f..8917360 100644 (file)
@@ -1,6 +1,6 @@
 /* usb-urb.c is part of the DVB USB library.
  *
- * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@posteo.de)
  * see dvb-usb-init.c for copyright information.
  *
  * This file keeps functions for initializing and handling the
index d361a72..27398c0 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de>
  *                    Metzler Brothers Systementwicklung GbR
  *
- * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de>
+ * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@posteo.de>
  *
  * Thanks to Twinhan who kindly provided hardware and information.
  *
index ee1e19e..40de33d 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de>
  *                    Metzler Brothers Systementwicklung GbR
  *
- * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de>
+ * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@posteo.de>
  *
  * Thanks to Twinhan who kindly provided hardware and information.
  *
@@ -439,7 +439,7 @@ static struct usb_driver vp702x_usb_driver = {
 
 module_usb_driver(vp702x_usb_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL");
index e708afc..7765602 100644 (file)
@@ -1,7 +1,7 @@
 /* DVB frontend part of the Linux driver for TwinhanDTV Alpha/MagicBoxII USB2.0
  * DVB-T receiver.
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * Thanks to Twinhan who kindly provided hardware and information.
  *
index d750724..13340af 100644 (file)
@@ -2,7 +2,7 @@
  *  - TwinhanDTV Alpha/MagicBoxII USB2.0 DVB-T receiver
  *  - DigitalNow TinyUSB2 DVB-t receiver
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * Thanks to Twinhan who kindly provided hardware and information.
  *
@@ -296,7 +296,7 @@ static struct usb_driver vp7045_usb_driver = {
 
 module_usb_driver(vp7045_usb_driver);
 
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
+MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@posteo.de>");
 MODULE_DESCRIPTION("Driver for Twinhan MagicBox/Alpha and DNTV tinyUSB2 DVB-T USB2.0");
 MODULE_VERSION("1.0");
 MODULE_LICENSE("GPL");
index cf5ec46..6649993 100644 (file)
@@ -1,7 +1,7 @@
 /* Common header-file of the Linux driver for the TwinhanDTV Alpha/MagicBoxII
  * USB2.0 DVB-T receiver.
  *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
+ * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@posteo.de)
  *
  * Thanks to Twinhan who kindly provided hardware and information.
  *
index b58acd3..72f3f4d 100644 (file)
@@ -64,6 +64,8 @@ static int em28xx_initialize_mt9m111(struct em28xx *dev)
                i2c_master_send(&dev->i2c_client[dev->def_i2c_bus],
                                &regs[i][0], 3);
 
+       /* FIXME: This won't be creating a sensor at the media graph */
+
        return 0;
 }
 
@@ -91,6 +93,8 @@ static int em28xx_initialize_mt9m001(struct em28xx *dev)
                i2c_master_send(&dev->i2c_client[dev->def_i2c_bus],
                                &regs[i][0], 3);
 
+       /* FIXME: This won't be creating a sensor at the media graph */
+
        return 0;
 }
 
index a1b6ef5..389e95f 100644 (file)
@@ -32,7 +32,7 @@
 #include <media/tuner.h>
 #include <media/drv-intf/msp3400.h>
 #include <media/i2c/saa7115.h>
-#include <media/i2c/tvp5150.h>
+#include <dt-bindings/media/tvp5150.h>
 #include <media/i2c/tvaudio.h>
 #include <media/i2c-addr.h>
 #include <media/tveeprom.h>
@@ -570,7 +570,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type    = TUNER_ABSENT,
                .is_webcam     = 1,
                .input         = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = 0,
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = silvercrest_reg_seq,
@@ -583,7 +583,7 @@ struct em28xx_board em28xx_boards[] = {
                .decoder      = EM28XX_SAA711X,
                .tuner_type   = TUNER_ABSENT,
                .input        = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -605,7 +605,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type    = TUNER_ABSENT,
                .is_webcam     = 1,
                .input         = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = 0,
                        .amux     = EM28XX_AMUX_VIDEO,
                } },
@@ -616,7 +616,7 @@ struct em28xx_board em28xx_boards[] = {
                .tda9887_conf = TDA9887_PRESENT,
                .decoder      = EM28XX_SAA711X,
                .input        = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -635,7 +635,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -655,7 +655,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -675,7 +675,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -715,7 +715,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -735,7 +735,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -755,7 +755,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -775,7 +775,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -800,7 +800,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE4,
                        .amux     = EM28XX_AMUX_AUX,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE5,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -819,7 +819,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type   = TUNER_ABSENT,
                .is_webcam    = 1,
                .input        = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = 0,
                        .amux     = EM28XX_AMUX_VIDEO,
                } },
@@ -829,7 +829,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type   = TUNER_ABSENT,
                .is_webcam    = 1,
                .input        = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = 0,
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = silvercrest_reg_seq,
@@ -848,7 +848,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
@@ -863,7 +863,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type   = TUNER_ABSENT,   /* Capture only device */
                .decoder      = EM28XX_SAA711X,
                .input        = { {
-                       .type  = EM28XX_VMUX_COMPOSITE1,
+                       .type  = EM28XX_VMUX_COMPOSITE,
                        .vmux  = SAA7115_COMPOSITE0,
                        .amux  = EM28XX_AMUX_LINE_IN,
                }, {
@@ -879,7 +879,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type   = TUNER_ABSENT,
                .is_webcam    = 1,
                .input        = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = 0,
                        .amux     = EM28XX_AMUX_VIDEO,
                } },
@@ -889,7 +889,7 @@ struct em28xx_board em28xx_boards[] = {
                .decoder      = EM28XX_SAA711X,
                .tuner_type   = TUNER_ABSENT,   /* Capture only device */
                .input        = { {
-                       .type  = EM28XX_VMUX_COMPOSITE1,
+                       .type  = EM28XX_VMUX_COMPOSITE,
                        .vmux  = SAA7115_COMPOSITE0,
                        .amux  = EM28XX_AMUX_LINE_IN,
                }, {
@@ -909,7 +909,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -930,7 +930,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -952,7 +952,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
@@ -974,7 +974,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = TVP5150_COMPOSITE0,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -992,7 +992,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = TVP5150_COMPOSITE0,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1006,7 +1006,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type    = TUNER_ABSENT,  /* Capture only device */
                .decoder       = EM28XX_TVP5150,
                .input         = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1029,7 +1029,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = pinnacle_hybrid_pro_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = pinnacle_hybrid_pro_analog,
@@ -1100,7 +1100,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = terratec_cinergy_USB_XS_FR_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = terratec_cinergy_USB_XS_FR_analog,
@@ -1186,7 +1186,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
@@ -1213,7 +1213,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
@@ -1239,7 +1239,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
@@ -1265,7 +1265,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
@@ -1291,7 +1291,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
@@ -1317,7 +1317,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
@@ -1343,7 +1343,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = default_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = default_analog,
@@ -1368,7 +1368,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
@@ -1392,7 +1392,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux      = SAA7115_COMPOSITE4,
                        .amux      = EM28XX_AMUX_VIDEO,
                }, {
-                       .type      = EM28XX_VMUX_COMPOSITE1,
+                       .type      = EM28XX_VMUX_COMPOSITE,
                        .vmux      = SAA7115_COMPOSITE0,
                        .amux      = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1413,7 +1413,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1428,7 +1428,7 @@ struct em28xx_board em28xx_boards[] = {
                .decoder    = EM28XX_SAA711X,
                .tuner_type = TUNER_ABSENT, /* capture only board */
                .input      = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1443,7 +1443,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type   = TUNER_ABSENT,   /* Capture-only board */
                .decoder      = EM28XX_SAA711X,
                .input        = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = vc211a_enable,
@@ -1465,7 +1465,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1485,7 +1485,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1500,7 +1500,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type   = TUNER_ABSENT, /* capture only board */
                .decoder      = EM28XX_SAA711X,
                .input        = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1520,7 +1520,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = SAA7115_COMPOSITE2,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1541,7 +1541,7 @@ struct em28xx_board em28xx_boards[] = {
                        .aout     = EM28XX_AOUT_MONO |  /* I2S */
                                    EM28XX_AOUT_MASTER, /* Line out pin */
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1555,6 +1555,7 @@ struct em28xx_board em28xx_boards[] = {
                .buttons = std_snapshot_button,
                .tda9887_conf = TDA9887_PRESENT,
                .tuner_type   = TUNER_YMEC_TVF_5533MF,
+               .tuner_addr   = 0x60,
                .decoder      = EM28XX_SAA711X,
                .input        = { {
                        .type     = EM28XX_VMUX_TELEVISION,
@@ -1563,7 +1564,7 @@ struct em28xx_board em28xx_boards[] = {
                        .aout     = EM28XX_AOUT_MONO |  /* I2S */
                                    EM28XX_AOUT_MASTER, /* Line out pin */
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1581,7 +1582,7 @@ struct em28xx_board em28xx_boards[] = {
                        .type     = EM28XX_VMUX_SVIDEO,
                        .vmux     = SAA7115_SVIDEO3,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                } },
        },
@@ -1610,7 +1611,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = em2880_msi_digivox_ad_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = em2880_msi_digivox_ad_analog,
@@ -1633,7 +1634,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = em2880_msi_digivox_ad_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = em2880_msi_digivox_ad_analog,
@@ -1654,7 +1655,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = TVP5150_COMPOSITE0,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1677,7 +1678,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = default_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = default_analog,
@@ -1708,7 +1709,7 @@ struct em28xx_board em28xx_boards[] = {
                        .gpio = em2882_kworld_315u_analog,
                        .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
                }, {
-                       .type = EM28XX_VMUX_COMPOSITE1,
+                       .type = EM28XX_VMUX_COMPOSITE,
                        .vmux = SAA7115_COMPOSITE0,
                        .amux = EM28XX_AMUX_LINE_IN,
                        .gpio = em2882_kworld_315u_analog1,
@@ -1735,7 +1736,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux = EM28XX_AMUX_VIDEO,
                        .gpio = default_analog,
                }, {
-                       .type = EM28XX_VMUX_COMPOSITE1,
+                       .type = EM28XX_VMUX_COMPOSITE,
                        .vmux = TVP5150_COMPOSITE1,
                        .amux = EM28XX_AMUX_LINE_IN,
                        .gpio = default_analog,
@@ -1758,7 +1759,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = default_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = default_analog,
@@ -1782,7 +1783,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = pinnacle_hybrid_pro_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = pinnacle_hybrid_pro_analog,
@@ -1808,7 +1809,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
@@ -1834,7 +1835,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = TVP5150_COMPOSITE0,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1859,7 +1860,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = hauppauge_wintv_hvr_900_analog,
@@ -1904,7 +1905,7 @@ struct em28xx_board em28xx_boards[] = {
                        .gpio     = kworld_330u_analog,
                        .aout     = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = kworld_330u_analog,
@@ -1951,7 +1952,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
 
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1970,7 +1971,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type   = TUNER_ABSENT,
                .decoder      = EM28XX_SAA711X,
                .input           = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -1990,7 +1991,7 @@ struct em28xx_board em28xx_boards[] = {
                        .vmux     = TVP5150_COMPOSITE0,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, { /* Composite has not been tested yet */
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_VIDEO,
                }, { /* S-video has not been tested yet */
@@ -2006,7 +2007,7 @@ struct em28xx_board em28xx_boards[] = {
                .decoder         = EM28XX_SAA711X,
                .xclk            = EM28XX_XCLK_FREQUENCY_12MHZ,
                .input           = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -2023,7 +2024,7 @@ struct em28xx_board em28xx_boards[] = {
                .xclk            = EM28XX_XCLK_FREQUENCY_12MHZ,
                .mute_gpio       = terratec_av350_mute_gpio,
                .input           = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AUDIO_SRC_LINE,
                        .gpio     = terratec_av350_unmute_gpio,
@@ -2041,7 +2042,7 @@ struct em28xx_board em28xx_boards[] = {
                .decoder      = EM28XX_SAA711X,
                .tuner_type   = TUNER_ABSENT,   /* Capture only device */
                .input        = { {
-                       .type  = EM28XX_VMUX_COMPOSITE1,
+                       .type  = EM28XX_VMUX_COMPOSITE,
                        .vmux  = SAA7115_COMPOSITE0,
                        .amux  = EM28XX_AMUX_LINE_IN,
                }, {
@@ -2067,7 +2068,7 @@ struct em28xx_board em28xx_boards[] = {
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = evga_indtube_analog,
                }, {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                        .gpio     = evga_indtube_analog,
@@ -2125,7 +2126,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type          = TUNER_ABSENT,
                .decoder             = EM28XX_SAA711X,
                .input               = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = SAA7115_COMPOSITE0,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -2238,7 +2239,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type   = TUNER_ABSENT,
                .is_webcam    = 1,
                .input        = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .amux     = EM28XX_AMUX_VIDEO,
                        .gpio     = speedlink_vad_laplace_reg_seq,
                } },
@@ -2272,7 +2273,7 @@ struct em28xx_board em28xx_boards[] = {
                .tuner_type    = TUNER_ABSENT,  /* Capture only device */
                .decoder       = EM28XX_TVP5150,
                .input         = { {
-                       .type     = EM28XX_VMUX_COMPOSITE1,
+                       .type     = EM28XX_VMUX_COMPOSITE,
                        .vmux     = TVP5150_COMPOSITE1,
                        .amux     = EM28XX_AMUX_LINE_IN,
                }, {
@@ -3012,6 +3013,41 @@ static void flush_request_modules(struct em28xx *dev)
        flush_work(&dev->request_module_wk);
 }
 
+static int em28xx_media_device_init(struct em28xx *dev,
+                                   struct usb_device *udev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct media_device *mdev;
+
+       if (udev->product) {
+               mdev = v4l2_mc_usb_media_device_init(udev, udev->product);
+       } else if (udev->manufacturer) {
+               mdev = v4l2_mc_usb_media_device_init(udev, udev->manufacturer);
+       } else {
+               mdev = v4l2_mc_usb_media_device_init(udev, dev->name);
+       }
+
+       if (!mdev)
+               return -ENOMEM;
+
+       dev->media_dev = mdev;
+#endif
+       return 0;
+}
+
+static void em28xx_unregister_media_device(struct em28xx *dev)
+{
+
+#ifdef CONFIG_MEDIA_CONTROLLER
+       if (dev->media_dev) {
+               media_device_unregister(dev->media_dev);
+               media_device_cleanup(dev->media_dev);
+               kfree(dev->media_dev);
+               dev->media_dev = NULL;
+       }
+#endif
+}
+
 /*
  * em28xx_release_resources()
  * unregisters the v4l2,i2c and usb devices
@@ -3023,6 +3059,8 @@ static void em28xx_release_resources(struct em28xx *dev)
 
        mutex_lock(&dev->lock);
 
+       em28xx_unregister_media_device(dev);
+
        if (dev->def_i2c_bus)
                em28xx_i2c_unregister(dev, 1);
        em28xx_i2c_unregister(dev, 0);
@@ -3167,6 +3205,8 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
         */
        snprintf(dev->name, sizeof(dev->name), "%s #%d", chip_name, dev->devno);
 
+       em28xx_media_device_init(dev, udev);
+
        if (dev->is_audio_only) {
                retval = em28xx_audio_setup(dev);
                if (retval)
@@ -3467,7 +3507,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
        /* save our data pointer in this interface device */
        usb_set_intfdata(interface, dev);
 
-       /* allocate device struct */
+       /* allocate device struct and check if the device is a webcam */
        mutex_init(&dev->lock);
        retval = em28xx_init_dev(dev, udev, interface, nr);
        if (retval) {
@@ -3483,6 +3523,15 @@ static int em28xx_usb_probe(struct usb_interface *interface,
                try_bulk = usb_xfer_mode > 0;
        }
 
+       /* Disable V4L2 if the device doesn't have a decoder */
+       if (has_video &&
+           dev->board.decoder == EM28XX_NODECODER && !dev->board.is_webcam) {
+               printk(DRIVER_NAME
+                      ": Currently, V4L2 is not supported on this model\n");
+               has_video = false;
+               dev->has_video = false;
+       }
+
        /* Select USB transfer types to use */
        if (has_video) {
                if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
@@ -3501,9 +3550,14 @@ static int em28xx_usb_probe(struct usb_interface *interface,
 
        request_modules(dev);
 
-       /* Should be the last thing to do, to avoid newer udev's to
-          open the device before fully initializing it
+       /*
+        * Do it at the end, to reduce dynamic configuration changes during
+        * the device init. Yet, as request_modules() can be async, the
+        * topology will likely change after the load of the em28xx subdrivers.
         */
+#ifdef CONFIG_MEDIA_CONTROLLER
+       retval = media_device_register(dev->media_dev);
+#endif
 
        return 0;
 
index bf5c244..5d209c7 100644 (file)
@@ -905,6 +905,7 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
                               struct em28xx *dev, struct device *device)
 {
        int result;
+       bool create_rf_connector = false;
 
        mutex_init(&dvb->lock);
 
@@ -916,6 +917,9 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
                       dev->name, result);
                goto fail_adapter;
        }
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+       dvb->adapter.mdev = dev->media_dev;
+#endif
 
        /* Ensure all frontends negotiate bus access */
        dvb->fe[0]->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl;
@@ -994,8 +998,19 @@ static int em28xx_register_dvb(struct em28xx_dvb *dvb, struct module *module,
 
        /* register network adapter */
        dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx);
+
+       /* If the analog part won't create RF connectors, DVB will do it */
+       if (!dev->has_video || (dev->tuner_type == TUNER_ABSENT))
+               create_rf_connector = true;
+
+       result = dvb_create_media_graph(&dvb->adapter, create_rf_connector);
+       if (result < 0)
+               goto fail_create_graph;
+
        return 0;
 
+fail_create_graph:
+       dvb_net_release(&dvb->net);
 fail_fe_conn:
        dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem);
 fail_fe_mem:
@@ -1656,6 +1671,9 @@ static int em28xx_dvb_init(struct em28xx *dev)
                        memset(&si2157_config, 0, sizeof(si2157_config));
                        si2157_config.fe = dvb->fe[0];
                        si2157_config.if_port = 1;
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+                       si2157_config.mdev = dev->media_dev;
+#endif
                        memset(&info, 0, sizeof(struct i2c_board_info));
                        strlcpy(info.type, "si2157", I2C_NAME_SIZE);
                        info.addr = 0x60;
@@ -1717,6 +1735,9 @@ static int em28xx_dvb_init(struct em28xx *dev)
                        memset(&si2157_config, 0, sizeof(si2157_config));
                        si2157_config.fe = dvb->fe[0];
                        si2157_config.if_port = 0;
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+                       si2157_config.mdev = dev->media_dev;
+#endif
                        memset(&info, 0, sizeof(struct i2c_board_info));
                        strlcpy(info.type, "si2146", I2C_NAME_SIZE);
                        info.addr = 0x60;
index 0e86ff4..f772e26 100644 (file)
@@ -196,7 +196,6 @@ static void em28xx_wake_i2c(struct em28xx *dev)
        v4l2_device_call_all(v4l2_dev, 0, core,  reset, 0);
        v4l2_device_call_all(v4l2_dev, 0, video, s_routing,
                             INPUT(dev->ctl_input)->vmux, 0, 0);
-       v4l2_device_call_all(v4l2_dev, 0, video, s_stream, 0);
 }
 
 static int em28xx_colorlevels_set_default(struct em28xx *dev)
@@ -867,6 +866,147 @@ static void res_free(struct em28xx *dev, enum v4l2_buf_type f_type)
        em28xx_videodbg("res: put %d\n", res_type);
 }
 
+static void em28xx_v4l2_media_release(struct em28xx *dev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+       int i;
+
+       for (i = 0; i < MAX_EM28XX_INPUT; i++) {
+               if (!INPUT(i)->type)
+                       return;
+               media_device_unregister_entity(&dev->input_ent[i]);
+       }
+#endif
+}
+
+/*
+ * Media Controller helper functions
+ */
+
+static int em28xx_enable_analog_tuner(struct em28xx *dev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct media_device *mdev = dev->media_dev;
+       struct em28xx_v4l2 *v4l2 = dev->v4l2;
+       struct media_entity *source;
+       struct media_link *link, *found_link = NULL;
+       int ret, active_links = 0;
+
+       if (!mdev || !v4l2->decoder)
+               return 0;
+
+       /*
+        * This will find the tuner that is connected into the decoder.
+        * Technically, this is not 100% correct, as the device may be
+        * using an analog input instead of the tuner. However, as we can't
+        * do DVB streaming while the DMA engine is being used for V4L2,
+        * this should be enough for the actual needs.
+        */
+       list_for_each_entry(link, &v4l2->decoder->links, list) {
+               if (link->sink->entity == v4l2->decoder) {
+                       found_link = link;
+                       if (link->flags & MEDIA_LNK_FL_ENABLED)
+                               active_links++;
+                       break;
+               }
+       }
+
+       if (active_links == 1 || !found_link)
+               return 0;
+
+       source = found_link->source->entity;
+       list_for_each_entry(link, &source->links, list) {
+               struct media_entity *sink;
+               int flags = 0;
+
+               sink = link->sink->entity;
+
+               if (sink == v4l2->decoder)
+                       flags = MEDIA_LNK_FL_ENABLED;
+
+               ret = media_entity_setup_link(link, flags);
+               if (ret) {
+                       pr_err("Couldn't change link %s->%s to %s. Error %d\n",
+                              source->name, sink->name,
+                              flags ? "enabled" : "disabled",
+                              ret);
+                       return ret;
+               } else
+                       em28xx_videodbg("link %s->%s was %s\n",
+                                       source->name, sink->name,
+                                       flags ? "ENABLED" : "disabled");
+       }
+#endif
+       return 0;
+}
+
+static const char * const iname[] = {
+       [EM28XX_VMUX_COMPOSITE]  = "Composite",
+       [EM28XX_VMUX_SVIDEO]     = "S-Video",
+       [EM28XX_VMUX_TELEVISION] = "Television",
+       [EM28XX_RADIO]           = "Radio",
+};
+
+static void em28xx_v4l2_create_entities(struct em28xx *dev)
+{
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       struct em28xx_v4l2 *v4l2 = dev->v4l2;
+       int ret, i;
+
+       /* Initialize Video, VBI and Radio pads */
+       v4l2->video_pad.flags = MEDIA_PAD_FL_SINK;
+       ret = media_entity_pads_init(&v4l2->vdev.entity, 1, &v4l2->video_pad);
+       if (ret < 0)
+               pr_err("failed to initialize video media entity!\n");
+
+       if (em28xx_vbi_supported(dev)) {
+               v4l2->vbi_pad.flags = MEDIA_PAD_FL_SINK;
+               ret = media_entity_pads_init(&v4l2->vbi_dev.entity, 1,
+                                            &v4l2->vbi_pad);
+               if (ret < 0)
+                       pr_err("failed to initialize vbi media entity!\n");
+       }
+
+       /* Webcams don't have input connectors */
+       if (dev->board.is_webcam)
+               return;
+
+       /* Create entities for each input connector */
+       for (i = 0; i < MAX_EM28XX_INPUT; i++) {
+               struct media_entity *ent = &dev->input_ent[i];
+
+               if (!INPUT(i)->type)
+                       break;
+
+               ent->name = iname[INPUT(i)->type];
+               ent->flags = MEDIA_ENT_FL_CONNECTOR;
+               dev->input_pad[i].flags = MEDIA_PAD_FL_SOURCE;
+
+               switch (INPUT(i)->type) {
+               case EM28XX_VMUX_COMPOSITE:
+                       ent->function = MEDIA_ENT_F_CONN_COMPOSITE;
+                       break;
+               case EM28XX_VMUX_SVIDEO:
+                       ent->function = MEDIA_ENT_F_CONN_SVIDEO;
+                       break;
+               default: /* EM28XX_VMUX_TELEVISION or EM28XX_RADIO */
+                       if (dev->tuner_type != TUNER_ABSENT)
+                               ent->function = MEDIA_ENT_F_CONN_RF;
+                       break;
+               }
+
+               ret = media_entity_pads_init(ent, 1, &dev->input_pad[i]);
+               if (ret < 0)
+                       pr_err("failed to initialize input pad[%d]!\n", i);
+
+               ret = media_device_register_entity(dev->media_dev, ent);
+               if (ret < 0)
+                       pr_err("failed to register input entity %d!\n", i);
+       }
+#endif
+}
+
+
 /* ------------------------------------------------------------------
        Videobuf2 operations
    ------------------------------------------------------------------*/
@@ -884,6 +1024,9 @@ static int queue_setup(struct vb2_queue *vq,
                return sizes[0] < size ? -EINVAL : 0;
        *nplanes = 1;
        sizes[0] = size;
+
+       em28xx_enable_analog_tuner(dev);
+
        return 0;
 }
 
@@ -962,6 +1105,9 @@ int em28xx_start_analog_streaming(struct vb2_queue *vq, unsigned int count)
                        f.type = V4L2_TUNER_ANALOG_TV;
                v4l2_device_call_all(&v4l2->v4l2_dev,
                                     0, tuner, s_frequency, &f);
+
+               /* Enable video stream at TV decoder */
+               v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 1);
        }
 
        v4l2->streaming_users++;
@@ -981,6 +1127,9 @@ static void em28xx_stop_streaming(struct vb2_queue *vq)
        res_free(dev, vq->type);
 
        if (v4l2->streaming_users-- == 1) {
+               /* Disable video stream at TV decoder */
+               v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 0);
+
                /* Last active user, so shutdown all the URBS */
                em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
        }
@@ -1013,6 +1162,9 @@ void em28xx_stop_vbi_streaming(struct vb2_queue *vq)
        res_free(dev, vq->type);
 
        if (v4l2->streaming_users-- == 1) {
+               /* Disable video stream at TV decoder */
+               v4l2_device_call_all(&v4l2->v4l2_dev, 0, video, s_stream, 0);
+
                /* Last active user, so shutdown all the URBS */
                em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
        }
@@ -1224,6 +1376,12 @@ static void scale_to_size(struct em28xx *dev,
 
        *width = (((unsigned long)maxw) << 12) / (hscale + 4096L);
        *height = (((unsigned long)maxh) << 12) / (vscale + 4096L);
+
+       /* Don't let width or height to be zero */
+       if (*width < 1)
+               *width = 1;
+       if (*height < 1)
+               *height = 1;
 }
 
 /* ------------------------------------------------------------------
@@ -1299,6 +1457,11 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
                v4l_bound_align_image(&width, 48, maxw, 1, &height, 32, maxh,
                                      1, 0);
        }
+       /* Avoid division by zero at size_to_scale */
+       if (width < 1)
+               width = 1;
+       if (height < 1)
+               height = 1;
 
        size_to_scale(dev, width, height, &hscale, &vscale);
        scale_to_size(dev, hscale, vscale, &width, &height);
@@ -1434,18 +1597,6 @@ static int vidioc_s_parm(struct file *file, void *priv,
                                          0, video, s_parm, p);
 }
 
-static const char *iname[] = {
-       [EM28XX_VMUX_COMPOSITE1] = "Composite1",
-       [EM28XX_VMUX_COMPOSITE2] = "Composite2",
-       [EM28XX_VMUX_COMPOSITE3] = "Composite3",
-       [EM28XX_VMUX_COMPOSITE4] = "Composite4",
-       [EM28XX_VMUX_SVIDEO]     = "S-Video",
-       [EM28XX_VMUX_TELEVISION] = "Television",
-       [EM28XX_VMUX_CABLE]      = "Cable TV",
-       [EM28XX_VMUX_DVB]        = "DVB",
-       [EM28XX_VMUX_DEBUG]      = "for debug only",
-};
-
 static int vidioc_enum_input(struct file *file, void *priv,
                             struct v4l2_input *i)
 {
@@ -1463,8 +1614,7 @@ static int vidioc_enum_input(struct file *file, void *priv,
 
        strcpy(i->name, iname[INPUT(n)->type]);
 
-       if ((EM28XX_VMUX_TELEVISION == INPUT(n)->type) ||
-           (EM28XX_VMUX_CABLE == INPUT(n)->type))
+       if ((EM28XX_VMUX_TELEVISION == INPUT(n)->type))
                i->type = V4L2_INPUT_TYPE_TUNER;
 
        i->std = dev->v4l2->vdev.tvnorms;
@@ -1961,6 +2111,8 @@ static int em28xx_v4l2_fini(struct em28xx *dev)
 
        em28xx_uninit_usb_xfer(dev, EM28XX_ANALOG_MODE);
 
+       em28xx_v4l2_media_release(dev);
+
        if (video_is_registered(&v4l2->radio_dev)) {
                em28xx_info("V4L2 device %s deregistered\n",
                            video_device_node_name(&v4l2->radio_dev));
@@ -2284,6 +2436,9 @@ static int em28xx_v4l2_init(struct em28xx *dev)
        v4l2->dev = dev;
        dev->v4l2 = v4l2;
 
+#ifdef CONFIG_MEDIA_CONTROLLER
+       v4l2->v4l2_dev.mdev = dev->media_dev;
+#endif
        ret = v4l2_device_register(&dev->udev->dev, &v4l2->v4l2_dev);
        if (ret < 0) {
                em28xx_errdev("Call to v4l2_device_register() failed!\n");
@@ -2556,6 +2711,16 @@ static int em28xx_v4l2_init(struct em28xx *dev)
                            video_device_node_name(&v4l2->radio_dev));
        }
 
+       /* Init entities at the Media Controller */
+       em28xx_v4l2_create_entities(dev);
+
+       ret = v4l2_mc_create_media_graph(dev->media_dev);
+       if (ret) {
+               em28xx_errdev("failed to create media graph\n");
+               em28xx_v4l2_media_release(dev);
+               goto unregister_dev;
+       }
+
        em28xx_info("V4L2 video device registered as %s\n",
                    video_device_node_name(&v4l2->vdev));
 
@@ -2577,6 +2742,22 @@ static int em28xx_v4l2_init(struct em28xx *dev)
        return 0;
 
 unregister_dev:
+       if (video_is_registered(&v4l2->radio_dev)) {
+               em28xx_info("V4L2 device %s deregistered\n",
+                           video_device_node_name(&v4l2->radio_dev));
+               video_unregister_device(&v4l2->radio_dev);
+       }
+       if (video_is_registered(&v4l2->vbi_dev)) {
+               em28xx_info("V4L2 device %s deregistered\n",
+                           video_device_node_name(&v4l2->vbi_dev));
+               video_unregister_device(&v4l2->vbi_dev);
+       }
+       if (video_is_registered(&v4l2->vdev)) {
+               em28xx_info("V4L2 device %s deregistered\n",
+                           video_device_node_name(&v4l2->vdev));
+               video_unregister_device(&v4l2->vdev);
+       }
+
        v4l2_ctrl_handler_free(&v4l2->ctrl_handler);
        v4l2_device_unregister(&v4l2->v4l2_dev);
 err:
index 8ff066c..2674449 100644 (file)
@@ -26,7 +26,7 @@
 #ifndef _EM28XX_H
 #define _EM28XX_H
 
-#define EM28XX_VERSION "0.2.1"
+#define EM28XX_VERSION "0.2.2"
 #define DRIVER_DESC    "Empia em28xx device driver"
 
 #include <linux/workqueue.h>
@@ -291,15 +291,9 @@ struct em28xx_dmaqueue {
 
 #define MAX_EM28XX_INPUT 4
 enum enum28xx_itype {
-       EM28XX_VMUX_COMPOSITE1 = 1,
-       EM28XX_VMUX_COMPOSITE2,
-       EM28XX_VMUX_COMPOSITE3,
-       EM28XX_VMUX_COMPOSITE4,
+       EM28XX_VMUX_COMPOSITE = 1,
        EM28XX_VMUX_SVIDEO,
        EM28XX_VMUX_TELEVISION,
-       EM28XX_VMUX_CABLE,
-       EM28XX_VMUX_DVB,
-       EM28XX_VMUX_DEBUG,
        EM28XX_RADIO,
 };
 
@@ -558,6 +552,11 @@ struct em28xx_v4l2 {
        bool top_field;
        int vbi_read;
        unsigned int field_count;
+
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct media_pad video_pad, vbi_pad;
+       struct media_entity *decoder;
+#endif
 };
 
 struct em28xx_audio {
@@ -718,6 +717,12 @@ struct em28xx {
        /* Snapshot button input device */
        char snapshot_button_path[30];  /* path of the input dev */
        struct input_dev *sbutton_input_dev;
+
+#ifdef CONFIG_MEDIA_CONTROLLER
+       struct media_device *media_dev;
+       struct media_entity input_ent[MAX_EM28XX_INPUT];
+       struct media_pad input_pad[MAX_EM28XX_INPUT];
+#endif
 };
 
 #define kref_to_dev(d) container_of(d, struct em28xx, ref)
index 745185e..bebee8c 100644 (file)
@@ -250,7 +250,7 @@ struct go7007 {
        struct i2c_adapter i2c_adapter;
 
        /* HPI driver */
-       struct go7007_hpi_ops *hpi_ops;
+       const struct go7007_hpi_ops *hpi_ops;
        void *hpi_context;
        int interrupt_available;
        wait_queue_head_t interrupt_waitq;
index 3dbf14c..14d3f8c 100644 (file)
@@ -932,7 +932,7 @@ static void go7007_usb_release(struct go7007 *go)
        kfree(go->hpi_context);
 }
 
-static struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
+static const struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
        .interface_reset        = go7007_usb_interface_reset,
        .write_interrupt        = go7007_usb_ezusb_write_interrupt,
        .read_interrupt         = go7007_usb_read_interrupt,
@@ -942,7 +942,7 @@ static struct go7007_hpi_ops go7007_usb_ezusb_hpi_ops = {
        .release                = go7007_usb_release,
 };
 
-static struct go7007_hpi_ops go7007_usb_onboard_hpi_ops = {
+static const struct go7007_hpi_ops go7007_usb_onboard_hpi_ops = {
        .interface_reset        = go7007_usb_interface_reset,
        .write_interrupt        = go7007_usb_onboard_write_interrupt,
        .read_interrupt         = go7007_usb_read_interrupt,
index 3fc6419..08f0ca7 100644 (file)
@@ -273,7 +273,9 @@ static int hdpvr_probe(struct usb_interface *interface,
        struct hdpvr_device *dev;
        struct usb_host_interface *iface_desc;
        struct usb_endpoint_descriptor *endpoint;
+#if IS_ENABLED(CONFIG_I2C)
        struct i2c_client *client;
+#endif
        size_t buffer_size;
        int i;
        int retval = -ENOMEM;
index 7dee22d..ba7f022 100644 (file)
@@ -462,10 +462,8 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
                        }
 
                        if (wait_event_interruptible(dev->wait_data,
-                                             buf->status == BUFSTAT_READY)) {
-                               ret = -ERESTARTSYS;
-                               goto err;
-                       }
+                                             buf->status == BUFSTAT_READY))
+                               return -ERESTARTSYS;
                }
 
                if (buf->status != BUFSTAT_READY)
index c104315..2d33033 100644 (file)
@@ -839,8 +839,6 @@ static int msi2500_set_usb_adc(struct msi2500_dev *dev)
                goto err;
 
        ret = msi2500_ctrl_msg(dev, CMD_WREG, reg3);
-       if (ret)
-               goto err;
 err:
        return ret;
 }
index fd888a6..c45f307 100644 (file)
@@ -196,7 +196,7 @@ int pvr2_context_global_init(void)
        pvr2_context_thread_ptr = kthread_run(pvr2_context_thread_func,
                                              NULL,
                                              "pvrusb2-context");
-       return (pvr2_context_thread_ptr ? 0 : -ENOMEM);
+       return IS_ERR(pvr2_context_thread_ptr) ? -ENOMEM : 0;
 }
 
 
index 086cf1c..18aed5d 100644 (file)
@@ -91,6 +91,7 @@ static const struct usb_device_id pwc_device_table [] = {
        { USB_DEVICE(0x0471, 0x0312) },
        { USB_DEVICE(0x0471, 0x0313) }, /* the 'new' 720K */
        { USB_DEVICE(0x0471, 0x0329) }, /* Philips SPC 900NC PC Camera */
+       { USB_DEVICE(0x0471, 0x032C) }, /* Philips SPC 880NC PC Camera */
        { USB_DEVICE(0x069A, 0x0001) }, /* Askey */
        { USB_DEVICE(0x046D, 0x08B0) }, /* Logitech QuickCam Pro 3000 */
        { USB_DEVICE(0x046D, 0x08B1) }, /* Logitech QuickCam Notebook Pro */
@@ -810,6 +811,11 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
                        name = "Philips SPC 900NC webcam";
                        type_id = 740;
                        break;
+               case 0x032C:
+                       PWC_INFO("Philips SPC 880NC USB webcam detected.\n");
+                       name = "Philips SPC 880NC webcam";
+                       type_id = 740;
+                       break;
                default:
                        return -ENODEV;
                        break;
index 8abbd3c..4dac499 100644 (file)
@@ -27,6 +27,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <linux/firmware.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <media/v4l2-mc.h>
 
 #include "sms-cards.h"
 #include "smsendian.h"
@@ -51,6 +52,9 @@ struct smsusb_urb_t {
        struct smsusb_device_t *dev;
 
        struct urb urb;
+
+       /* For the bottom half */
+       struct work_struct wq;
 };
 
 struct smsusb_device_t {
@@ -71,6 +75,18 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
                             struct smsusb_urb_t *surb);
 
 /**
+ * Completing URB's callback handler - bottom half (proccess context)
+ * submits the URB prepared on smsusb_onresponse()
+ */
+static void do_submit_urb(struct work_struct *work)
+{
+       struct smsusb_urb_t *surb = container_of(work, struct smsusb_urb_t, wq);
+       struct smsusb_device_t *dev = surb->dev;
+
+       smsusb_submit_urb(dev, surb);
+}
+
+/**
  * Completing URB's callback handler - top half (interrupt context)
  * adds completing sms urb to the global surbs list and activtes the worker
  * thread the surb
@@ -138,13 +154,15 @@ static void smsusb_onresponse(struct urb *urb)
 
 
 exit_and_resubmit:
-       smsusb_submit_urb(dev, surb);
+       INIT_WORK(&surb->wq, do_submit_urb);
+       schedule_work(&surb->wq);
 }
 
 static int smsusb_submit_urb(struct smsusb_device_t *dev,
                             struct smsusb_urb_t *surb)
 {
        if (!surb->cb) {
+               /* This function can sleep */
                surb->cb = smscore_getbuffer(dev->coredev);
                if (!surb->cb) {
                        pr_err("smscore_getbuffer(...) returned NULL\n");
@@ -349,20 +367,10 @@ static void *siano_media_device_register(struct smsusb_device_t *dev,
        struct sms_board *board = sms_get_board(board_id);
        int ret;
 
-       mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+       mdev = v4l2_mc_usb_media_device_init(udev, board->name);
        if (!mdev)
                return NULL;
 
-       mdev->dev = &udev->dev;
-       strlcpy(mdev->model, board->name, sizeof(mdev->model));
-       if (udev->serial)
-               strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
-       strcpy(mdev->bus_info, udev->devpath);
-       mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
-       mdev->driver_version = LINUX_VERSION_CODE;
-
-       media_device_init(mdev);
-
        ret = media_device_register(mdev);
        if (ret) {
                media_device_cleanup(mdev);
index 46191d5..6ecb0b4 100644 (file)
@@ -98,7 +98,6 @@ void stk1160_buffer_done(struct stk1160 *dev)
 
        buf->vb.sequence = dev->sequence++;
        buf->vb.field = V4L2_FIELD_INTERLACED;
-       buf->vb.vb2_buf.planes[0].bytesused = buf->bytesused;
        buf->vb.vb2_buf.timestamp = ktime_get_ns();
 
        vb2_set_plane_payload(&buf->vb.vb2_buf, 0, buf->bytesused);
index 4ebb339..f6cfad4 100644 (file)
@@ -312,20 +312,24 @@ static void usbtv_image_chunk(struct usbtv *usbtv, __be32 *chunk)
        usbtv_chunk_to_vbuf(frame, &chunk[1], chunk_no, odd);
        usbtv->chunks_done++;
 
-       /* Last chunk in a frame, signalling an end */
-       if (odd && chunk_no == usbtv->n_chunks-1) {
-               int size = vb2_plane_size(&buf->vb.vb2_buf, 0);
-               enum vb2_buffer_state state = usbtv->chunks_done ==
-                                               usbtv->n_chunks ?
-                                               VB2_BUF_STATE_DONE :
-                                               VB2_BUF_STATE_ERROR;
-
-               buf->vb.field = V4L2_FIELD_INTERLACED;
-               buf->vb.sequence = usbtv->sequence++;
-               buf->vb.vb2_buf.timestamp = ktime_get_ns();
-               vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size);
-               vb2_buffer_done(&buf->vb.vb2_buf, state);
-               list_del(&buf->list);
+       /* Last chunk in a field */
+       if (chunk_no == usbtv->n_chunks-1) {
+               /* Last chunk in a frame, signalling an end */
+               if (odd && !usbtv->last_odd) {
+                       int size = vb2_plane_size(&buf->vb.vb2_buf, 0);
+                       enum vb2_buffer_state state = usbtv->chunks_done ==
+                               usbtv->n_chunks ?
+                               VB2_BUF_STATE_DONE :
+                               VB2_BUF_STATE_ERROR;
+
+                       buf->vb.field = V4L2_FIELD_INTERLACED;
+                       buf->vb.sequence = usbtv->sequence++;
+                       buf->vb.vb2_buf.timestamp = ktime_get_ns();
+                       vb2_set_plane_payload(&buf->vb.vb2_buf, 0, size);
+                       vb2_buffer_done(&buf->vb.vb2_buf, state);
+                       list_del(&buf->list);
+               }
+               usbtv->last_odd = odd;
        }
 
        spin_unlock_irqrestore(&usbtv->buflock, flags);
@@ -389,6 +393,10 @@ static struct urb *usbtv_setup_iso_transfer(struct usbtv *usbtv)
        ip->transfer_flags = URB_ISO_ASAP;
        ip->transfer_buffer = kzalloc(size * USBTV_ISOC_PACKETS,
                                                GFP_KERNEL);
+       if (!ip->transfer_buffer) {
+               usb_free_urb(ip);
+               return NULL;
+       }
        ip->complete = usbtv_iso_cb;
        ip->number_of_packets = USBTV_ISOC_PACKETS;
        ip->transfer_buffer_length = size * USBTV_ISOC_PACKETS;
@@ -639,6 +647,7 @@ static int usbtv_start_streaming(struct vb2_queue *vq, unsigned int count)
        if (usbtv->udev == NULL)
                return -ENODEV;
 
+       usbtv->last_odd = 1;
        usbtv->sequence = 0;
        return usbtv_start(usbtv);
 }
index 19cb8bf..161b38d 100644 (file)
@@ -95,6 +95,7 @@ struct usbtv {
        int width, height;
        int n_chunks;
        int iso_size;
+       int last_odd;
        unsigned int sequence;
        struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS];
 
index de9ff3b..12f5ebb 100644 (file)
@@ -162,8 +162,7 @@ MODULE_ALIAS(DRIVER_ALIAS);
 
 static inline struct usb_usbvision *cd_to_usbvision(struct device *cd)
 {
-       struct video_device *vdev =
-               container_of(cd, struct video_device, dev);
+       struct video_device *vdev = to_video_device(cd);
        return video_get_drvdata(vdev);
 }
 
@@ -177,8 +176,7 @@ static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
 static ssize_t show_model(struct device *cd,
                          struct device_attribute *attr, char *buf)
 {
-       struct video_device *vdev =
-               container_of(cd, struct video_device, dev);
+       struct video_device *vdev = to_video_device(cd);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        return sprintf(buf, "%s\n",
                       usbvision_device_data[usbvision->dev_model].model_string);
@@ -188,8 +186,7 @@ static DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
 static ssize_t show_hue(struct device *cd,
                        struct device_attribute *attr, char *buf)
 {
-       struct video_device *vdev =
-               container_of(cd, struct video_device, dev);
+       struct video_device *vdev = to_video_device(cd);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        struct v4l2_control ctrl;
        ctrl.id = V4L2_CID_HUE;
@@ -203,8 +200,7 @@ static DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
 static ssize_t show_contrast(struct device *cd,
                             struct device_attribute *attr, char *buf)
 {
-       struct video_device *vdev =
-               container_of(cd, struct video_device, dev);
+       struct video_device *vdev = to_video_device(cd);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        struct v4l2_control ctrl;
        ctrl.id = V4L2_CID_CONTRAST;
@@ -218,8 +214,7 @@ static DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
 static ssize_t show_brightness(struct device *cd,
                               struct device_attribute *attr, char *buf)
 {
-       struct video_device *vdev =
-               container_of(cd, struct video_device, dev);
+       struct video_device *vdev = to_video_device(cd);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        struct v4l2_control ctrl;
        ctrl.id = V4L2_CID_BRIGHTNESS;
@@ -233,8 +228,7 @@ static DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
 static ssize_t show_saturation(struct device *cd,
                               struct device_attribute *attr, char *buf)
 {
-       struct video_device *vdev =
-               container_of(cd, struct video_device, dev);
+       struct video_device *vdev = to_video_device(cd);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        struct v4l2_control ctrl;
        ctrl.id = V4L2_CID_SATURATION;
@@ -248,8 +242,7 @@ static DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
 static ssize_t show_streaming(struct device *cd,
                              struct device_attribute *attr, char *buf)
 {
-       struct video_device *vdev =
-               container_of(cd, struct video_device, dev);
+       struct video_device *vdev = to_video_device(cd);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        return sprintf(buf, "%s\n",
                       YES_NO(usbvision->streaming == stream_on ? 1 : 0));
@@ -259,8 +252,7 @@ static DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL);
 static ssize_t show_compression(struct device *cd,
                                struct device_attribute *attr, char *buf)
 {
-       struct video_device *vdev =
-               container_of(cd, struct video_device, dev);
+       struct video_device *vdev = to_video_device(cd);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        return sprintf(buf, "%s\n",
                       YES_NO(usbvision->isoc_mode == ISOC_MODE_COMPRESS));
@@ -270,8 +262,7 @@ static DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL);
 static ssize_t show_device_bridge(struct device *cd,
                                  struct device_attribute *attr, char *buf)
 {
-       struct video_device *vdev =
-               container_of(cd, struct video_device, dev);
+       struct video_device *vdev = to_video_device(cd);
        struct usb_usbvision *usbvision = video_get_drvdata(vdev);
        return sprintf(buf, "%d\n", usbvision->bridge_type);
 }
@@ -1156,6 +1147,7 @@ static int usbvision_radio_close(struct file *file)
        usbvision_audio_off(usbvision);
        usbvision->radio = 0;
        usbvision->user--;
+       mutex_unlock(&usbvision->v4l2_lock);
 
        if (usbvision->remove_pending) {
                printk(KERN_INFO "%s: Final disconnect\n", __func__);
@@ -1164,7 +1156,6 @@ static int usbvision_radio_close(struct file *file)
                return 0;
        }
 
-       mutex_unlock(&usbvision->v4l2_lock);
        PDEBUG(DBG_IO, "success");
        return v4l2_fh_release(file);
 }
index 9beece0..29b3436 100644 (file)
@@ -37,7 +37,6 @@ config VIDEO_PCI_SKELETON
 # Used by drivers that need tuner.ko
 config VIDEO_TUNER
        tristate
-       depends on MEDIA_TUNER
 
 # Used by drivers that need v4l2-mem2mem.ko
 config V4L2_MEM2MEM_DEV
index 1dc8bba..795a535 100644 (file)
@@ -16,6 +16,7 @@ endif
 ifeq ($(CONFIG_TRACEPOINTS),y)
   videodev-objs += vb2-trace.o v4l2-trace.o
 endif
+videodev-$(CONFIG_MEDIA_CONTROLLER) += v4l2-mc.o
 
 obj-$(CONFIG_VIDEO_V4L2) += videodev.o
 obj-$(CONFIG_VIDEO_V4L2) += v4l2-common.o
index 76496fd..731487b 100644 (file)
@@ -696,16 +696,32 @@ static int tuner_probe(struct i2c_client *client,
        /* Should be just before return */
 register_client:
 #if defined(CONFIG_MEDIA_CONTROLLER)
-       t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
-       t->pad[TUNER_PAD_IF_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
-       t->sd.entity.function = MEDIA_ENT_F_TUNER;
        t->sd.entity.name = t->name;
+       /*
+        * Handle the special case where the tuner has actually
+        * two stages: the PLL to tune into a frequency and the
+        * IF-PLL demodulator (tda988x).
+        */
+       if (t->type == TUNER_TDA9887) {
+               t->pad[IF_VID_DEC_PAD_IF_INPUT].flags = MEDIA_PAD_FL_SINK;
+               t->pad[IF_VID_DEC_PAD_OUT].flags = MEDIA_PAD_FL_SOURCE;
+               ret = media_entity_pads_init(&t->sd.entity,
+                                            IF_VID_DEC_PAD_NUM_PADS,
+                                            &t->pad[0]);
+               t->sd.entity.function = MEDIA_ENT_F_IF_VID_DECODER;
+       } else {
+               t->pad[TUNER_PAD_RF_INPUT].flags = MEDIA_PAD_FL_SINK;
+               t->pad[TUNER_PAD_OUTPUT].flags = MEDIA_PAD_FL_SOURCE;
+               t->pad[TUNER_PAD_AUD_OUT].flags = MEDIA_PAD_FL_SOURCE;
+               ret = media_entity_pads_init(&t->sd.entity, TUNER_NUM_PADS,
+                                            &t->pad[0]);
+               t->sd.entity.function = MEDIA_ENT_F_TUNER;
+       }
 
-       ret = media_entity_pads_init(&t->sd.entity, TUNER_NUM_PADS, &t->pad[0]);
        if (ret < 0) {
                tuner_err("failed to initialize media entity!\n");
                kfree(t);
-               return -ENODEV;
+               return ret;
        }
 #endif
        /* Sets a default mode */
index 5bada20..a4b224d 100644 (file)
@@ -119,6 +119,13 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
                return ret;
        }
 
+       ret = v4l2_subdev_call(sd, core, registered_async);
+       if (ret < 0 && ret != -ENOIOCTLCMD) {
+               if (notifier->unbind)
+                       notifier->unbind(notifier, sd, asd);
+               return ret;
+       }
+
        if (list_empty(&notifier->waiting) && notifier->complete)
                return notifier->complete(notifier);
 
index 8fd84a6..019644f 100644 (file)
@@ -415,7 +415,8 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
                get_user(kp->index, &up->index) ||
                get_user(kp->type, &up->type) ||
                get_user(kp->flags, &up->flags) ||
-               get_user(kp->memory, &up->memory))
+               get_user(kp->memory, &up->memory) ||
+               get_user(kp->length, &up->length))
                        return -EFAULT;
 
        if (V4L2_TYPE_IS_OUTPUT(kp->type))
@@ -427,9 +428,6 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
                        return -EFAULT;
 
        if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) {
-               if (get_user(kp->length, &up->length))
-                       return -EFAULT;
-
                num_planes = kp->length;
                if (num_planes == 0) {
                        kp->m.planes = NULL;
@@ -462,16 +460,14 @@ static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
        } else {
                switch (kp->memory) {
                case V4L2_MEMORY_MMAP:
-                       if (get_user(kp->length, &up->length) ||
-                               get_user(kp->m.offset, &up->m.offset))
+                       if (get_user(kp->m.offset, &up->m.offset))
                                return -EFAULT;
                        break;
                case V4L2_MEMORY_USERPTR:
                        {
                        compat_long_t tmp;
 
-                       if (get_user(kp->length, &up->length) ||
-                           get_user(tmp, &up->m.userptr))
+                       if (get_user(tmp, &up->m.userptr))
                                return -EFAULT;
 
                        kp->m.userptr = (unsigned long)compat_ptr(tmp);
@@ -513,7 +509,8 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
                copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) ||
                put_user(kp->sequence, &up->sequence) ||
                put_user(kp->reserved2, &up->reserved2) ||
-               put_user(kp->reserved, &up->reserved))
+               put_user(kp->reserved, &up->reserved) ||
+               put_user(kp->length, &up->length))
                        return -EFAULT;
 
        if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) {
@@ -536,13 +533,11 @@ static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user
        } else {
                switch (kp->memory) {
                case V4L2_MEMORY_MMAP:
-                       if (put_user(kp->length, &up->length) ||
-                               put_user(kp->m.offset, &up->m.offset))
+                       if (put_user(kp->m.offset, &up->m.offset))
                                return -EFAULT;
                        break;
                case V4L2_MEMORY_USERPTR:
-                       if (put_user(kp->length, &up->length) ||
-                               put_user(kp->m.userptr, &up->m.userptr))
+                       if (put_user(kp->m.userptr, &up->m.userptr))
                                return -EFAULT;
                        break;
                case V4L2_MEMORY_OVERLAY:
index c9d5537..8b321e0 100644 (file)
@@ -462,6 +462,14 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
                "RGB full range (0-255)",
                NULL,
        };
+       static const char * const dv_it_content_type[] = {
+               "Graphics",
+               "Photo",
+               "Cinema",
+               "Game",
+               "No IT Content",
+               NULL,
+       };
        static const char * const detect_md_mode[] = {
                "Disabled",
                "Global",
@@ -560,6 +568,9 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
        case V4L2_CID_DV_TX_RGB_RANGE:
        case V4L2_CID_DV_RX_RGB_RANGE:
                return dv_rgb_range;
+       case V4L2_CID_DV_TX_IT_CONTENT_TYPE:
+       case V4L2_CID_DV_RX_IT_CONTENT_TYPE:
+               return dv_it_content_type;
        case V4L2_CID_DETECT_MD_MODE:
                return detect_md_mode;
 
@@ -747,6 +758,7 @@ const char *v4l2_ctrl_get_name(u32 id)
        case V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE:             return "Horizontal MV Search Range";
        case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE:             return "Vertical MV Search Range";
        case V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER:             return "Repeat Sequence Header";
+       case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:               return "Force Key Frame";
 
        /* VPX controls */
        case V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS:            return "VPX Number of Partitions";
@@ -881,8 +893,10 @@ const char *v4l2_ctrl_get_name(u32 id)
        case V4L2_CID_DV_TX_EDID_PRESENT:       return "EDID Present";
        case V4L2_CID_DV_TX_MODE:               return "Transmit Mode";
        case V4L2_CID_DV_TX_RGB_RANGE:          return "Tx RGB Quantization Range";
+       case V4L2_CID_DV_TX_IT_CONTENT_TYPE:    return "Tx IT Content Type";
        case V4L2_CID_DV_RX_POWER_PRESENT:      return "Power Present";
        case V4L2_CID_DV_RX_RGB_RANGE:          return "Rx RGB Quantization Range";
+       case V4L2_CID_DV_RX_IT_CONTENT_TYPE:    return "Rx IT Content Type";
 
        case V4L2_CID_FM_RX_CLASS:              return "FM Radio Receiver Controls";
        case V4L2_CID_TUNE_DEEMPHASIS:          return "De-Emphasis";
@@ -985,6 +999,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE:
                *type = V4L2_CTRL_TYPE_INTEGER;
                break;
+       case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME:
        case V4L2_CID_PAN_RESET:
        case V4L2_CID_TILT_RESET:
        case V4L2_CID_FLASH_STROBE:
@@ -1038,7 +1053,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_SCENE_MODE:
        case V4L2_CID_DV_TX_MODE:
        case V4L2_CID_DV_TX_RGB_RANGE:
+       case V4L2_CID_DV_TX_IT_CONTENT_TYPE:
        case V4L2_CID_DV_RX_RGB_RANGE:
+       case V4L2_CID_DV_RX_IT_CONTENT_TYPE:
        case V4L2_CID_TEST_PATTERN:
        case V4L2_CID_TUNE_DEEMPHASIS:
        case V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL:
@@ -1185,6 +1202,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
        case V4L2_CID_DV_TX_RXSENSE:
        case V4L2_CID_DV_TX_EDID_PRESENT:
        case V4L2_CID_DV_RX_POWER_PRESENT:
+       case V4L2_CID_DV_RX_IT_CONTENT_TYPE:
        case V4L2_CID_RDS_RX_PTY:
        case V4L2_CID_RDS_RX_PS_NAME:
        case V4L2_CID_RDS_RX_RADIO_TEXT:
@@ -2211,22 +2229,6 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
 }
 EXPORT_SYMBOL(v4l2_ctrl_new_int_menu);
 
-/* Add a control from another handler to this handler */
-struct v4l2_ctrl *v4l2_ctrl_add_ctrl(struct v4l2_ctrl_handler *hdl,
-                                         struct v4l2_ctrl *ctrl)
-{
-       if (hdl == NULL || hdl->error)
-               return NULL;
-       if (ctrl == NULL) {
-               handler_set_err(hdl, -EINVAL);
-               return NULL;
-       }
-       if (ctrl->handler == hdl)
-               return ctrl;
-       return handler_new_ref(hdl, ctrl) ? NULL : ctrl;
-}
-EXPORT_SYMBOL(v4l2_ctrl_add_ctrl);
-
 /* Add the controls from another handler to our own. */
 int v4l2_ctrl_add_handler(struct v4l2_ctrl_handler *hdl,
                          struct v4l2_ctrl_handler *add,
index ec258b7..889de0a 100644 (file)
@@ -165,7 +165,8 @@ bool v4l2_valid_dv_timings(const struct v4l2_dv_timings *t,
            bt->width > cap->max_width ||
            bt->pixelclock < cap->min_pixelclock ||
            bt->pixelclock > cap->max_pixelclock ||
-           (cap->standards && bt->standards &&
+           (!(caps & V4L2_DV_BT_CAP_CUSTOM) &&
+            cap->standards && bt->standards &&
             !(bt->standards & cap->standards)) ||
            (bt->interlaced && !(caps & V4L2_DV_BT_CAP_INTERLACED)) ||
            (!bt->interlaced && !(caps & V4L2_DV_BT_CAP_PROGRESSIVE)))
index 8a018c6..1484309 100644 (file)
@@ -1191,6 +1191,10 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
        case V4L2_PIX_FMT_NV12MT_16X16: descr = "Y/CbCr 4:2:0 (16x16 MB, N-C)"; break;
        case V4L2_PIX_FMT_YUV420M:      descr = "Planar YUV 4:2:0 (N-C)"; break;
        case V4L2_PIX_FMT_YVU420M:      descr = "Planar YVU 4:2:0 (N-C)"; break;
+       case V4L2_PIX_FMT_YUV422M:      descr = "Planar YUV 4:2:2 (N-C)"; break;
+       case V4L2_PIX_FMT_YVU422M:      descr = "Planar YVU 4:2:2 (N-C)"; break;
+       case V4L2_PIX_FMT_YUV444M:      descr = "Planar YUV 4:4:4 (N-C)"; break;
+       case V4L2_PIX_FMT_YVU444M:      descr = "Planar YVU 4:4:4 (N-C)"; break;
        case V4L2_PIX_FMT_SBGGR8:       descr = "8-bit Bayer BGBG/GRGR"; break;
        case V4L2_PIX_FMT_SGBRG8:       descr = "8-bit Bayer GBGB/RGRG"; break;
        case V4L2_PIX_FMT_SGRBG8:       descr = "8-bit Bayer GRGR/BGBG"; break;
diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c
new file mode 100644 (file)
index 0000000..a7f41b3
--- /dev/null
@@ -0,0 +1,258 @@
+/*
+ * Media Controller ancillary functions
+ *
+ * (c) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/usb.h>
+#include <media/media-entity.h>
+#include <media/v4l2-mc.h>
+
+
+struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev,
+                                                  const char *name)
+{
+#ifdef CONFIG_PCI
+       struct media_device *mdev;
+
+       mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+       if (!mdev)
+               return NULL;
+
+       mdev->dev = &pci_dev->dev;
+
+       if (name)
+               strlcpy(mdev->model, name, sizeof(mdev->model));
+       else
+               strlcpy(mdev->model, pci_name(pci_dev), sizeof(mdev->model));
+
+       sprintf(mdev->bus_info, "PCI:%s", pci_name(pci_dev));
+
+       mdev->hw_revision = pci_dev->subsystem_vendor << 16
+                           || pci_dev->subsystem_device;
+
+       mdev->driver_version = LINUX_VERSION_CODE;
+
+       media_device_init(mdev);
+
+       return mdev;
+#else
+       return NULL;
+#endif
+}
+EXPORT_SYMBOL_GPL(v4l2_mc_pci_media_device_init);
+
+struct media_device *__v4l2_mc_usb_media_device_init(struct usb_device *udev,
+                                                    const char *board_name,
+                                                    const char *driver_name)
+{
+#ifdef CONFIG_USB
+       struct media_device *mdev;
+
+       mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
+       if (!mdev)
+               return NULL;
+
+       mdev->dev = &udev->dev;
+
+       if (driver_name)
+               strlcpy(mdev->driver_name, driver_name,
+                       sizeof(mdev->driver_name));
+
+       if (board_name)
+               strlcpy(mdev->model, board_name, sizeof(mdev->model));
+       else if (udev->product)
+               strlcpy(mdev->model, udev->product, sizeof(mdev->model));
+       else
+               strlcpy(mdev->model, "unknown model", sizeof(mdev->model));
+       if (udev->serial)
+               strlcpy(mdev->serial, udev->serial, sizeof(mdev->serial));
+       usb_make_path(udev, mdev->bus_info, sizeof(mdev->bus_info));
+       mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice);
+       mdev->driver_version = LINUX_VERSION_CODE;
+
+       media_device_init(mdev);
+
+       return mdev;
+#else
+       return NULL;
+#endif
+}
+EXPORT_SYMBOL_GPL(__v4l2_mc_usb_media_device_init);
+
+int v4l2_mc_create_media_graph(struct media_device *mdev)
+
+{
+       struct media_entity *entity;
+       struct media_entity *if_vid = NULL, *if_aud = NULL;
+       struct media_entity *tuner = NULL, *decoder = NULL;
+       struct media_entity *io_v4l = NULL, *io_vbi = NULL, *io_swradio = NULL;
+       bool is_webcam = false;
+       u32 flags;
+       int ret;
+
+       if (!mdev)
+               return 0;
+
+       media_device_for_each_entity(entity, mdev) {
+               switch (entity->function) {
+               case MEDIA_ENT_F_IF_VID_DECODER:
+                       if_vid = entity;
+                       break;
+               case MEDIA_ENT_F_IF_AUD_DECODER:
+                       if_aud = entity;
+                       break;
+               case MEDIA_ENT_F_TUNER:
+                       tuner = entity;
+                       break;
+               case MEDIA_ENT_F_ATV_DECODER:
+                       decoder = entity;
+                       break;
+               case MEDIA_ENT_F_IO_V4L:
+                       io_v4l = entity;
+                       break;
+               case MEDIA_ENT_F_IO_VBI:
+                       io_vbi = entity;
+                       break;
+               case MEDIA_ENT_F_IO_SWRADIO:
+                       io_swradio = entity;
+                       break;
+               case MEDIA_ENT_F_CAM_SENSOR:
+                       is_webcam = true;
+                       break;
+               }
+       }
+
+       /* It should have at least one I/O entity */
+       if (!io_v4l && !io_vbi && !io_swradio)
+               return -EINVAL;
+
+       /*
+        * Here, webcams are modelled on a very simple way: the sensor is
+        * connected directly to the I/O entity. All dirty details, like
+        * scaler and crop HW are hidden. While such mapping is not enough
+        * for mc-centric hardware, it is enough for v4l2 interface centric
+        * PC-consumer's hardware.
+        */
+       if (is_webcam) {
+               if (!io_v4l)
+                       return -EINVAL;
+
+               media_device_for_each_entity(entity, mdev) {
+                       if (entity->function != MEDIA_ENT_F_CAM_SENSOR)
+                               continue;
+                       ret = media_create_pad_link(entity, 0,
+                                                   io_v4l, 0,
+                                                   MEDIA_LNK_FL_ENABLED);
+                       if (ret)
+                               return ret;
+               }
+               if (!decoder)
+                       return 0;
+       }
+
+       /* The device isn't a webcam. So, it should have a decoder */
+       if (!decoder)
+               return -EINVAL;
+
+       /* Link the tuner and IF video output pads */
+       if (tuner) {
+               if (if_vid) {
+                       ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
+                                                   if_vid,
+                                                   IF_VID_DEC_PAD_IF_INPUT,
+                                                   MEDIA_LNK_FL_ENABLED);
+                       if (ret)
+                               return ret;
+                       ret = media_create_pad_link(if_vid, IF_VID_DEC_PAD_OUT,
+                                               decoder, DEMOD_PAD_IF_INPUT,
+                                               MEDIA_LNK_FL_ENABLED);
+                       if (ret)
+                               return ret;
+               } else {
+                       ret = media_create_pad_link(tuner, TUNER_PAD_OUTPUT,
+                                               decoder, DEMOD_PAD_IF_INPUT,
+                                               MEDIA_LNK_FL_ENABLED);
+                       if (ret)
+                               return ret;
+               }
+
+               if (if_aud) {
+                       ret = media_create_pad_link(tuner, TUNER_PAD_AUD_OUT,
+                                                   if_aud,
+                                                   IF_AUD_DEC_PAD_IF_INPUT,
+                                                   MEDIA_LNK_FL_ENABLED);
+                       if (ret)
+                               return ret;
+               } else {
+                       if_aud = tuner;
+               }
+
+       }
+
+       /* Create demod to V4L, VBI and SDR radio links */
+       if (io_v4l) {
+               ret = media_create_pad_link(decoder, DEMOD_PAD_VID_OUT,
+                                       io_v4l, 0,
+                                       MEDIA_LNK_FL_ENABLED);
+               if (ret)
+                       return ret;
+       }
+
+       if (io_swradio) {
+               ret = media_create_pad_link(decoder, DEMOD_PAD_VID_OUT,
+                                       io_swradio, 0,
+                                       MEDIA_LNK_FL_ENABLED);
+               if (ret)
+                       return ret;
+       }
+
+       if (io_vbi) {
+               ret = media_create_pad_link(decoder, DEMOD_PAD_VBI_OUT,
+                                           io_vbi, 0,
+                                           MEDIA_LNK_FL_ENABLED);
+               if (ret)
+                       return ret;
+       }
+
+       /* Create links for the media connectors */
+       flags = MEDIA_LNK_FL_ENABLED;
+       media_device_for_each_entity(entity, mdev) {
+               switch (entity->function) {
+               case MEDIA_ENT_F_CONN_RF:
+                       if (!tuner)
+                               continue;
+
+                       ret = media_create_pad_link(entity, 0, tuner,
+                                                   TUNER_PAD_RF_INPUT,
+                                                   flags);
+                       break;
+               case MEDIA_ENT_F_CONN_SVIDEO:
+               case MEDIA_ENT_F_CONN_COMPOSITE:
+                       ret = media_create_pad_link(entity, 0, decoder,
+                                                   DEMOD_PAD_IF_INPUT,
+                                                   flags);
+                       break;
+               default:
+                       continue;
+               }
+               if (ret)
+                       return ret;
+
+               flags = 0;
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_mc_create_media_graph);
index b27cbb1..93b3368 100644 (file)
@@ -146,7 +146,7 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node,
  * variable without a low fixed limit. Please use
  * v4l2_of_alloc_parse_endpoint() in new drivers instead.
  *
- * Return: 0.
+ * Return: 0 on success or a negative error code on failure.
  */
 int v4l2_of_parse_endpoint(const struct device_node *node,
                           struct v4l2_of_endpoint *endpoint)
index ff8953a..dab9408 100644 (file)
@@ -1227,6 +1227,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const void *pb)
                if (planes[plane].length < vb->planes[plane].min_length) {
                        dprintk(1, "invalid dmabuf length for plane %d\n",
                                plane);
+                       dma_buf_put(dbuf);
                        ret = -EINVAL;
                        goto err;
                }
index d092698..9f38b42 100644 (file)
@@ -77,6 +77,7 @@ static int vb2_dvb_register_adapter(struct vb2_dvb_frontends *fe,
                          struct module *module,
                          void *adapter_priv,
                          struct device *device,
+                         struct media_device *mdev,
                          char *adapter_name,
                          short *adapter_nr,
                          int mfe_shared)
@@ -94,7 +95,10 @@ static int vb2_dvb_register_adapter(struct vb2_dvb_frontends *fe,
        }
        fe->adapter.priv = adapter_priv;
        fe->adapter.mfe_shared = mfe_shared;
-
+#ifdef CONFIG_MEDIA_CONTROLLER_DVB
+       if (mdev)
+               fe->adapter.mdev = mdev;
+#endif
        return result;
 }
 
@@ -193,6 +197,7 @@ int vb2_dvb_register_bus(struct vb2_dvb_frontends *f,
                         struct module *module,
                         void *adapter_priv,
                         struct device *device,
+                        struct media_device *mdev,
                         short *adapter_nr,
                         int mfe_shared)
 {
@@ -207,7 +212,7 @@ int vb2_dvb_register_bus(struct vb2_dvb_frontends *f,
        }
 
        /* Bring up the adapter */
-       res = vb2_dvb_register_adapter(f, module, adapter_priv, device,
+       res = vb2_dvb_register_adapter(f, module, adapter_priv, device, mdev,
                fe->dvb.name, adapter_nr, mfe_shared);
        if (res < 0) {
                pr_warn("vb2_dvb_register_adapter failed (errno = %d)\n", res);
@@ -224,7 +229,11 @@ int vb2_dvb_register_bus(struct vb2_dvb_frontends *f,
                                fe->dvb.name, res);
                        goto err;
                }
+               res = dvb_create_media_graph(&f->adapter, false);
+               if (res < 0)
+                       goto err;
        }
+
        mutex_unlock(&f->lock);
        return 0;
 
index e6e4bac..12099b0 100644 (file)
@@ -2048,6 +2048,7 @@ int db8500_prcmu_config_hotmon(u8 low, u8 high)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(db8500_prcmu_config_hotmon);
 
 static int config_hot_period(u16 val)
 {
@@ -2074,11 +2075,13 @@ int db8500_prcmu_start_temp_sense(u16 cycles32k)
 
        return config_hot_period(cycles32k);
 }
+EXPORT_SYMBOL_GPL(db8500_prcmu_start_temp_sense);
 
 int db8500_prcmu_stop_temp_sense(void)
 {
        return config_hot_period(0xFFFF);
 }
+EXPORT_SYMBOL_GPL(db8500_prcmu_stop_temp_sense);
 
 static int prcmu_a9wdog(u8 cmd, u8 d0, u8 d1, u8 d2, u8 d3)
 {
index 4c1903f..0c6c17a 100644 (file)
@@ -415,7 +415,7 @@ static int cxl_setup_psl_timebase(struct cxl *adapter, struct pci_dev *dev)
                delta = mftb() - psl_tb;
                if (delta < 0)
                        delta = -delta;
-       } while (cputime_to_usecs(delta) > 16);
+       } while (tb_to_ns(delta) > 16000);
 
        return 0;
 }
index 677d036..80f9afc 100644 (file)
@@ -458,7 +458,11 @@ static int mei_ioctl_client_notify_request(struct file *file, u32 request)
 {
        struct mei_cl *cl = file->private_data;
 
-       return mei_cl_notify_request(cl, file, request);
+       if (request != MEI_HBM_NOTIFICATION_START &&
+           request != MEI_HBM_NOTIFICATION_STOP)
+               return -EINVAL;
+
+       return mei_cl_notify_request(cl, file, (u8)request);
 }
 
 /**
index 5914263..fe207e5 100644 (file)
 #include "queue.h"
 
 MODULE_ALIAS("mmc:block");
-
-#ifdef KERNEL
 #ifdef MODULE_PARAM_PREFIX
 #undef MODULE_PARAM_PREFIX
 #endif
 #define MODULE_PARAM_PREFIX "mmcblk."
-#endif
 
 #define INAND_CMD38_ARG_EXT_CSD  113
 #define INAND_CMD38_ARG_ERASE    0x00
@@ -655,8 +652,10 @@ static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev,
        }
 
        md = mmc_blk_get(bdev->bd_disk);
-       if (!md)
+       if (!md) {
+               err = -EINVAL;
                goto cmd_err;
+       }
 
        card = md->queue.card;
        if (IS_ERR(card)) {
index 1c1b45e..3446097 100644 (file)
@@ -925,6 +925,10 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
 
                        dma_addr = dma_map_page(dma_dev, sg_page(sg), 0,
                                                PAGE_SIZE, dir);
+                       if (dma_mapping_error(dma_dev, dma_addr)) {
+                               data->error = -EFAULT;
+                               break;
+                       }
                        if (direction == DMA_TO_DEVICE)
                                t->tx_dma = dma_addr + sg->offset;
                        else
@@ -1393,10 +1397,12 @@ static int mmc_spi_probe(struct spi_device *spi)
                host->dma_dev = dev;
                host->ones_dma = dma_map_single(dev, ones,
                                MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE);
+               if (dma_mapping_error(dev, host->ones_dma))
+                       goto fail_ones_dma;
                host->data_dma = dma_map_single(dev, host->data,
                                sizeof(*host->data), DMA_BIDIRECTIONAL);
-
-               /* REVISIT in theory those map operations can fail... */
+               if (dma_mapping_error(dev, host->data_dma))
+                       goto fail_data_dma;
 
                dma_sync_single_for_cpu(host->dma_dev,
                                host->data_dma, sizeof(*host->data),
@@ -1462,6 +1468,11 @@ fail_glue_init:
        if (host->dma_dev)
                dma_unmap_single(host->dma_dev, host->data_dma,
                                sizeof(*host->data), DMA_BIDIRECTIONAL);
+fail_data_dma:
+       if (host->dma_dev)
+               dma_unmap_single(host->dma_dev, host->ones_dma,
+                               MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE);
+fail_ones_dma:
        kfree(host->data);
 
 fail_nobuf1:
index b6639ea..f6e4d97 100644 (file)
@@ -2232,6 +2232,7 @@ err_irq:
                dma_release_channel(host->tx_chan);
        if (host->rx_chan)
                dma_release_channel(host->rx_chan);
+       pm_runtime_dont_use_autosuspend(host->dev);
        pm_runtime_put_sync(host->dev);
        pm_runtime_disable(host->dev);
        if (host->dbclk)
@@ -2253,6 +2254,7 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
        dma_release_channel(host->tx_chan);
        dma_release_channel(host->rx_chan);
 
+       pm_runtime_dont_use_autosuspend(host->dev);
        pm_runtime_put_sync(host->dev);
        pm_runtime_disable(host->dev);
        device_init_wakeup(&pdev->dev, false);
index ce08896..da82477 100644 (file)
@@ -86,7 +86,7 @@ struct pxamci_host {
 static inline void pxamci_init_ocr(struct pxamci_host *host)
 {
 #ifdef CONFIG_REGULATOR
-       host->vcc = regulator_get_optional(mmc_dev(host->mmc), "vmmc");
+       host->vcc = devm_regulator_get_optional(mmc_dev(host->mmc), "vmmc");
 
        if (IS_ERR(host->vcc))
                host->vcc = NULL;
@@ -654,12 +654,8 @@ static int pxamci_probe(struct platform_device *pdev)
 
        r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        irq = platform_get_irq(pdev, 0);
-       if (!r || irq < 0)
-               return -ENXIO;
-
-       r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
-       if (!r)
-               return -EBUSY;
+       if (irq < 0)
+               return irq;
 
        mmc = mmc_alloc_host(sizeof(struct pxamci_host), &pdev->dev);
        if (!mmc) {
@@ -695,7 +691,7 @@ static int pxamci_probe(struct platform_device *pdev)
        host->pdata = pdev->dev.platform_data;
        host->clkrt = CLKRT_OFF;
 
-       host->clk = clk_get(&pdev->dev, NULL);
+       host->clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(host->clk)) {
                ret = PTR_ERR(host->clk);
                host->clk = NULL;
@@ -727,9 +723,9 @@ static int pxamci_probe(struct platform_device *pdev)
        host->irq = irq;
        host->imask = MMC_I_MASK_ALL;
 
-       host->base = ioremap(r->start, SZ_4K);
-       if (!host->base) {
-               ret = -ENOMEM;
+       host->base = devm_ioremap_resource(&pdev->dev, r);
+       if (IS_ERR(host->base)) {
+               ret = PTR_ERR(host->base);
                goto out;
        }
 
@@ -742,7 +738,8 @@ static int pxamci_probe(struct platform_device *pdev)
        writel(64, host->base + MMC_RESTO);
        writel(host->imask, host->base + MMC_I_MASK);
 
-       ret = request_irq(host->irq, pxamci_irq, 0, DRIVER_NAME, host);
+       ret = devm_request_irq(&pdev->dev, host->irq, pxamci_irq, 0,
+                              DRIVER_NAME, host);
        if (ret)
                goto out;
 
@@ -804,7 +801,7 @@ static int pxamci_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "Failed requesting gpio_ro %d\n", gpio_ro);
                goto out;
        } else {
-               mmc->caps |= host->pdata->gpio_card_ro_invert ?
+               mmc->caps2 |= host->pdata->gpio_card_ro_invert ?
                        0 : MMC_CAP2_RO_ACTIVE_HIGH;
        }
 
@@ -833,14 +830,9 @@ out:
                        dma_release_channel(host->dma_chan_rx);
                if (host->dma_chan_tx)
                        dma_release_channel(host->dma_chan_tx);
-               if (host->base)
-                       iounmap(host->base);
-               if (host->clk)
-                       clk_put(host->clk);
        }
        if (mmc)
                mmc_free_host(mmc);
-       release_resource(r);
        return ret;
 }
 
@@ -859,9 +851,6 @@ static int pxamci_remove(struct platform_device *pdev)
                        gpio_ro = host->pdata->gpio_card_ro;
                        gpio_power = host->pdata->gpio_power;
                }
-               if (host->vcc)
-                       regulator_put(host->vcc);
-
                if (host->pdata && host->pdata->exit)
                        host->pdata->exit(&pdev->dev, mmc);
 
@@ -870,16 +859,10 @@ static int pxamci_remove(struct platform_device *pdev)
                       END_CMD_RES|PRG_DONE|DATA_TRAN_DONE,
                       host->base + MMC_I_MASK);
 
-               free_irq(host->irq, host);
                dmaengine_terminate_all(host->dma_chan_rx);
                dmaengine_terminate_all(host->dma_chan_tx);
                dma_release_channel(host->dma_chan_rx);
                dma_release_channel(host->dma_chan_tx);
-               iounmap(host->base);
-
-               clk_put(host->clk);
-
-               release_resource(host->res);
 
                mmc_free_host(mmc);
        }
index f6047fc..a5cda92 100644 (file)
@@ -146,6 +146,33 @@ static const struct sdhci_acpi_chip sdhci_acpi_chip_int = {
        .ops = &sdhci_acpi_ops_int,
 };
 
+static int bxt_get_cd(struct mmc_host *mmc)
+{
+       int gpio_cd = mmc_gpio_get_cd(mmc);
+       struct sdhci_host *host = mmc_priv(mmc);
+       unsigned long flags;
+       int ret = 0;
+
+       if (!gpio_cd)
+               return 0;
+
+       pm_runtime_get_sync(mmc->parent);
+
+       spin_lock_irqsave(&host->lock, flags);
+
+       if (host->flags & SDHCI_DEVICE_DEAD)
+               goto out;
+
+       ret = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
+out:
+       spin_unlock_irqrestore(&host->lock, flags);
+
+       pm_runtime_mark_last_busy(mmc->parent);
+       pm_runtime_put_autosuspend(mmc->parent);
+
+       return ret;
+}
+
 static int sdhci_acpi_emmc_probe_slot(struct platform_device *pdev,
                                      const char *hid, const char *uid)
 {
@@ -196,6 +223,9 @@ static int sdhci_acpi_sd_probe_slot(struct platform_device *pdev,
 
        /* Platform specific code during sd probe slot goes here */
 
+       if (hid && !strcmp(hid, "80865ACA"))
+               host->mmc_host_ops.get_cd = bxt_get_cd;
+
        return 0;
 }
 
index 7e7d8f0..9cb86fb 100644 (file)
@@ -217,6 +217,7 @@ static int sdhci_at91_probe(struct platform_device *pdev)
 pm_runtime_disable:
        pm_runtime_disable(&pdev->dev);
        pm_runtime_set_suspended(&pdev->dev);
+       pm_runtime_put_noidle(&pdev->dev);
 clocks_disable_unprepare:
        clk_disable_unprepare(priv->gck);
        clk_disable_unprepare(priv->mainck);
index cc851b0..df3b8ec 100644 (file)
@@ -330,6 +330,33 @@ static void spt_read_drive_strength(struct sdhci_host *host)
        sdhci_pci_spt_drive_strength = 0x10 | ((val >> 12) & 0xf);
 }
 
+static int bxt_get_cd(struct mmc_host *mmc)
+{
+       int gpio_cd = mmc_gpio_get_cd(mmc);
+       struct sdhci_host *host = mmc_priv(mmc);
+       unsigned long flags;
+       int ret = 0;
+
+       if (!gpio_cd)
+               return 0;
+
+       pm_runtime_get_sync(mmc->parent);
+
+       spin_lock_irqsave(&host->lock, flags);
+
+       if (host->flags & SDHCI_DEVICE_DEAD)
+               goto out;
+
+       ret = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
+out:
+       spin_unlock_irqrestore(&host->lock, flags);
+
+       pm_runtime_mark_last_busy(mmc->parent);
+       pm_runtime_put_autosuspend(mmc->parent);
+
+       return ret;
+}
+
 static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
 {
        slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE |
@@ -362,6 +389,10 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
        slot->cd_con_id = NULL;
        slot->cd_idx = 0;
        slot->cd_override_level = true;
+       if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BXT_SD ||
+           slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD)
+               slot->host->mmc_host_ops.get_cd = bxt_get_cd;
+
        return 0;
 }
 
index d622435..add9fdf 100644 (file)
@@ -1360,7 +1360,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
        sdhci_runtime_pm_get(host);
 
        /* Firstly check card presence */
-       present = sdhci_do_get_cd(host);
+       present = mmc->ops->get_cd(mmc);
 
        spin_lock_irqsave(&host->lock, flags);
 
@@ -2849,6 +2849,8 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
 
        host = mmc_priv(mmc);
        host->mmc = mmc;
+       host->mmc_host_ops = sdhci_ops;
+       mmc->ops = &host->mmc_host_ops;
 
        return host;
 }
@@ -3037,7 +3039,6 @@ int sdhci_add_host(struct sdhci_host *host)
        /*
         * Set host parameters.
         */
-       mmc->ops = &sdhci_ops;
        max_clk = host->max_clk;
 
        if (host->ops->get_min_clock)
index 7654ae5..0115e99 100644 (file)
@@ -430,6 +430,7 @@ struct sdhci_host {
 
        /* Internal data */
        struct mmc_host *mmc;   /* MMC structure */
+       struct mmc_host_ops mmc_host_ops;       /* MMC host ops */
        u64 dma_mask;           /* custom DMA mask */
 
 #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
index 1ca8a13..6234eab 100644 (file)
@@ -445,7 +445,7 @@ static void sh_mmcif_request_dma(struct sh_mmcif_host *host)
                                                        pdata->slave_id_rx);
        } else {
                host->chan_tx = dma_request_slave_channel(dev, "tx");
-               host->chan_tx = dma_request_slave_channel(dev, "rx");
+               host->chan_rx = dma_request_slave_channel(dev, "rx");
        }
        dev_dbg(dev, "%s: got channel TX %p RX %p\n", __func__, host->chan_tx,
                host->chan_rx);
index 2a1b6e0..0134ba3 100644 (file)
@@ -193,7 +193,7 @@ int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
        vol->changing_leb = 1;
        vol->ch_lnum = req->lnum;
 
-       vol->upd_buf = vmalloc(req->bytes);
+       vol->upd_buf = vmalloc(ALIGN((int)req->bytes, ubi->min_io_size));
        if (!vol->upd_buf)
                return -ENOMEM;
 
index 56b5605..b7f1a99 100644 (file)
@@ -214,6 +214,8 @@ static void bond_uninit(struct net_device *bond_dev);
 static struct rtnl_link_stats64 *bond_get_stats(struct net_device *bond_dev,
                                                struct rtnl_link_stats64 *stats);
 static void bond_slave_arr_handler(struct work_struct *work);
+static bool bond_time_in_interval(struct bonding *bond, unsigned long last_act,
+                                 int mod);
 
 /*---------------------------- General routines -----------------------------*/
 
@@ -2127,6 +2129,7 @@ static void bond_miimon_commit(struct bonding *bond)
                        continue;
 
                case BOND_LINK_UP:
+                       bond_update_speed_duplex(slave);
                        bond_set_slave_link_state(slave, BOND_LINK_UP,
                                                  BOND_SLAVE_NOTIFY_NOW);
                        slave->last_link_up = jiffies;
@@ -2459,7 +2462,7 @@ int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond,
                 struct slave *slave)
 {
        struct arphdr *arp = (struct arphdr *)skb->data;
-       struct slave *curr_active_slave;
+       struct slave *curr_active_slave, *curr_arp_slave;
        unsigned char *arp_ptr;
        __be32 sip, tip;
        int alen, is_arp = skb->protocol == __cpu_to_be16(ETH_P_ARP);
@@ -2506,26 +2509,41 @@ int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond,
                     &sip, &tip);
 
        curr_active_slave = rcu_dereference(bond->curr_active_slave);
+       curr_arp_slave = rcu_dereference(bond->current_arp_slave);
 
-       /* Backup slaves won't see the ARP reply, but do come through
-        * here for each ARP probe (so we swap the sip/tip to validate
-        * the probe).  In a "redundant switch, common router" type of
-        * configuration, the ARP probe will (hopefully) travel from
-        * the active, through one switch, the router, then the other
-        * switch before reaching the backup.
+       /* We 'trust' the received ARP enough to validate it if:
+        *
+        * (a) the slave receiving the ARP is active (which includes the
+        * current ARP slave, if any), or
+        *
+        * (b) the receiving slave isn't active, but there is a currently
+        * active slave and it received valid arp reply(s) after it became
+        * the currently active slave, or
+        *
+        * (c) there is an ARP slave that sent an ARP during the prior ARP
+        * interval, and we receive an ARP reply on any slave.  We accept
+        * these because switch FDB update delays may deliver the ARP
+        * reply to a slave other than the sender of the ARP request.
         *
-        * We 'trust' the arp requests if there is an active slave and
-        * it received valid arp reply(s) after it became active. This
-        * is done to avoid endless looping when we can't reach the
+        * Note: for (b), backup slaves are receiving the broadcast ARP
+        * request, not a reply.  This request passes from the sending
+        * slave through the L2 switch(es) to the receiving slave.  Since
+        * this is checking the request, sip/tip are swapped for
+        * validation.
+        *
+        * This is done to avoid endless looping when we can't reach the
         * arp_ip_target and fool ourselves with our own arp requests.
         */
-
        if (bond_is_active_slave(slave))
                bond_validate_arp(bond, slave, sip, tip);
        else if (curr_active_slave &&
                 time_after(slave_last_rx(bond, curr_active_slave),
                            curr_active_slave->last_link_up))
                bond_validate_arp(bond, slave, tip, sip);
+       else if (curr_arp_slave && (arp->ar_op == htons(ARPOP_REPLY)) &&
+                bond_time_in_interval(bond,
+                                      dev_trans_start(curr_arp_slave->dev), 1))
+               bond_validate_arp(bond, slave, sip, tip);
 
 out_unlock:
        if (arp != (struct arphdr *)skb->data)
index 575790e..74a7dfe 100644 (file)
@@ -843,7 +843,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
                if (clear_intf)
                        mcp251x_write_bits(spi, CANINTF, clear_intf, 0x00);
 
-               if (eflag)
+               if (eflag & (EFLG_RX0OVR | EFLG_RX1OVR))
                        mcp251x_write_bits(spi, EFLG, eflag, 0x00);
 
                /* Update can state */
index fc5b756..eb7192f 100644 (file)
@@ -117,6 +117,9 @@ MODULE_LICENSE("GPL v2");
  */
 #define EMS_USB_ARM7_CLOCK 8000000
 
+#define CPC_TX_QUEUE_TRIGGER_LOW       25
+#define CPC_TX_QUEUE_TRIGGER_HIGH      35
+
 /*
  * CAN-Message representation in a CPC_MSG. Message object type is
  * CPC_MSG_TYPE_CAN_FRAME or CPC_MSG_TYPE_RTR_FRAME or
@@ -278,6 +281,11 @@ static void ems_usb_read_interrupt_callback(struct urb *urb)
        switch (urb->status) {
        case 0:
                dev->free_slots = dev->intr_in_buffer[1];
+               if(dev->free_slots > CPC_TX_QUEUE_TRIGGER_HIGH){
+                       if (netif_queue_stopped(netdev)){
+                               netif_wake_queue(netdev);
+                       }
+               }
                break;
 
        case -ECONNRESET: /* unlink */
@@ -526,8 +534,6 @@ static void ems_usb_write_bulk_callback(struct urb *urb)
        /* Release context */
        context->echo_index = MAX_TX_URBS;
 
-       if (netif_queue_stopped(netdev))
-               netif_wake_queue(netdev);
 }
 
 /*
@@ -587,7 +593,7 @@ static int ems_usb_start(struct ems_usb *dev)
        int err, i;
 
        dev->intr_in_buffer[0] = 0;
-       dev->free_slots = 15; /* initial size */
+       dev->free_slots = 50; /* initial size */
 
        for (i = 0; i < MAX_RX_URBS; i++) {
                struct urb *urb = NULL;
@@ -835,7 +841,7 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
 
                /* Slow down tx path */
                if (atomic_read(&dev->active_tx_urbs) >= MAX_TX_URBS ||
-                   dev->free_slots < 5) {
+                   dev->free_slots < CPC_TX_QUEUE_TRIGGER_LOW) {
                        netif_stop_queue(netdev);
                }
        }
index 5eee62b..cbc99d5 100644 (file)
@@ -826,9 +826,8 @@ static struct gs_can *gs_make_candev(unsigned int channel, struct usb_interface
 static void gs_destroy_candev(struct gs_can *dev)
 {
        unregister_candev(dev->netdev);
-       free_candev(dev->netdev);
        usb_kill_anchored_urbs(&dev->tx_submitted);
-       kfree(dev);
+       free_candev(dev->netdev);
 }
 
 static int gs_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
@@ -913,12 +912,15 @@ static int gs_usb_probe(struct usb_interface *intf, const struct usb_device_id *
        for (i = 0; i < icount; i++) {
                dev->canch[i] = gs_make_candev(i, intf);
                if (IS_ERR_OR_NULL(dev->canch[i])) {
+                       /* save error code to return later */
+                       rc = PTR_ERR(dev->canch[i]);
+
                        /* on failure destroy previously created candevs */
                        icount = i;
-                       for (i = 0; i < icount; i++) {
+                       for (i = 0; i < icount; i++)
                                gs_destroy_candev(dev->canch[i]);
-                               dev->canch[i] = NULL;
-                       }
+
+                       usb_kill_anchored_urbs(&dev->rx_submitted);
                        kfree(dev);
                        return rc;
                }
@@ -939,16 +941,12 @@ static void gs_usb_disconnect(struct usb_interface *intf)
                return;
        }
 
-       for (i = 0; i < GS_MAX_INTF; i++) {
-               struct gs_can *can = dev->canch[i];
-
-               if (!can)
-                       continue;
-
-               gs_destroy_candev(can);
-       }
+       for (i = 0; i < GS_MAX_INTF; i++)
+               if (dev->canch[i])
+                       gs_destroy_candev(dev->canch[i]);
 
        usb_kill_anchored_urbs(&dev->rx_submitted);
+       kfree(dev);
 }
 
 static const struct usb_device_id gs_usb_table[] = {
index cc6c545..a47f52f 100644 (file)
@@ -25,6 +25,7 @@
 static const struct mv88e6xxx_switch_id mv88e6352_table[] = {
        { PORT_SWITCH_ID_6172, "Marvell 88E6172" },
        { PORT_SWITCH_ID_6176, "Marvell 88E6176" },
+       { PORT_SWITCH_ID_6240, "Marvell 88E6240" },
        { PORT_SWITCH_ID_6320, "Marvell 88E6320" },
        { PORT_SWITCH_ID_6320_A1, "Marvell 88E6320 (A1)" },
        { PORT_SWITCH_ID_6320_A2, "Marvell 88e6320 (A2)" },
index cf34681..512c8c0 100644 (file)
@@ -1555,7 +1555,7 @@ static int _mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, u16 vid)
 
        if (vlan.vid != vid || !vlan.valid ||
            vlan.data[port] == GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER)
-               return -ENOENT;
+               return -EOPNOTSUPP;
 
        vlan.data[port] = GLOBAL_VTU_DATA_MEMBER_TAG_NON_MEMBER;
 
@@ -1582,6 +1582,7 @@ int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
                            const struct switchdev_obj_port_vlan *vlan)
 {
        struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
+       const u16 defpvid = 4000 + ds->index * DSA_MAX_PORTS + port;
        u16 pvid, vid;
        int err = 0;
 
@@ -1597,7 +1598,8 @@ int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port,
                        goto unlock;
 
                if (vid == pvid) {
-                       err = _mv88e6xxx_port_pvid_set(ds, port, 0);
+                       /* restore reserved VLAN ID */
+                       err = _mv88e6xxx_port_pvid_set(ds, port, defpvid);
                        if (err)
                                goto unlock;
                }
@@ -1889,26 +1891,20 @@ unlock:
 
 int mv88e6xxx_port_bridge_join(struct dsa_switch *ds, int port, u32 members)
 {
-       struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
-       const u16 pvid = 4000 + ds->index * DSA_MAX_PORTS + port;
-       int err;
-
-       /* The port joined a bridge, so leave its reserved VLAN */
-       mutex_lock(&ps->smi_mutex);
-       err = _mv88e6xxx_port_vlan_del(ds, port, pvid);
-       if (!err)
-               err = _mv88e6xxx_port_pvid_set(ds, port, 0);
-       mutex_unlock(&ps->smi_mutex);
-       return err;
+       return 0;
 }
 
 int mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port, u32 members)
 {
+       return 0;
+}
+
+static int mv88e6xxx_setup_port_default_vlan(struct dsa_switch *ds, int port)
+{
        struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
        const u16 pvid = 4000 + ds->index * DSA_MAX_PORTS + port;
        int err;
 
-       /* The port left the bridge, so join its reserved VLAN */
        mutex_lock(&ps->smi_mutex);
        err = _mv88e6xxx_port_vlan_add(ds, port, pvid, true);
        if (!err)
@@ -2192,8 +2188,7 @@ int mv88e6xxx_setup_ports(struct dsa_switch *ds)
                if (dsa_is_cpu_port(ds, i) || dsa_is_dsa_port(ds, i))
                        continue;
 
-               /* setup the unbridged state */
-               ret = mv88e6xxx_port_bridge_leave(ds, i, 0);
+               ret = mv88e6xxx_setup_port_default_vlan(ds, i);
                if (ret < 0)
                        return ret;
        }
index 79e1a02..17b2126 100644 (file)
@@ -2461,7 +2461,7 @@ boomerang_interrupt(int irq, void *dev_id)
                                        int i;
                                        pci_unmap_single(VORTEX_PCI(vp),
                                                        le32_to_cpu(vp->tx_ring[entry].frag[0].addr),
-                                                       le32_to_cpu(vp->tx_ring[entry].frag[0].length),
+                                                       le32_to_cpu(vp->tx_ring[entry].frag[0].length)&0xFFF,
                                                        PCI_DMA_TODEVICE);
 
                                        for (i=1; i<=skb_shinfo(skb)->nr_frags; i++)
index 2777289..2f79d29 100644 (file)
@@ -1501,6 +1501,7 @@ static const struct pcmcia_device_id pcnet_ids[] = {
        PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030a),
        PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1103),
        PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1121),
+       PCMCIA_DEVICE_MANF_CARD(0xc001, 0x0009),
        PCMCIA_DEVICE_PROD_ID12("2408LAN", "Ethernet", 0x352fff7f, 0x00b2e941),
        PCMCIA_DEVICE_PROD_ID1234("Socket", "CF 10/100 Ethernet Card", "Revision B", "05/11/06", 0xb38bcc2e, 0x4de88352, 0xeaca6c8d, 0x7e57c22e),
        PCMCIA_DEVICE_PROD_ID123("Cardwell", "PCMCIA", "ETHERNET", 0x9533672e, 0x281f1c5d, 0x3ff7175b),
index 3f3bcbe..0907ab6 100644 (file)
@@ -2380,7 +2380,7 @@ static int et131x_tx_dma_memory_alloc(struct et131x_adapter *adapter)
                                                    sizeof(u32),
                                                    &tx_ring->tx_status_pa,
                                                    GFP_KERNEL);
-       if (!tx_ring->tx_status_pa) {
+       if (!tx_ring->tx_status) {
                dev_err(&adapter->pdev->dev,
                        "Cannot alloc memory for Tx status block\n");
                return -ENOMEM;
index 1747285..f749e4d 100644 (file)
@@ -193,7 +193,6 @@ static void altera_tse_mdio_destroy(struct net_device *dev)
                            priv->mdio->id);
 
        mdiobus_unregister(priv->mdio);
-       kfree(priv->mdio->irq);
        mdiobus_free(priv->mdio);
        priv->mdio = NULL;
 }
index 87e727b..fcdf5dd 100644 (file)
@@ -50,8 +50,8 @@ static const char version[] =
 static void write_rreg(u_long base, u_int reg, u_int val)
 {
        asm volatile(
-       "str%?h %1, [%2]        @ NET_RAP\n\t"
-       "str%?h %0, [%2, #-4]   @ NET_RDP"
+       "strh   %1, [%2]        @ NET_RAP\n\t"
+       "strh   %0, [%2, #-4]   @ NET_RDP"
        :
        : "r" (val), "r" (reg), "r" (ISAIO_BASE + 0x0464));
 }
@@ -60,8 +60,8 @@ static inline unsigned short read_rreg(u_long base_addr, u_int reg)
 {
        unsigned short v;
        asm volatile(
-       "str%?h %1, [%2]        @ NET_RAP\n\t"
-       "ldr%?h %0, [%2, #-4]   @ NET_RDP"
+       "strh   %1, [%2]        @ NET_RAP\n\t"
+       "ldrh   %0, [%2, #-4]   @ NET_RDP"
        : "=r" (v)
        : "r" (reg), "r" (ISAIO_BASE + 0x0464));
        return v;
@@ -70,8 +70,8 @@ static inline unsigned short read_rreg(u_long base_addr, u_int reg)
 static inline void write_ireg(u_long base, u_int reg, u_int val)
 {
        asm volatile(
-       "str%?h %1, [%2]        @ NET_RAP\n\t"
-       "str%?h %0, [%2, #8]    @ NET_IDP"
+       "strh   %1, [%2]        @ NET_RAP\n\t"
+       "strh   %0, [%2, #8]    @ NET_IDP"
        :
        : "r" (val), "r" (reg), "r" (ISAIO_BASE + 0x0464));
 }
@@ -80,8 +80,8 @@ static inline unsigned short read_ireg(u_long base_addr, u_int reg)
 {
        u_short v;
        asm volatile(
-       "str%?h %1, [%2]        @ NAT_RAP\n\t"
-       "ldr%?h %0, [%2, #8]    @ NET_IDP\n\t"
+       "strh   %1, [%2]        @ NAT_RAP\n\t"
+       "ldrh   %0, [%2, #8]    @ NET_IDP\n\t"
        : "=r" (v)
        : "r" (reg), "r" (ISAIO_BASE + 0x0464));
        return v;
@@ -96,7 +96,7 @@ am_writebuffer(struct net_device *dev, u_int offset, unsigned char *buf, unsigne
        offset = ISAMEM_BASE + (offset << 1);
        length = (length + 1) & ~1;
        if ((int)buf & 2) {
-               asm volatile("str%?h    %2, [%0], #4"
+               asm volatile("strh      %2, [%0], #4"
                 : "=&r" (offset) : "0" (offset), "r" (buf[0] | (buf[1] << 8)));
                buf += 2;
                length -= 2;
@@ -104,20 +104,20 @@ am_writebuffer(struct net_device *dev, u_int offset, unsigned char *buf, unsigne
        while (length > 8) {
                register unsigned int tmp asm("r2"), tmp2 asm("r3");
                asm volatile(
-                       "ldm%?ia        %0!, {%1, %2}"
+                       "ldmia  %0!, {%1, %2}"
                        : "+r" (buf), "=&r" (tmp), "=&r" (tmp2));
                length -= 8;
                asm volatile(
-                       "str%?h %1, [%0], #4\n\t"
-                       "mov%?  %1, %1, lsr #16\n\t"
-                       "str%?h %1, [%0], #4\n\t"
-                       "str%?h %2, [%0], #4\n\t"
-                       "mov%?  %2, %2, lsr #16\n\t"
-                       "str%?h %2, [%0], #4"
+                       "strh   %1, [%0], #4\n\t"
+                       "mov    %1, %1, lsr #16\n\t"
+                       "strh   %1, [%0], #4\n\t"
+                       "strh   %2, [%0], #4\n\t"
+                       "mov    %2, %2, lsr #16\n\t"
+                       "strh   %2, [%0], #4"
                : "+r" (offset), "=&r" (tmp), "=&r" (tmp2));
        }
        while (length > 0) {
-               asm volatile("str%?h    %2, [%0], #4"
+               asm volatile("strh      %2, [%0], #4"
                 : "=&r" (offset) : "0" (offset), "r" (buf[0] | (buf[1] << 8)));
                buf += 2;
                length -= 2;
@@ -132,23 +132,23 @@ am_readbuffer(struct net_device *dev, u_int offset, unsigned char *buf, unsigned
        if ((int)buf & 2) {
                unsigned int tmp;
                asm volatile(
-                       "ldr%?h %2, [%0], #4\n\t"
-                       "str%?b %2, [%1], #1\n\t"
-                       "mov%?  %2, %2, lsr #8\n\t"
-                       "str%?b %2, [%1], #1"
+                       "ldrh   %2, [%0], #4\n\t"
+                       "strb   %2, [%1], #1\n\t"
+                       "mov    %2, %2, lsr #8\n\t"
+                       "strb   %2, [%1], #1"
                : "=&r" (offset), "=&r" (buf), "=r" (tmp): "0" (offset), "1" (buf));
                length -= 2;
        }
        while (length > 8) {
                register unsigned int tmp asm("r2"), tmp2 asm("r3"), tmp3;
                asm volatile(
-                       "ldr%?h %2, [%0], #4\n\t"
-                       "ldr%?h %4, [%0], #4\n\t"
-                       "ldr%?h %3, [%0], #4\n\t"
-                       "orr%?  %2, %2, %4, lsl #16\n\t"
-                       "ldr%?h %4, [%0], #4\n\t"
-                       "orr%?  %3, %3, %4, lsl #16\n\t"
-                       "stm%?ia        %1!, {%2, %3}"
+                       "ldrh   %2, [%0], #4\n\t"
+                       "ldrh   %4, [%0], #4\n\t"
+                       "ldrh   %3, [%0], #4\n\t"
+                       "orr    %2, %2, %4, lsl #16\n\t"
+                       "ldrh   %4, [%0], #4\n\t"
+                       "orr    %3, %3, %4, lsl #16\n\t"
+                       "stmia  %1!, {%2, %3}"
                : "=&r" (offset), "=&r" (buf), "=r" (tmp), "=r" (tmp2), "=r" (tmp3)
                : "0" (offset), "1" (buf));
                length -= 8;
@@ -156,10 +156,10 @@ am_readbuffer(struct net_device *dev, u_int offset, unsigned char *buf, unsigned
        while (length > 0) {
                unsigned int tmp;
                asm volatile(
-                       "ldr%?h %2, [%0], #4\n\t"
-                       "str%?b %2, [%1], #1\n\t"
-                       "mov%?  %2, %2, lsr #8\n\t"
-                       "str%?b %2, [%1], #1"
+                       "ldrh   %2, [%0], #4\n\t"
+                       "strb   %2, [%1], #1\n\t"
+                       "mov    %2, %2, lsr #8\n\t"
+                       "strb   %2, [%1], #1"
                : "=&r" (offset), "=&r" (buf), "=r" (tmp) : "0" (offset), "1" (buf));
                length -= 2;
        }
index 256f590..3a7ebfd 100644 (file)
@@ -547,8 +547,8 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int
        /* Make certain the data structures used by the LANCE are aligned and DMAble. */
 
        lp = kzalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL);
-       if(lp==NULL)
-               return -ENODEV;
+       if (!lp)
+               return -ENOMEM;
        if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp);
        dev->ml_priv = lp;
        lp->name = chipname;
index abe1eab..6446af1 100644 (file)
@@ -163,7 +163,7 @@ static void arc_emac_tx_clean(struct net_device *ndev)
                struct sk_buff *skb = tx_buff->skb;
                unsigned int info = le32_to_cpu(txbd->info);
 
-               if ((info & FOR_EMAC) || !txbd->data)
+               if ((info & FOR_EMAC) || !txbd->data || !skb)
                        break;
 
                if (unlikely(info & (DROP | DEFR | LTCL | UFLO))) {
@@ -191,6 +191,7 @@ static void arc_emac_tx_clean(struct net_device *ndev)
 
                txbd->data = 0;
                txbd->info = 0;
+               tx_buff->skb = NULL;
 
                *txbd_dirty = (*txbd_dirty + 1) % TX_BD_NUM;
        }
@@ -446,6 +447,9 @@ static int arc_emac_open(struct net_device *ndev)
                *last_rx_bd = (*last_rx_bd + 1) % RX_BD_NUM;
        }
 
+       priv->txbd_curr = 0;
+       priv->txbd_dirty = 0;
+
        /* Clean Tx BD's */
        memset(priv->txbd, 0, TX_RING_SZ);
 
@@ -514,6 +518,64 @@ static void arc_emac_set_rx_mode(struct net_device *ndev)
 }
 
 /**
+ * arc_free_tx_queue - free skb from tx queue
+ * @ndev:      Pointer to the network device.
+ *
+ * This function must be called while EMAC disable
+ */
+static void arc_free_tx_queue(struct net_device *ndev)
+{
+       struct arc_emac_priv *priv = netdev_priv(ndev);
+       unsigned int i;
+
+       for (i = 0; i < TX_BD_NUM; i++) {
+               struct arc_emac_bd *txbd = &priv->txbd[i];
+               struct buffer_state *tx_buff = &priv->tx_buff[i];
+
+               if (tx_buff->skb) {
+                       dma_unmap_single(&ndev->dev, dma_unmap_addr(tx_buff, addr),
+                                        dma_unmap_len(tx_buff, len), DMA_TO_DEVICE);
+
+                       /* return the sk_buff to system */
+                       dev_kfree_skb_irq(tx_buff->skb);
+               }
+
+               txbd->info = 0;
+               txbd->data = 0;
+               tx_buff->skb = NULL;
+       }
+}
+
+/**
+ * arc_free_rx_queue - free skb from rx queue
+ * @ndev:      Pointer to the network device.
+ *
+ * This function must be called while EMAC disable
+ */
+static void arc_free_rx_queue(struct net_device *ndev)
+{
+       struct arc_emac_priv *priv = netdev_priv(ndev);
+       unsigned int i;
+
+       for (i = 0; i < RX_BD_NUM; i++) {
+               struct arc_emac_bd *rxbd = &priv->rxbd[i];
+               struct buffer_state *rx_buff = &priv->rx_buff[i];
+
+               if (rx_buff->skb) {
+                       dma_unmap_single(&ndev->dev, dma_unmap_addr(rx_buff, addr),
+                                       dma_unmap_len(rx_buff, len), DMA_FROM_DEVICE);
+
+                       /* return the sk_buff to system */
+                       dev_kfree_skb_irq(rx_buff->skb);
+               }
+
+               rxbd->info = 0;
+               rxbd->data = 0;
+               rx_buff->skb = NULL;
+       }
+}
+
+/**
  * arc_emac_stop - Close the network device.
  * @ndev:      Pointer to the network device.
  *
@@ -534,6 +596,10 @@ static int arc_emac_stop(struct net_device *ndev)
        /* Disable EMAC */
        arc_reg_clr(priv, R_CTRL, EN_MASK);
 
+       /* Return the sk_buff to system */
+       arc_free_tx_queue(ndev);
+       arc_free_rx_queue(ndev);
+
        return 0;
 }
 
@@ -610,7 +676,6 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
        dma_unmap_addr_set(&priv->tx_buff[*txbd_curr], addr, addr);
        dma_unmap_len_set(&priv->tx_buff[*txbd_curr], len, len);
 
-       priv->tx_buff[*txbd_curr].skb = skb;
        priv->txbd[*txbd_curr].data = cpu_to_le32(addr);
 
        /* Make sure pointer to data buffer is set */
@@ -620,6 +685,11 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev)
 
        *info = cpu_to_le32(FOR_EMAC | FIRST_OR_LAST_MASK | len);
 
+       /* Make sure info word is set */
+       wmb();
+
+       priv->tx_buff[*txbd_curr].skb = skb;
+
        /* Increment index to point to the next BD */
        *txbd_curr = (*txbd_curr + 1) % TX_BD_NUM;
 
index f71ab26..08a23e6 100644 (file)
@@ -1460,7 +1460,19 @@ static int nb8800_probe(struct platform_device *pdev)
                goto err_disable_clk;
        }
 
-       priv->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
+       if (of_phy_is_fixed_link(pdev->dev.of_node)) {
+               ret = of_phy_register_fixed_link(pdev->dev.of_node);
+               if (ret < 0) {
+                       dev_err(&pdev->dev, "bad fixed-link spec\n");
+                       goto err_free_bus;
+               }
+               priv->phy_node = of_node_get(pdev->dev.of_node);
+       }
+
+       if (!priv->phy_node)
+               priv->phy_node = of_parse_phandle(pdev->dev.of_node,
+                                                 "phy-handle", 0);
+
        if (!priv->phy_node) {
                dev_err(&pdev->dev, "no PHY specified\n");
                ret = -ENODEV;
index 27aa080..91874d2 100644 (file)
@@ -4896,9 +4896,9 @@ struct c2s_pri_trans_table_entry {
  * cfc delete event data
  */
 struct cfc_del_event_data {
-       u32 cid;
-       u32 reserved0;
-       u32 reserved1;
+       __le32 cid;
+       __le32 reserved0;
+       __le32 reserved1;
 };
 
 
@@ -5114,15 +5114,9 @@ struct vf_pf_channel_zone_trigger {
  * zone that triggers the in-bound interrupt
  */
 struct trigger_vf_zone {
-#if defined(__BIG_ENDIAN)
-       u16 reserved1;
-       u8 reserved0;
-       struct vf_pf_channel_zone_trigger vf_pf_channel;
-#elif defined(__LITTLE_ENDIAN)
        struct vf_pf_channel_zone_trigger vf_pf_channel;
        u8 reserved0;
        u16 reserved1;
-#endif
        u32 reserved2;
 };
 
@@ -5207,9 +5201,9 @@ struct e2_integ_data {
  * set mac event data
  */
 struct eth_event_data {
-       u32 echo;
-       u32 reserved0;
-       u32 reserved1;
+       __le32 echo;
+       __le32 reserved0;
+       __le32 reserved1;
 };
 
 
@@ -5219,9 +5213,9 @@ struct eth_event_data {
 struct vf_pf_event_data {
        u8 vf_id;
        u8 reserved0;
-       u16 reserved1;
-       u32 msg_addr_lo;
-       u32 msg_addr_hi;
+       __le16 reserved1;
+       __le32 msg_addr_lo;
+       __le32 msg_addr_hi;
 };
 
 /*
@@ -5230,9 +5224,9 @@ struct vf_pf_event_data {
 struct vf_flr_event_data {
        u8 vf_id;
        u8 reserved0;
-       u16 reserved1;
-       u32 reserved2;
-       u32 reserved3;
+       __le16 reserved1;
+       __le32 reserved2;
+       __le32 reserved3;
 };
 
 /*
@@ -5241,9 +5235,9 @@ struct vf_flr_event_data {
 struct malicious_vf_event_data {
        u8 vf_id;
        u8 err_id;
-       u16 reserved1;
-       u32 reserved2;
-       u32 reserved3;
+       __le16 reserved1;
+       __le32 reserved2;
+       __le32 reserved3;
 };
 
 /*
index d946bba..1fb8010 100644 (file)
@@ -6185,26 +6185,80 @@ static int bnx2x_format_ver(u32 num, u8 *str, u16 *len)
                shift -= 4;
                digit = ((num & mask) >> shift);
                if (digit == 0 && remove_leading_zeros) {
-                       mask = mask >> 4;
-                       continue;
-               } else if (digit < 0xa)
-                       *str_ptr = digit + '0';
-               else
-                       *str_ptr = digit - 0xa + 'a';
-               remove_leading_zeros = 0;
-               str_ptr++;
-               (*len)--;
+                       *str_ptr = '0';
+               } else {
+                       if (digit < 0xa)
+                               *str_ptr = digit + '0';
+                       else
+                               *str_ptr = digit - 0xa + 'a';
+
+                       remove_leading_zeros = 0;
+                       str_ptr++;
+                       (*len)--;
+               }
                mask = mask >> 4;
                if (shift == 4*4) {
+                       if (remove_leading_zeros) {
+                               str_ptr++;
+                               (*len)--;
+                       }
                        *str_ptr = '.';
                        str_ptr++;
                        (*len)--;
                        remove_leading_zeros = 1;
                }
        }
+       if (remove_leading_zeros)
+               (*len)--;
        return 0;
 }
 
+static int bnx2x_3_seq_format_ver(u32 num, u8 *str, u16 *len)
+{
+       u8 *str_ptr = str;
+       u32 mask = 0x00f00000;
+       u8 shift = 8*3;
+       u8 digit;
+       u8 remove_leading_zeros = 1;
+
+       if (*len < 10) {
+               /* Need more than 10chars for this format */
+               *str_ptr = '\0';
+               (*len)--;
+               return -EINVAL;
+       }
+
+       while (shift > 0) {
+               shift -= 4;
+               digit = ((num & mask) >> shift);
+               if (digit == 0 && remove_leading_zeros) {
+                       *str_ptr = '0';
+               } else {
+                       if (digit < 0xa)
+                               *str_ptr = digit + '0';
+                       else
+                               *str_ptr = digit - 0xa + 'a';
+
+                       remove_leading_zeros = 0;
+                       str_ptr++;
+                       (*len)--;
+               }
+               mask = mask >> 4;
+               if ((shift == 4*4) || (shift == 4*2)) {
+                       if (remove_leading_zeros) {
+                               str_ptr++;
+                               (*len)--;
+                       }
+                       *str_ptr = '.';
+                       str_ptr++;
+                       (*len)--;
+                       remove_leading_zeros = 1;
+               }
+       }
+       if (remove_leading_zeros)
+               (*len)--;
+       return 0;
+}
 
 static int bnx2x_null_format_ver(u32 spirom_ver, u8 *str, u16 *len)
 {
@@ -9677,8 +9731,9 @@ static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy *phy,
 
        if (bnx2x_is_8483x_8485x(phy)) {
                bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD, 0x400f, &fw_ver1);
-               bnx2x_save_spirom_version(bp, port, fw_ver1 & 0xfff,
-                               phy->ver_addr);
+               if (phy->type != PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84858)
+                       fw_ver1 &= 0xfff;
+               bnx2x_save_spirom_version(bp, port, fw_ver1, phy->ver_addr);
        } else {
                /* For 32-bit registers in 848xx, access via MDIO2ARM i/f. */
                /* (1) set reg 0xc200_0014(SPI_BRIDGE_CTRL_2) to 0x03000000 */
@@ -9732,16 +9787,32 @@ static void bnx2x_save_848xx_spirom_version(struct bnx2x_phy *phy,
 static void bnx2x_848xx_set_led(struct bnx2x *bp,
                                struct bnx2x_phy *phy)
 {
-       u16 val, offset, i;
+       u16 val, led3_blink_rate, offset, i;
        static struct bnx2x_reg_set reg_set[] = {
                {MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_LED1_MASK, 0x0080},
                {MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_LED2_MASK, 0x0018},
                {MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_LED3_MASK, 0x0006},
-               {MDIO_PMA_DEVAD, MDIO_PMA_REG_8481_LED3_BLINK, 0x0000},
                {MDIO_PMA_DEVAD, MDIO_PMA_REG_84823_CTL_SLOW_CLK_CNT_HIGH,
                        MDIO_PMA_REG_84823_BLINK_RATE_VAL_15P9HZ},
                {MDIO_AN_DEVAD, 0xFFFB, 0xFFFD}
        };
+
+       if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84858) {
+               /* Set LED5 source */
+               bnx2x_cl45_write(bp, phy,
+                                MDIO_PMA_DEVAD,
+                                MDIO_PMA_REG_8481_LED5_MASK,
+                                0x90);
+               led3_blink_rate = 0x000f;
+       } else {
+               led3_blink_rate = 0x0000;
+       }
+       /* Set LED3 BLINK */
+       bnx2x_cl45_write(bp, phy,
+                        MDIO_PMA_DEVAD,
+                        MDIO_PMA_REG_8481_LED3_BLINK,
+                        led3_blink_rate);
+
        /* PHYC_CTL_LED_CTL */
        bnx2x_cl45_read(bp, phy,
                        MDIO_PMA_DEVAD,
@@ -9749,6 +9820,9 @@ static void bnx2x_848xx_set_led(struct bnx2x *bp,
        val &= 0xFE00;
        val |= 0x0092;
 
+       if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84858)
+               val |= 2 << 12; /* LED5 ON based on source */
+
        bnx2x_cl45_write(bp, phy,
                         MDIO_PMA_DEVAD,
                         MDIO_PMA_REG_8481_LINK_SIGNAL, val);
@@ -9762,10 +9836,17 @@ static void bnx2x_848xx_set_led(struct bnx2x *bp,
        else
                offset = MDIO_PMA_REG_84823_CTL_LED_CTL_1;
 
-       /* stretch_en for LED3*/
+       if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84858)
+               val = MDIO_PMA_REG_84858_ALLOW_GPHY_ACT |
+                     MDIO_PMA_REG_84823_LED3_STRETCH_EN;
+       else
+               val = MDIO_PMA_REG_84823_LED3_STRETCH_EN;
+
+       /* stretch_en for LEDs */
        bnx2x_cl45_read_or_write(bp, phy,
-                                MDIO_PMA_DEVAD, offset,
-                                MDIO_PMA_REG_84823_LED3_STRETCH_EN);
+                                MDIO_PMA_DEVAD,
+                                offset,
+                                val);
 }
 
 static void bnx2x_848xx_specific_func(struct bnx2x_phy *phy,
@@ -9775,7 +9856,7 @@ static void bnx2x_848xx_specific_func(struct bnx2x_phy *phy,
        struct bnx2x *bp = params->bp;
        switch (action) {
        case PHY_INIT:
-               if (!bnx2x_is_8483x_8485x(phy)) {
+               if (bnx2x_is_8483x_8485x(phy)) {
                        /* Save spirom version */
                        bnx2x_save_848xx_spirom_version(phy, bp, params->port);
                }
@@ -10036,15 +10117,20 @@ static int bnx2x_84858_cmd_hdlr(struct bnx2x_phy *phy,
 
 static int bnx2x_84833_cmd_hdlr(struct bnx2x_phy *phy,
                                struct link_params *params, u16 fw_cmd,
-                               u16 cmd_args[], int argc)
+                               u16 cmd_args[], int argc, int process)
 {
        int idx;
        u16 val;
        struct bnx2x *bp = params->bp;
-       /* Write CMD_OPEN_OVERRIDE to STATUS reg */
-       bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD,
-                       MDIO_848xx_CMD_HDLR_STATUS,
-                       PHY84833_STATUS_CMD_OPEN_OVERRIDE);
+       int rc = 0;
+
+       if (process == PHY84833_MB_PROCESS2) {
+               /* Write CMD_OPEN_OVERRIDE to STATUS reg */
+               bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD,
+                                MDIO_848xx_CMD_HDLR_STATUS,
+                                PHY84833_STATUS_CMD_OPEN_OVERRIDE);
+       }
+
        for (idx = 0; idx < PHY848xx_CMDHDLR_WAIT; idx++) {
                bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD,
                                MDIO_848xx_CMD_HDLR_STATUS, &val);
@@ -10054,15 +10140,27 @@ static int bnx2x_84833_cmd_hdlr(struct bnx2x_phy *phy,
        }
        if (idx >= PHY848xx_CMDHDLR_WAIT) {
                DP(NETIF_MSG_LINK, "FW cmd: FW not ready.\n");
+               /* if the status is CMD_COMPLETE_PASS or CMD_COMPLETE_ERROR
+                * clear the status to CMD_CLEAR_COMPLETE
+                */
+               if (val == PHY84833_STATUS_CMD_COMPLETE_PASS ||
+                   val == PHY84833_STATUS_CMD_COMPLETE_ERROR) {
+                       bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD,
+                                        MDIO_848xx_CMD_HDLR_STATUS,
+                                        PHY84833_STATUS_CMD_CLEAR_COMPLETE);
+               }
                return -EINVAL;
        }
-
-       /* Prepare argument(s) and issue command */
-       for (idx = 0; idx < argc; idx++) {
-               bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD,
-                               MDIO_848xx_CMD_HDLR_DATA1 + idx,
-                               cmd_args[idx]);
+       if (process == PHY84833_MB_PROCESS1 ||
+           process == PHY84833_MB_PROCESS2) {
+               /* Prepare argument(s) */
+               for (idx = 0; idx < argc; idx++) {
+                       bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD,
+                                        MDIO_848xx_CMD_HDLR_DATA1 + idx,
+                                        cmd_args[idx]);
+               }
        }
+
        bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD,
                        MDIO_848xx_CMD_HDLR_COMMAND, fw_cmd);
        for (idx = 0; idx < PHY848xx_CMDHDLR_WAIT; idx++) {
@@ -10076,24 +10174,30 @@ static int bnx2x_84833_cmd_hdlr(struct bnx2x_phy *phy,
        if ((idx >= PHY848xx_CMDHDLR_WAIT) ||
            (val == PHY84833_STATUS_CMD_COMPLETE_ERROR)) {
                DP(NETIF_MSG_LINK, "FW cmd failed.\n");
-               return -EINVAL;
+               rc = -EINVAL;
        }
-       /* Gather returning data */
-       for (idx = 0; idx < argc; idx++) {
-               bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD,
-                               MDIO_848xx_CMD_HDLR_DATA1 + idx,
-                               &cmd_args[idx]);
+       if (process == PHY84833_MB_PROCESS3 && rc == 0) {
+               /* Gather returning data */
+               for (idx = 0; idx < argc; idx++) {
+                       bnx2x_cl45_read(bp, phy, MDIO_CTL_DEVAD,
+                                       MDIO_848xx_CMD_HDLR_DATA1 + idx,
+                                       &cmd_args[idx]);
+               }
        }
-       bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD,
-                       MDIO_848xx_CMD_HDLR_STATUS,
-                       PHY84833_STATUS_CMD_CLEAR_COMPLETE);
-       return 0;
+       if (val == PHY84833_STATUS_CMD_COMPLETE_ERROR ||
+           val == PHY84833_STATUS_CMD_COMPLETE_PASS) {
+               bnx2x_cl45_write(bp, phy, MDIO_CTL_DEVAD,
+                                MDIO_848xx_CMD_HDLR_STATUS,
+                                PHY84833_STATUS_CMD_CLEAR_COMPLETE);
+       }
+       return rc;
 }
 
 static int bnx2x_848xx_cmd_hdlr(struct bnx2x_phy *phy,
                                struct link_params *params,
                                u16 fw_cmd,
-                               u16 cmd_args[], int argc)
+                                          u16 cmd_args[], int argc,
+                                          int process)
 {
        struct bnx2x *bp = params->bp;
 
@@ -10106,7 +10210,7 @@ static int bnx2x_848xx_cmd_hdlr(struct bnx2x_phy *phy,
                                            argc);
        } else {
                return bnx2x_84833_cmd_hdlr(phy, params, fw_cmd, cmd_args,
-                                           argc);
+                                           argc, process);
        }
 }
 
@@ -10133,7 +10237,7 @@ static int bnx2x_848xx_pair_swap_cfg(struct bnx2x_phy *phy,
 
        status = bnx2x_848xx_cmd_hdlr(phy, params,
                                      PHY848xx_CMD_SET_PAIR_SWAP, data,
-                                     PHY848xx_CMDHDLR_MAX_ARGS);
+                                     2, PHY84833_MB_PROCESS2);
        if (status == 0)
                DP(NETIF_MSG_LINK, "Pairswap OK, val=0x%x\n", data[1]);
 
@@ -10222,8 +10326,8 @@ static int bnx2x_8483x_disable_eee(struct bnx2x_phy *phy,
        DP(NETIF_MSG_LINK, "Don't Advertise 10GBase-T EEE\n");
 
        /* Prevent Phy from working in EEE and advertising it */
-       rc = bnx2x_848xx_cmd_hdlr(phy, params,
-                                 PHY848xx_CMD_SET_EEE_MODE, &cmd_args, 1);
+       rc = bnx2x_848xx_cmd_hdlr(phy, params, PHY848xx_CMD_SET_EEE_MODE,
+                                 &cmd_args, 1, PHY84833_MB_PROCESS1);
        if (rc) {
                DP(NETIF_MSG_LINK, "EEE disable failed.\n");
                return rc;
@@ -10240,8 +10344,8 @@ static int bnx2x_8483x_enable_eee(struct bnx2x_phy *phy,
        struct bnx2x *bp = params->bp;
        u16 cmd_args = 1;
 
-       rc = bnx2x_848xx_cmd_hdlr(phy, params,
-                                 PHY848xx_CMD_SET_EEE_MODE, &cmd_args, 1);
+       rc = bnx2x_848xx_cmd_hdlr(phy, params, PHY848xx_CMD_SET_EEE_MODE,
+                                 &cmd_args, 1, PHY84833_MB_PROCESS1);
        if (rc) {
                DP(NETIF_MSG_LINK, "EEE enable failed.\n");
                return rc;
@@ -10362,7 +10466,7 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy,
                cmd_args[3] = PHY84833_CONSTANT_LATENCY;
                rc = bnx2x_848xx_cmd_hdlr(phy, params,
                                          PHY848xx_CMD_SET_EEE_MODE, cmd_args,
-                                         PHY848xx_CMDHDLR_MAX_ARGS);
+                                         4, PHY84833_MB_PROCESS1);
                if (rc)
                        DP(NETIF_MSG_LINK, "Cfg AutogrEEEn failed.\n");
        }
@@ -10416,6 +10520,32 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy,
                vars->eee_status &= ~SHMEM_EEE_SUPPORTED_MASK;
        }
 
+       if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84833) {
+               /* Additional settings for jumbo packets in 1000BASE-T mode */
+               /* Allow rx extended length */
+               bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD,
+                               MDIO_AN_REG_8481_AUX_CTRL, &val);
+               val |= 0x4000;
+               bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
+                                MDIO_AN_REG_8481_AUX_CTRL, val);
+               /* TX FIFO Elasticity LSB */
+               bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD,
+                               MDIO_AN_REG_8481_1G_100T_EXT_CTRL, &val);
+               val |= 0x1;
+               bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
+                                MDIO_AN_REG_8481_1G_100T_EXT_CTRL, val);
+               /* TX FIFO Elasticity MSB */
+               /* Enable expansion register 0x46 (Pattern Generator status) */
+               bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
+                                MDIO_AN_REG_8481_EXPANSION_REG_ACCESS, 0xf46);
+
+               bnx2x_cl45_read(bp, phy, MDIO_AN_DEVAD,
+                               MDIO_AN_REG_8481_EXPANSION_REG_RD_RW, &val);
+               val |= 0x4000;
+               bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
+                                MDIO_AN_REG_8481_EXPANSION_REG_RD_RW, val);
+       }
+
        if (bnx2x_is_8483x_8485x(phy)) {
                /* Bring PHY out of super isolate mode as the final step. */
                bnx2x_cl45_read_and_write(bp, phy,
@@ -10555,6 +10685,17 @@ static u8 bnx2x_848xx_read_status(struct bnx2x_phy *phy,
        return link_up;
 }
 
+static int bnx2x_8485x_format_ver(u32 raw_ver, u8 *str, u16 *len)
+{
+       int status = 0;
+       u32 num;
+
+       num = ((raw_ver & 0xF80) >> 7) << 16 | ((raw_ver & 0x7F) << 8) |
+             ((raw_ver & 0xF000) >> 12);
+       status = bnx2x_3_seq_format_ver(num, str, len);
+       return status;
+}
+
 static int bnx2x_848xx_format_ver(u32 raw_ver, u8 *str, u16 *len)
 {
        int status = 0;
@@ -10651,10 +10792,25 @@ static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy,
                                        0x0);
 
                } else {
+                       /* LED 1 OFF */
                        bnx2x_cl45_write(bp, phy,
                                         MDIO_PMA_DEVAD,
                                         MDIO_PMA_REG_8481_LED1_MASK,
                                         0x0);
+
+                       if (phy->type ==
+                               PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84858) {
+                               /* LED 2 OFF */
+                               bnx2x_cl45_write(bp, phy,
+                                                MDIO_PMA_DEVAD,
+                                                MDIO_PMA_REG_8481_LED2_MASK,
+                                                0x0);
+                               /* LED 3 OFF */
+                               bnx2x_cl45_write(bp, phy,
+                                                MDIO_PMA_DEVAD,
+                                                MDIO_PMA_REG_8481_LED3_MASK,
+                                                0x0);
+                       }
                }
                break;
        case LED_MODE_FRONT_PANEL_OFF:
@@ -10713,6 +10869,19 @@ static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy,
                                                 MDIO_PMA_REG_8481_SIGNAL_MASK,
                                                 0x0);
                        }
+                       if (phy->type ==
+                               PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84858) {
+                               /* LED 2 OFF */
+                               bnx2x_cl45_write(bp, phy,
+                                                MDIO_PMA_DEVAD,
+                                                MDIO_PMA_REG_8481_LED2_MASK,
+                                                0x0);
+                               /* LED 3 OFF */
+                               bnx2x_cl45_write(bp, phy,
+                                                MDIO_PMA_DEVAD,
+                                                MDIO_PMA_REG_8481_LED3_MASK,
+                                                0x0);
+                       }
                }
                break;
        case LED_MODE_ON:
@@ -10776,6 +10945,25 @@ static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy,
                                                params->port*4,
                                                NIG_MASK_MI_INT);
                                }
+                       }
+                       if (phy->type ==
+                           PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84858) {
+                               /* Tell LED3 to constant on */
+                               bnx2x_cl45_read(bp, phy,
+                                               MDIO_PMA_DEVAD,
+                                               MDIO_PMA_REG_8481_LINK_SIGNAL,
+                                               &val);
+                               val &= ~(7<<6);
+                               val |= (2<<6);  /* A83B[8:6]= 2 */
+                               bnx2x_cl45_write(bp, phy,
+                                                MDIO_PMA_DEVAD,
+                                                MDIO_PMA_REG_8481_LINK_SIGNAL,
+                                                val);
+                               bnx2x_cl45_write(bp, phy,
+                                                MDIO_PMA_DEVAD,
+                                                MDIO_PMA_REG_8481_LED3_MASK,
+                                                0x20);
+                       } else {
                                bnx2x_cl45_write(bp, phy,
                                                 MDIO_PMA_DEVAD,
                                                 MDIO_PMA_REG_8481_SIGNAL_MASK,
@@ -10854,6 +11042,17 @@ static void bnx2x_848xx_set_link_led(struct bnx2x_phy *phy,
                                         MDIO_PMA_REG_8481_LINK_SIGNAL,
                                         val);
                        if (phy->type ==
+                           PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84858) {
+                               bnx2x_cl45_write(bp, phy,
+                                                MDIO_PMA_DEVAD,
+                                                MDIO_PMA_REG_8481_LED2_MASK,
+                                                0x18);
+                               bnx2x_cl45_write(bp, phy,
+                                                MDIO_PMA_DEVAD,
+                                                MDIO_PMA_REG_8481_LED3_MASK,
+                                                0x06);
+                       }
+                       if (phy->type ==
                            PORT_HW_CFG_XGXS_EXT_PHY_TYPE_BCM84834) {
                                /* Restore LED4 source to external link,
                                 * and re-enable interrupts.
@@ -11982,7 +12181,7 @@ static const struct bnx2x_phy phy_84858 = {
        .read_status    = (read_status_t)bnx2x_848xx_read_status,
        .link_reset     = (link_reset_t)bnx2x_848x3_link_reset,
        .config_loopback = (config_loopback_t)NULL,
-       .format_fw_ver  = (format_fw_ver_t)bnx2x_848xx_format_ver,
+       .format_fw_ver  = (format_fw_ver_t)bnx2x_8485x_format_ver,
        .hw_reset       = (hw_reset_t)bnx2x_84833_hw_reset_phy,
        .set_link_led   = (set_link_led_t)bnx2x_848xx_set_link_led,
        .phy_specific_func = (phy_specific_func_t)bnx2x_848xx_specific_func
@@ -13807,8 +14006,10 @@ void bnx2x_period_func(struct link_params *params, struct link_vars *vars)
        if (CHIP_IS_E3(bp)) {
                struct bnx2x_phy *phy = &params->phy[INT_PHY];
                bnx2x_set_aer_mmd(params, phy);
-               if ((phy->supported & SUPPORTED_20000baseKR2_Full) &&
-                   (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_20G))
+               if (((phy->req_line_speed == SPEED_AUTO_NEG) &&
+                    (phy->speed_cap_mask &
+                     PORT_HW_CFG_SPEED_CAPABILITY_D0_20G)) ||
+                   (phy->req_line_speed == SPEED_20000))
                        bnx2x_check_kr2_wa(params, vars, phy);
                bnx2x_check_over_curr(params, vars);
                if (vars->rx_tx_asic_rst)
index 6c4e3a6..2bf9c87 100644 (file)
@@ -5280,14 +5280,14 @@ static void bnx2x_handle_classification_eqe(struct bnx2x *bp,
 {
        unsigned long ramrod_flags = 0;
        int rc = 0;
-       u32 cid = elem->message.data.eth_event.echo & BNX2X_SWCID_MASK;
+       u32 echo = le32_to_cpu(elem->message.data.eth_event.echo);
+       u32 cid = echo & BNX2X_SWCID_MASK;
        struct bnx2x_vlan_mac_obj *vlan_mac_obj;
 
        /* Always push next commands out, don't wait here */
        __set_bit(RAMROD_CONT, &ramrod_flags);
 
-       switch (le32_to_cpu((__force __le32)elem->message.data.eth_event.echo)
-                           >> BNX2X_SWCID_SHIFT) {
+       switch (echo >> BNX2X_SWCID_SHIFT) {
        case BNX2X_FILTER_MAC_PENDING:
                DP(BNX2X_MSG_SP, "Got SETUP_MAC completions\n");
                if (CNIC_LOADED(bp) && (cid == BNX2X_ISCSI_ETH_CID(bp)))
@@ -5308,8 +5308,7 @@ static void bnx2x_handle_classification_eqe(struct bnx2x *bp,
                bnx2x_handle_mcast_eqe(bp);
                return;
        default:
-               BNX2X_ERR("Unsupported classification command: %d\n",
-                         elem->message.data.eth_event.echo);
+               BNX2X_ERR("Unsupported classification command: 0x%x\n", echo);
                return;
        }
 
@@ -5478,9 +5477,6 @@ static void bnx2x_eq_int(struct bnx2x *bp)
                        goto next_spqe;
                }
 
-               /* elem CID originates from FW; actually LE */
-               cid = SW_CID((__force __le32)
-                            elem->message.data.cfc_del_event.cid);
                opcode = elem->message.opcode;
 
                /* handle eq element */
@@ -5503,6 +5499,10 @@ static void bnx2x_eq_int(struct bnx2x *bp)
                         * we may want to verify here that the bp state is
                         * HALTING
                         */
+
+                       /* elem CID originates from FW; actually LE */
+                       cid = SW_CID(elem->message.data.cfc_del_event.cid);
+
                        DP(BNX2X_MSG_SP,
                           "got delete ramrod for MULTI[%d]\n", cid);
 
@@ -5596,10 +5596,8 @@ static void bnx2x_eq_int(struct bnx2x *bp)
                      BNX2X_STATE_OPENING_WAIT4_PORT):
                case (EVENT_RING_OPCODE_RSS_UPDATE_RULES |
                      BNX2X_STATE_CLOSING_WAIT4_HALT):
-                       cid = elem->message.data.eth_event.echo &
-                               BNX2X_SWCID_MASK;
                        DP(BNX2X_MSG_SP, "got RSS_UPDATE ramrod. CID %d\n",
-                          cid);
+                          SW_CID(elem->message.data.eth_event.echo));
                        rss_raw->clear_pending(rss_raw);
                        break;
 
@@ -5684,7 +5682,7 @@ static void bnx2x_sp_task(struct work_struct *work)
                if (status & BNX2X_DEF_SB_IDX) {
                        struct bnx2x_fastpath *fp = bnx2x_fcoe_fp(bp);
 
-               if (FCOE_INIT(bp) &&
+                       if (FCOE_INIT(bp) &&
                            (bnx2x_has_rx_work(fp) || bnx2x_has_tx_work(fp))) {
                                /* Prevent local bottom-halves from running as
                                 * we are going to change the local NAPI list.
index 4dead49..a43dea2 100644 (file)
@@ -7296,6 +7296,8 @@ Theotherbitsarereservedandshouldbezero*/
 #define MDIO_PMA_REG_84823_CTL_LED_CTL_1                       0xa8e3
 #define MDIO_PMA_REG_84833_CTL_LED_CTL_1                       0xa8ec
 #define MDIO_PMA_REG_84823_LED3_STRETCH_EN                     0x0080
+/* BCM84858 only */
+#define MDIO_PMA_REG_84858_ALLOW_GPHY_ACT                      0x8000
 
 /* BCM84833 only */
 #define MDIO_84833_TOP_CFG_FW_REV                      0x400f
@@ -7337,6 +7339,10 @@ Theotherbitsarereservedandshouldbezero*/
 #define PHY84833_STATUS_CMD_NOT_OPEN_FOR_CMDS          0x0040
 #define PHY84833_STATUS_CMD_CLEAR_COMPLETE             0x0080
 #define PHY84833_STATUS_CMD_OPEN_OVERRIDE              0xa5a5
+/* Mailbox Process */
+#define PHY84833_MB_PROCESS1                           1
+#define PHY84833_MB_PROCESS2                           2
+#define PHY84833_MB_PROCESS3                           3
 
 /* Mailbox status set used by 84858 only */
 #define PHY84858_STATUS_CMD_RECEIVED                   0x0001
index 9d02734..632daff 100644 (file)
@@ -1672,11 +1672,12 @@ void bnx2x_vf_handle_classification_eqe(struct bnx2x *bp,
 {
        unsigned long ramrod_flags = 0;
        int rc = 0;
+       u32 echo = le32_to_cpu(elem->message.data.eth_event.echo);
 
        /* Always push next commands out, don't wait here */
        set_bit(RAMROD_CONT, &ramrod_flags);
 
-       switch (elem->message.data.eth_event.echo >> BNX2X_SWCID_SHIFT) {
+       switch (echo >> BNX2X_SWCID_SHIFT) {
        case BNX2X_FILTER_MAC_PENDING:
                rc = vfq->mac_obj.complete(bp, &vfq->mac_obj, elem,
                                           &ramrod_flags);
@@ -1686,8 +1687,7 @@ void bnx2x_vf_handle_classification_eqe(struct bnx2x *bp,
                                            &ramrod_flags);
                break;
        default:
-               BNX2X_ERR("Unsupported classification command: %d\n",
-                         elem->message.data.eth_event.echo);
+               BNX2X_ERR("Unsupported classification command: 0x%x\n", echo);
                return;
        }
        if (rc < 0)
@@ -1747,16 +1747,14 @@ int bnx2x_iov_eq_sp_event(struct bnx2x *bp, union event_ring_elem *elem)
 
        switch (opcode) {
        case EVENT_RING_OPCODE_CFC_DEL:
-               cid = SW_CID((__force __le32)
-                            elem->message.data.cfc_del_event.cid);
+               cid = SW_CID(elem->message.data.cfc_del_event.cid);
                DP(BNX2X_MSG_IOV, "checking cfc-del comp cid=%d\n", cid);
                break;
        case EVENT_RING_OPCODE_CLASSIFICATION_RULES:
        case EVENT_RING_OPCODE_MULTICAST_RULES:
        case EVENT_RING_OPCODE_FILTERS_RULES:
        case EVENT_RING_OPCODE_RSS_UPDATE_RULES:
-               cid = (elem->message.data.eth_event.echo &
-                      BNX2X_SWCID_MASK);
+               cid = SW_CID(elem->message.data.eth_event.echo);
                DP(BNX2X_MSG_IOV, "checking filtering comp cid=%d\n", cid);
                break;
        case EVENT_RING_OPCODE_VF_FLR:
index 1374e53..bfae300 100644 (file)
@@ -2187,8 +2187,10 @@ void bnx2x_vf_mbx_schedule(struct bnx2x *bp,
 
        /* Update VFDB with current message and schedule its handling */
        mutex_lock(&BP_VFDB(bp)->event_mutex);
-       BP_VF_MBX(bp, vf_idx)->vf_addr_hi = vfpf_event->msg_addr_hi;
-       BP_VF_MBX(bp, vf_idx)->vf_addr_lo = vfpf_event->msg_addr_lo;
+       BP_VF_MBX(bp, vf_idx)->vf_addr_hi =
+               le32_to_cpu(vfpf_event->msg_addr_hi);
+       BP_VF_MBX(bp, vf_idx)->vf_addr_lo =
+               le32_to_cpu(vfpf_event->msg_addr_lo);
        BP_VFDB(bp)->event_occur |= (1ULL << vf_idx);
        mutex_unlock(&BP_VFDB(bp)->event_mutex);
 
index 5dc89e5..82f1913 100644 (file)
@@ -69,7 +69,7 @@ MODULE_VERSION(DRV_MODULE_VERSION);
 #define BNXT_RX_DMA_OFFSET NET_SKB_PAD
 #define BNXT_RX_COPY_THRESH 256
 
-#define BNXT_TX_PUSH_THRESH 92
+#define BNXT_TX_PUSH_THRESH 164
 
 enum board_idx {
        BCM57301,
@@ -223,11 +223,12 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
        }
 
        if (free_size == bp->tx_ring_size && length <= bp->tx_push_thresh) {
-               struct tx_push_bd *push = txr->tx_push;
-               struct tx_bd *tx_push = &push->txbd1;
-               struct tx_bd_ext *tx_push1 = &push->txbd2;
-               void *pdata = tx_push1 + 1;
-               int j;
+               struct tx_push_buffer *tx_push_buf = txr->tx_push;
+               struct tx_push_bd *tx_push = &tx_push_buf->push_bd;
+               struct tx_bd_ext *tx_push1 = &tx_push->txbd2;
+               void *pdata = tx_push_buf->data;
+               u64 *end;
+               int j, push_len;
 
                /* Set COAL_NOW to be ready quickly for the next push */
                tx_push->tx_bd_len_flags_type =
@@ -247,6 +248,10 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
                tx_push1->tx_bd_cfa_meta = cpu_to_le32(vlan_tag_flags);
                tx_push1->tx_bd_cfa_action = cpu_to_le32(cfa_action);
 
+               end = pdata + length;
+               end = PTR_ALIGN(end, 8) - 1;
+               *end = 0;
+
                skb_copy_from_linear_data(skb, pdata, len);
                pdata += len;
                for (j = 0; j < last_frag; j++) {
@@ -261,22 +266,29 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
                        pdata += skb_frag_size(frag);
                }
 
-               memcpy(txbd, tx_push, sizeof(*txbd));
+               txbd->tx_bd_len_flags_type = tx_push->tx_bd_len_flags_type;
+               txbd->tx_bd_haddr = txr->data_mapping;
                prod = NEXT_TX(prod);
                txbd = &txr->tx_desc_ring[TX_RING(prod)][TX_IDX(prod)];
                memcpy(txbd, tx_push1, sizeof(*txbd));
                prod = NEXT_TX(prod);
-               push->doorbell =
+               tx_push->doorbell =
                        cpu_to_le32(DB_KEY_TX_PUSH | DB_LONG_TX_PUSH | prod);
                txr->tx_prod = prod;
 
                netdev_tx_sent_queue(txq, skb->len);
 
-               __iowrite64_copy(txr->tx_doorbell, push,
-                                (length + sizeof(*push) + 8) / 8);
+               push_len = (length + sizeof(*tx_push) + 7) / 8;
+               if (push_len > 16) {
+                       __iowrite64_copy(txr->tx_doorbell, tx_push_buf, 16);
+                       __iowrite64_copy(txr->tx_doorbell + 4, tx_push_buf + 1,
+                                        push_len - 16);
+               } else {
+                       __iowrite64_copy(txr->tx_doorbell, tx_push_buf,
+                                        push_len);
+               }
 
                tx_buf->is_push = 1;
-
                goto tx_done;
        }
 
@@ -1753,7 +1765,7 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)
                push_size  = L1_CACHE_ALIGN(sizeof(struct tx_push_bd) +
                                        bp->tx_push_thresh);
 
-               if (push_size > 128) {
+               if (push_size > 256) {
                        push_size = 0;
                        bp->tx_push_thresh = 0;
                }
@@ -1772,7 +1784,6 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)
                        return rc;
 
                if (bp->tx_push_size) {
-                       struct tx_bd *txbd;
                        dma_addr_t mapping;
 
                        /* One pre-allocated DMA buffer to backup
@@ -1786,13 +1797,11 @@ static int bnxt_alloc_tx_rings(struct bnxt *bp)
                        if (!txr->tx_push)
                                return -ENOMEM;
 
-                       txbd = &txr->tx_push->txbd1;
-
                        mapping = txr->tx_push_mapping +
                                sizeof(struct tx_push_bd);
-                       txbd->tx_bd_haddr = cpu_to_le64(mapping);
+                       txr->data_mapping = cpu_to_le64(mapping);
 
-                       memset(txbd + 1, 0, sizeof(struct tx_bd_ext));
+                       memset(txr->tx_push, 0, sizeof(struct tx_push_bd));
                }
                ring->queue_id = bp->q_info[j].queue_id;
                if (i % bp->tx_nr_rings_per_tc == (bp->tx_nr_rings_per_tc - 1))
@@ -4546,20 +4555,18 @@ static int bnxt_update_phy_setting(struct bnxt *bp)
        if (!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) &&
            link_info->force_pause_setting != link_info->req_flow_ctrl)
                update_pause = true;
-       if (link_info->req_duplex != link_info->duplex_setting)
-               update_link = true;
        if (!(link_info->autoneg & BNXT_AUTONEG_SPEED)) {
                if (BNXT_AUTO_MODE(link_info->auto_mode))
                        update_link = true;
                if (link_info->req_link_speed != link_info->force_link_speed)
                        update_link = true;
+               if (link_info->req_duplex != link_info->duplex_setting)
+                       update_link = true;
        } else {
                if (link_info->auto_mode == BNXT_LINK_AUTO_NONE)
                        update_link = true;
                if (link_info->advertising != link_info->auto_link_speeds)
                        update_link = true;
-               if (link_info->req_link_speed != link_info->auto_link_speed)
-                       update_link = true;
        }
 
        if (update_link)
@@ -4636,7 +4643,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
        if (link_re_init) {
                rc = bnxt_update_phy_setting(bp);
                if (rc)
-                       goto open_err;
+                       netdev_warn(bp->dev, "failed to update phy settings\n");
        }
 
        if (irq_re_init) {
@@ -4654,6 +4661,7 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
        /* Enable TX queues */
        bnxt_tx_enable(bp);
        mod_timer(&bp->timer, jiffies + bp->current_interval);
+       bnxt_update_link(bp, true);
 
        return 0;
 
@@ -5670,22 +5678,16 @@ static int bnxt_probe_phy(struct bnxt *bp)
        }
 
        /*initialize the ethool setting copy with NVM settings */
-       if (BNXT_AUTO_MODE(link_info->auto_mode))
-               link_info->autoneg |= BNXT_AUTONEG_SPEED;
-
-       if (link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH) {
-               if (link_info->auto_pause_setting == BNXT_LINK_PAUSE_BOTH)
-                       link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL;
+       if (BNXT_AUTO_MODE(link_info->auto_mode)) {
+               link_info->autoneg = BNXT_AUTONEG_SPEED |
+                                    BNXT_AUTONEG_FLOW_CTRL;
+               link_info->advertising = link_info->auto_link_speeds;
                link_info->req_flow_ctrl = link_info->auto_pause_setting;
-       } else if (link_info->force_pause_setting & BNXT_LINK_PAUSE_BOTH) {
+       } else {
+               link_info->req_link_speed = link_info->force_link_speed;
+               link_info->req_duplex = link_info->duplex_setting;
                link_info->req_flow_ctrl = link_info->force_pause_setting;
        }
-       link_info->req_duplex = link_info->duplex_setting;
-       if (link_info->autoneg & BNXT_AUTONEG_SPEED)
-               link_info->req_link_speed = link_info->auto_link_speed;
-       else
-               link_info->req_link_speed = link_info->force_link_speed;
-       link_info->advertising = link_info->auto_link_speeds;
        snprintf(phy_ver, PHY_VER_STR_LEN, " ph %d.%d.%d",
                 link_info->phy_ver[0],
                 link_info->phy_ver[1],
index 8af3ca8..2be51b3 100644 (file)
@@ -411,8 +411,8 @@ struct rx_tpa_end_cmp_ext {
 
 #define BNXT_NUM_TESTS(bp)     0
 
-#define BNXT_DEFAULT_RX_RING_SIZE      1023
-#define BNXT_DEFAULT_TX_RING_SIZE      512
+#define BNXT_DEFAULT_RX_RING_SIZE      511
+#define BNXT_DEFAULT_TX_RING_SIZE      511
 
 #define MAX_TPA                64
 
@@ -523,10 +523,16 @@ struct bnxt_ring_struct {
 
 struct tx_push_bd {
        __le32                  doorbell;
-       struct tx_bd            txbd1;
+       __le32                  tx_bd_len_flags_type;
+       u32                     tx_bd_opaque;
        struct tx_bd_ext        txbd2;
 };
 
+struct tx_push_buffer {
+       struct tx_push_bd       push_bd;
+       u32                     data[25];
+};
+
 struct bnxt_tx_ring_info {
        struct bnxt_napi        *bnapi;
        u16                     tx_prod;
@@ -538,8 +544,9 @@ struct bnxt_tx_ring_info {
 
        dma_addr_t              tx_desc_mapping[MAX_TX_PAGES];
 
-       struct tx_push_bd       *tx_push;
+       struct tx_push_buffer   *tx_push;
        dma_addr_t              tx_push_mapping;
+       __le64                  data_mapping;
 
 #define BNXT_DEV_STATE_CLOSING 0x1
        u32                     dev_state;
index 922b898..3238817 100644 (file)
@@ -486,15 +486,8 @@ static u32 bnxt_fw_to_ethtool_support_spds(struct bnxt_link_info *link_info)
                speed_mask |= SUPPORTED_2500baseX_Full;
        if (fw_speeds & BNXT_LINK_SPEED_MSK_10GB)
                speed_mask |= SUPPORTED_10000baseT_Full;
-       /* TODO: support 25GB, 50GB with different cable type */
-       if (fw_speeds & BNXT_LINK_SPEED_MSK_20GB)
-               speed_mask |= SUPPORTED_20000baseMLD2_Full |
-                       SUPPORTED_20000baseKR2_Full;
        if (fw_speeds & BNXT_LINK_SPEED_MSK_40GB)
-               speed_mask |= SUPPORTED_40000baseKR4_Full |
-                       SUPPORTED_40000baseCR4_Full |
-                       SUPPORTED_40000baseSR4_Full |
-                       SUPPORTED_40000baseLR4_Full;
+               speed_mask |= SUPPORTED_40000baseCR4_Full;
 
        return speed_mask;
 }
@@ -514,15 +507,8 @@ static u32 bnxt_fw_to_ethtool_advertised_spds(struct bnxt_link_info *link_info)
                speed_mask |= ADVERTISED_2500baseX_Full;
        if (fw_speeds & BNXT_LINK_SPEED_MSK_10GB)
                speed_mask |= ADVERTISED_10000baseT_Full;
-       /* TODO: how to advertise 20, 25, 40, 50GB with different cable type ?*/
-       if (fw_speeds & BNXT_LINK_SPEED_MSK_20GB)
-               speed_mask |= ADVERTISED_20000baseMLD2_Full |
-                             ADVERTISED_20000baseKR2_Full;
        if (fw_speeds & BNXT_LINK_SPEED_MSK_40GB)
-               speed_mask |= ADVERTISED_40000baseKR4_Full |
-                             ADVERTISED_40000baseCR4_Full |
-                             ADVERTISED_40000baseSR4_Full |
-                             ADVERTISED_40000baseLR4_Full;
+               speed_mask |= ADVERTISED_40000baseCR4_Full;
        return speed_mask;
 }
 
@@ -557,11 +543,12 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
        u16 ethtool_speed;
 
        cmd->supported = bnxt_fw_to_ethtool_support_spds(link_info);
+       cmd->supported |= SUPPORTED_Pause | SUPPORTED_Asym_Pause;
 
        if (link_info->auto_link_speeds)
                cmd->supported |= SUPPORTED_Autoneg;
 
-       if (BNXT_AUTO_MODE(link_info->auto_mode)) {
+       if (link_info->autoneg) {
                cmd->advertising =
                        bnxt_fw_to_ethtool_advertised_spds(link_info);
                cmd->advertising |= ADVERTISED_Autoneg;
@@ -570,28 +557,16 @@ static int bnxt_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                cmd->autoneg = AUTONEG_DISABLE;
                cmd->advertising = 0;
        }
-       if (link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH) {
+       if (link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL) {
                if ((link_info->auto_pause_setting & BNXT_LINK_PAUSE_BOTH) ==
                    BNXT_LINK_PAUSE_BOTH) {
                        cmd->advertising |= ADVERTISED_Pause;
-                       cmd->supported |= SUPPORTED_Pause;
                } else {
                        cmd->advertising |= ADVERTISED_Asym_Pause;
-                       cmd->supported |= SUPPORTED_Asym_Pause;
                        if (link_info->auto_pause_setting &
                            BNXT_LINK_PAUSE_RX)
                                cmd->advertising |= ADVERTISED_Pause;
                }
-       } else if (link_info->force_pause_setting & BNXT_LINK_PAUSE_BOTH) {
-               if ((link_info->force_pause_setting & BNXT_LINK_PAUSE_BOTH) ==
-                   BNXT_LINK_PAUSE_BOTH) {
-                       cmd->supported |= SUPPORTED_Pause;
-               } else {
-                       cmd->supported |= SUPPORTED_Asym_Pause;
-                       if (link_info->force_pause_setting &
-                           BNXT_LINK_PAUSE_RX)
-                               cmd->supported |= SUPPORTED_Pause;
-               }
        }
 
        cmd->port = PORT_NONE;
@@ -670,6 +645,9 @@ static u16 bnxt_get_fw_auto_link_speeds(u32 advertising)
        if (advertising & ADVERTISED_10000baseT_Full)
                fw_speed_mask |= BNXT_LINK_SPEED_MSK_10GB;
 
+       if (advertising & ADVERTISED_40000baseCR4_Full)
+               fw_speed_mask |= BNXT_LINK_SPEED_MSK_40GB;
+
        return fw_speed_mask;
 }
 
@@ -729,7 +707,7 @@ static int bnxt_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
                speed = ethtool_cmd_speed(cmd);
                link_info->req_link_speed = bnxt_get_fw_speed(dev, speed);
                link_info->req_duplex = BNXT_LINK_DUPLEX_FULL;
-               link_info->autoneg &= ~BNXT_AUTONEG_SPEED;
+               link_info->autoneg = 0;
                link_info->advertising = 0;
        }
 
@@ -748,8 +726,7 @@ static void bnxt_get_pauseparam(struct net_device *dev,
 
        if (BNXT_VF(bp))
                return;
-       epause->autoneg = !!(link_info->auto_pause_setting &
-                            BNXT_LINK_PAUSE_BOTH);
+       epause->autoneg = !!(link_info->autoneg & BNXT_AUTONEG_FLOW_CTRL);
        epause->rx_pause = ((link_info->pause & BNXT_LINK_PAUSE_RX) != 0);
        epause->tx_pause = ((link_info->pause & BNXT_LINK_PAUSE_TX) != 0);
 }
@@ -765,6 +742,9 @@ static int bnxt_set_pauseparam(struct net_device *dev,
                return rc;
 
        if (epause->autoneg) {
+               if (!(link_info->autoneg & BNXT_AUTONEG_SPEED))
+                       return -EINVAL;
+
                link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL;
                link_info->req_flow_ctrl |= BNXT_LINK_PAUSE_BOTH;
        } else {
index b15a60d..d7e01a7 100644 (file)
@@ -2445,8 +2445,7 @@ static void bcmgenet_irq_task(struct work_struct *work)
        }
 
        /* Link UP/DOWN event */
-       if ((priv->hw_params->flags & GENET_HAS_MDIO_INTR) &&
-           (priv->irq0_stat & UMAC_IRQ_LINK_EVENT)) {
+       if (priv->irq0_stat & UMAC_IRQ_LINK_EVENT) {
                phy_mac_interrupt(priv->phydev,
                                  !!(priv->irq0_stat & UMAC_IRQ_LINK_UP));
                priv->irq0_stat &= ~UMAC_IRQ_LINK_EVENT;
index 49eea89..3010080 100644 (file)
@@ -7831,6 +7831,14 @@ static int tigon3_dma_hwbug_workaround(struct tg3_napi *tnapi,
        return ret;
 }
 
+static bool tg3_tso_bug_gso_check(struct tg3_napi *tnapi, struct sk_buff *skb)
+{
+       /* Check if we will never have enough descriptors,
+        * as gso_segs can be more than current ring size
+        */
+       return skb_shinfo(skb)->gso_segs < tnapi->tx_pending / 3;
+}
+
 static netdev_tx_t tg3_start_xmit(struct sk_buff *, struct net_device *);
 
 /* Use GSO to workaround all TSO packets that meet HW bug conditions
@@ -7934,14 +7942,19 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
                 * vlan encapsulated.
                 */
                if (skb->protocol == htons(ETH_P_8021Q) ||
-                   skb->protocol == htons(ETH_P_8021AD))
-                       return tg3_tso_bug(tp, tnapi, txq, skb);
+                   skb->protocol == htons(ETH_P_8021AD)) {
+                       if (tg3_tso_bug_gso_check(tnapi, skb))
+                               return tg3_tso_bug(tp, tnapi, txq, skb);
+                       goto drop;
+               }
 
                if (!skb_is_gso_v6(skb)) {
                        if (unlikely((ETH_HLEN + hdr_len) > 80) &&
-                           tg3_flag(tp, TSO_BUG))
-                               return tg3_tso_bug(tp, tnapi, txq, skb);
-
+                           tg3_flag(tp, TSO_BUG)) {
+                               if (tg3_tso_bug_gso_check(tnapi, skb))
+                                       return tg3_tso_bug(tp, tnapi, txq, skb);
+                               goto drop;
+                       }
                        ip_csum = iph->check;
                        ip_tot_len = iph->tot_len;
                        iph->check = 0;
@@ -8073,7 +8086,7 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (would_hit_hwbug) {
                tg3_tx_skb_unmap(tnapi, tnapi->tx_prod, i);
 
-               if (mss) {
+               if (mss && tg3_tso_bug_gso_check(tnapi, skb)) {
                        /* If it's a TSO packet, do GSO instead of
                         * allocating and copying to a large linear SKB
                         */
index 04b0d16..95bc470 100644 (file)
@@ -987,7 +987,7 @@ bna_rxf_ucast_cfg_apply(struct bna_rxf *rxf)
        if (!list_empty(&rxf->ucast_pending_add_q)) {
                mac = list_first_entry(&rxf->ucast_pending_add_q,
                                       struct bna_mac, qe);
-               list_add_tail(&mac->qe, &rxf->ucast_active_q);
+               list_move_tail(&mac->qe, &rxf->ucast_active_q);
                bna_bfi_ucast_req(rxf, mac, BFI_ENET_H2I_MAC_UCAST_ADD_REQ);
                return 1;
        }
index 8727655..34d269c 100644 (file)
@@ -1683,7 +1683,7 @@ static int octeon_setup_droq(struct octeon_device *oct, int q_no, int num_descs,
        dev_dbg(&oct->pci_dev->dev, "Creating Droq: %d\n", q_no);
        /* droq creation and local register settings. */
        ret_val = octeon_create_droq(oct, q_no, num_descs, desc_size, app_ctx);
-       if (ret_val == -1)
+       if (ret_val < 0)
                return ret_val;
 
        if (ret_val == 1) {
@@ -2524,7 +2524,7 @@ static void handle_timestamp(struct octeon_device *oct,
 
        octeon_swap_8B_data(&resp->timestamp, 1);
 
-       if (unlikely((skb_shinfo(skb)->tx_flags | SKBTX_IN_PROGRESS) != 0)) {
+       if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS) != 0)) {
                struct skb_shared_hwtstamps ts;
                u64 ns = resp->timestamp;
 
index 4dba86e..174072b 100644 (file)
@@ -983,5 +983,5 @@ int octeon_create_droq(struct octeon_device *oct,
 
 create_droq_fail:
        octeon_delete_droq(oct, q_no);
-       return -1;
+       return -ENOMEM;
 }
index 6888288..34e9ace 100644 (file)
 #define NIC_PF_INTR_ID_MBOX0           8
 #define NIC_PF_INTR_ID_MBOX1           9
 
+/* Minimum FIFO level before all packets for the CQ are dropped
+ *
+ * This value ensures that once a packet has been "accepted"
+ * for reception it will not get dropped due to non-availability
+ * of CQ descriptor. An errata in HW mandates this value to be
+ * atleast 0x100.
+ */
+#define NICPF_CQM_MIN_DROP_LEVEL       0x100
+
 /* Global timer for CQ timer thresh interrupts
  * Calculated for SCLK of 700Mhz
  * value written should be a 1/16th of what is expected
index 4dded90..95f17f8 100644 (file)
@@ -304,6 +304,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic)
 static void nic_init_hw(struct nicpf *nic)
 {
        int i;
+       u64 cqm_cfg;
 
        /* Enable NIC HW block */
        nic_reg_write(nic, NIC_PF_CFG, 0x3);
@@ -340,6 +341,11 @@ static void nic_init_hw(struct nicpf *nic)
        /* Enable VLAN ethertype matching and stripping */
        nic_reg_write(nic, NIC_PF_RX_ETYPE_0_7,
                      (2 << 19) | (ETYPE_ALG_VLAN_STRIP << 16) | ETH_P_8021Q);
+
+       /* Check if HW expected value is higher (could be in future chips) */
+       cqm_cfg = nic_reg_read(nic, NIC_PF_CQM_CFG);
+       if (cqm_cfg < NICPF_CQM_MIN_DROP_LEVEL)
+               nic_reg_write(nic, NIC_PF_CQM_CFG, NICPF_CQM_MIN_DROP_LEVEL);
 }
 
 /* Channel parse index configuration */
index dd536be..afb10e3 100644 (file)
@@ -21,7 +21,7 @@
 #define   NIC_PF_TCP_TIMER                     (0x0060)
 #define   NIC_PF_BP_CFG                                (0x0080)
 #define   NIC_PF_RRM_CFG                       (0x0088)
-#define   NIC_PF_CQM_CF                                (0x00A0)
+#define   NIC_PF_CQM_CFG                       (0x00A0)
 #define   NIC_PF_CNM_CF                                (0x00A8)
 #define   NIC_PF_CNM_STATUS                    (0x00B0)
 #define   NIC_PF_CQ_AVG_CFG                    (0x00C0)
index c24cb2a..a009bc3 100644 (file)
@@ -574,8 +574,7 @@ static inline void nicvf_set_rxhash(struct net_device *netdev,
 
 static void nicvf_rcv_pkt_handler(struct net_device *netdev,
                                  struct napi_struct *napi,
-                                 struct cmp_queue *cq,
-                                 struct cqe_rx_t *cqe_rx, int cqe_type)
+                                 struct cqe_rx_t *cqe_rx)
 {
        struct sk_buff *skb;
        struct nicvf *nic = netdev_priv(netdev);
@@ -591,7 +590,7 @@ static void nicvf_rcv_pkt_handler(struct net_device *netdev,
        }
 
        /* Check for errors */
-       err = nicvf_check_cqe_rx_errs(nic, cq, cqe_rx);
+       err = nicvf_check_cqe_rx_errs(nic, cqe_rx);
        if (err && !cqe_rx->rb_cnt)
                return;
 
@@ -682,8 +681,7 @@ loop:
                           cq_idx, cq_desc->cqe_type);
                switch (cq_desc->cqe_type) {
                case CQE_TYPE_RX:
-                       nicvf_rcv_pkt_handler(netdev, napi, cq,
-                                             cq_desc, CQE_TYPE_RX);
+                       nicvf_rcv_pkt_handler(netdev, napi, cq_desc);
                        work_done++;
                break;
                case CQE_TYPE_SEND:
@@ -1125,7 +1123,6 @@ int nicvf_stop(struct net_device *netdev)
 
        /* Clear multiqset info */
        nic->pnicvf = nic;
-       nic->sqs_count = 0;
 
        return 0;
 }
@@ -1354,6 +1351,9 @@ void nicvf_update_stats(struct nicvf *nic)
        drv_stats->tx_frames_ok = stats->tx_ucast_frames_ok +
                                  stats->tx_bcast_frames_ok +
                                  stats->tx_mcast_frames_ok;
+       drv_stats->rx_frames_ok = stats->rx_ucast_frames +
+                                 stats->rx_bcast_frames +
+                                 stats->rx_mcast_frames;
        drv_stats->rx_drops = stats->rx_drop_red +
                              stats->rx_drop_overrun;
        drv_stats->tx_drops = stats->tx_drops;
@@ -1538,6 +1538,9 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        nicvf_send_vf_struct(nic);
 
+       if (!pass1_silicon(nic->pdev))
+               nic->hw_tso = true;
+
        /* Check if this VF is in QS only mode */
        if (nic->sqs_mode)
                return 0;
@@ -1557,9 +1560,6 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        netdev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO;
 
-       if (!pass1_silicon(nic->pdev))
-               nic->hw_tso = true;
-
        netdev->netdev_ops = &nicvf_netdev_ops;
        netdev->watchdog_timeo = NICVF_TX_TIMEOUT;
 
index d0d1b54..767347b 100644 (file)
@@ -1329,16 +1329,12 @@ void nicvf_update_sq_stats(struct nicvf *nic, int sq_idx)
 }
 
 /* Check for errors in the receive cmp.queue entry */
-int nicvf_check_cqe_rx_errs(struct nicvf *nic,
-                           struct cmp_queue *cq, struct cqe_rx_t *cqe_rx)
+int nicvf_check_cqe_rx_errs(struct nicvf *nic, struct cqe_rx_t *cqe_rx)
 {
        struct nicvf_hw_stats *stats = &nic->hw_stats;
-       struct nicvf_drv_stats *drv_stats = &nic->drv_stats;
 
-       if (!cqe_rx->err_level && !cqe_rx->err_opcode) {
-               drv_stats->rx_frames_ok++;
+       if (!cqe_rx->err_level && !cqe_rx->err_opcode)
                return 0;
-       }
 
        if (netif_msg_rx_err(nic))
                netdev_err(nic->netdev,
index c5030a7..6673e11 100644 (file)
@@ -338,8 +338,7 @@ u64  nicvf_queue_reg_read(struct nicvf *nic,
 /* Stats */
 void nicvf_update_rq_stats(struct nicvf *nic, int rq_idx);
 void nicvf_update_sq_stats(struct nicvf *nic, int sq_idx);
-int nicvf_check_cqe_rx_errs(struct nicvf *nic,
-                           struct cmp_queue *cq, struct cqe_rx_t *cqe_rx);
+int nicvf_check_cqe_rx_errs(struct nicvf *nic, struct cqe_rx_t *cqe_rx);
 int nicvf_check_cqe_tx_errs(struct nicvf *nic,
                            struct cmp_queue *cq, struct cqe_send_t *cqe_tx);
 #endif /* NICVF_QUEUES_H */
index ee04caa..a89721f 100644 (file)
@@ -681,6 +681,24 @@ int t3_seeprom_wp(struct adapter *adapter, int enable)
        return t3_seeprom_write(adapter, EEPROM_STAT_ADDR, enable ? 0xc : 0);
 }
 
+static int vpdstrtouint(char *s, int len, unsigned int base, unsigned int *val)
+{
+       char tok[len + 1];
+
+       memcpy(tok, s, len);
+       tok[len] = 0;
+       return kstrtouint(strim(tok), base, val);
+}
+
+static int vpdstrtou16(char *s, int len, unsigned int base, u16 *val)
+{
+       char tok[len + 1];
+
+       memcpy(tok, s, len);
+       tok[len] = 0;
+       return kstrtou16(strim(tok), base, val);
+}
+
 /**
  *     get_vpd_params - read VPD parameters from VPD EEPROM
  *     @adapter: adapter to read
@@ -709,19 +727,19 @@ static int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
                        return ret;
        }
 
-       ret = kstrtouint(vpd.cclk_data, 10, &p->cclk);
+       ret = vpdstrtouint(vpd.cclk_data, vpd.cclk_len, 10, &p->cclk);
        if (ret)
                return ret;
-       ret = kstrtouint(vpd.mclk_data, 10, &p->mclk);
+       ret = vpdstrtouint(vpd.mclk_data, vpd.mclk_len, 10, &p->mclk);
        if (ret)
                return ret;
-       ret = kstrtouint(vpd.uclk_data, 10, &p->uclk);
+       ret = vpdstrtouint(vpd.uclk_data, vpd.uclk_len, 10, &p->uclk);
        if (ret)
                return ret;
-       ret = kstrtouint(vpd.mdc_data, 10, &p->mdc);
+       ret = vpdstrtouint(vpd.mdc_data, vpd.mdc_len, 10, &p->mdc);
        if (ret)
                return ret;
-       ret = kstrtouint(vpd.mt_data, 10, &p->mem_timing);
+       ret = vpdstrtouint(vpd.mt_data, vpd.mt_len, 10, &p->mem_timing);
        if (ret)
                return ret;
        memcpy(p->sn, vpd.sn_data, SERNUM_LEN);
@@ -733,10 +751,12 @@ static int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
        } else {
                p->port_type[0] = hex_to_bin(vpd.port0_data[0]);
                p->port_type[1] = hex_to_bin(vpd.port1_data[0]);
-               ret = kstrtou16(vpd.xaui0cfg_data, 16, &p->xauicfg[0]);
+               ret = vpdstrtou16(vpd.xaui0cfg_data, vpd.xaui0cfg_len, 16,
+                                 &p->xauicfg[0]);
                if (ret)
                        return ret;
-               ret = kstrtou16(vpd.xaui1cfg_data, 16, &p->xauicfg[1]);
+               ret = vpdstrtou16(vpd.xaui1cfg_data, vpd.xaui1cfg_len, 16,
+                                 &p->xauicfg[1]);
                if (ret)
                        return ret;
        }
index a8dda63..06bc2d2 100644 (file)
@@ -165,6 +165,7 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN
        CH_PCI_ID_TABLE_FENTRY(0x5098), /* Custom 2x40G QSFP */
        CH_PCI_ID_TABLE_FENTRY(0x5099), /* Custom 2x40G QSFP */
        CH_PCI_ID_TABLE_FENTRY(0x509a), /* Custom T520-CR */
+       CH_PCI_ID_TABLE_FENTRY(0x509b), /* Custom T540-CR LOM */
 
        /* T6 adapters:
         */
index 1671fa3..7ba6d53 100644 (file)
@@ -33,7 +33,7 @@
 
 #define DRV_NAME               "enic"
 #define DRV_DESCRIPTION                "Cisco VIC Ethernet NIC Driver"
-#define DRV_VERSION            "2.3.0.12"
+#define DRV_VERSION            "2.3.0.20"
 #define DRV_COPYRIGHT          "Copyright 2008-2013 Cisco Systems, Inc"
 
 #define ENIC_BARS_MAX          6
index 1ffd105..1fdf5fe 100644 (file)
@@ -298,7 +298,8 @@ static int _vnic_dev_cmd2(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
                          int wait)
 {
        struct devcmd2_controller *dc2c = vdev->devcmd2;
-       struct devcmd2_result *result = dc2c->result + dc2c->next_result;
+       struct devcmd2_result *result;
+       u8 color;
        unsigned int i;
        int delay, err;
        u32 fetch_index, new_posted;
@@ -336,13 +337,17 @@ static int _vnic_dev_cmd2(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
        if (dc2c->cmd_ring[posted].flags & DEVCMD2_FNORESULT)
                return 0;
 
+       result = dc2c->result + dc2c->next_result;
+       color = dc2c->color;
+
+       dc2c->next_result++;
+       if (dc2c->next_result == dc2c->result_size) {
+               dc2c->next_result = 0;
+               dc2c->color = dc2c->color ? 0 : 1;
+       }
+
        for (delay = 0; delay < wait; delay++) {
-               if (result->color == dc2c->color) {
-                       dc2c->next_result++;
-                       if (dc2c->next_result == dc2c->result_size) {
-                               dc2c->next_result = 0;
-                               dc2c->color = dc2c->color ? 0 : 1;
-                       }
+               if (result->color == color) {
                        if (result->error) {
                                err = result->error;
                                if (err != ERR_ECMDUNKNOWN ||
index cf94b72..48d9194 100644 (file)
@@ -128,7 +128,6 @@ struct board_info {
        struct resource *data_res;
        struct resource *addr_req;   /* resources requested */
        struct resource *data_req;
-       struct resource *irq_res;
 
        int              irq_wake;
 
@@ -1300,22 +1299,16 @@ static int
 dm9000_open(struct net_device *dev)
 {
        struct board_info *db = netdev_priv(dev);
-       unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
 
        if (netif_msg_ifup(db))
                dev_dbg(db->dev, "enabling %s\n", dev->name);
 
-       /* If there is no IRQ type specified, default to something that
-        * may work, and tell the user that this is a problem */
-
-       if (irqflags == IRQF_TRIGGER_NONE)
-               irqflags = irq_get_trigger_type(dev->irq);
-
-       if (irqflags == IRQF_TRIGGER_NONE)
+       /* If there is no IRQ type specified, tell the user that this is a
+        * problem
+        */
+       if (irq_get_trigger_type(dev->irq) == IRQF_TRIGGER_NONE)
                dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
 
-       irqflags |= IRQF_SHARED;
-
        /* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */
        iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */
        mdelay(1); /* delay needs by DM9000B */
@@ -1323,7 +1316,8 @@ dm9000_open(struct net_device *dev)
        /* Initialize DM9000 board */
        dm9000_init_dm9000(dev);
 
-       if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
+       if (request_irq(dev->irq, dm9000_interrupt, IRQF_SHARED,
+                       dev->name, dev))
                return -EAGAIN;
        /* Now that we have an interrupt handler hooked up we can unmask
         * our interrupts
@@ -1500,15 +1494,22 @@ dm9000_probe(struct platform_device *pdev)
 
        db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-       db->irq_res  = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 
-       if (db->addr_res == NULL || db->data_res == NULL ||
-           db->irq_res == NULL) {
-               dev_err(db->dev, "insufficient resources\n");
+       if (!db->addr_res || !db->data_res) {
+               dev_err(db->dev, "insufficient resources addr=%p data=%p\n",
+                       db->addr_res, db->data_res);
                ret = -ENOENT;
                goto out;
        }
 
+       ndev->irq = platform_get_irq(pdev, 0);
+       if (ndev->irq < 0) {
+               dev_err(db->dev, "interrupt resource unavailable: %d\n",
+                       ndev->irq);
+               ret = ndev->irq;
+               goto out;
+       }
+
        db->irq_wake = platform_get_irq(pdev, 1);
        if (db->irq_wake >= 0) {
                dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake);
@@ -1570,7 +1571,6 @@ dm9000_probe(struct platform_device *pdev)
 
        /* fill in parameters for net-dev structure */
        ndev->base_addr = (unsigned long)db->io_addr;
-       ndev->irq       = db->irq_res->start;
 
        /* ensure at least we have a default set of IO routines */
        dm9000_set_io(db, iosize);
index cf83783..f975129 100644 (file)
@@ -531,6 +531,7 @@ struct be_adapter {
 
        struct delayed_work be_err_detection_work;
        u8 err_flags;
+       bool pcicfg_mapped;     /* pcicfg obtained via pci_iomap() */
        u32 flags;
        u32 cmd_privileges;
        /* Ethtool knobs and info */
index 241819b..6d9a8d7 100644 (file)
@@ -622,10 +622,13 @@ enum be_if_flags {
                                         BE_IF_FLAGS_VLAN_PROMISCUOUS |\
                                         BE_IF_FLAGS_MCAST_PROMISCUOUS)
 
-#define BE_IF_EN_FLAGS (BE_IF_FLAGS_BROADCAST | BE_IF_FLAGS_PASS_L3L4_ERRORS |\
-                       BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_UNTAGGED)
+#define BE_IF_FILT_FLAGS_BASIC (BE_IF_FLAGS_BROADCAST | \
+                               BE_IF_FLAGS_PASS_L3L4_ERRORS | \
+                               BE_IF_FLAGS_UNTAGGED)
 
-#define BE_IF_ALL_FILT_FLAGS   (BE_IF_EN_FLAGS | BE_IF_FLAGS_ALL_PROMISCUOUS)
+#define BE_IF_ALL_FILT_FLAGS   (BE_IF_FILT_FLAGS_BASIC | \
+                                BE_IF_FLAGS_MULTICAST | \
+                                BE_IF_FLAGS_ALL_PROMISCUOUS)
 
 /* An RX interface is an object with one or more MAC addresses and
  * filtering capabilities. */
index f99de36..d1cf127 100644 (file)
@@ -125,6 +125,11 @@ static const char * const ue_status_hi_desc[] = {
        "Unknown"
 };
 
+#define BE_VF_IF_EN_FLAGS      (BE_IF_FLAGS_UNTAGGED | \
+                                BE_IF_FLAGS_BROADCAST | \
+                                BE_IF_FLAGS_MULTICAST | \
+                                BE_IF_FLAGS_PASS_L3L4_ERRORS)
+
 static void be_queue_free(struct be_adapter *adapter, struct be_queue_info *q)
 {
        struct be_dma_mem *mem = &q->dma_mem;
@@ -3537,7 +3542,7 @@ static int be_enable_if_filters(struct be_adapter *adapter)
 {
        int status;
 
-       status = be_cmd_rx_filter(adapter, BE_IF_EN_FLAGS, ON);
+       status = be_cmd_rx_filter(adapter, BE_IF_FILT_FLAGS_BASIC, ON);
        if (status)
                return status;
 
@@ -3857,8 +3862,7 @@ static int be_vfs_if_create(struct be_adapter *adapter)
        int status;
 
        /* If a FW profile exists, then cap_flags are updated */
-       cap_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
-                   BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS;
+       cap_flags = BE_VF_IF_EN_FLAGS;
 
        for_all_vfs(adapter, vf_cfg, vf) {
                if (!BE3_chip(adapter)) {
@@ -3874,10 +3878,8 @@ static int be_vfs_if_create(struct be_adapter *adapter)
                        }
                }
 
-               en_flags = cap_flags & (BE_IF_FLAGS_UNTAGGED |
-                                       BE_IF_FLAGS_BROADCAST |
-                                       BE_IF_FLAGS_MULTICAST |
-                                       BE_IF_FLAGS_PASS_L3L4_ERRORS);
+               /* PF should enable IF flags during proxy if_create call */
+               en_flags = cap_flags & BE_VF_IF_EN_FLAGS;
                status = be_cmd_if_create(adapter, cap_flags, en_flags,
                                          &vf_cfg->if_handle, vf + 1);
                if (status)
@@ -4968,6 +4970,8 @@ static void be_unmap_pci_bars(struct be_adapter *adapter)
                pci_iounmap(adapter->pdev, adapter->csr);
        if (adapter->db)
                pci_iounmap(adapter->pdev, adapter->db);
+       if (adapter->pcicfg && adapter->pcicfg_mapped)
+               pci_iounmap(adapter->pdev, adapter->pcicfg);
 }
 
 static int db_bar(struct be_adapter *adapter)
@@ -5019,8 +5023,10 @@ static int be_map_pci_bars(struct be_adapter *adapter)
                        if (!addr)
                                goto pci_map_err;
                        adapter->pcicfg = addr;
+                       adapter->pcicfg_mapped = true;
                } else {
                        adapter->pcicfg = adapter->db + SRIOV_VF_PCICFG_OFFSET;
+                       adapter->pcicfg_mapped = false;
                }
        }
 
index 62fa136..41b0106 100644 (file)
@@ -1265,7 +1265,6 @@ static int ethoc_remove(struct platform_device *pdev)
 
                if (priv->mdio) {
                        mdiobus_unregister(priv->mdio);
-                       kfree(priv->mdio->irq);
                        mdiobus_free(priv->mdio);
                }
                if (priv->clk)
index 623aa1c..79a210a 100644 (file)
@@ -2791,6 +2791,8 @@ static struct fman *read_dts_node(struct platform_device *of_dev)
                goto fman_free;
        }
 
+       fman->dev = &of_dev->dev;
+
        return fman;
 
 fman_node_put:
@@ -2845,8 +2847,6 @@ static int fman_probe(struct platform_device *of_dev)
 
        dev_set_drvdata(dev, fman);
 
-       fman->dev = dev;
-
        dev_dbg(dev, "FMan%d probed\n", fman->dts_params.id);
 
        return 0;
index 2aa7b40..b9ecf19 100644 (file)
@@ -1111,8 +1111,10 @@ static void __gfar_detect_errata_85xx(struct gfar_private *priv)
 
        if ((SVR_SOC_VER(svr) == SVR_8548) && (SVR_REV(svr) == 0x20))
                priv->errata |= GFAR_ERRATA_12;
+       /* P2020/P1010 Rev 1; MPC8548 Rev 2 */
        if (((SVR_SOC_VER(svr) == SVR_P2020) && (SVR_REV(svr) < 0x20)) ||
-           ((SVR_SOC_VER(svr) == SVR_P2010) && (SVR_REV(svr) < 0x20)))
+           ((SVR_SOC_VER(svr) == SVR_P2010) && (SVR_REV(svr) < 0x20)) ||
+           ((SVR_SOC_VER(svr) == SVR_8548) && (SVR_REV(svr) < 0x31)))
                priv->errata |= GFAR_ERRATA_76; /* aka eTSEC 20 */
 }
 #endif
index a7139f5..678f501 100644 (file)
@@ -469,8 +469,8 @@ static int fmvj18x_config(struct pcmcia_device *link)
                    goto failed;
            }
            /* Read MACID from CIS */
-           for (i = 5; i < 11; i++)
-                   dev->dev_addr[i] = buf[i];
+           for (i = 0; i < 6; i++)
+                   dev->dev_addr[i] = buf[i + 5];
            kfree(buf);
        } else {
            if (pcmcia_get_mac_from_cis(link, dev))
index 74beb18..4ccc032 100644 (file)
@@ -25,6 +25,7 @@ config HIX5HD2_GMAC
 
 config HIP04_ETH
        tristate "HISILICON P04 Ethernet support"
+       depends on HAS_IOMEM    # For MFD_SYSCON
        select MARVELL_PHY
        select MFD_SYSCON
        select HNS_MDIO
index a0070d0..d4f92ed 100644 (file)
@@ -675,8 +675,12 @@ static int hns_ae_config_loopback(struct hnae_handle *handle,
 {
        int ret;
        struct hnae_vf_cb *vf_cb = hns_ae_get_vf_cb(handle);
+       struct hns_mac_cb *mac_cb = hns_get_mac_cb(handle);
 
        switch (loop) {
+       case MAC_INTERNALLOOP_PHY:
+               ret = 0;
+               break;
        case MAC_INTERNALLOOP_SERDES:
                ret = hns_mac_config_sds_loopback(vf_cb->mac_cb, en);
                break;
@@ -686,6 +690,10 @@ static int hns_ae_config_loopback(struct hnae_handle *handle,
        default:
                ret = -EINVAL;
        }
+
+       if (!ret)
+               hns_dsaf_set_inner_lb(mac_cb->dsaf_dev, mac_cb->mac_id, en);
+
        return ret;
 }
 
index 9439f04..38fc5be 100644 (file)
@@ -230,6 +230,30 @@ static void hns_dsaf_mix_def_qid_cfg(struct dsaf_device *dsaf_dev)
        }
 }
 
+static void hns_dsaf_inner_qid_cfg(struct dsaf_device *dsaf_dev)
+{
+       u16 max_q_per_vf, max_vfn;
+       u32 q_id, q_num_per_port;
+       u32 mac_id;
+
+       if (AE_IS_VER1(dsaf_dev->dsaf_ver))
+               return;
+
+       hns_rcb_get_queue_mode(dsaf_dev->dsaf_mode,
+                              HNS_DSAF_COMM_SERVICE_NW_IDX,
+                              &max_vfn, &max_q_per_vf);
+       q_num_per_port = max_vfn * max_q_per_vf;
+
+       for (mac_id = 0, q_id = 0; mac_id < DSAF_SERVICE_NW_NUM; mac_id++) {
+               dsaf_set_dev_field(dsaf_dev,
+                                  DSAFV2_SERDES_LBK_0_REG + 4 * mac_id,
+                                  DSAFV2_SERDES_LBK_QID_M,
+                                  DSAFV2_SERDES_LBK_QID_S,
+                                  q_id);
+               q_id += q_num_per_port;
+       }
+}
+
 /**
  * hns_dsaf_sw_port_type_cfg - cfg sw type
  * @dsaf_id: dsa fabric id
@@ -691,6 +715,16 @@ void hns_dsaf_set_promisc_mode(struct dsaf_device *dsaf_dev, u32 en)
        dsaf_set_dev_bit(dsaf_dev, DSAF_CFG_0_REG, DSAF_CFG_MIX_MODE_S, !!en);
 }
 
+void hns_dsaf_set_inner_lb(struct dsaf_device *dsaf_dev, u32 mac_id, u32 en)
+{
+       if (AE_IS_VER1(dsaf_dev->dsaf_ver) ||
+           dsaf_dev->mac_cb[mac_id].mac_type == HNAE_PORT_DEBUG)
+               return;
+
+       dsaf_set_dev_bit(dsaf_dev, DSAFV2_SERDES_LBK_0_REG + 4 * mac_id,
+                        DSAFV2_SERDES_LBK_EN_B, !!en);
+}
+
 /**
  * hns_dsaf_tbl_stat_en - tbl
  * @dsaf_id: dsa fabric id
@@ -1022,6 +1056,9 @@ static void hns_dsaf_comm_init(struct dsaf_device *dsaf_dev)
        /* set promisc def queue id */
        hns_dsaf_mix_def_qid_cfg(dsaf_dev);
 
+       /* set inner loopback queue id */
+       hns_dsaf_inner_qid_cfg(dsaf_dev);
+
        /* in non switch mode, set all port to access mode */
        hns_dsaf_sw_port_type_cfg(dsaf_dev, DSAF_SW_PORT_TYPE_NON_VLAN);
 
index 40205b9..5fea226 100644 (file)
@@ -417,5 +417,6 @@ void hns_dsaf_get_strings(int stringset, u8 *data, int port);
 void hns_dsaf_get_regs(struct dsaf_device *ddev, u32 port, void *data);
 int hns_dsaf_get_regs_count(void);
 void hns_dsaf_set_promisc_mode(struct dsaf_device *dsaf_dev, u32 en);
+void hns_dsaf_set_inner_lb(struct dsaf_device *dsaf_dev, u32 mac_id, u32 en);
 
 #endif /* __HNS_DSAF_MAIN_H__ */
index f0c4f9b..60d695d 100644 (file)
 #define DSAF_XGE_INT_STS_0_REG         0x1C0
 #define DSAF_PPE_INT_STS_0_REG         0x1E0
 #define DSAF_ROCEE_INT_STS_0_REG       0x200
+#define DSAFV2_SERDES_LBK_0_REG         0x220
 #define DSAF_PPE_QID_CFG_0_REG         0x300
 #define DSAF_SW_PORT_TYPE_0_REG                0x320
 #define DSAF_STP_PORT_TYPE_0_REG       0x340
 #define PPEV2_CFG_RSS_TBL_4N3_S        24
 #define PPEV2_CFG_RSS_TBL_4N3_M        (((1UL << 5) - 1) << PPEV2_CFG_RSS_TBL_4N3_S)
 
+#define DSAFV2_SERDES_LBK_EN_B  8
+#define DSAFV2_SERDES_LBK_QID_S 0
+#define DSAFV2_SERDES_LBK_QID_M        (((1UL << 8) - 1) << DSAFV2_SERDES_LBK_QID_S)
+
 #define PPE_CNT_CLR_CE_B       0
 #define PPE_CNT_CLR_SNAP_EN_B  1
 
index 3df2284..3c4a3bc 100644 (file)
@@ -295,8 +295,10 @@ static int __lb_setup(struct net_device *ndev,
 
        switch (loop) {
        case MAC_INTERNALLOOP_PHY:
-               if ((phy_dev) && (!phy_dev->is_c45))
+               if ((phy_dev) && (!phy_dev->is_c45)) {
                        ret = hns_nic_config_phy_loopback(phy_dev, 0x1);
+                       ret |= h->dev->ops->set_loopback(h, loop, 0x1);
+               }
                break;
        case MAC_INTERNALLOOP_MAC:
                if ((h->dev->ops->set_loopback) &&
@@ -376,6 +378,7 @@ static void __lb_other_process(struct hns_nic_ring_data *ring_data,
                               struct sk_buff *skb)
 {
        struct net_device *ndev;
+       struct hns_nic_priv *priv;
        struct hnae_ring *ring;
        struct netdev_queue *dev_queue;
        struct sk_buff *new_skb;
@@ -385,8 +388,17 @@ static void __lb_other_process(struct hns_nic_ring_data *ring_data,
        char buff[33]; /* 32B data and the last character '\0' */
 
        if (!ring_data) { /* Just for doing create frame*/
+               ndev = skb->dev;
+               priv = netdev_priv(ndev);
+
                frame_size = skb->len;
                memset(skb->data, 0xFF, frame_size);
+               if ((!AE_IS_VER1(priv->enet_ver)) &&
+                   (priv->ae_handle->port_type == HNAE_PORT_SERVICE)) {
+                       memcpy(skb->data, ndev->dev_addr, 6);
+                       skb->data[5] += 0x1f;
+               }
+
                frame_size &= ~1ul;
                memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
                memset(&skb->data[frame_size / 2 + 10], 0xBE,
@@ -486,6 +498,7 @@ static int __lb_run_test(struct net_device *ndev,
 
        /* place data into test skb */
        (void)skb_put(skb, size);
+       skb->dev = ndev;
        __lb_other_process(NULL, skb);
        skb->queue_mapping = NIC_LB_TEST_RING_ID;
 
index 335417b..ebe6071 100644 (file)
@@ -1166,7 +1166,10 @@ map_failed:
        if (!firmware_has_feature(FW_FEATURE_CMO))
                netdev_err(netdev, "tx: unable to map xmit buffer\n");
        adapter->tx_map_failed++;
-       skb_linearize(skb);
+       if (skb_linearize(skb)) {
+               netdev->stats.tx_dropped++;
+               goto out;
+       }
        force_bounce = 1;
        goto retry_bounce;
 }
index 7d65708..6e9e16e 100644 (file)
@@ -1348,44 +1348,44 @@ static void init_sub_crqs(struct ibmvnic_adapter *adapter, int retry)
        crq.request_capability.cmd = REQUEST_CAPABILITY;
 
        crq.request_capability.capability = cpu_to_be16(REQ_TX_QUEUES);
-       crq.request_capability.number = cpu_to_be32(adapter->req_tx_queues);
+       crq.request_capability.number = cpu_to_be64(adapter->req_tx_queues);
        ibmvnic_send_crq(adapter, &crq);
 
        crq.request_capability.capability = cpu_to_be16(REQ_RX_QUEUES);
-       crq.request_capability.number = cpu_to_be32(adapter->req_rx_queues);
+       crq.request_capability.number = cpu_to_be64(adapter->req_rx_queues);
        ibmvnic_send_crq(adapter, &crq);
 
        crq.request_capability.capability = cpu_to_be16(REQ_RX_ADD_QUEUES);
-       crq.request_capability.number = cpu_to_be32(adapter->req_rx_add_queues);
+       crq.request_capability.number = cpu_to_be64(adapter->req_rx_add_queues);
        ibmvnic_send_crq(adapter, &crq);
 
        crq.request_capability.capability =
            cpu_to_be16(REQ_TX_ENTRIES_PER_SUBCRQ);
        crq.request_capability.number =
-           cpu_to_be32(adapter->req_tx_entries_per_subcrq);
+           cpu_to_be64(adapter->req_tx_entries_per_subcrq);
        ibmvnic_send_crq(adapter, &crq);
 
        crq.request_capability.capability =
            cpu_to_be16(REQ_RX_ADD_ENTRIES_PER_SUBCRQ);
        crq.request_capability.number =
-           cpu_to_be32(adapter->req_rx_add_entries_per_subcrq);
+           cpu_to_be64(adapter->req_rx_add_entries_per_subcrq);
        ibmvnic_send_crq(adapter, &crq);
 
        crq.request_capability.capability = cpu_to_be16(REQ_MTU);
-       crq.request_capability.number = cpu_to_be32(adapter->req_mtu);
+       crq.request_capability.number = cpu_to_be64(adapter->req_mtu);
        ibmvnic_send_crq(adapter, &crq);
 
        if (adapter->netdev->flags & IFF_PROMISC) {
                if (adapter->promisc_supported) {
                        crq.request_capability.capability =
                            cpu_to_be16(PROMISC_REQUESTED);
-                       crq.request_capability.number = cpu_to_be32(1);
+                       crq.request_capability.number = cpu_to_be64(1);
                        ibmvnic_send_crq(adapter, &crq);
                }
        } else {
                crq.request_capability.capability =
                    cpu_to_be16(PROMISC_REQUESTED);
-               crq.request_capability.number = cpu_to_be32(0);
+               crq.request_capability.number = cpu_to_be64(0);
                ibmvnic_send_crq(adapter, &crq);
        }
 
@@ -2312,93 +2312,93 @@ static void handle_query_cap_rsp(union ibmvnic_crq *crq,
        switch (be16_to_cpu(crq->query_capability.capability)) {
        case MIN_TX_QUEUES:
                adapter->min_tx_queues =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "min_tx_queues = %lld\n",
                           adapter->min_tx_queues);
                break;
        case MIN_RX_QUEUES:
                adapter->min_rx_queues =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "min_rx_queues = %lld\n",
                           adapter->min_rx_queues);
                break;
        case MIN_RX_ADD_QUEUES:
                adapter->min_rx_add_queues =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "min_rx_add_queues = %lld\n",
                           adapter->min_rx_add_queues);
                break;
        case MAX_TX_QUEUES:
                adapter->max_tx_queues =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "max_tx_queues = %lld\n",
                           adapter->max_tx_queues);
                break;
        case MAX_RX_QUEUES:
                adapter->max_rx_queues =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "max_rx_queues = %lld\n",
                           adapter->max_rx_queues);
                break;
        case MAX_RX_ADD_QUEUES:
                adapter->max_rx_add_queues =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "max_rx_add_queues = %lld\n",
                           adapter->max_rx_add_queues);
                break;
        case MIN_TX_ENTRIES_PER_SUBCRQ:
                adapter->min_tx_entries_per_subcrq =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "min_tx_entries_per_subcrq = %lld\n",
                           adapter->min_tx_entries_per_subcrq);
                break;
        case MIN_RX_ADD_ENTRIES_PER_SUBCRQ:
                adapter->min_rx_add_entries_per_subcrq =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "min_rx_add_entrs_per_subcrq = %lld\n",
                           adapter->min_rx_add_entries_per_subcrq);
                break;
        case MAX_TX_ENTRIES_PER_SUBCRQ:
                adapter->max_tx_entries_per_subcrq =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "max_tx_entries_per_subcrq = %lld\n",
                           adapter->max_tx_entries_per_subcrq);
                break;
        case MAX_RX_ADD_ENTRIES_PER_SUBCRQ:
                adapter->max_rx_add_entries_per_subcrq =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "max_rx_add_entrs_per_subcrq = %lld\n",
                           adapter->max_rx_add_entries_per_subcrq);
                break;
        case TCP_IP_OFFLOAD:
                adapter->tcp_ip_offload =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "tcp_ip_offload = %lld\n",
                           adapter->tcp_ip_offload);
                break;
        case PROMISC_SUPPORTED:
                adapter->promisc_supported =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "promisc_supported = %lld\n",
                           adapter->promisc_supported);
                break;
        case MIN_MTU:
-               adapter->min_mtu = be32_to_cpu(crq->query_capability.number);
+               adapter->min_mtu = be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "min_mtu = %lld\n", adapter->min_mtu);
                break;
        case MAX_MTU:
-               adapter->max_mtu = be32_to_cpu(crq->query_capability.number);
+               adapter->max_mtu = be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "max_mtu = %lld\n", adapter->max_mtu);
                break;
        case MAX_MULTICAST_FILTERS:
                adapter->max_multicast_filters =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "max_multicast_filters = %lld\n",
                           adapter->max_multicast_filters);
                break;
        case VLAN_HEADER_INSERTION:
                adapter->vlan_header_insertion =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                if (adapter->vlan_header_insertion)
                        netdev->features |= NETIF_F_HW_VLAN_STAG_TX;
                netdev_dbg(netdev, "vlan_header_insertion = %lld\n",
@@ -2406,43 +2406,43 @@ static void handle_query_cap_rsp(union ibmvnic_crq *crq,
                break;
        case MAX_TX_SG_ENTRIES:
                adapter->max_tx_sg_entries =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "max_tx_sg_entries = %lld\n",
                           adapter->max_tx_sg_entries);
                break;
        case RX_SG_SUPPORTED:
                adapter->rx_sg_supported =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "rx_sg_supported = %lld\n",
                           adapter->rx_sg_supported);
                break;
        case OPT_TX_COMP_SUB_QUEUES:
                adapter->opt_tx_comp_sub_queues =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "opt_tx_comp_sub_queues = %lld\n",
                           adapter->opt_tx_comp_sub_queues);
                break;
        case OPT_RX_COMP_QUEUES:
                adapter->opt_rx_comp_queues =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "opt_rx_comp_queues = %lld\n",
                           adapter->opt_rx_comp_queues);
                break;
        case OPT_RX_BUFADD_Q_PER_RX_COMP_Q:
                adapter->opt_rx_bufadd_q_per_rx_comp_q =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "opt_rx_bufadd_q_per_rx_comp_q = %lld\n",
                           adapter->opt_rx_bufadd_q_per_rx_comp_q);
                break;
        case OPT_TX_ENTRIES_PER_SUBCRQ:
                adapter->opt_tx_entries_per_subcrq =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "opt_tx_entries_per_subcrq = %lld\n",
                           adapter->opt_tx_entries_per_subcrq);
                break;
        case OPT_RXBA_ENTRIES_PER_SUBCRQ:
                adapter->opt_rxba_entries_per_subcrq =
-                   be32_to_cpu(crq->query_capability.number);
+                   be64_to_cpu(crq->query_capability.number);
                netdev_dbg(netdev, "opt_rxba_entries_per_subcrq = %lld\n",
                           adapter->opt_rxba_entries_per_subcrq);
                break;
index 1242925..1a9993c 100644 (file)
@@ -319,10 +319,8 @@ struct ibmvnic_capability {
        u8 first;
        u8 cmd;
        __be16 capability; /* one of ibmvnic_capabilities */
+       __be64 number;
        struct ibmvnic_rc rc;
-       __be32 number; /*FIX: should be __be64, but I'm getting the least
-                       * significant word first
-                       */
 } __packed __aligned(8);
 
 struct ibmvnic_login {
index b1de7af..3ddf657 100644 (file)
@@ -270,11 +270,17 @@ jme_reset_mac_processor(struct jme_adapter *jme)
 }
 
 static inline void
-jme_clear_pm(struct jme_adapter *jme)
+jme_clear_pm_enable_wol(struct jme_adapter *jme)
 {
        jwrite32(jme, JME_PMCS, PMCS_STMASK | jme->reg_pmcs);
 }
 
+static inline void
+jme_clear_pm_disable_wol(struct jme_adapter *jme)
+{
+       jwrite32(jme, JME_PMCS, PMCS_STMASK);
+}
+
 static int
 jme_reload_eeprom(struct jme_adapter *jme)
 {
@@ -1853,7 +1859,7 @@ jme_open(struct net_device *netdev)
        struct jme_adapter *jme = netdev_priv(netdev);
        int rc;
 
-       jme_clear_pm(jme);
+       jme_clear_pm_disable_wol(jme);
        JME_NAPI_ENABLE(jme);
 
        tasklet_init(&jme->linkch_task, jme_link_change_tasklet,
@@ -1925,11 +1931,11 @@ jme_wait_link(struct jme_adapter *jme)
 static void
 jme_powersave_phy(struct jme_adapter *jme)
 {
-       if (jme->reg_pmcs) {
+       if (jme->reg_pmcs && device_may_wakeup(&jme->pdev->dev)) {
                jme_set_100m_half(jme);
                if (jme->reg_pmcs & (PMCS_LFEN | PMCS_LREN))
                        jme_wait_link(jme);
-               jme_clear_pm(jme);
+               jme_clear_pm_enable_wol(jme);
        } else {
                jme_phy_off(jme);
        }
@@ -2646,9 +2652,6 @@ jme_set_wol(struct net_device *netdev,
        if (wol->wolopts & WAKE_MAGIC)
                jme->reg_pmcs |= PMCS_MFEN;
 
-       jwrite32(jme, JME_PMCS, jme->reg_pmcs);
-       device_set_wakeup_enable(&jme->pdev->dev, !!(jme->reg_pmcs));
-
        return 0;
 }
 
@@ -3172,8 +3175,8 @@ jme_init_one(struct pci_dev *pdev,
        jme->mii_if.mdio_read = jme_mdio_read;
        jme->mii_if.mdio_write = jme_mdio_write;
 
-       jme_clear_pm(jme);
-       device_set_wakeup_enable(&pdev->dev, true);
+       jme_clear_pm_disable_wol(jme);
+       device_init_wakeup(&pdev->dev, true);
 
        jme_set_phyfifo_5level(jme);
        jme->pcirev = pdev->revision;
@@ -3304,7 +3307,7 @@ jme_resume(struct device *dev)
        if (!netif_running(netdev))
                return 0;
 
-       jme_clear_pm(jme);
+       jme_clear_pm_disable_wol(jme);
        jme_phy_on(jme);
        if (test_bit(JME_FLAG_SSET, &jme->flags))
                jme_set_settings(netdev, &jme->old_ecmd);
@@ -3312,13 +3315,14 @@ jme_resume(struct device *dev)
                jme_reset_phy_processor(jme);
        jme_phy_calibration(jme);
        jme_phy_setEA(jme);
-       jme_start_irq(jme);
        netif_device_attach(netdev);
 
        atomic_inc(&jme->link_changing);
 
        jme_reset_link(jme);
 
+       jme_start_irq(jme);
+
        return 0;
 }
 
index 662c2ee..b0ae69f 100644 (file)
@@ -370,6 +370,11 @@ struct mvneta_port {
        struct net_device *dev;
        struct notifier_block cpu_notifier;
        int rxq_def;
+       /* Protect the access to the percpu interrupt registers,
+        * ensuring that the configuration remains coherent.
+        */
+       spinlock_t lock;
+       bool is_stopped;
 
        /* Core clock */
        struct clk *clk;
@@ -1038,6 +1043,43 @@ static void mvneta_set_autoneg(struct mvneta_port *pp, int enable)
        }
 }
 
+static void mvneta_percpu_unmask_interrupt(void *arg)
+{
+       struct mvneta_port *pp = arg;
+
+       /* All the queue are unmasked, but actually only the ones
+        * mapped to this CPU will be unmasked
+        */
+       mvreg_write(pp, MVNETA_INTR_NEW_MASK,
+                   MVNETA_RX_INTR_MASK_ALL |
+                   MVNETA_TX_INTR_MASK_ALL |
+                   MVNETA_MISCINTR_INTR_MASK);
+}
+
+static void mvneta_percpu_mask_interrupt(void *arg)
+{
+       struct mvneta_port *pp = arg;
+
+       /* All the queue are masked, but actually only the ones
+        * mapped to this CPU will be masked
+        */
+       mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
+       mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
+       mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
+}
+
+static void mvneta_percpu_clear_intr_cause(void *arg)
+{
+       struct mvneta_port *pp = arg;
+
+       /* All the queue are cleared, but actually only the ones
+        * mapped to this CPU will be cleared
+        */
+       mvreg_write(pp, MVNETA_INTR_NEW_CAUSE, 0);
+       mvreg_write(pp, MVNETA_INTR_MISC_CAUSE, 0);
+       mvreg_write(pp, MVNETA_INTR_OLD_CAUSE, 0);
+}
+
 /* This method sets defaults to the NETA port:
  *     Clears interrupt Cause and Mask registers.
  *     Clears all MAC tables.
@@ -1055,14 +1097,10 @@ static void mvneta_defaults_set(struct mvneta_port *pp)
        int max_cpu = num_present_cpus();
 
        /* Clear all Cause registers */
-       mvreg_write(pp, MVNETA_INTR_NEW_CAUSE, 0);
-       mvreg_write(pp, MVNETA_INTR_OLD_CAUSE, 0);
-       mvreg_write(pp, MVNETA_INTR_MISC_CAUSE, 0);
+       on_each_cpu(mvneta_percpu_clear_intr_cause, pp, true);
 
        /* Mask all interrupts */
-       mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
-       mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
-       mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
+       on_each_cpu(mvneta_percpu_mask_interrupt, pp, true);
        mvreg_write(pp, MVNETA_INTR_ENABLE, 0);
 
        /* Enable MBUS Retry bit16 */
@@ -2528,34 +2566,9 @@ static int mvneta_setup_txqs(struct mvneta_port *pp)
        return 0;
 }
 
-static void mvneta_percpu_unmask_interrupt(void *arg)
-{
-       struct mvneta_port *pp = arg;
-
-       /* All the queue are unmasked, but actually only the ones
-        * maped to this CPU will be unmasked
-        */
-       mvreg_write(pp, MVNETA_INTR_NEW_MASK,
-                   MVNETA_RX_INTR_MASK_ALL |
-                   MVNETA_TX_INTR_MASK_ALL |
-                   MVNETA_MISCINTR_INTR_MASK);
-}
-
-static void mvneta_percpu_mask_interrupt(void *arg)
-{
-       struct mvneta_port *pp = arg;
-
-       /* All the queue are masked, but actually only the ones
-        * maped to this CPU will be masked
-        */
-       mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
-       mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
-       mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
-}
-
 static void mvneta_start_dev(struct mvneta_port *pp)
 {
-       unsigned int cpu;
+       int cpu;
 
        mvneta_max_rx_size_set(pp, pp->pkt_size);
        mvneta_txq_max_tx_size_set(pp, pp->pkt_size);
@@ -2564,16 +2577,15 @@ static void mvneta_start_dev(struct mvneta_port *pp)
        mvneta_port_enable(pp);
 
        /* Enable polling on the port */
-       for_each_present_cpu(cpu) {
+       for_each_online_cpu(cpu) {
                struct mvneta_pcpu_port *port = per_cpu_ptr(pp->ports, cpu);
 
                napi_enable(&port->napi);
        }
 
        /* Unmask interrupts. It has to be done from each CPU */
-       for_each_online_cpu(cpu)
-               smp_call_function_single(cpu, mvneta_percpu_unmask_interrupt,
-                                        pp, true);
+       on_each_cpu(mvneta_percpu_unmask_interrupt, pp, true);
+
        mvreg_write(pp, MVNETA_INTR_MISC_MASK,
                    MVNETA_CAUSE_PHY_STATUS_CHANGE |
                    MVNETA_CAUSE_LINK_CHANGE |
@@ -2589,7 +2601,7 @@ static void mvneta_stop_dev(struct mvneta_port *pp)
 
        phy_stop(pp->phy_dev);
 
-       for_each_present_cpu(cpu) {
+       for_each_online_cpu(cpu) {
                struct mvneta_pcpu_port *port = per_cpu_ptr(pp->ports, cpu);
 
                napi_disable(&port->napi);
@@ -2604,13 +2616,10 @@ static void mvneta_stop_dev(struct mvneta_port *pp)
        mvneta_port_disable(pp);
 
        /* Clear all ethernet port interrupts */
-       mvreg_write(pp, MVNETA_INTR_MISC_CAUSE, 0);
-       mvreg_write(pp, MVNETA_INTR_OLD_CAUSE, 0);
+       on_each_cpu(mvneta_percpu_clear_intr_cause, pp, true);
 
        /* Mask all ethernet port interrupts */
-       mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
-       mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
-       mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
+       on_each_cpu(mvneta_percpu_mask_interrupt, pp, true);
 
        mvneta_tx_reset(pp);
        mvneta_rx_reset(pp);
@@ -2847,11 +2856,20 @@ static void mvneta_percpu_disable(void *arg)
        disable_percpu_irq(pp->dev->irq);
 }
 
+/* Electing a CPU must be done in an atomic way: it should be done
+ * after or before the removal/insertion of a CPU and this function is
+ * not reentrant.
+ */
 static void mvneta_percpu_elect(struct mvneta_port *pp)
 {
-       int online_cpu_idx, max_cpu, cpu, i = 0;
+       int elected_cpu = 0, max_cpu, cpu, i = 0;
+
+       /* Use the cpu associated to the rxq when it is online, in all
+        * the other cases, use the cpu 0 which can't be offline.
+        */
+       if (cpu_online(pp->rxq_def))
+               elected_cpu = pp->rxq_def;
 
-       online_cpu_idx = pp->rxq_def % num_online_cpus();
        max_cpu = num_present_cpus();
 
        for_each_online_cpu(cpu) {
@@ -2862,7 +2880,7 @@ static void mvneta_percpu_elect(struct mvneta_port *pp)
                        if ((rxq % max_cpu) == cpu)
                                rxq_map |= MVNETA_CPU_RXQ_ACCESS(rxq);
 
-               if (i == online_cpu_idx)
+               if (cpu == elected_cpu)
                        /* Map the default receive queue queue to the
                         * elected CPU
                         */
@@ -2873,7 +2891,7 @@ static void mvneta_percpu_elect(struct mvneta_port *pp)
                 * the CPU bound to the default RX queue
                 */
                if (txq_number == 1)
-                       txq_map = (i == online_cpu_idx) ?
+                       txq_map = (cpu == elected_cpu) ?
                                MVNETA_CPU_TXQ_ACCESS(1) : 0;
                else
                        txq_map = mvreg_read(pp, MVNETA_CPU_MAP(cpu)) &
@@ -2902,6 +2920,14 @@ static int mvneta_percpu_notifier(struct notifier_block *nfb,
        switch (action) {
        case CPU_ONLINE:
        case CPU_ONLINE_FROZEN:
+               spin_lock(&pp->lock);
+               /* Configuring the driver for a new CPU while the
+                * driver is stopping is racy, so just avoid it.
+                */
+               if (pp->is_stopped) {
+                       spin_unlock(&pp->lock);
+                       break;
+               }
                netif_tx_stop_all_queues(pp->dev);
 
                /* We have to synchronise on tha napi of each CPU
@@ -2917,9 +2943,7 @@ static int mvneta_percpu_notifier(struct notifier_block *nfb,
                }
 
                /* Mask all ethernet port interrupts */
-               mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
-               mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
-               mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
+               on_each_cpu(mvneta_percpu_mask_interrupt, pp, true);
                napi_enable(&port->napi);
 
 
@@ -2934,27 +2958,25 @@ static int mvneta_percpu_notifier(struct notifier_block *nfb,
                 */
                mvneta_percpu_elect(pp);
 
-               /* Unmask all ethernet port interrupts, as this
-                * notifier is called for each CPU then the CPU to
-                * Queue mapping is applied
-                */
-               mvreg_write(pp, MVNETA_INTR_NEW_MASK,
-                       MVNETA_RX_INTR_MASK(rxq_number) |
-                       MVNETA_TX_INTR_MASK(txq_number) |
-                       MVNETA_MISCINTR_INTR_MASK);
+               /* Unmask all ethernet port interrupts */
+               on_each_cpu(mvneta_percpu_unmask_interrupt, pp, true);
                mvreg_write(pp, MVNETA_INTR_MISC_MASK,
                        MVNETA_CAUSE_PHY_STATUS_CHANGE |
                        MVNETA_CAUSE_LINK_CHANGE |
                        MVNETA_CAUSE_PSC_SYNC_CHANGE);
                netif_tx_start_all_queues(pp->dev);
+               spin_unlock(&pp->lock);
                break;
        case CPU_DOWN_PREPARE:
        case CPU_DOWN_PREPARE_FROZEN:
                netif_tx_stop_all_queues(pp->dev);
+               /* Thanks to this lock we are sure that any pending
+                * cpu election is done
+                */
+               spin_lock(&pp->lock);
                /* Mask all ethernet port interrupts */
-               mvreg_write(pp, MVNETA_INTR_NEW_MASK, 0);
-               mvreg_write(pp, MVNETA_INTR_OLD_MASK, 0);
-               mvreg_write(pp, MVNETA_INTR_MISC_MASK, 0);
+               on_each_cpu(mvneta_percpu_mask_interrupt, pp, true);
+               spin_unlock(&pp->lock);
 
                napi_synchronize(&port->napi);
                napi_disable(&port->napi);
@@ -2968,12 +2990,11 @@ static int mvneta_percpu_notifier(struct notifier_block *nfb,
        case CPU_DEAD:
        case CPU_DEAD_FROZEN:
                /* Check if a new CPU must be elected now this on is down */
+               spin_lock(&pp->lock);
                mvneta_percpu_elect(pp);
+               spin_unlock(&pp->lock);
                /* Unmask all ethernet port interrupts */
-               mvreg_write(pp, MVNETA_INTR_NEW_MASK,
-                       MVNETA_RX_INTR_MASK(rxq_number) |
-                       MVNETA_TX_INTR_MASK(txq_number) |
-                       MVNETA_MISCINTR_INTR_MASK);
+               on_each_cpu(mvneta_percpu_unmask_interrupt, pp, true);
                mvreg_write(pp, MVNETA_INTR_MISC_MASK,
                        MVNETA_CAUSE_PHY_STATUS_CHANGE |
                        MVNETA_CAUSE_LINK_CHANGE |
@@ -2988,7 +3009,7 @@ static int mvneta_percpu_notifier(struct notifier_block *nfb,
 static int mvneta_open(struct net_device *dev)
 {
        struct mvneta_port *pp = netdev_priv(dev);
-       int ret, cpu;
+       int ret;
 
        pp->pkt_size = MVNETA_RX_PKT_SIZE(pp->dev->mtu);
        pp->frag_size = SKB_DATA_ALIGN(MVNETA_RX_BUF_SIZE(pp->pkt_size)) +
@@ -3010,22 +3031,12 @@ static int mvneta_open(struct net_device *dev)
                goto err_cleanup_txqs;
        }
 
-       /* Even though the documentation says that request_percpu_irq
-        * doesn't enable the interrupts automatically, it actually
-        * does so on the local CPU.
-        *
-        * Make sure it's disabled.
-        */
-       mvneta_percpu_disable(pp);
-
        /* Enable per-CPU interrupt on all the CPU to handle our RX
         * queue interrupts
         */
-       for_each_online_cpu(cpu)
-               smp_call_function_single(cpu, mvneta_percpu_enable,
-                                        pp, true);
-
+       on_each_cpu(mvneta_percpu_enable, pp, true);
 
+       pp->is_stopped = false;
        /* Register a CPU notifier to handle the case where our CPU
         * might be taken offline.
         */
@@ -3057,13 +3068,20 @@ err_cleanup_rxqs:
 static int mvneta_stop(struct net_device *dev)
 {
        struct mvneta_port *pp = netdev_priv(dev);
-       int cpu;
 
+       /* Inform that we are stopping so we don't want to setup the
+        * driver for new CPUs in the notifiers
+        */
+       spin_lock(&pp->lock);
+       pp->is_stopped = true;
        mvneta_stop_dev(pp);
        mvneta_mdio_remove(pp);
        unregister_cpu_notifier(&pp->cpu_notifier);
-       for_each_present_cpu(cpu)
-               smp_call_function_single(cpu, mvneta_percpu_disable, pp, true);
+       /* Now that the notifier are unregistered, we can release le
+        * lock
+        */
+       spin_unlock(&pp->lock);
+       on_each_cpu(mvneta_percpu_disable, pp, true);
        free_percpu_irq(dev->irq, pp->ports);
        mvneta_cleanup_rxqs(pp);
        mvneta_cleanup_txqs(pp);
@@ -3312,9 +3330,7 @@ static int  mvneta_config_rss(struct mvneta_port *pp)
 
        netif_tx_stop_all_queues(pp->dev);
 
-       for_each_online_cpu(cpu)
-               smp_call_function_single(cpu, mvneta_percpu_mask_interrupt,
-                                        pp, true);
+       on_each_cpu(mvneta_percpu_mask_interrupt, pp, true);
 
        /* We have to synchronise on the napi of each CPU */
        for_each_online_cpu(cpu) {
@@ -3335,7 +3351,9 @@ static int  mvneta_config_rss(struct mvneta_port *pp)
        mvreg_write(pp, MVNETA_PORT_CONFIG, val);
 
        /* Update the elected CPU matching the new rxq_def */
+       spin_lock(&pp->lock);
        mvneta_percpu_elect(pp);
+       spin_unlock(&pp->lock);
 
        /* We have to synchronise on the napi of each CPU */
        for_each_online_cpu(cpu) {
index a4beccf..c797971 100644 (file)
@@ -3061,7 +3061,7 @@ static int mvpp2_prs_mac_da_accept(struct mvpp2 *priv, int port,
 
                pe = kzalloc(sizeof(*pe), GFP_KERNEL);
                if (!pe)
-                       return -1;
+                       return -ENOMEM;
                mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_MAC);
                pe->index = tid;
 
@@ -3077,7 +3077,7 @@ static int mvpp2_prs_mac_da_accept(struct mvpp2 *priv, int port,
        if (pmap == 0) {
                if (add) {
                        kfree(pe);
-                       return -1;
+                       return -EINVAL;
                }
                mvpp2_prs_hw_inv(priv, pe->index);
                priv->prs_shadow[pe->index].valid = false;
index 715de8a..c7e9399 100644 (file)
@@ -182,10 +182,17 @@ void mlx4_enter_error_state(struct mlx4_dev_persistent *persist)
                err = mlx4_reset_slave(dev);
        else
                err = mlx4_reset_master(dev);
-       BUG_ON(err != 0);
 
+       if (!err) {
+               mlx4_err(dev, "device was reset successfully\n");
+       } else {
+               /* EEH could have disabled the PCI channel during reset. That's
+                * recoverable and the PCI error flow will handle it.
+                */
+               if (!pci_channel_offline(dev->persist->pdev))
+                       BUG_ON(1);
+       }
        dev->persist->state |= MLX4_DEVICE_STATE_INTERNAL_ERROR;
-       mlx4_err(dev, "device was reset successfully\n");
        mutex_unlock(&persist->device_state_mutex);
 
        /* At that step HW was already reset, now notify clients */
index d48d579..e94ca1c 100644 (file)
@@ -2429,7 +2429,7 @@ err_thread:
        flush_workqueue(priv->mfunc.master.comm_wq);
        destroy_workqueue(priv->mfunc.master.comm_wq);
 err_slaves:
-       while (--i) {
+       while (i--) {
                for (port = 1; port <= MLX4_MAX_PORTS; port++)
                        kfree(priv->mfunc.master.slave_state[i].vlan_filter[port]);
        }
index 3348e64..a849da9 100644 (file)
@@ -318,7 +318,9 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent,
        if (timestamp_en)
                cq_context->flags  |= cpu_to_be32(1 << 19);
 
-       cq_context->logsize_usrpage = cpu_to_be32((ilog2(nent) << 24) | uar->index);
+       cq_context->logsize_usrpage =
+               cpu_to_be32((ilog2(nent) << 24) |
+                           mlx4_to_hw_uar_index(dev, uar->index));
        cq_context->comp_eqn        = priv->eq_table.eq[MLX4_CQ_TO_EQ_VECTOR(vector)].eqn;
        cq_context->log_page_size   = mtt->page_shift - MLX4_ICM_PAGE_SHIFT;
 
index 038f9ce..1494997 100644 (file)
@@ -236,6 +236,24 @@ static const struct ptp_clock_info mlx4_en_ptp_clock_info = {
        .enable         = mlx4_en_phc_enable,
 };
 
+#define MLX4_EN_WRAP_AROUND_SEC        10ULL
+
+/* This function calculates the max shift that enables the user range
+ * of MLX4_EN_WRAP_AROUND_SEC values in the cycles register.
+ */
+static u32 freq_to_shift(u16 freq)
+{
+       u32 freq_khz = freq * 1000;
+       u64 max_val_cycles = freq_khz * 1000 * MLX4_EN_WRAP_AROUND_SEC;
+       u64 max_val_cycles_rounded = is_power_of_2(max_val_cycles + 1) ?
+               max_val_cycles : roundup_pow_of_two(max_val_cycles) - 1;
+       /* calculate max possible multiplier in order to fit in 64bit */
+       u64 max_mul = div_u64(0xffffffffffffffffULL, max_val_cycles_rounded);
+
+       /* This comes from the reverse of clocksource_khz2mult */
+       return ilog2(div_u64(max_mul * freq_khz, 1000000));
+}
+
 void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev)
 {
        struct mlx4_dev *dev = mdev->dev;
@@ -254,12 +272,7 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev)
        memset(&mdev->cycles, 0, sizeof(mdev->cycles));
        mdev->cycles.read = mlx4_en_read_clock;
        mdev->cycles.mask = CLOCKSOURCE_MASK(48);
-       /* Using shift to make calculation more accurate. Since current HW
-        * clock frequency is 427 MHz, and cycles are given using a 48 bits
-        * register, the biggest shift when calculating using u64, is 14
-        * (max_cycles * multiplier < 2^64)
-        */
-       mdev->cycles.shift = 14;
+       mdev->cycles.shift = freq_to_shift(dev->caps.hca_core_clock);
        mdev->cycles.mult =
                clocksource_khz2mult(1000 * dev->caps.hca_core_clock, mdev->cycles.shift);
        mdev->nominal_c_mult = mdev->cycles.mult;
index 0c7e3f6..21e2c09 100644 (file)
@@ -2245,7 +2245,7 @@ static int mlx4_en_set_vf_mac(struct net_device *dev, int queue, u8 *mac)
        struct mlx4_en_dev *mdev = en_priv->mdev;
        u64 mac_u64 = mlx4_mac_to_u64(mac);
 
-       if (!is_valid_ether_addr(mac))
+       if (is_multicast_ether_addr(mac))
                return -EINVAL;
 
        return mlx4_set_vf_mac(mdev->dev, en_priv->port, queue, mac_u64);
@@ -2344,8 +2344,6 @@ out:
        /* set offloads */
        priv->dev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
                                      NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL;
-       priv->dev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
-       priv->dev->features    |= NETIF_F_GSO_UDP_TUNNEL;
 }
 
 static void mlx4_en_del_vxlan_offloads(struct work_struct *work)
@@ -2356,8 +2354,6 @@ static void mlx4_en_del_vxlan_offloads(struct work_struct *work)
        /* unset offloads */
        priv->dev->hw_enc_features &= ~(NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
                                      NETIF_F_TSO | NETIF_F_GSO_UDP_TUNNEL);
-       priv->dev->hw_features &= ~NETIF_F_GSO_UDP_TUNNEL;
-       priv->dev->features    &= ~NETIF_F_GSO_UDP_TUNNEL;
 
        ret = mlx4_SET_PORT_VXLAN(priv->mdev->dev, priv->port,
                                  VXLAN_STEER_BY_OUTER_MAC, 0);
@@ -2980,6 +2976,11 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
                priv->rss_hash_fn = ETH_RSS_HASH_TOP;
        }
 
+       if (mdev->dev->caps.tunnel_offload_mode == MLX4_TUNNEL_OFFLOAD_MODE_VXLAN) {
+               dev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
+               dev->features    |= NETIF_F_GSO_UDP_TUNNEL;
+       }
+
        mdev->pndev[port] = dev;
        mdev->upper[port] = NULL;
 
index ee99e67..3904b5f 100644 (file)
@@ -238,11 +238,11 @@ int mlx4_en_DUMP_ETH_STATS(struct mlx4_en_dev *mdev, u8 port, u8 reset)
        stats->collisions = 0;
        stats->rx_dropped = be32_to_cpu(mlx4_en_stats->RDROP);
        stats->rx_length_errors = be32_to_cpu(mlx4_en_stats->RdropLength);
-       stats->rx_over_errors = be32_to_cpu(mlx4_en_stats->RdropOvflw);
+       stats->rx_over_errors = 0;
        stats->rx_crc_errors = be32_to_cpu(mlx4_en_stats->RCRC);
        stats->rx_frame_errors = 0;
        stats->rx_fifo_errors = be32_to_cpu(mlx4_en_stats->RdropOvflw);
-       stats->rx_missed_errors = be32_to_cpu(mlx4_en_stats->RdropOvflw);
+       stats->rx_missed_errors = 0;
        stats->tx_aborted_errors = 0;
        stats->tx_carrier_errors = 0;
        stats->tx_fifo_errors = 0;
index 12aab5a..02e925d 100644 (file)
@@ -58,7 +58,8 @@ void mlx4_en_fill_qp_context(struct mlx4_en_priv *priv, int size, int stride,
        } else {
                context->sq_size_stride = ilog2(TXBB_SIZE) - 4;
        }
-       context->usr_page = cpu_to_be32(mdev->priv_uar.index);
+       context->usr_page = cpu_to_be32(mlx4_to_hw_uar_index(mdev->dev,
+                                       mdev->priv_uar.index));
        context->local_qpn = cpu_to_be32(qpn);
        context->pri_path.ackto = 1 & 0x07;
        context->pri_path.sched_queue = 0x83 | (priv->port - 1) << 6;
index 4421bf5..e0946ab 100644 (file)
@@ -213,7 +213,9 @@ int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv,
        mlx4_en_fill_qp_context(priv, ring->size, ring->stride, 1, 0, ring->qpn,
                                ring->cqn, user_prio, &ring->context);
        if (ring->bf_alloced)
-               ring->context.usr_page = cpu_to_be32(ring->bf.uar->index);
+               ring->context.usr_page =
+                       cpu_to_be32(mlx4_to_hw_uar_index(mdev->dev,
+                                                        ring->bf.uar->index));
 
        err = mlx4_qp_to_ready(mdev->dev, &ring->wqres.mtt, &ring->context,
                               &ring->qp, &ring->qp_state);
index 4696053..f613977 100644 (file)
@@ -940,9 +940,10 @@ static void __iomem *mlx4_get_eq_uar(struct mlx4_dev *dev, struct mlx4_eq *eq)
 
        if (!priv->eq_table.uar_map[index]) {
                priv->eq_table.uar_map[index] =
-                       ioremap(pci_resource_start(dev->persist->pdev, 2) +
-                               ((eq->eqn / 4) << PAGE_SHIFT),
-                               PAGE_SIZE);
+                       ioremap(
+                               pci_resource_start(dev->persist->pdev, 2) +
+                               ((eq->eqn / 4) << (dev->uar_page_shift)),
+                               (1 << (dev->uar_page_shift)));
                if (!priv->eq_table.uar_map[index]) {
                        mlx4_err(dev, "Couldn't map EQ doorbell for EQN 0x%06x\n",
                                 eq->eqn);
index f1b6d21..f8674ae 100644 (file)
@@ -168,6 +168,20 @@ struct mlx4_port_config {
 
 static atomic_t pf_loading = ATOMIC_INIT(0);
 
+static inline void mlx4_set_num_reserved_uars(struct mlx4_dev *dev,
+                                             struct mlx4_dev_cap *dev_cap)
+{
+       /* The reserved_uars is calculated by system page size unit.
+        * Therefore, adjustment is added when the uar page size is less
+        * than the system page size
+        */
+       dev->caps.reserved_uars =
+               max_t(int,
+                     mlx4_get_num_reserved_uar(dev),
+                     dev_cap->reserved_uars /
+                       (1 << (PAGE_SHIFT - dev->uar_page_shift)));
+}
+
 int mlx4_check_port_params(struct mlx4_dev *dev,
                           enum mlx4_port_type *port_type)
 {
@@ -386,8 +400,6 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
        dev->caps.reserved_mtts      = dev_cap->reserved_mtts;
        dev->caps.reserved_mrws      = dev_cap->reserved_mrws;
 
-       /* The first 128 UARs are used for EQ doorbells */
-       dev->caps.reserved_uars      = max_t(int, 128, dev_cap->reserved_uars);
        dev->caps.reserved_pds       = dev_cap->reserved_pds;
        dev->caps.reserved_xrcds     = (dev->caps.flags & MLX4_DEV_CAP_FLAG_XRC) ?
                                        dev_cap->reserved_xrcds : 0;
@@ -405,6 +417,15 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
        dev->caps.max_gso_sz         = dev_cap->max_gso_sz;
        dev->caps.max_rss_tbl_sz     = dev_cap->max_rss_tbl_sz;
 
+       /* Save uar page shift */
+       if (!mlx4_is_slave(dev)) {
+               /* Virtual PCI function needs to determine UAR page size from
+                * firmware. Only master PCI function can set the uar page size
+                */
+               dev->uar_page_shift = DEFAULT_UAR_PAGE_SHIFT;
+               mlx4_set_num_reserved_uars(dev, dev_cap);
+       }
+
        if (dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_PHV_EN) {
                struct mlx4_init_hca_param hca_param;
 
@@ -815,16 +836,25 @@ static int mlx4_slave_cap(struct mlx4_dev *dev)
                return -ENODEV;
        }
 
-       /* slave gets uar page size from QUERY_HCA fw command */
-       dev->caps.uar_page_size = 1 << (hca_param.uar_page_sz + 12);
+       /* Set uar_page_shift for VF */
+       dev->uar_page_shift = hca_param.uar_page_sz + 12;
 
-       /* TODO: relax this assumption */
-       if (dev->caps.uar_page_size != PAGE_SIZE) {
-               mlx4_err(dev, "UAR size:%d != kernel PAGE_SIZE of %ld\n",
-                        dev->caps.uar_page_size, PAGE_SIZE);
-               return -ENODEV;
+       /* Make sure the master uar page size is valid */
+       if (dev->uar_page_shift > PAGE_SHIFT) {
+               mlx4_err(dev,
+                        "Invalid configuration: uar page size is larger than system page size\n");
+               return  -ENODEV;
        }
 
+       /* Set reserved_uars based on the uar_page_shift */
+       mlx4_set_num_reserved_uars(dev, &dev_cap);
+
+       /* Although uar page size in FW differs from system page size,
+        * upper software layers (mlx4_ib, mlx4_en and part of mlx4_core)
+        * still works with assumption that uar page size == system page size
+        */
+       dev->caps.uar_page_size = PAGE_SIZE;
+
        memset(&func_cap, 0, sizeof(func_cap));
        err = mlx4_QUERY_FUNC_CAP(dev, 0, &func_cap);
        if (err) {
@@ -1226,6 +1256,7 @@ err_set_port:
 static int mlx4_mf_bond(struct mlx4_dev *dev)
 {
        int err = 0;
+       int nvfs;
        struct mlx4_slaves_pport slaves_port1;
        struct mlx4_slaves_pport slaves_port2;
        DECLARE_BITMAP(slaves_port_1_2, MLX4_MFUNC_MAX);
@@ -1242,11 +1273,18 @@ static int mlx4_mf_bond(struct mlx4_dev *dev)
                return -EINVAL;
        }
 
+       /* number of virtual functions is number of total functions minus one
+        * physical function for each port.
+        */
+       nvfs = bitmap_weight(slaves_port1.slaves, dev->persist->num_vfs + 1) +
+               bitmap_weight(slaves_port2.slaves, dev->persist->num_vfs + 1) - 2;
+
        /* limit on maximum allowed VFs */
-       if ((bitmap_weight(slaves_port1.slaves, dev->persist->num_vfs + 1) +
-           bitmap_weight(slaves_port2.slaves, dev->persist->num_vfs + 1)) >
-           MAX_MF_BOND_ALLOWED_SLAVES)
+       if (nvfs > MAX_MF_BOND_ALLOWED_SLAVES) {
+               mlx4_warn(dev, "HA mode is not supported for %d VFs (max %d are allowed)\n",
+                         nvfs, MAX_MF_BOND_ALLOWED_SLAVES);
                return -EINVAL;
+       }
 
        if (dev->caps.steering_mode != MLX4_STEERING_MODE_DEVICE_MANAGED) {
                mlx4_warn(dev, "HA mode unsupported for NON DMFS steering\n");
@@ -2179,8 +2217,12 @@ static int mlx4_init_hca(struct mlx4_dev *dev)
 
                dev->caps.max_fmr_maps = (1 << (32 - ilog2(dev->caps.num_mpts))) - 1;
 
-               init_hca.log_uar_sz = ilog2(dev->caps.num_uars);
-               init_hca.uar_page_sz = PAGE_SHIFT - 12;
+               /* Always set UAR page size 4KB, set log_uar_sz accordingly */
+               init_hca.log_uar_sz = ilog2(dev->caps.num_uars) +
+                                     PAGE_SHIFT -
+                                     DEFAULT_UAR_PAGE_SHIFT;
+               init_hca.uar_page_sz = DEFAULT_UAR_PAGE_SHIFT - 12;
+
                init_hca.mw_enabled = 0;
                if (dev->caps.flags & MLX4_DEV_CAP_FLAG_MEM_WINDOW ||
                    dev->caps.bmme_flags & MLX4_BMME_FLAG_TYPE_2_WIN)
index 609c59d..b3cc3ab 100644 (file)
@@ -269,9 +269,15 @@ EXPORT_SYMBOL_GPL(mlx4_bf_free);
 
 int mlx4_init_uar_table(struct mlx4_dev *dev)
 {
-       if (dev->caps.num_uars <= 128) {
-               mlx4_err(dev, "Only %d UAR pages (need more than 128)\n",
-                        dev->caps.num_uars);
+       int num_reserved_uar = mlx4_get_num_reserved_uar(dev);
+
+       mlx4_dbg(dev, "uar_page_shift = %d", dev->uar_page_shift);
+       mlx4_dbg(dev, "Effective reserved_uars=%d", dev->caps.reserved_uars);
+
+       if (dev->caps.num_uars <= num_reserved_uar) {
+               mlx4_err(
+                       dev, "Only %d UAR pages (need more than %d)\n",
+                       dev->caps.num_uars, num_reserved_uar);
                mlx4_err(dev, "Increase firmware log2_uar_bar_megabytes?\n");
                return -ENODEV;
        }
index 787b7bb..211c650 100644 (file)
@@ -193,10 +193,10 @@ int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac)
        if (need_mf_bond) {
                if (port == 1) {
                        mutex_lock(&table->mutex);
-                       mutex_lock(&dup_table->mutex);
+                       mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING);
                } else {
                        mutex_lock(&dup_table->mutex);
-                       mutex_lock(&table->mutex);
+                       mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
                }
        } else {
                mutex_lock(&table->mutex);
@@ -389,10 +389,10 @@ void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac)
        if (dup) {
                if (port == 1) {
                        mutex_lock(&table->mutex);
-                       mutex_lock(&dup_table->mutex);
+                       mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING);
                } else {
                        mutex_lock(&dup_table->mutex);
-                       mutex_lock(&table->mutex);
+                       mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
                }
        } else {
                mutex_lock(&table->mutex);
@@ -479,10 +479,10 @@ int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac)
        if (dup) {
                if (port == 1) {
                        mutex_lock(&table->mutex);
-                       mutex_lock(&dup_table->mutex);
+                       mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING);
                } else {
                        mutex_lock(&dup_table->mutex);
-                       mutex_lock(&table->mutex);
+                       mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
                }
        } else {
                mutex_lock(&table->mutex);
@@ -588,10 +588,10 @@ int __mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan,
        if (need_mf_bond) {
                if (port == 1) {
                        mutex_lock(&table->mutex);
-                       mutex_lock(&dup_table->mutex);
+                       mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING);
                } else {
                        mutex_lock(&dup_table->mutex);
-                       mutex_lock(&table->mutex);
+                       mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
                }
        } else {
                mutex_lock(&table->mutex);
@@ -764,10 +764,10 @@ void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan)
        if (dup) {
                if (port == 1) {
                        mutex_lock(&table->mutex);
-                       mutex_lock(&dup_table->mutex);
+                       mutex_lock_nested(&dup_table->mutex, SINGLE_DEPTH_NESTING);
                } else {
                        mutex_lock(&dup_table->mutex);
-                       mutex_lock(&table->mutex);
+                       mutex_lock_nested(&table->mutex, SINGLE_DEPTH_NESTING);
                }
        } else {
                mutex_lock(&table->mutex);
index b46dbe2..25ce1b0 100644 (file)
@@ -915,11 +915,13 @@ static int handle_existing_counter(struct mlx4_dev *dev, u8 slave, int port,
 
        spin_lock_irq(mlx4_tlock(dev));
        r = find_res(dev, counter_index, RES_COUNTER);
-       if (!r || r->owner != slave)
+       if (!r || r->owner != slave) {
                ret = -EINVAL;
-       counter = container_of(r, struct res_counter, com);
-       if (!counter->port)
-               counter->port = port;
+       } else {
+               counter = container_of(r, struct res_counter, com);
+               if (!counter->port)
+                       counter->port = port;
+       }
 
        spin_unlock_irq(mlx4_tlock(dev));
        return ret;
index aac071a..5b17532 100644 (file)
@@ -223,6 +223,7 @@ struct mlx5e_pport_stats {
 
 static const char rq_stats_strings[][ETH_GSTRING_LEN] = {
        "packets",
+       "bytes",
        "csum_none",
        "csum_sw",
        "lro_packets",
@@ -232,16 +233,18 @@ static const char rq_stats_strings[][ETH_GSTRING_LEN] = {
 
 struct mlx5e_rq_stats {
        u64 packets;
+       u64 bytes;
        u64 csum_none;
        u64 csum_sw;
        u64 lro_packets;
        u64 lro_bytes;
        u64 wqe_err;
-#define NUM_RQ_STATS 6
+#define NUM_RQ_STATS 7
 };
 
 static const char sq_stats_strings[][ETH_GSTRING_LEN] = {
        "packets",
+       "bytes",
        "tso_packets",
        "tso_bytes",
        "csum_offload_none",
@@ -253,6 +256,7 @@ static const char sq_stats_strings[][ETH_GSTRING_LEN] = {
 
 struct mlx5e_sq_stats {
        u64 packets;
+       u64 bytes;
        u64 tso_packets;
        u64 tso_bytes;
        u64 csum_offload_none;
@@ -260,7 +264,7 @@ struct mlx5e_sq_stats {
        u64 wake;
        u64 dropped;
        u64 nop;
-#define NUM_SQ_STATS 8
+#define NUM_SQ_STATS 9
 };
 
 struct mlx5e_stats {
@@ -304,14 +308,9 @@ enum {
        MLX5E_RQ_STATE_POST_WQES_ENABLE,
 };
 
-enum cq_flags {
-       MLX5E_CQ_HAS_CQES = 1,
-};
-
 struct mlx5e_cq {
        /* data path - accessed per cqe */
        struct mlx5_cqwq           wq;
-       unsigned long              flags;
 
        /* data path - accessed per napi poll */
        struct napi_struct        *napi;
@@ -452,6 +451,8 @@ enum mlx5e_traffic_types {
        MLX5E_NUM_TT,
 };
 
+#define IS_HASHING_TT(tt) (tt != MLX5E_TT_ANY)
+
 enum mlx5e_rqt_ix {
        MLX5E_INDIRECTION_RQT,
        MLX5E_SINGLE_RQ_RQT,
@@ -618,9 +619,12 @@ void mlx5e_enable_vlan_filter(struct mlx5e_priv *priv);
 void mlx5e_disable_vlan_filter(struct mlx5e_priv *priv);
 
 int mlx5e_redirect_rqt(struct mlx5e_priv *priv, enum mlx5e_rqt_ix rqt_ix);
+void mlx5e_build_tir_ctx_hash(void *tirc, struct mlx5e_priv *priv);
 
 int mlx5e_open_locked(struct net_device *netdev);
 int mlx5e_close_locked(struct net_device *netdev);
+void mlx5e_build_default_indir_rqt(u32 *indirection_rqt, int len,
+                                  int num_channels);
 
 static inline void mlx5e_tx_notify_hw(struct mlx5e_sq *sq,
                                      struct mlx5e_tx_wqe *wqe, int bf_sz)
index be65435..2018eeb 100644 (file)
@@ -62,10 +62,11 @@ static void mlx5e_timestamp_overflow(struct work_struct *work)
        struct delayed_work *dwork = to_delayed_work(work);
        struct mlx5e_tstamp *tstamp = container_of(dwork, struct mlx5e_tstamp,
                                                   overflow_work);
+       unsigned long flags;
 
-       write_lock(&tstamp->lock);
+       write_lock_irqsave(&tstamp->lock, flags);
        timecounter_read(&tstamp->clock);
-       write_unlock(&tstamp->lock);
+       write_unlock_irqrestore(&tstamp->lock, flags);
        schedule_delayed_work(&tstamp->overflow_work, tstamp->overflow_period);
 }
 
@@ -136,10 +137,11 @@ static int mlx5e_ptp_settime(struct ptp_clock_info *ptp,
        struct mlx5e_tstamp *tstamp = container_of(ptp, struct mlx5e_tstamp,
                                                   ptp_info);
        u64 ns = timespec64_to_ns(ts);
+       unsigned long flags;
 
-       write_lock(&tstamp->lock);
+       write_lock_irqsave(&tstamp->lock, flags);
        timecounter_init(&tstamp->clock, &tstamp->cycles, ns);
-       write_unlock(&tstamp->lock);
+       write_unlock_irqrestore(&tstamp->lock, flags);
 
        return 0;
 }
@@ -150,10 +152,11 @@ static int mlx5e_ptp_gettime(struct ptp_clock_info *ptp,
        struct mlx5e_tstamp *tstamp = container_of(ptp, struct mlx5e_tstamp,
                                                   ptp_info);
        u64 ns;
+       unsigned long flags;
 
-       write_lock(&tstamp->lock);
+       write_lock_irqsave(&tstamp->lock, flags);
        ns = timecounter_read(&tstamp->clock);
-       write_unlock(&tstamp->lock);
+       write_unlock_irqrestore(&tstamp->lock, flags);
 
        *ts = ns_to_timespec64(ns);
 
@@ -164,10 +167,11 @@ static int mlx5e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 {
        struct mlx5e_tstamp *tstamp = container_of(ptp, struct mlx5e_tstamp,
                                                   ptp_info);
+       unsigned long flags;
 
-       write_lock(&tstamp->lock);
+       write_lock_irqsave(&tstamp->lock, flags);
        timecounter_adjtime(&tstamp->clock, delta);
-       write_unlock(&tstamp->lock);
+       write_unlock_irqrestore(&tstamp->lock, flags);
 
        return 0;
 }
@@ -176,6 +180,7 @@ static int mlx5e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 delta)
 {
        u64 adj;
        u32 diff;
+       unsigned long flags;
        int neg_adj = 0;
        struct mlx5e_tstamp *tstamp = container_of(ptp, struct mlx5e_tstamp,
                                                  ptp_info);
@@ -189,11 +194,11 @@ static int mlx5e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 delta)
        adj *= delta;
        diff = div_u64(adj, 1000000000ULL);
 
-       write_lock(&tstamp->lock);
+       write_lock_irqsave(&tstamp->lock, flags);
        timecounter_read(&tstamp->clock);
        tstamp->cycles.mult = neg_adj ? tstamp->nominal_c_mult - diff :
                                        tstamp->nominal_c_mult + diff;
-       write_unlock(&tstamp->lock);
+       write_unlock_irqrestore(&tstamp->lock, flags);
 
        return 0;
 }
index 65624ac..5abeb00 100644 (file)
@@ -385,6 +385,8 @@ static int mlx5e_set_channels(struct net_device *dev,
                mlx5e_close_locked(dev);
 
        priv->params.num_channels = count;
+       mlx5e_build_default_indir_rqt(priv->params.indirection_rqt,
+                                     MLX5E_INDIR_RQT_SIZE, count);
 
        if (was_opened)
                err = mlx5e_open_locked(dev);
@@ -703,18 +705,36 @@ static int mlx5e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
        return 0;
 }
 
+static void mlx5e_modify_tirs_hash(struct mlx5e_priv *priv, void *in, int inlen)
+{
+       struct mlx5_core_dev *mdev = priv->mdev;
+       void *tirc = MLX5_ADDR_OF(modify_tir_in, in, ctx);
+       int i;
+
+       MLX5_SET(modify_tir_in, in, bitmask.hash, 1);
+       mlx5e_build_tir_ctx_hash(tirc, priv);
+
+       for (i = 0; i < MLX5E_NUM_TT; i++)
+               if (IS_HASHING_TT(i))
+                       mlx5_core_modify_tir(mdev, priv->tirn[i], in, inlen);
+}
+
 static int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,
                          const u8 *key, const u8 hfunc)
 {
        struct mlx5e_priv *priv = netdev_priv(dev);
-       bool close_open;
-       int err = 0;
+       int inlen = MLX5_ST_SZ_BYTES(modify_tir_in);
+       void *in;
 
        if ((hfunc != ETH_RSS_HASH_NO_CHANGE) &&
            (hfunc != ETH_RSS_HASH_XOR) &&
            (hfunc != ETH_RSS_HASH_TOP))
                return -EINVAL;
 
+       in = mlx5_vzalloc(inlen);
+       if (!in)
+               return -ENOMEM;
+
        mutex_lock(&priv->state_lock);
 
        if (indir) {
@@ -723,11 +743,6 @@ static int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,
                mlx5e_redirect_rqt(priv, MLX5E_INDIRECTION_RQT);
        }
 
-       close_open = (key || (hfunc != ETH_RSS_HASH_NO_CHANGE)) &&
-                    test_bit(MLX5E_STATE_OPENED, &priv->state);
-       if (close_open)
-               mlx5e_close_locked(dev);
-
        if (key)
                memcpy(priv->params.toeplitz_hash_key, key,
                       sizeof(priv->params.toeplitz_hash_key));
@@ -735,12 +750,13 @@ static int mlx5e_set_rxfh(struct net_device *dev, const u32 *indir,
        if (hfunc != ETH_RSS_HASH_NO_CHANGE)
                priv->params.rss_hfunc = hfunc;
 
-       if (close_open)
-               err = mlx5e_open_locked(priv->netdev);
+       mlx5e_modify_tirs_hash(priv, in, inlen);
 
        mutex_unlock(&priv->state_lock);
 
-       return err;
+       kvfree(in);
+
+       return 0;
 }
 
 static int mlx5e_get_rxnfc(struct net_device *netdev,
index 6a3e430..402994b 100644 (file)
@@ -141,6 +141,10 @@ void mlx5e_update_stats(struct mlx5e_priv *priv)
                return;
 
        /* Collect firts the SW counters and then HW for consistency */
+       s->rx_packets           = 0;
+       s->rx_bytes             = 0;
+       s->tx_packets           = 0;
+       s->tx_bytes             = 0;
        s->tso_packets          = 0;
        s->tso_bytes            = 0;
        s->tx_queue_stopped     = 0;
@@ -155,6 +159,8 @@ void mlx5e_update_stats(struct mlx5e_priv *priv)
        for (i = 0; i < priv->params.num_channels; i++) {
                rq_stats = &priv->channel[i]->rq.stats;
 
+               s->rx_packets   += rq_stats->packets;
+               s->rx_bytes     += rq_stats->bytes;
                s->lro_packets  += rq_stats->lro_packets;
                s->lro_bytes    += rq_stats->lro_bytes;
                s->rx_csum_none += rq_stats->csum_none;
@@ -164,6 +170,8 @@ void mlx5e_update_stats(struct mlx5e_priv *priv)
                for (j = 0; j < priv->params.num_tc; j++) {
                        sq_stats = &priv->channel[i]->sq[j].stats;
 
+                       s->tx_packets           += sq_stats->packets;
+                       s->tx_bytes             += sq_stats->bytes;
                        s->tso_packets          += sq_stats->tso_packets;
                        s->tso_bytes            += sq_stats->tso_bytes;
                        s->tx_queue_stopped     += sq_stats->stopped;
@@ -225,23 +233,6 @@ void mlx5e_update_stats(struct mlx5e_priv *priv)
        s->tx_broadcast_bytes   =
                MLX5_GET_CTR(out, transmitted_eth_broadcast.octets);
 
-       s->rx_packets =
-               s->rx_unicast_packets +
-               s->rx_multicast_packets +
-               s->rx_broadcast_packets;
-       s->rx_bytes =
-               s->rx_unicast_bytes +
-               s->rx_multicast_bytes +
-               s->rx_broadcast_bytes;
-       s->tx_packets =
-               s->tx_unicast_packets +
-               s->tx_multicast_packets +
-               s->tx_broadcast_packets;
-       s->tx_bytes =
-               s->tx_unicast_bytes +
-               s->tx_multicast_bytes +
-               s->tx_broadcast_bytes;
-
        /* Update calculated offload counters */
        s->tx_csum_offload = s->tx_packets - tx_offload_none;
        s->rx_csum_good    = s->rx_packets - s->rx_csum_none -
@@ -1199,7 +1190,6 @@ static void mlx5e_fill_indir_rqt_rqns(struct mlx5e_priv *priv, void *rqtc)
                        ix = mlx5e_bits_invert(i, MLX5E_LOG_INDIR_RQT_SIZE);
 
                ix = priv->params.indirection_rqt[ix];
-               ix = ix % priv->params.num_channels;
                MLX5_SET(rqtc, rqtc, rq_num[i],
                         test_bit(MLX5E_STATE_OPENED, &priv->state) ?
                         priv->channel[ix]->rq.rqn :
@@ -1317,7 +1307,22 @@ static void mlx5e_build_tir_ctx_lro(void *tirc, struct mlx5e_priv *priv)
                              lro_timer_supported_periods[2]));
 }
 
-static int mlx5e_modify_tir_lro(struct mlx5e_priv *priv, int tt)
+void mlx5e_build_tir_ctx_hash(void *tirc, struct mlx5e_priv *priv)
+{
+       MLX5_SET(tirc, tirc, rx_hash_fn,
+                mlx5e_rx_hash_fn(priv->params.rss_hfunc));
+       if (priv->params.rss_hfunc == ETH_RSS_HASH_TOP) {
+               void *rss_key = MLX5_ADDR_OF(tirc, tirc,
+                                            rx_hash_toeplitz_key);
+               size_t len = MLX5_FLD_SZ_BYTES(tirc,
+                                              rx_hash_toeplitz_key);
+
+               MLX5_SET(tirc, tirc, rx_hash_symmetric, 1);
+               memcpy(rss_key, priv->params.toeplitz_hash_key, len);
+       }
+}
+
+static int mlx5e_modify_tirs_lro(struct mlx5e_priv *priv)
 {
        struct mlx5_core_dev *mdev = priv->mdev;
 
@@ -1325,6 +1330,7 @@ static int mlx5e_modify_tir_lro(struct mlx5e_priv *priv, int tt)
        void *tirc;
        int inlen;
        int err;
+       int tt;
 
        inlen = MLX5_ST_SZ_BYTES(modify_tir_in);
        in = mlx5_vzalloc(inlen);
@@ -1336,7 +1342,11 @@ static int mlx5e_modify_tir_lro(struct mlx5e_priv *priv, int tt)
 
        mlx5e_build_tir_ctx_lro(tirc, priv);
 
-       err = mlx5_core_modify_tir(mdev, priv->tirn[tt], in, inlen);
+       for (tt = 0; tt < MLX5E_NUM_TT; tt++) {
+               err = mlx5_core_modify_tir(mdev, priv->tirn[tt], in, inlen);
+               if (err)
+                       break;
+       }
 
        kvfree(in);
 
@@ -1672,17 +1682,7 @@ static void mlx5e_build_tir_ctx(struct mlx5e_priv *priv, u32 *tirc, int tt)
        default:
                MLX5_SET(tirc, tirc, indirect_table,
                         priv->rqtn[MLX5E_INDIRECTION_RQT]);
-               MLX5_SET(tirc, tirc, rx_hash_fn,
-                        mlx5e_rx_hash_fn(priv->params.rss_hfunc));
-               if (priv->params.rss_hfunc == ETH_RSS_HASH_TOP) {
-                       void *rss_key = MLX5_ADDR_OF(tirc, tirc,
-                                                    rx_hash_toeplitz_key);
-                       size_t len = MLX5_FLD_SZ_BYTES(tirc,
-                                                      rx_hash_toeplitz_key);
-
-                       MLX5_SET(tirc, tirc, rx_hash_symmetric, 1);
-                       memcpy(rss_key, priv->params.toeplitz_hash_key, len);
-               }
+               mlx5e_build_tir_ctx_hash(tirc, priv);
                break;
        }
 
@@ -1885,8 +1885,10 @@ static int mlx5e_set_features(struct net_device *netdev,
                        mlx5e_close_locked(priv->netdev);
 
                priv->params.lro_en = !!(features & NETIF_F_LRO);
-               mlx5e_modify_tir_lro(priv, MLX5E_TT_IPV4_TCP);
-               mlx5e_modify_tir_lro(priv, MLX5E_TT_IPV6_TCP);
+               err = mlx5e_modify_tirs_lro(priv);
+               if (err)
+                       mlx5_core_warn(priv->mdev, "lro modify failed, %d\n",
+                                      err);
 
                if (was_opened)
                        err = mlx5e_open_locked(priv->netdev);
@@ -2024,18 +2026,37 @@ static int mlx5e_get_vf_stats(struct net_device *dev,
                                            vf_stats);
 }
 
-static struct net_device_ops mlx5e_netdev_ops = {
+static const struct net_device_ops mlx5e_netdev_ops_basic = {
+       .ndo_open                = mlx5e_open,
+       .ndo_stop                = mlx5e_close,
+       .ndo_start_xmit          = mlx5e_xmit,
+       .ndo_get_stats64         = mlx5e_get_stats,
+       .ndo_set_rx_mode         = mlx5e_set_rx_mode,
+       .ndo_set_mac_address     = mlx5e_set_mac,
+       .ndo_vlan_rx_add_vid     = mlx5e_vlan_rx_add_vid,
+       .ndo_vlan_rx_kill_vid    = mlx5e_vlan_rx_kill_vid,
+       .ndo_set_features        = mlx5e_set_features,
+       .ndo_change_mtu          = mlx5e_change_mtu,
+       .ndo_do_ioctl            = mlx5e_ioctl,
+};
+
+static const struct net_device_ops mlx5e_netdev_ops_sriov = {
        .ndo_open                = mlx5e_open,
        .ndo_stop                = mlx5e_close,
        .ndo_start_xmit          = mlx5e_xmit,
        .ndo_get_stats64         = mlx5e_get_stats,
        .ndo_set_rx_mode         = mlx5e_set_rx_mode,
        .ndo_set_mac_address     = mlx5e_set_mac,
-       .ndo_vlan_rx_add_vid     = mlx5e_vlan_rx_add_vid,
-       .ndo_vlan_rx_kill_vid    = mlx5e_vlan_rx_kill_vid,
+       .ndo_vlan_rx_add_vid     = mlx5e_vlan_rx_add_vid,
+       .ndo_vlan_rx_kill_vid    = mlx5e_vlan_rx_kill_vid,
        .ndo_set_features        = mlx5e_set_features,
-       .ndo_change_mtu          = mlx5e_change_mtu,
-       .ndo_do_ioctl            = mlx5e_ioctl,
+       .ndo_change_mtu          = mlx5e_change_mtu,
+       .ndo_do_ioctl            = mlx5e_ioctl,
+       .ndo_set_vf_mac          = mlx5e_set_vf_mac,
+       .ndo_set_vf_vlan         = mlx5e_set_vf_vlan,
+       .ndo_get_vf_config       = mlx5e_get_vf_config,
+       .ndo_set_vf_link_state   = mlx5e_set_vf_link_state,
+       .ndo_get_vf_stats        = mlx5e_get_vf_stats,
 };
 
 static int mlx5e_check_required_hca_cap(struct mlx5_core_dev *mdev)
@@ -2070,12 +2091,20 @@ u16 mlx5e_get_max_inline_cap(struct mlx5_core_dev *mdev)
               2 /*sizeof(mlx5e_tx_wqe.inline_hdr_start)*/;
 }
 
+void mlx5e_build_default_indir_rqt(u32 *indirection_rqt, int len,
+                                  int num_channels)
+{
+       int i;
+
+       for (i = 0; i < len; i++)
+               indirection_rqt[i] = i % num_channels;
+}
+
 static void mlx5e_build_netdev_priv(struct mlx5_core_dev *mdev,
                                    struct net_device *netdev,
                                    int num_channels)
 {
        struct mlx5e_priv *priv = netdev_priv(netdev);
-       int i;
 
        priv->params.log_sq_size           =
                MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;
@@ -2099,8 +2128,8 @@ static void mlx5e_build_netdev_priv(struct mlx5_core_dev *mdev,
        netdev_rss_key_fill(priv->params.toeplitz_hash_key,
                            sizeof(priv->params.toeplitz_hash_key));
 
-       for (i = 0; i < MLX5E_INDIR_RQT_SIZE; i++)
-               priv->params.indirection_rqt[i] = i % num_channels;
+       mlx5e_build_default_indir_rqt(priv->params.indirection_rqt,
+                                     MLX5E_INDIR_RQT_SIZE, num_channels);
 
        priv->params.lro_wqe_sz            =
                MLX5E_PARAMS_DEFAULT_LRO_WQE_SZ;
@@ -2137,18 +2166,11 @@ static void mlx5e_build_netdev(struct net_device *netdev)
 
        SET_NETDEV_DEV(netdev, &mdev->pdev->dev);
 
-       if (priv->params.num_tc > 1)
-               mlx5e_netdev_ops.ndo_select_queue = mlx5e_select_queue;
-
-       if (MLX5_CAP_GEN(mdev, vport_group_manager)) {
-               mlx5e_netdev_ops.ndo_set_vf_mac = mlx5e_set_vf_mac;
-               mlx5e_netdev_ops.ndo_set_vf_vlan = mlx5e_set_vf_vlan;
-               mlx5e_netdev_ops.ndo_get_vf_config = mlx5e_get_vf_config;
-               mlx5e_netdev_ops.ndo_set_vf_link_state = mlx5e_set_vf_link_state;
-               mlx5e_netdev_ops.ndo_get_vf_stats = mlx5e_get_vf_stats;
-       }
+       if (MLX5_CAP_GEN(mdev, vport_group_manager))
+               netdev->netdev_ops = &mlx5e_netdev_ops_sriov;
+       else
+               netdev->netdev_ops = &mlx5e_netdev_ops_basic;
 
-       netdev->netdev_ops        = &mlx5e_netdev_ops;
        netdev->watchdog_timeo    = 15 * HZ;
 
        netdev->ethtool_ops       = &mlx5e_ethtool_ops;
index dd959d9..59658b9 100644 (file)
@@ -230,10 +230,6 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
        struct mlx5e_rq *rq = container_of(cq, struct mlx5e_rq, cq);
        int work_done;
 
-       /* avoid accessing cq (dma coherent memory) if not needed */
-       if (!test_and_clear_bit(MLX5E_CQ_HAS_CQES, &cq->flags))
-               return 0;
-
        for (work_done = 0; work_done < budget; work_done++) {
                struct mlx5e_rx_wqe *wqe;
                struct mlx5_cqe64 *cqe;
@@ -267,6 +263,7 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
 
                mlx5e_build_rx_skb(cqe, rq, skb);
                rq->stats.packets++;
+               rq->stats.bytes += be32_to_cpu(cqe->byte_cnt);
                napi_gro_receive(cq->napi, skb);
 
 wq_ll_pop:
@@ -279,8 +276,5 @@ wq_ll_pop:
        /* ensure cq space is freed before enabling more cqes */
        wmb();
 
-       if (work_done == budget)
-               set_bit(MLX5E_CQ_HAS_CQES, &cq->flags);
-
        return work_done;
 }
index 2c3fba0..bb4eeeb 100644 (file)
@@ -179,6 +179,7 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
        unsigned int skb_len = skb->len;
        u8  opcode = MLX5_OPCODE_SEND;
        dma_addr_t dma_addr = 0;
+       unsigned int num_bytes;
        bool bf = false;
        u16 headlen;
        u16 ds_cnt;
@@ -204,8 +205,7 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
                opcode       = MLX5_OPCODE_LSO;
                ihs          = skb_transport_offset(skb) + tcp_hdrlen(skb);
                payload_len  = skb->len - ihs;
-               wi->num_bytes = skb->len +
-                               (skb_shinfo(skb)->gso_segs - 1) * ihs;
+               num_bytes = skb->len + (skb_shinfo(skb)->gso_segs - 1) * ihs;
                sq->stats.tso_packets++;
                sq->stats.tso_bytes += payload_len;
        } else {
@@ -213,9 +213,11 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
                     !skb->xmit_more &&
                     !skb_shinfo(skb)->nr_frags;
                ihs = mlx5e_get_inline_hdr_size(sq, skb, bf);
-               wi->num_bytes = max_t(unsigned int, skb->len, ETH_ZLEN);
+               num_bytes = max_t(unsigned int, skb->len, ETH_ZLEN);
        }
 
+       wi->num_bytes = num_bytes;
+
        if (skb_vlan_tag_present(skb)) {
                mlx5e_insert_vlan(eseg->inline_hdr_start, skb, ihs, &skb_data,
                                  &skb_len);
@@ -307,6 +309,7 @@ static netdev_tx_t mlx5e_sq_xmit(struct mlx5e_sq *sq, struct sk_buff *skb)
        sq->bf_budget = bf ? sq->bf_budget - 1 : 0;
 
        sq->stats.packets++;
+       sq->stats.bytes += num_bytes;
        return NETDEV_TX_OK;
 
 dma_unmap_wqe_err:
@@ -335,10 +338,6 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq)
        u16 sqcc;
        int i;
 
-       /* avoid accessing cq (dma coherent memory) if not needed */
-       if (!test_and_clear_bit(MLX5E_CQ_HAS_CQES, &cq->flags))
-               return false;
-
        sq = container_of(cq, struct mlx5e_sq, cq);
 
        npkts = 0;
@@ -422,10 +421,6 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq)
                                netif_tx_wake_queue(sq->txq);
                                sq->stats.wake++;
        }
-       if (i == MLX5E_TX_CQ_POLL_BUDGET) {
-               set_bit(MLX5E_CQ_HAS_CQES, &cq->flags);
-               return true;
-       }
 
-       return false;
+       return (i == MLX5E_TX_CQ_POLL_BUDGET);
 }
index 4ac8d71..66d51a7 100644 (file)
@@ -88,7 +88,6 @@ void mlx5e_completion_event(struct mlx5_core_cq *mcq)
 {
        struct mlx5e_cq *cq = container_of(mcq, struct mlx5e_cq, mcq);
 
-       set_bit(MLX5E_CQ_HAS_CQES, &cq->flags);
        set_bit(MLX5E_CHANNEL_NAPI_SCHED, &cq->channel->flags);
        barrier();
        napi_schedule(cq->napi);
index c071077..7992c55 100644 (file)
@@ -215,7 +215,7 @@ mlxsw_pci_queue_elem_info_producer_get(struct mlxsw_pci_queue *q)
 {
        int index = q->producer_counter & (q->count - 1);
 
-       if ((q->producer_counter - q->consumer_counter) == q->count)
+       if ((u16) (q->producer_counter - q->consumer_counter) == q->count)
                return NULL;
        return mlxsw_pci_queue_elem_info_get(q, index);
 }
index 726f543..ae65b99 100644 (file)
@@ -49,7 +49,7 @@
 #define MLXSW_PORT_MID                 0xd000
 
 #define MLXSW_PORT_MAX_PHY_PORTS       0x40
-#define MLXSW_PORT_MAX_PORTS           MLXSW_PORT_MAX_PHY_PORTS
+#define MLXSW_PORT_MAX_PORTS           (MLXSW_PORT_MAX_PHY_PORTS + 1)
 
 #define MLXSW_PORT_DEVID_BITS_OFFSET   10
 #define MLXSW_PORT_PHY_BITS_OFFSET     4
index bb77e22..ffe4c03 100644 (file)
@@ -873,6 +873,62 @@ static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
        }
 }
 
+/* SPAFT - Switch Port Acceptable Frame Types
+ * ------------------------------------------
+ * The Switch Port Acceptable Frame Types register configures the frame
+ * admittance of the port.
+ */
+#define MLXSW_REG_SPAFT_ID 0x2010
+#define MLXSW_REG_SPAFT_LEN 0x08
+
+static const struct mlxsw_reg_info mlxsw_reg_spaft = {
+       .id = MLXSW_REG_SPAFT_ID,
+       .len = MLXSW_REG_SPAFT_LEN,
+};
+
+/* reg_spaft_local_port
+ * Local port number.
+ * Access: Index
+ *
+ * Note: CPU port is not supported (all tag types are allowed).
+ */
+MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
+
+/* reg_spaft_sub_port
+ * Virtual port within the physical port.
+ * Should be set to 0 when virtual ports are not enabled on the port.
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
+
+/* reg_spaft_allow_untagged
+ * When set, untagged frames on the ingress are allowed (default).
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
+
+/* reg_spaft_allow_prio_tagged
+ * When set, priority tagged frames on the ingress are allowed (default).
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
+
+/* reg_spaft_allow_tagged
+ * When set, tagged frames on the ingress are allowed (default).
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
+
+static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
+                                       bool allow_untagged)
+{
+       MLXSW_REG_ZERO(spaft, payload);
+       mlxsw_reg_spaft_local_port_set(payload, local_port);
+       mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
+       mlxsw_reg_spaft_allow_prio_tagged_set(payload, true);
+       mlxsw_reg_spaft_allow_tagged_set(payload, true);
+}
+
 /* SFGC - Switch Flooding Group Configuration
  * ------------------------------------------
  * The following register controls the association of flooding tables and MIDs
@@ -3203,6 +3259,8 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
                return "SPVID";
        case MLXSW_REG_SPVM_ID:
                return "SPVM";
+       case MLXSW_REG_SPAFT_ID:
+               return "SPAFT";
        case MLXSW_REG_SFGC_ID:
                return "SFGC";
        case MLXSW_REG_SFTR_ID:
index 217856b..a94daa8 100644 (file)
@@ -2123,6 +2123,8 @@ static int mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
        if (flush_fdb && mlxsw_sp_port_fdb_flush(mlxsw_sp_port))
                netdev_err(mlxsw_sp_port->dev, "Failed to flush FDB\n");
 
+       mlxsw_sp_port_pvid_set(mlxsw_sp_port, 1);
+
        mlxsw_sp_port->learning = 0;
        mlxsw_sp_port->learning_sync = 0;
        mlxsw_sp_port->uc_flood = 0;
@@ -2356,9 +2358,7 @@ static int mlxsw_sp_port_lag_leave(struct mlxsw_sp_port *mlxsw_sp_port,
        if (mlxsw_sp_port->bridged) {
                mlxsw_sp_port_active_vlans_del(mlxsw_sp_port);
                mlxsw_sp_port_bridge_leave(mlxsw_sp_port, false);
-
-               if (lag->ref_count == 1)
-                       mlxsw_sp_master_bridge_dec(mlxsw_sp, NULL);
+               mlxsw_sp_master_bridge_dec(mlxsw_sp, NULL);
        }
 
        if (lag->ref_count == 1) {
@@ -2746,6 +2746,13 @@ static int mlxsw_sp_vport_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_vport,
                goto err_vport_flood_set;
        }
 
+       err = mlxsw_sp_port_stp_state_set(mlxsw_sp_vport, vid,
+                                         MLXSW_REG_SPMS_STATE_FORWARDING);
+       if (err) {
+               netdev_err(dev, "Failed to set STP state\n");
+               goto err_port_stp_state_set;
+       }
+
        if (flush_fdb && mlxsw_sp_vport_fdb_flush(mlxsw_sp_vport))
                netdev_err(dev, "Failed to flush FDB\n");
 
@@ -2763,6 +2770,7 @@ static int mlxsw_sp_vport_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_vport,
 
        return 0;
 
+err_port_stp_state_set:
 err_vport_flood_set:
 err_port_vid_learning_set:
 err_port_vid_to_fid_validate:
index 7f42eb1..3b89ed2 100644 (file)
@@ -254,5 +254,6 @@ int mlxsw_sp_port_kill_vid(struct net_device *dev,
 int mlxsw_sp_vport_flood_set(struct mlxsw_sp_port *mlxsw_sp_vport, u16 vfid,
                             bool set, bool only_uc);
 void mlxsw_sp_port_active_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port);
+int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
 
 #endif
index e492ca2..7b56098 100644 (file)
@@ -370,7 +370,8 @@ static int mlxsw_sp_port_attr_set(struct net_device *dev,
        return err;
 }
 
-static int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid)
+static int __mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port,
+                                   u16 vid)
 {
        struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
        char spvid_pl[MLXSW_REG_SPVID_LEN];
@@ -379,6 +380,53 @@ static int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid)
        return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvid), spvid_pl);
 }
 
+static int mlxsw_sp_port_allow_untagged_set(struct mlxsw_sp_port *mlxsw_sp_port,
+                                           bool allow)
+{
+       struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
+       char spaft_pl[MLXSW_REG_SPAFT_LEN];
+
+       mlxsw_reg_spaft_pack(spaft_pl, mlxsw_sp_port->local_port, allow);
+       return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spaft), spaft_pl);
+}
+
+int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid)
+{
+       struct net_device *dev = mlxsw_sp_port->dev;
+       int err;
+
+       if (!vid) {
+               err = mlxsw_sp_port_allow_untagged_set(mlxsw_sp_port, false);
+               if (err) {
+                       netdev_err(dev, "Failed to disallow untagged traffic\n");
+                       return err;
+               }
+       } else {
+               err = __mlxsw_sp_port_pvid_set(mlxsw_sp_port, vid);
+               if (err) {
+                       netdev_err(dev, "Failed to set PVID\n");
+                       return err;
+               }
+
+               /* Only allow if not already allowed. */
+               if (!mlxsw_sp_port->pvid) {
+                       err = mlxsw_sp_port_allow_untagged_set(mlxsw_sp_port,
+                                                              true);
+                       if (err) {
+                               netdev_err(dev, "Failed to allow untagged traffic\n");
+                               goto err_port_allow_untagged_set;
+                       }
+               }
+       }
+
+       mlxsw_sp_port->pvid = vid;
+       return 0;
+
+err_port_allow_untagged_set:
+       __mlxsw_sp_port_pvid_set(mlxsw_sp_port, mlxsw_sp_port->pvid);
+       return err;
+}
+
 static int mlxsw_sp_fid_create(struct mlxsw_sp *mlxsw_sp, u16 fid)
 {
        char sfmr_pl[MLXSW_REG_SFMR_LEN];
@@ -540,7 +588,12 @@ static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port,
                        netdev_err(dev, "Unable to add PVID %d\n", vid_begin);
                        goto err_port_pvid_set;
                }
-               mlxsw_sp_port->pvid = vid_begin;
+       } else if (!flag_pvid && old_pvid >= vid_begin && old_pvid <= vid_end) {
+               err = mlxsw_sp_port_pvid_set(mlxsw_sp_port, 0);
+               if (err) {
+                       netdev_err(dev, "Unable to del PVID\n");
+                       goto err_port_pvid_set;
+               }
        }
 
        /* Changing activity bits only if HW operation succeded */
@@ -892,20 +945,18 @@ static int __mlxsw_sp_port_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port,
                return err;
        }
 
+       if (init)
+               goto out;
+
        pvid = mlxsw_sp_port->pvid;
-       if (pvid >= vid_begin && pvid <= vid_end && pvid != 1) {
-               /* Default VLAN is always 1 */
-               err = mlxsw_sp_port_pvid_set(mlxsw_sp_port, 1);
+       if (pvid >= vid_begin && pvid <= vid_end) {
+               err = mlxsw_sp_port_pvid_set(mlxsw_sp_port, 0);
                if (err) {
                        netdev_err(dev, "Unable to del PVID %d\n", pvid);
                        return err;
                }
-               mlxsw_sp_port->pvid = 1;
        }
 
-       if (init)
-               goto out;
-
        err = __mlxsw_sp_port_flood_set(mlxsw_sp_port, vid_begin, vid_end,
                                        false, false);
        if (err) {
index 00cfd95..3e67f45 100644 (file)
@@ -474,9 +474,9 @@ static int moxart_mac_probe(struct platform_device *pdev)
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        ndev->base_addr = res->start;
        priv->base = devm_ioremap_resource(p_dev, res);
-       ret = IS_ERR(priv->base);
-       if (ret) {
+       if (IS_ERR(priv->base)) {
                dev_err(p_dev, "devm_ioremap_resource failed\n");
+               ret = PTR_ERR(priv->base);
                goto init_fail;
        }
 
index 689a4a5..1ef0393 100644 (file)
@@ -811,7 +811,7 @@ qcaspi_netdev_setup(struct net_device *dev)
        dev->netdev_ops = &qcaspi_netdev_ops;
        qcaspi_set_ethtool_ops(dev);
        dev->watchdog_timeo = QCASPI_TX_TIMEOUT;
-       dev->flags = IFF_MULTICAST;
+       dev->priv_flags &= ~IFF_TX_SKB_SHARING;
        dev->tx_queue_len = 100;
 
        qca = netdev_priv(dev);
index 17d5571..dd2cf37 100644 (file)
@@ -4933,8 +4933,6 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
                RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST);
                break;
        case RTL_GIGA_MAC_VER_40:
-               RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF);
-               break;
        case RTL_GIGA_MAC_VER_41:
        case RTL_GIGA_MAC_VER_42:
        case RTL_GIGA_MAC_VER_43:
@@ -4943,8 +4941,6 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
        case RTL_GIGA_MAC_VER_46:
        case RTL_GIGA_MAC_VER_47:
        case RTL_GIGA_MAC_VER_48:
-               RTL_W32(RxConfig, RX128_INT_EN | RX_DMA_BURST | RX_EARLY_OFF);
-               break;
        case RTL_GIGA_MAC_VER_49:
        case RTL_GIGA_MAC_VER_50:
        case RTL_GIGA_MAC_VER_51:
@@ -6137,28 +6133,28 @@ static void rtl_hw_start_8168h_1(struct rtl8169_private *tp)
                sw_cnt_1ms_ini = 16000000/rg_saw_cnt;
                sw_cnt_1ms_ini &= 0x0fff;
                data = r8168_mac_ocp_read(tp, 0xd412);
-               data &= 0x0fff;
+               data &= ~0x0fff;
                data |= sw_cnt_1ms_ini;
                r8168_mac_ocp_write(tp, 0xd412, data);
        }
 
        data = r8168_mac_ocp_read(tp, 0xe056);
-       data &= 0xf0;
-       data |= 0x07;
+       data &= ~0xf0;
+       data |= 0x70;
        r8168_mac_ocp_write(tp, 0xe056, data);
 
        data = r8168_mac_ocp_read(tp, 0xe052);
-       data &= 0x8008;
-       data |= 0x6000;
+       data &= ~0x6000;
+       data |= 0x8008;
        r8168_mac_ocp_write(tp, 0xe052, data);
 
        data = r8168_mac_ocp_read(tp, 0xe0d6);
-       data &= 0x01ff;
+       data &= ~0x01ff;
        data |= 0x017f;
        r8168_mac_ocp_write(tp, 0xe0d6, data);
 
        data = r8168_mac_ocp_read(tp, 0xd420);
-       data &= 0x0fff;
+       data &= ~0x0fff;
        data |= 0x047f;
        r8168_mac_ocp_write(tp, 0xd420, data);
 
@@ -7730,10 +7726,13 @@ rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
 {
        struct rtl8169_private *tp = netdev_priv(dev);
        void __iomem *ioaddr = tp->mmio_addr;
+       struct pci_dev *pdev = tp->pci_dev;
        struct rtl8169_counters *counters = tp->counters;
        unsigned int start;
 
-       if (netif_running(dev))
+       pm_runtime_get_noresume(&pdev->dev);
+
+       if (netif_running(dev) && pm_runtime_active(&pdev->dev))
                rtl8169_rx_missed(dev, ioaddr);
 
        do {
@@ -7761,7 +7760,8 @@ rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
         * Fetch additonal counter values missing in stats collected by driver
         * from tally counters.
         */
-       rtl8169_update_counters(dev);
+       if (pm_runtime_active(&pdev->dev))
+               rtl8169_update_counters(dev);
 
        /*
         * Subtract values fetched during initalization.
@@ -7774,6 +7774,8 @@ rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
        stats->tx_aborted_errors = le16_to_cpu(counters->tx_aborted) -
                le16_to_cpu(tp->tc_offset.tx_aborted);
 
+       pm_runtime_put_noidle(&pdev->dev);
+
        return stats;
 }
 
@@ -7853,6 +7855,10 @@ static int rtl8169_runtime_suspend(struct device *device)
 
        rtl8169_net_suspend(dev);
 
+       /* Update counters before going runtime suspend */
+       rtl8169_rx_missed(dev, tp->mmio_addr);
+       rtl8169_update_counters(dev);
+
        return 0;
 }
 
index ac43ed9..86449c3 100644 (file)
@@ -1139,7 +1139,8 @@ static int ravb_set_ringparam(struct net_device *ndev,
        if (netif_running(ndev)) {
                netif_device_detach(ndev);
                /* Stop PTP Clock driver */
-               ravb_ptp_stop(ndev);
+               if (priv->chip_id == RCAR_GEN2)
+                       ravb_ptp_stop(ndev);
                /* Wait for DMA stopping */
                error = ravb_stop_dma(ndev);
                if (error) {
@@ -1170,7 +1171,8 @@ static int ravb_set_ringparam(struct net_device *ndev,
                ravb_emac_init(ndev);
 
                /* Initialise PTP Clock driver */
-               ravb_ptp_init(ndev, priv->pdev);
+               if (priv->chip_id == RCAR_GEN2)
+                       ravb_ptp_init(ndev, priv->pdev);
 
                netif_device_attach(ndev);
        }
@@ -1298,7 +1300,8 @@ static void ravb_tx_timeout_work(struct work_struct *work)
        netif_tx_stop_all_queues(ndev);
 
        /* Stop PTP Clock driver */
-       ravb_ptp_stop(ndev);
+       if (priv->chip_id == RCAR_GEN2)
+               ravb_ptp_stop(ndev);
 
        /* Wait for DMA stopping */
        ravb_stop_dma(ndev);
@@ -1311,7 +1314,8 @@ static void ravb_tx_timeout_work(struct work_struct *work)
        ravb_emac_init(ndev);
 
        /* Initialise PTP Clock driver */
-       ravb_ptp_init(ndev, priv->pdev);
+       if (priv->chip_id == RCAR_GEN2)
+               ravb_ptp_init(ndev, priv->pdev);
 
        netif_tx_start_all_queues(ndev);
 }
@@ -1718,7 +1722,6 @@ static int ravb_set_gti(struct net_device *ndev)
 static int ravb_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
-       const struct of_device_id *match;
        struct ravb_private *priv;
        enum ravb_chip_id chip_id;
        struct net_device *ndev;
@@ -1750,8 +1753,7 @@ static int ravb_probe(struct platform_device *pdev)
        ndev->base_addr = res->start;
        ndev->dma = -1;
 
-       match = of_match_device(of_match_ptr(ravb_match_table), &pdev->dev);
-       chip_id = (enum ravb_chip_id)match->data;
+       chip_id = (enum ravb_chip_id)of_device_get_match_data(&pdev->dev);
 
        if (chip_id == RCAR_GEN3)
                irq = platform_get_irq_byname(pdev, "ch22");
@@ -1814,10 +1816,6 @@ static int ravb_probe(struct platform_device *pdev)
                           CCC_OPC_CONFIG | CCC_GAC | CCC_CSEL_HPB, CCC);
        }
 
-       /* Set CSEL value */
-       ravb_write(ndev, (ravb_read(ndev, CCC) & ~CCC_CSEL) | CCC_CSEL_HPB,
-                  CCC);
-
        /* Set GTI value */
        error = ravb_set_gti(ndev);
        if (error)
index dfa9e59..7384499 100644 (file)
@@ -3061,15 +3061,11 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
        mdp->ether_link_active_low = pd->ether_link_active_low;
 
        /* set cpu data */
-       if (id) {
+       if (id)
                mdp->cd = (struct sh_eth_cpu_data *)id->driver_data;
-       } else  {
-               const struct of_device_id *match;
+       else
+               mdp->cd = (struct sh_eth_cpu_data *)of_device_get_match_data(&pdev->dev);
 
-               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",
index 0e2fc1a..db7db8a 100644 (file)
@@ -2342,8 +2342,8 @@ static int smc_drv_probe(struct platform_device *pdev)
        }
 
        ndev->irq = platform_get_irq(pdev, 0);
-       if (ndev->irq <= 0) {
-               ret = -ENODEV;
+       if (ndev->irq < 0) {
+               ret = ndev->irq;
                goto out_release_io;
        }
        /*
index 0faf163..efb54f3 100644 (file)
@@ -199,21 +199,12 @@ int stmmac_mdio_register(struct net_device *ndev)
        struct stmmac_priv *priv = netdev_priv(ndev);
        struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
        int addr, found;
-       struct device_node *mdio_node = NULL;
-       struct device_node *child_node = NULL;
+       struct device_node *mdio_node = priv->plat->mdio_node;
 
        if (!mdio_bus_data)
                return 0;
 
        if (IS_ENABLED(CONFIG_OF)) {
-               for_each_child_of_node(priv->device->of_node, child_node) {
-                       if (of_device_is_compatible(child_node,
-                                                   "snps,dwmac-mdio")) {
-                               mdio_node = child_node;
-                               break;
-                       }
-               }
-
                if (mdio_node) {
                        netdev_dbg(ndev, "FOUND MDIO subnode\n");
                } else {
index 6a52fa1..4514ba7 100644 (file)
@@ -110,6 +110,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
        struct device_node *np = pdev->dev.of_node;
        struct plat_stmmacenet_data *plat;
        struct stmmac_dma_cfg *dma_cfg;
+       struct device_node *child_node = NULL;
 
        plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
        if (!plat)
@@ -140,13 +141,19 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
                plat->phy_node = of_node_get(np);
        }
 
+       for_each_child_of_node(np, child_node)
+               if (of_device_is_compatible(child_node, "snps,dwmac-mdio")) {
+                       plat->mdio_node = child_node;
+                       break;
+               }
+
        /* "snps,phy-addr" is not a standard property. Mark it as deprecated
         * and warn of its use. Remove this when phy node support is added.
         */
        if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0)
                dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n");
 
-       if ((plat->phy_node && !of_phy_is_fixed_link(np)) || plat->phy_bus_name)
+       if ((plat->phy_node && !of_phy_is_fixed_link(np)) || !plat->mdio_node)
                plat->mdio_bus_data = NULL;
        else
                plat->mdio_bus_data =
index 70814b7..af11ed1 100644 (file)
 #define DWC_MMC_RXOCTETCOUNT_GB          0x0784
 #define DWC_MMC_RXPACKETCOUNT_GB         0x0780
 
-static int debug = 3;
+static int debug = -1;
 module_param(debug, int, 0);
 MODULE_PARM_DESC(debug, "DWC_eth_qos debug level (0=none,...,16=all)");
 
@@ -650,6 +650,11 @@ struct net_local {
        u32 mmc_tx_counters_mask;
 
        struct dwceqos_flowcontrol flowcontrol;
+
+       /* Tracks the intermediate state of phy started but hardware
+        * init not finished yet.
+        */
+       bool phy_defer;
 };
 
 static void dwceqos_read_mmc_counters(struct net_local *lp, u32 rx_mask,
@@ -901,6 +906,9 @@ static void dwceqos_adjust_link(struct net_device *ndev)
        struct phy_device *phydev = lp->phy_dev;
        int status_change = 0;
 
+       if (lp->phy_defer)
+               return;
+
        if (phydev->link) {
                if ((lp->speed != phydev->speed) ||
                    (lp->duplex != phydev->duplex)) {
@@ -1113,7 +1121,7 @@ static int dwceqos_descriptor_init(struct net_local *lp)
        /* Allocate DMA descriptors */
        size = DWCEQOS_RX_DCNT * sizeof(struct dwceqos_dma_desc);
        lp->rx_descs = dma_alloc_coherent(lp->ndev->dev.parent, size,
-                       &lp->rx_descs_addr, 0);
+                       &lp->rx_descs_addr, GFP_KERNEL);
        if (!lp->rx_descs)
                goto err_out;
        lp->rx_descs_tail_addr = lp->rx_descs_addr +
@@ -1121,7 +1129,7 @@ static int dwceqos_descriptor_init(struct net_local *lp)
 
        size = DWCEQOS_TX_DCNT * sizeof(struct dwceqos_dma_desc);
        lp->tx_descs = dma_alloc_coherent(lp->ndev->dev.parent, size,
-                       &lp->tx_descs_addr, 0);
+                       &lp->tx_descs_addr, GFP_KERNEL);
        if (!lp->tx_descs)
                goto err_out;
        lp->tx_descs_tail_addr = lp->tx_descs_addr +
@@ -1635,6 +1643,12 @@ static void dwceqos_init_hw(struct net_local *lp)
        regval = dwceqos_read(lp, REG_DWCEQOS_MAC_CFG);
        dwceqos_write(lp, REG_DWCEQOS_MAC_CFG,
                      regval | DWCEQOS_MAC_CFG_TE | DWCEQOS_MAC_CFG_RE);
+
+       lp->phy_defer = false;
+       mutex_lock(&lp->phy_dev->lock);
+       phy_read_status(lp->phy_dev);
+       dwceqos_adjust_link(lp->ndev);
+       mutex_unlock(&lp->phy_dev->lock);
 }
 
 static void dwceqos_tx_reclaim(unsigned long data)
@@ -1880,9 +1894,13 @@ static int dwceqos_open(struct net_device *ndev)
        }
        netdev_reset_queue(ndev);
 
-       napi_enable(&lp->napi);
+       /* The dwceqos reset state machine requires all phy clocks to complete,
+        * hence the unusual init order with phy_start first.
+        */
+       lp->phy_defer = true;
        phy_start(lp->phy_dev);
        dwceqos_init_hw(lp);
+       napi_enable(&lp->napi);
 
        netif_start_queue(ndev);
        tasklet_enable(&lp->tx_bdreclaim_tasklet);
@@ -1915,18 +1933,19 @@ static int dwceqos_stop(struct net_device *ndev)
 {
        struct net_local *lp = netdev_priv(ndev);
 
-       phy_stop(lp->phy_dev);
-
        tasklet_disable(&lp->tx_bdreclaim_tasklet);
-       netif_stop_queue(ndev);
        napi_disable(&lp->napi);
 
-       dwceqos_drain_dma(lp);
+       /* Stop all tx before we drain the tx dma. */
+       netif_tx_lock_bh(lp->ndev);
+       netif_stop_queue(ndev);
+       netif_tx_unlock_bh(lp->ndev);
 
-       netif_tx_lock(lp->ndev);
+       dwceqos_drain_dma(lp);
        dwceqos_reset_hw(lp);
+       phy_stop(lp->phy_dev);
+
        dwceqos_descriptor_free(lp);
-       netif_tx_unlock(lp->ndev);
 
        return 0;
 }
@@ -2178,12 +2197,10 @@ static int dwceqos_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                ((trans.initial_descriptor + trans.nr_descriptors) %
                 DWCEQOS_TX_DCNT));
 
-       dwceqos_tx_finalize(skb, lp, &trans);
-
-       netdev_sent_queue(ndev, skb->len);
-
        spin_lock_bh(&lp->tx_lock);
        lp->tx_free -= trans.nr_descriptors;
+       dwceqos_tx_finalize(skb, lp, &trans);
+       netdev_sent_queue(ndev, skb->len);
        spin_unlock_bh(&lp->tx_lock);
 
        ndev->trans_start = jiffies;
index e9cc61e..c3e85ac 100644 (file)
@@ -63,8 +63,12 @@ static void cpsw_gmii_sel_am3352(struct cpsw_phy_sel_priv *priv,
                mode = AM33XX_GMII_SEL_MODE_RGMII;
                break;
 
-       case PHY_INTERFACE_MODE_MII:
        default:
+               dev_warn(priv->dev,
+                        "Unsupported PHY mode: \"%s\". Defaulting to MII.\n",
+                       phy_modes(phy_mode));
+               /* fallthrough */
+       case PHY_INTERFACE_MODE_MII:
                mode = AM33XX_GMII_SEL_MODE_MII;
                break;
        };
@@ -106,8 +110,12 @@ static void cpsw_gmii_sel_dra7xx(struct cpsw_phy_sel_priv *priv,
                mode = AM33XX_GMII_SEL_MODE_RGMII;
                break;
 
-       case PHY_INTERFACE_MODE_MII:
        default:
+               dev_warn(priv->dev,
+                        "Unsupported PHY mode: \"%s\". Defaulting to MII.\n",
+                       phy_modes(phy_mode));
+               /* fallthrough */
+       case PHY_INTERFACE_MODE_MII:
                mode = AM33XX_GMII_SEL_MODE_MII;
                break;
        };
index c61d66d..029841f 100644 (file)
@@ -117,21 +117,17 @@ static void get_pkt_info(dma_addr_t *buff, u32 *buff_len, dma_addr_t *ndesc,
        *ndesc = le32_to_cpu(desc->next_desc);
 }
 
-static void get_pad_info(u32 *pad0, u32 *pad1, u32 *pad2, struct knav_dma_desc *desc)
+static u32 get_sw_data(int index, struct knav_dma_desc *desc)
 {
-       *pad0 = le32_to_cpu(desc->pad[0]);
-       *pad1 = le32_to_cpu(desc->pad[1]);
-       *pad2 = le32_to_cpu(desc->pad[2]);
+       /* No Endian conversion needed as this data is untouched by hw */
+       return desc->sw_data[index];
 }
 
-static void get_pad_ptr(void **padptr, struct knav_dma_desc *desc)
-{
-       u64 pad64;
-
-       pad64 = le32_to_cpu(desc->pad[0]) +
-               ((u64)le32_to_cpu(desc->pad[1]) << 32);
-       *padptr = (void *)(uintptr_t)pad64;
-}
+/* use these macros to get sw data */
+#define GET_SW_DATA0(desc) get_sw_data(0, desc)
+#define GET_SW_DATA1(desc) get_sw_data(1, desc)
+#define GET_SW_DATA2(desc) get_sw_data(2, desc)
+#define GET_SW_DATA3(desc) get_sw_data(3, desc)
 
 static void get_org_pkt_info(dma_addr_t *buff, u32 *buff_len,
                             struct knav_dma_desc *desc)
@@ -163,13 +159,18 @@ static void set_desc_info(u32 desc_info, u32 pkt_info,
        desc->packet_info = cpu_to_le32(pkt_info);
 }
 
-static void set_pad_info(u32 pad0, u32 pad1, u32 pad2, struct knav_dma_desc *desc)
+static void set_sw_data(int index, u32 data, struct knav_dma_desc *desc)
 {
-       desc->pad[0] = cpu_to_le32(pad0);
-       desc->pad[1] = cpu_to_le32(pad1);
-       desc->pad[2] = cpu_to_le32(pad1);
+       /* No Endian conversion needed as this data is untouched by hw */
+       desc->sw_data[index] = data;
 }
 
+/* use these macros to set sw data */
+#define SET_SW_DATA0(data, desc) set_sw_data(0, data, desc)
+#define SET_SW_DATA1(data, desc) set_sw_data(1, data, desc)
+#define SET_SW_DATA2(data, desc) set_sw_data(2, data, desc)
+#define SET_SW_DATA3(data, desc) set_sw_data(3, data, desc)
+
 static void set_org_pkt_info(dma_addr_t buff, u32 buff_len,
                             struct knav_dma_desc *desc)
 {
@@ -581,7 +582,6 @@ static void netcp_free_rx_desc_chain(struct netcp_intf *netcp,
        dma_addr_t dma_desc, dma_buf;
        unsigned int buf_len, dma_sz = sizeof(*ndesc);
        void *buf_ptr;
-       u32 pad[2];
        u32 tmp;
 
        get_words(&dma_desc, 1, &desc->next_desc);
@@ -593,14 +593,20 @@ static void netcp_free_rx_desc_chain(struct netcp_intf *netcp,
                        break;
                }
                get_pkt_info(&dma_buf, &tmp, &dma_desc, ndesc);
-               get_pad_ptr(&buf_ptr, ndesc);
+               /* warning!!!! We are retrieving the virtual ptr in the sw_data
+                * field as a 32bit value. Will not work on 64bit machines
+                */
+               buf_ptr = (void *)GET_SW_DATA0(ndesc);
+               buf_len = (int)GET_SW_DATA1(desc);
                dma_unmap_page(netcp->dev, dma_buf, PAGE_SIZE, DMA_FROM_DEVICE);
                __free_page(buf_ptr);
                knav_pool_desc_put(netcp->rx_pool, desc);
        }
-
-       get_pad_info(&pad[0], &pad[1], &buf_len, desc);
-       buf_ptr = (void *)(uintptr_t)(pad[0] + ((u64)pad[1] << 32));
+       /* warning!!!! We are retrieving the virtual ptr in the sw_data
+        * field as a 32bit value. Will not work on 64bit machines
+        */
+       buf_ptr = (void *)GET_SW_DATA0(desc);
+       buf_len = (int)GET_SW_DATA1(desc);
 
        if (buf_ptr)
                netcp_frag_free(buf_len <= PAGE_SIZE, buf_ptr);
@@ -639,7 +645,6 @@ static int netcp_process_one_rx_packet(struct netcp_intf *netcp)
        dma_addr_t dma_desc, dma_buff;
        struct netcp_packet p_info;
        struct sk_buff *skb;
-       u32 pad[2];
        void *org_buf_ptr;
 
        dma_desc = knav_queue_pop(netcp->rx_queue, &dma_sz);
@@ -653,8 +658,11 @@ static int netcp_process_one_rx_packet(struct netcp_intf *netcp)
        }
 
        get_pkt_info(&dma_buff, &buf_len, &dma_desc, desc);
-       get_pad_info(&pad[0], &pad[1], &org_buf_len, desc);
-       org_buf_ptr = (void *)(uintptr_t)(pad[0] + ((u64)pad[1] << 32));
+       /* warning!!!! We are retrieving the virtual ptr in the sw_data
+        * field as a 32bit value. Will not work on 64bit machines
+        */
+       org_buf_ptr = (void *)GET_SW_DATA0(desc);
+       org_buf_len = (int)GET_SW_DATA1(desc);
 
        if (unlikely(!org_buf_ptr)) {
                dev_err(netcp->ndev_dev, "NULL bufptr in desc\n");
@@ -679,7 +687,6 @@ static int netcp_process_one_rx_packet(struct netcp_intf *netcp)
        /* Fill in the page fragment list */
        while (dma_desc) {
                struct page *page;
-               void *ptr;
 
                ndesc = knav_pool_desc_unmap(netcp->rx_pool, dma_desc, dma_sz);
                if (unlikely(!ndesc)) {
@@ -688,8 +695,10 @@ static int netcp_process_one_rx_packet(struct netcp_intf *netcp)
                }
 
                get_pkt_info(&dma_buff, &buf_len, &dma_desc, ndesc);
-               get_pad_ptr(&ptr, ndesc);
-               page = ptr;
+               /* warning!!!! We are retrieving the virtual ptr in the sw_data
+                * field as a 32bit value. Will not work on 64bit machines
+                */
+               page = (struct page *)GET_SW_DATA0(desc);
 
                if (likely(dma_buff && buf_len && page)) {
                        dma_unmap_page(netcp->dev, dma_buff, PAGE_SIZE,
@@ -777,7 +786,10 @@ static void netcp_free_rx_buf(struct netcp_intf *netcp, int fdq)
                }
 
                get_org_pkt_info(&dma, &buf_len, desc);
-               get_pad_ptr(&buf_ptr, desc);
+               /* warning!!!! We are retrieving the virtual ptr in the sw_data
+                * field as a 32bit value. Will not work on 64bit machines
+                */
+               buf_ptr = (void *)GET_SW_DATA0(desc);
 
                if (unlikely(!dma)) {
                        dev_err(netcp->ndev_dev, "NULL orig_buff in desc\n");
@@ -829,7 +841,7 @@ static int netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq)
        struct page *page;
        dma_addr_t dma;
        void *bufptr;
-       u32 pad[3];
+       u32 sw_data[2];
 
        /* Allocate descriptor */
        hwdesc = knav_pool_desc_get(netcp->rx_pool);
@@ -846,7 +858,7 @@ static int netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq)
                                SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
 
                bufptr = netdev_alloc_frag(primary_buf_len);
-               pad[2] = primary_buf_len;
+               sw_data[1] = primary_buf_len;
 
                if (unlikely(!bufptr)) {
                        dev_warn_ratelimited(netcp->ndev_dev,
@@ -858,9 +870,10 @@ static int netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq)
                if (unlikely(dma_mapping_error(netcp->dev, dma)))
                        goto fail;
 
-               pad[0] = lower_32_bits((uintptr_t)bufptr);
-               pad[1] = upper_32_bits((uintptr_t)bufptr);
-
+               /* warning!!!! We are saving the virtual ptr in the sw_data
+                * field as a 32bit value. Will not work on 64bit machines
+                */
+               sw_data[0] = (u32)bufptr;
        } else {
                /* Allocate a secondary receive queue entry */
                page = alloc_page(GFP_ATOMIC | GFP_DMA | __GFP_COLD);
@@ -870,9 +883,11 @@ static int netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq)
                }
                buf_len = PAGE_SIZE;
                dma = dma_map_page(netcp->dev, page, 0, buf_len, DMA_TO_DEVICE);
-               pad[0] = lower_32_bits(dma);
-               pad[1] = upper_32_bits(dma);
-               pad[2] = 0;
+               /* warning!!!! We are saving the virtual ptr in the sw_data
+                * field as a 32bit value. Will not work on 64bit machines
+                */
+               sw_data[0] = (u32)page;
+               sw_data[1] = 0;
        }
 
        desc_info =  KNAV_DMA_DESC_PS_INFO_IN_DESC;
@@ -882,7 +897,8 @@ static int netcp_allocate_rx_buf(struct netcp_intf *netcp, int fdq)
        pkt_info |= (netcp->rx_queue_id & KNAV_DMA_DESC_RETQ_MASK) <<
                    KNAV_DMA_DESC_RETQ_SHIFT;
        set_org_pkt_info(dma, buf_len, hwdesc);
-       set_pad_info(pad[0], pad[1], pad[2], hwdesc);
+       SET_SW_DATA0(sw_data[0], hwdesc);
+       SET_SW_DATA1(sw_data[1], hwdesc);
        set_desc_info(desc_info, pkt_info, hwdesc);
 
        /* Push to FDQs */
@@ -971,7 +987,6 @@ static int netcp_process_tx_compl_packets(struct netcp_intf *netcp,
                                          unsigned int budget)
 {
        struct knav_dma_desc *desc;
-       void *ptr;
        struct sk_buff *skb;
        unsigned int dma_sz;
        dma_addr_t dma;
@@ -988,8 +1003,10 @@ static int netcp_process_tx_compl_packets(struct netcp_intf *netcp,
                        continue;
                }
 
-               get_pad_ptr(&ptr, desc);
-               skb = ptr;
+               /* warning!!!! We are retrieving the virtual ptr in the sw_data
+                * field as a 32bit value. Will not work on 64bit machines
+                */
+               skb = (struct sk_buff *)GET_SW_DATA0(desc);
                netcp_free_tx_desc_chain(netcp, desc, dma_sz);
                if (!skb) {
                        dev_err(netcp->ndev_dev, "No skb in Tx desc\n");
@@ -1194,10 +1211,10 @@ static int netcp_tx_submit_skb(struct netcp_intf *netcp,
        }
 
        set_words(&tmp, 1, &desc->packet_info);
-       tmp = lower_32_bits((uintptr_t)&skb);
-       set_words(&tmp, 1, &desc->pad[0]);
-       tmp = upper_32_bits((uintptr_t)&skb);
-       set_words(&tmp, 1, &desc->pad[1]);
+       /* warning!!!! We are saving the virtual ptr in the sw_data
+        * field as a 32bit value. Will not work on 64bit machines
+        */
+       SET_SW_DATA0((u32)skb, desc);
 
        if (tx_pipe->flags & SWITCH_TO_PORT_IN_TAGINFO) {
                tmp = tx_pipe->switch_to_port;
index 0b14ac3..0bf7edd 100644 (file)
@@ -1039,6 +1039,34 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
        return geneve_xmit_skb(skb, dev, info);
 }
 
+static int __geneve_change_mtu(struct net_device *dev, int new_mtu, bool strict)
+{
+       /* The max_mtu calculation does not take account of GENEVE
+        * options, to avoid excluding potentially valid
+        * configurations.
+        */
+       int max_mtu = IP_MAX_MTU - GENEVE_BASE_HLEN - sizeof(struct iphdr)
+               - dev->hard_header_len;
+
+       if (new_mtu < 68)
+               return -EINVAL;
+
+       if (new_mtu > max_mtu) {
+               if (strict)
+                       return -EINVAL;
+
+               new_mtu = max_mtu;
+       }
+
+       dev->mtu = new_mtu;
+       return 0;
+}
+
+static int geneve_change_mtu(struct net_device *dev, int new_mtu)
+{
+       return __geneve_change_mtu(dev, new_mtu, true);
+}
+
 static int geneve_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
 {
        struct ip_tunnel_info *info = skb_tunnel_info(skb);
@@ -1083,7 +1111,7 @@ static const struct net_device_ops geneve_netdev_ops = {
        .ndo_stop               = geneve_stop,
        .ndo_start_xmit         = geneve_xmit,
        .ndo_get_stats64        = ip_tunnel_get_stats64,
-       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_change_mtu         = geneve_change_mtu,
        .ndo_validate_addr      = eth_validate_addr,
        .ndo_set_mac_address    = eth_mac_addr,
        .ndo_fill_metadata_dst  = geneve_fill_metadata_dst,
@@ -1150,6 +1178,7 @@ static void geneve_setup(struct net_device *dev)
        dev->hw_features |= NETIF_F_GSO_SOFTWARE;
 
        netif_keep_dst(dev);
+       dev->priv_flags &= ~IFF_TX_SKB_SHARING;
        dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE;
        eth_hw_addr_random(dev);
 }
@@ -1441,12 +1470,23 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
                return dev;
 
        err = geneve_configure(net, dev, &geneve_remote_unspec,
-                              0, 0, 0, htons(dst_port), true, 0);
-       if (err) {
-               free_netdev(dev);
-               return ERR_PTR(err);
-       }
+                              0, 0, 0, htons(dst_port), true,
+                              GENEVE_F_UDP_ZERO_CSUM6_RX);
+       if (err)
+               goto err;
+
+       /* openvswitch users expect packet sizes to be unrestricted,
+        * so set the largest MTU we can.
+        */
+       err = __geneve_change_mtu(dev, IP_MAX_MTU, false);
+       if (err)
+               goto err;
+
        return dev;
+
+ err:
+       free_netdev(dev);
+       return ERR_PTR(err);
 }
 EXPORT_SYMBOL_GPL(geneve_dev_create_fb);
 
index 1d3a665..98e34fe 100644 (file)
@@ -1089,6 +1089,9 @@ static int netvsc_probe(struct hv_device *dev,
        net->ethtool_ops = &ethtool_ops;
        SET_NETDEV_DEV(net, &dev->device);
 
+       /* We always need headroom for rndis header */
+       net->needed_headroom = RNDIS_AND_PPI_SIZE;
+
        /* Notify the netvsc driver of the new device */
        memset(&device_info, 0, sizeof(device_info));
        device_info.ring_size = ring_size;
index bf241a3..db507e3 100644 (file)
@@ -250,10 +250,6 @@ static int bcm7xxx_config_init(struct phy_device *phydev)
        phy_write(phydev, MII_BCM7XXX_AUX_MODE, MII_BCM7XX_64CLK_MDIO);
        phy_read(phydev, MII_BCM7XXX_AUX_MODE);
 
-       /* Workaround only required for 100Mbits/sec capable PHYs */
-       if (phydev->supported & PHY_GBIT_FEATURES)
-               return 0;
-
        /* set shadow mode 2 */
        ret = phy_set_clr_bits(phydev, MII_BCM7XXX_TEST,
                        MII_BCM7XXX_SHD_MODE_2, MII_BCM7XXX_SHD_MODE_2);
@@ -270,7 +266,7 @@ static int bcm7xxx_config_init(struct phy_device *phydev)
        phy_write(phydev, MII_BCM7XXX_100TX_FALSE_CAR, 0x7555);
 
        /* reset shadow mode 2 */
-       ret = phy_set_clr_bits(phydev, MII_BCM7XXX_TEST, MII_BCM7XXX_SHD_MODE_2, 0);
+       ret = phy_set_clr_bits(phydev, MII_BCM7XXX_TEST, 0, MII_BCM7XXX_SHD_MODE_2);
        if (ret < 0)
                return ret;
 
@@ -307,11 +303,6 @@ static int bcm7xxx_suspend(struct phy_device *phydev)
        return 0;
 }
 
-static int bcm7xxx_dummy_config_init(struct phy_device *phydev)
-{
-       return 0;
-}
-
 #define BCM7XXX_28NM_GPHY(_oui, _name)                                 \
 {                                                                      \
        .phy_id         = (_oui),                                       \
@@ -337,7 +328,7 @@ static struct phy_driver bcm7xxx_driver[] = {
        .phy_id         = PHY_ID_BCM7425,
        .phy_id_mask    = 0xfffffff0,
        .name           = "Broadcom BCM7425",
-       .features       = PHY_GBIT_FEATURES |
+       .features       = PHY_BASIC_FEATURES |
                          SUPPORTED_Pause | SUPPORTED_Asym_Pause,
        .flags          = PHY_IS_INTERNAL,
        .config_init    = bcm7xxx_config_init,
@@ -349,7 +340,7 @@ static struct phy_driver bcm7xxx_driver[] = {
        .phy_id         = PHY_ID_BCM7429,
        .phy_id_mask    = 0xfffffff0,
        .name           = "Broadcom BCM7429",
-       .features       = PHY_GBIT_FEATURES |
+       .features       = PHY_BASIC_FEATURES |
                          SUPPORTED_Pause | SUPPORTED_Asym_Pause,
        .flags          = PHY_IS_INTERNAL,
        .config_init    = bcm7xxx_config_init,
@@ -361,7 +352,7 @@ static struct phy_driver bcm7xxx_driver[] = {
        .phy_id         = PHY_ID_BCM7435,
        .phy_id_mask    = 0xfffffff0,
        .name           = "Broadcom BCM7435",
-       .features       = PHY_GBIT_FEATURES |
+       .features       = PHY_BASIC_FEATURES |
                          SUPPORTED_Pause | SUPPORTED_Asym_Pause,
        .flags          = PHY_IS_INTERNAL,
        .config_init    = bcm7xxx_config_init,
@@ -369,30 +360,6 @@ static struct phy_driver bcm7xxx_driver[] = {
        .read_status    = genphy_read_status,
        .suspend        = bcm7xxx_suspend,
        .resume         = bcm7xxx_config_init,
-}, {
-       .phy_id         = PHY_BCM_OUI_4,
-       .phy_id_mask    = 0xffff0000,
-       .name           = "Broadcom BCM7XXX 40nm",
-       .features       = PHY_GBIT_FEATURES |
-                         SUPPORTED_Pause | SUPPORTED_Asym_Pause,
-       .flags          = PHY_IS_INTERNAL,
-       .config_init    = bcm7xxx_config_init,
-       .config_aneg    = genphy_config_aneg,
-       .read_status    = genphy_read_status,
-       .suspend        = bcm7xxx_suspend,
-       .resume         = bcm7xxx_config_init,
-}, {
-       .phy_id         = PHY_BCM_OUI_5,
-       .phy_id_mask    = 0xffffff00,
-       .name           = "Broadcom BCM7XXX 65nm",
-       .features       = PHY_BASIC_FEATURES |
-                         SUPPORTED_Pause | SUPPORTED_Asym_Pause,
-       .flags          = PHY_IS_INTERNAL,
-       .config_init    = bcm7xxx_dummy_config_init,
-       .config_aneg    = genphy_config_aneg,
-       .read_status    = genphy_read_status,
-       .suspend        = bcm7xxx_suspend,
-       .resume         = bcm7xxx_config_init,
 } };
 
 static struct mdio_device_id __maybe_unused bcm7xxx_tbl[] = {
@@ -404,8 +371,6 @@ static struct mdio_device_id __maybe_unused bcm7xxx_tbl[] = {
        { PHY_ID_BCM7439, 0xfffffff0, },
        { PHY_ID_BCM7435, 0xfffffff0, },
        { PHY_ID_BCM7445, 0xfffffff0, },
-       { PHY_BCM_OUI_4, 0xffff0000 },
-       { PHY_BCM_OUI_5, 0xffffff00 },
        { }
 };
 
index e3eb964..ab1d0fc 100644 (file)
@@ -446,6 +446,12 @@ static int m88e1510_config_aneg(struct phy_device *phydev)
        if (err < 0)
                return err;
 
+       return 0;
+}
+
+static int marvell_config_init(struct phy_device *phydev)
+{
+       /* Set registers from marvell,reg-init DT property */
        return marvell_of_reg_init(phydev);
 }
 
@@ -495,7 +501,7 @@ static int m88e1116r_config_init(struct phy_device *phydev)
 
        mdelay(500);
 
-       return 0;
+       return marvell_config_init(phydev);
 }
 
 static int m88e3016_config_init(struct phy_device *phydev)
@@ -514,7 +520,7 @@ static int m88e3016_config_init(struct phy_device *phydev)
        if (reg < 0)
                return reg;
 
-       return 0;
+       return marvell_config_init(phydev);
 }
 
 static int m88e1111_config_init(struct phy_device *phydev)
@@ -1078,6 +1084,7 @@ static struct phy_driver marvell_drivers[] = {
                .features = PHY_GBIT_FEATURES,
                .probe = marvell_probe,
                .flags = PHY_HAS_INTERRUPT,
+               .config_init = &marvell_config_init,
                .config_aneg = &marvell_config_aneg,
                .read_status = &genphy_read_status,
                .ack_interrupt = &marvell_ack_interrupt,
@@ -1149,6 +1156,7 @@ static struct phy_driver marvell_drivers[] = {
                .features = PHY_GBIT_FEATURES,
                .flags = PHY_HAS_INTERRUPT,
                .probe = marvell_probe,
+               .config_init = &marvell_config_init,
                .config_aneg = &m88e1121_config_aneg,
                .read_status = &marvell_read_status,
                .ack_interrupt = &marvell_ack_interrupt,
@@ -1167,6 +1175,7 @@ static struct phy_driver marvell_drivers[] = {
                .features = PHY_GBIT_FEATURES,
                .flags = PHY_HAS_INTERRUPT,
                .probe = marvell_probe,
+               .config_init = &marvell_config_init,
                .config_aneg = &m88e1318_config_aneg,
                .read_status = &marvell_read_status,
                .ack_interrupt = &marvell_ack_interrupt,
@@ -1259,6 +1268,7 @@ static struct phy_driver marvell_drivers[] = {
                .features = PHY_GBIT_FEATURES,
                .flags = PHY_HAS_INTERRUPT,
                .probe = marvell_probe,
+               .config_init = &marvell_config_init,
                .config_aneg = &m88e1510_config_aneg,
                .read_status = &marvell_read_status,
                .ack_interrupt = &marvell_ack_interrupt,
@@ -1277,6 +1287,7 @@ static struct phy_driver marvell_drivers[] = {
                .features = PHY_GBIT_FEATURES,
                .flags = PHY_HAS_INTERRUPT,
                .probe = marvell_probe,
+               .config_init = &marvell_config_init,
                .config_aneg = &m88e1510_config_aneg,
                .read_status = &marvell_read_status,
                .ack_interrupt = &marvell_ack_interrupt,
index 03833db..dc85f70 100644 (file)
@@ -297,6 +297,17 @@ static int kszphy_config_init(struct phy_device *phydev)
        if (priv->led_mode >= 0)
                kszphy_setup_led(phydev, type->led_mode_reg, priv->led_mode);
 
+       if (phy_interrupt_is_valid(phydev)) {
+               int ctl = phy_read(phydev, MII_BMCR);
+
+               if (ctl < 0)
+                       return ctl;
+
+               ret = phy_write(phydev, MII_BMCR, ctl & ~BMCR_ANENABLE);
+               if (ret < 0)
+                       return ret;
+       }
+
        return 0;
 }
 
@@ -635,6 +646,21 @@ static void kszphy_get_stats(struct phy_device *phydev,
                data[i] = kszphy_get_stat(phydev, i);
 }
 
+static int kszphy_resume(struct phy_device *phydev)
+{
+       int value;
+
+       mutex_lock(&phydev->lock);
+
+       value = phy_read(phydev, MII_BMCR);
+       phy_write(phydev, MII_BMCR, value & ~BMCR_PDOWN);
+
+       kszphy_config_intr(phydev);
+       mutex_unlock(&phydev->lock);
+
+       return 0;
+}
+
 static int kszphy_probe(struct phy_device *phydev)
 {
        const struct kszphy_type *type = phydev->drv->driver_data;
@@ -844,7 +870,7 @@ static struct phy_driver ksphy_driver[] = {
        .get_strings    = kszphy_get_strings,
        .get_stats      = kszphy_get_stats,
        .suspend        = genphy_suspend,
-       .resume         = genphy_resume,
+       .resume         = kszphy_resume,
 }, {
        .phy_id         = PHY_ID_KSZ8061,
        .name           = "Micrel KSZ8061",
index bad3f00..e551f3a 100644 (file)
@@ -1410,7 +1410,7 @@ int genphy_config_init(struct phy_device *phydev)
 
        features = (SUPPORTED_TP | SUPPORTED_MII
                        | SUPPORTED_AUI | SUPPORTED_FIBRE |
-                       SUPPORTED_BNC);
+                       SUPPORTED_BNC | SUPPORTED_Pause | SUPPORTED_Asym_Pause);
 
        /* Do we support autonegotiation? */
        val = phy_read(phydev, MII_BMSR);
index fc8ad00..d61da9e 100644 (file)
@@ -443,9 +443,14 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
                         * network traffic (demand mode).
                         */
                        struct ppp *ppp = PF_TO_PPP(pf);
+
+                       ppp_recv_lock(ppp);
                        if (ppp->n_channels == 0 &&
-                           (ppp->flags & SC_LOOP_TRAFFIC) == 0)
+                           (ppp->flags & SC_LOOP_TRAFFIC) == 0) {
+                               ppp_recv_unlock(ppp);
                                break;
+                       }
+                       ppp_recv_unlock(ppp);
                }
                ret = -EAGAIN;
                if (file->f_flags & O_NONBLOCK)
@@ -532,9 +537,12 @@ static unsigned int ppp_poll(struct file *file, poll_table *wait)
        else if (pf->kind == INTERFACE) {
                /* see comment in ppp_read */
                struct ppp *ppp = PF_TO_PPP(pf);
+
+               ppp_recv_lock(ppp);
                if (ppp->n_channels == 0 &&
                    (ppp->flags & SC_LOOP_TRAFFIC) == 0)
                        mask |= POLLIN | POLLRDNORM;
+               ppp_recv_unlock(ppp);
        }
 
        return mask;
@@ -2808,6 +2816,7 @@ static struct ppp *ppp_create_interface(struct net *net, int unit,
 
 out2:
        mutex_unlock(&pn->all_ppp_mutex);
+       rtnl_unlock();
        free_netdev(dev);
 out1:
        *retp = ret;
index f3c6302..4ddae81 100644 (file)
@@ -395,6 +395,8 @@ static int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb)
 
                if (!__pppoe_xmit(sk_pppox(relay_po), skb))
                        goto abort_put;
+
+               sock_put(sk_pppox(relay_po));
        } else {
                if (sock_queue_rcv_skb(sk, skb))
                        goto abort_kfree;
index 7f83504..cdde590 100644 (file)
@@ -395,6 +395,10 @@ config USB_NET_RNDIS_HOST
          The protocol specification is incomplete, and is controlled by
          (and for) Microsoft; it isn't an "Open" ecosystem or market.
 
+config USB_NET_CDC_SUBSET_ENABLE
+       tristate
+       depends on USB_NET_CDC_SUBSET
+
 config USB_NET_CDC_SUBSET
        tristate "Simple USB Network Links (CDC Ethernet subset)"
        depends on USB_USBNET
@@ -413,6 +417,7 @@ config USB_NET_CDC_SUBSET
 config USB_ALI_M5632
        bool "ALi M5632 based 'USB 2.0 Data Link' cables"
        depends on USB_NET_CDC_SUBSET
+       select USB_NET_CDC_SUBSET_ENABLE
        help
          Choose this option if you're using a host-to-host cable
          based on this design, which supports USB 2.0 high speed.
@@ -420,6 +425,7 @@ config USB_ALI_M5632
 config USB_AN2720
        bool "AnchorChips 2720 based cables (Xircom PGUNET, ...)"
        depends on USB_NET_CDC_SUBSET
+       select USB_NET_CDC_SUBSET_ENABLE
        help
          Choose this option if you're using a host-to-host cable
          based on this design.  Note that AnchorChips is now a
@@ -428,6 +434,7 @@ config USB_AN2720
 config USB_BELKIN
        bool "eTEK based host-to-host cables (Advance, Belkin, ...)"
        depends on USB_NET_CDC_SUBSET
+       select USB_NET_CDC_SUBSET_ENABLE
        default y
        help
          Choose this option if you're using a host-to-host cable
@@ -437,6 +444,7 @@ config USB_BELKIN
 config USB_ARMLINUX
        bool "Embedded ARM Linux links (iPaq, ...)"
        depends on USB_NET_CDC_SUBSET
+       select USB_NET_CDC_SUBSET_ENABLE
        default y
        help
          Choose this option to support the "usb-eth" networking driver
@@ -454,6 +462,7 @@ config USB_ARMLINUX
 config USB_EPSON2888
        bool "Epson 2888 based firmware (DEVELOPMENT)"
        depends on USB_NET_CDC_SUBSET
+       select USB_NET_CDC_SUBSET_ENABLE
        help
          Choose this option to support the usb networking links used
          by some sample firmware from Epson.
@@ -461,6 +470,7 @@ config USB_EPSON2888
 config USB_KC2190
        bool "KT Technology KC2190 based cables (InstaNet)"
        depends on USB_NET_CDC_SUBSET
+       select USB_NET_CDC_SUBSET_ENABLE
        help
          Choose this option if you're using a host-to-host cable
          with one of these chips.
index b5f0406..37fb46a 100644 (file)
@@ -23,7 +23,7 @@ obj-$(CONFIG_USB_NET_GL620A)  += gl620a.o
 obj-$(CONFIG_USB_NET_NET1080)  += net1080.o
 obj-$(CONFIG_USB_NET_PLUSB)    += plusb.o
 obj-$(CONFIG_USB_NET_RNDIS_HOST)       += rndis_host.o
-obj-$(CONFIG_USB_NET_CDC_SUBSET)       += cdc_subset.o
+obj-$(CONFIG_USB_NET_CDC_SUBSET_ENABLE)        += cdc_subset.o
 obj-$(CONFIG_USB_NET_ZAURUS)   += zaurus.o
 obj-$(CONFIG_USB_NET_MCS7830)  += mcs7830.o
 obj-$(CONFIG_USB_USBNET)       += usbnet.o
index 224e7d8..cf77f2d 100644 (file)
@@ -134,7 +134,6 @@ static void ax88172a_remove_mdio(struct usbnet *dev)
 
        netdev_info(dev->net, "deregistering mdio bus %s\n", priv->mdio->id);
        mdiobus_unregister(priv->mdio);
-       kfree(priv->mdio->irq);
        mdiobus_free(priv->mdio);
 }
 
index dc0212c..86ba30b 100644 (file)
@@ -837,7 +837,11 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
 
        iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber;
 
-       /* reset data interface */
+       /* Reset data interface. Some devices will not reset properly
+        * unless they are configured first.  Toggle the altsetting to
+        * force a reset
+        */
+       usb_set_interface(dev->udev, iface_no, data_altsetting);
        temp = usb_set_interface(dev->udev, iface_no, 0);
        if (temp) {
                dev_dbg(&intf->dev, "set interface failed\n");
@@ -984,8 +988,6 @@ EXPORT_SYMBOL_GPL(cdc_ncm_select_altsetting);
 
 static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
 {
-       int ret;
-
        /* MBIM backwards compatible function? */
        if (cdc_ncm_select_altsetting(intf) != CDC_NCM_COMM_ALTSETTING_NCM)
                return -ENODEV;
@@ -994,16 +996,7 @@ static int cdc_ncm_bind(struct usbnet *dev, struct usb_interface *intf)
         * Additionally, generic NCM devices are assumed to accept arbitrarily
         * placed NDP.
         */
-       ret = cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM, 0);
-
-       /*
-        * We should get an event when network connection is "connected" or
-        * "disconnected". Set network connection in "disconnected" state
-        * (carrier is OFF) during attach, so the IP network stack does not
-        * start IPv6 negotiation and more.
-        */
-       usbnet_link_change(dev, 0, 0);
-       return ret;
+       return cdc_ncm_bind_common(dev, intf, CDC_NCM_DATA_ALTSETTING_NCM, 0);
 }
 
 static void cdc_ncm_align_tail(struct sk_buff *skb, size_t modulus, size_t remainder, size_t max)
@@ -1586,7 +1579,8 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb)
 
 static const struct driver_info cdc_ncm_info = {
        .description = "CDC NCM",
-       .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET,
+       .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
+                       | FLAG_LINK_INTR,
        .bind = cdc_ncm_bind,
        .unbind = cdc_ncm_unbind,
        .manage_power = usbnet_manage_power,
@@ -1599,7 +1593,7 @@ static const struct driver_info cdc_ncm_info = {
 static const struct driver_info wwan_info = {
        .description = "Mobile Broadband Network Device",
        .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
-                       | FLAG_WWAN,
+                       | FLAG_LINK_INTR | FLAG_WWAN,
        .bind = cdc_ncm_bind,
        .unbind = cdc_ncm_unbind,
        .manage_power = usbnet_manage_power,
@@ -1612,7 +1606,7 @@ static const struct driver_info wwan_info = {
 static const struct driver_info wwan_noarp_info = {
        .description = "Mobile Broadband Network Device (NO ARP)",
        .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET
-                       | FLAG_WWAN | FLAG_NOARP,
+                       | FLAG_LINK_INTR | FLAG_WWAN | FLAG_NOARP,
        .bind = cdc_ncm_bind,
        .unbind = cdc_ncm_unbind,
        .manage_power = usbnet_manage_power,
index 23e9880..a3a4ccf 100644 (file)
@@ -637,6 +637,7 @@ static const struct usb_device_id products[] = {
 
        /* 3. Combined interface devices matching on interface number */
        {QMI_FIXED_INTF(0x0408, 0xea42, 4)},    /* Yota / Megafon M100-1 */
+       {QMI_FIXED_INTF(0x05c6, 0x6001, 3)},    /* 4G LTE usb-modem U901 */
        {QMI_FIXED_INTF(0x05c6, 0x7000, 0)},
        {QMI_FIXED_INTF(0x05c6, 0x7001, 1)},
        {QMI_FIXED_INTF(0x05c6, 0x7002, 1)},
@@ -860,8 +861,10 @@ static const struct usb_device_id products[] = {
        {QMI_FIXED_INTF(0x1199, 0x9056, 8)},    /* Sierra Wireless Modem */
        {QMI_FIXED_INTF(0x1199, 0x9057, 8)},
        {QMI_FIXED_INTF(0x1199, 0x9061, 8)},    /* Sierra Wireless Modem */
-       {QMI_FIXED_INTF(0x1199, 0x9071, 8)},    /* Sierra Wireless MC74xx/EM74xx */
-       {QMI_FIXED_INTF(0x1199, 0x9071, 10)},   /* Sierra Wireless MC74xx/EM74xx */
+       {QMI_FIXED_INTF(0x1199, 0x9071, 8)},    /* Sierra Wireless MC74xx */
+       {QMI_FIXED_INTF(0x1199, 0x9071, 10)},   /* Sierra Wireless MC74xx */
+       {QMI_FIXED_INTF(0x1199, 0x9079, 8)},    /* Sierra Wireless EM74xx */
+       {QMI_FIXED_INTF(0x1199, 0x9079, 10)},   /* Sierra Wireless EM74xx */
        {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)},    /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
        {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)},    /* Alcatel L800MA */
        {QMI_FIXED_INTF(0x2357, 0x0201, 4)},    /* TP-LINK HSUPA Modem MA180 */
@@ -884,6 +887,7 @@ static const struct usb_device_id products[] = {
        {QMI_FIXED_INTF(0x413c, 0x81a8, 8)},    /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
        {QMI_FIXED_INTF(0x413c, 0x81a9, 8)},    /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
        {QMI_FIXED_INTF(0x413c, 0x81b1, 8)},    /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */
+       {QMI_FIXED_INTF(0x413c, 0x81b3, 8)},    /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */
        {QMI_FIXED_INTF(0x03f0, 0x4e1d, 8)},    /* HP lt4111 LTE/EV-DO/HSPA+ Gobi 4G Module */
        {QMI_FIXED_INTF(0x22de, 0x9061, 3)},    /* WeTelecom WPD-600N */
        {QMI_FIXED_INTF(0x1e0e, 0x9001, 5)},    /* SIMCom 7230E */
index 0b0ba7e..1079812 100644 (file)
@@ -1769,6 +1769,13 @@ out3:
        if (info->unbind)
                info->unbind (dev, udev);
 out1:
+       /* subdrivers must undo all they did in bind() if they
+        * fail it, but we may fail later and a deferred kevent
+        * may trigger an error resubmitting itself and, worse,
+        * schedule a timer. So we kill it all just in case.
+        */
+       cancel_work_sync(&dev->kevent);
+       del_timer_sync(&dev->delay);
        free_netdev(net);
 out:
        return status;
index 221a530..72ba8ae 100644 (file)
@@ -377,7 +377,7 @@ union Vmxnet3_GenericDesc {
 #define VMXNET3_TX_RING_MAX_SIZE   4096
 #define VMXNET3_TC_RING_MAX_SIZE   4096
 #define VMXNET3_RX_RING_MAX_SIZE   4096
-#define VMXNET3_RX_RING2_MAX_SIZE  2048
+#define VMXNET3_RX_RING2_MAX_SIZE  4096
 #define VMXNET3_RC_RING_MAX_SIZE   8192
 
 /* a list of reasons for queue stop */
index 0cbf520..fc895d0 100644 (file)
@@ -814,7 +814,7 @@ vmxnet3_tq_init_all(struct vmxnet3_adapter *adapter)
 
 
 /*
- *    parse and copy relevant protocol headers:
+ *    parse relevant protocol headers:
  *      For a tso pkt, relevant headers are L2/3/4 including options
  *      For a pkt requesting csum offloading, they are L2/3 and may include L4
  *      if it's a TCP/UDP pkt
@@ -827,15 +827,14 @@ vmxnet3_tq_init_all(struct vmxnet3_adapter *adapter)
  * Other effects:
  *    1. related *ctx fields are updated.
  *    2. ctx->copy_size is # of bytes copied
- *    3. the portion copied is guaranteed to be in the linear part
+ *    3. the portion to be copied is guaranteed to be in the linear part
  *
  */
 static int
-vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
-                          struct vmxnet3_tx_ctx *ctx,
-                          struct vmxnet3_adapter *adapter)
+vmxnet3_parse_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
+                 struct vmxnet3_tx_ctx *ctx,
+                 struct vmxnet3_adapter *adapter)
 {
-       struct Vmxnet3_TxDataDesc *tdd;
        u8 protocol = 0;
 
        if (ctx->mss) { /* TSO */
@@ -892,16 +891,34 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
                return 0;
        }
 
+       return 1;
+err:
+       return -1;
+}
+
+/*
+ *    copy relevant protocol headers to the transmit ring:
+ *      For a tso pkt, relevant headers are L2/3/4 including options
+ *      For a pkt requesting csum offloading, they are L2/3 and may include L4
+ *      if it's a TCP/UDP pkt
+ *
+ *
+ *    Note that this requires that vmxnet3_parse_hdr be called first to set the
+ *      appropriate bits in ctx first
+ */
+static void
+vmxnet3_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
+                struct vmxnet3_tx_ctx *ctx,
+                struct vmxnet3_adapter *adapter)
+{
+       struct Vmxnet3_TxDataDesc *tdd;
+
        tdd = tq->data_ring.base + tq->tx_ring.next2fill;
 
        memcpy(tdd->data, skb->data, ctx->copy_size);
        netdev_dbg(adapter->netdev,
                "copy %u bytes to dataRing[%u]\n",
                ctx->copy_size, tq->tx_ring.next2fill);
-       return 1;
-
-err:
-       return -1;
 }
 
 
@@ -998,22 +1015,7 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
                }
        }
 
-       spin_lock_irqsave(&tq->tx_lock, flags);
-
-       if (count > vmxnet3_cmd_ring_desc_avail(&tq->tx_ring)) {
-               tq->stats.tx_ring_full++;
-               netdev_dbg(adapter->netdev,
-                       "tx queue stopped on %s, next2comp %u"
-                       " next2fill %u\n", adapter->netdev->name,
-                       tq->tx_ring.next2comp, tq->tx_ring.next2fill);
-
-               vmxnet3_tq_stop(tq, adapter);
-               spin_unlock_irqrestore(&tq->tx_lock, flags);
-               return NETDEV_TX_BUSY;
-       }
-
-
-       ret = vmxnet3_parse_and_copy_hdr(skb, tq, &ctx, adapter);
+       ret = vmxnet3_parse_hdr(skb, tq, &ctx, adapter);
        if (ret >= 0) {
                BUG_ON(ret <= 0 && ctx.copy_size != 0);
                /* hdrs parsed, check against other limits */
@@ -1033,9 +1035,26 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
                }
        } else {
                tq->stats.drop_hdr_inspect_err++;
-               goto unlock_drop_pkt;
+               goto drop_pkt;
        }
 
+       spin_lock_irqsave(&tq->tx_lock, flags);
+
+       if (count > vmxnet3_cmd_ring_desc_avail(&tq->tx_ring)) {
+               tq->stats.tx_ring_full++;
+               netdev_dbg(adapter->netdev,
+                       "tx queue stopped on %s, next2comp %u"
+                       " next2fill %u\n", adapter->netdev->name,
+                       tq->tx_ring.next2comp, tq->tx_ring.next2fill);
+
+               vmxnet3_tq_stop(tq, adapter);
+               spin_unlock_irqrestore(&tq->tx_lock, flags);
+               return NETDEV_TX_BUSY;
+       }
+
+
+       vmxnet3_copy_hdr(skb, tq, &ctx, adapter);
+
        /* fill tx descs related to addr & len */
        if (vmxnet3_map_pkt(skb, &ctx, tq, adapter->pdev, adapter))
                goto unlock_drop_pkt;
index bdb8a6c..729c344 100644 (file)
 /*
  * Version numbers
  */
-#define VMXNET3_DRIVER_VERSION_STRING   "1.4.5.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING   "1.4.6.0-k"
 
 /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM      0x01040500
+#define VMXNET3_DRIVER_VERSION_NUM      0x01040600
 
 #if defined(CONFIG_PCI_MSI)
        /* RSS only makes sense if MSI-X is supported. */
index 66addb7..bdcf617 100644 (file)
@@ -104,20 +104,23 @@ static struct dst_ops vrf_dst_ops = {
 #if IS_ENABLED(CONFIG_IPV6)
 static bool check_ipv6_frame(const struct sk_buff *skb)
 {
-       const struct ipv6hdr *ipv6h = (struct ipv6hdr *)skb->data;
-       size_t hlen = sizeof(*ipv6h);
+       const struct ipv6hdr *ipv6h;
+       struct ipv6hdr _ipv6h;
        bool rc = true;
 
-       if (skb->len < hlen)
+       ipv6h = skb_header_pointer(skb, 0, sizeof(_ipv6h), &_ipv6h);
+       if (!ipv6h)
                goto out;
 
        if (ipv6h->nexthdr == NEXTHDR_ICMP) {
                const struct icmp6hdr *icmph;
+               struct icmp6hdr _icmph;
 
-               if (skb->len < hlen + sizeof(*icmph))
+               icmph = skb_header_pointer(skb, sizeof(_ipv6h),
+                                          sizeof(_icmph), &_icmph);
+               if (!icmph)
                        goto out;
 
-               icmph = (struct icmp6hdr *)(skb->data + sizeof(*ipv6h));
                switch (icmph->icmp6_type) {
                case NDISC_ROUTER_SOLICITATION:
                case NDISC_ROUTER_ADVERTISEMENT:
index 6543918..1c32bd1 100644 (file)
@@ -931,8 +931,10 @@ static int vxlan_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
                                                     cb->nlh->nlmsg_seq,
                                                     RTM_NEWNEIGH,
                                                     NLM_F_MULTI, rd);
-                               if (err < 0)
+                               if (err < 0) {
+                                       cb->args[1] = err;
                                        goto out;
+                               }
 skip:
                                ++idx;
                        }
@@ -1306,8 +1308,10 @@ static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
                gbp = (struct vxlanhdr_gbp *)vxh;
                md->gbp = ntohs(gbp->policy_id);
 
-               if (tun_dst)
+               if (tun_dst) {
                        tun_dst->u.tun_info.key.tun_flags |= TUNNEL_VXLAN_OPT;
+                       tun_dst->u.tun_info.options_len = sizeof(*md);
+               }
 
                if (gbp->dont_learn)
                        md->gbp |= VXLAN_GBP_DONT_LEARN;
@@ -2171,9 +2175,11 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
 #endif
        }
 
-       if (vxlan->flags & VXLAN_F_COLLECT_METADATA &&
-           info && info->mode & IP_TUNNEL_INFO_TX) {
-               vxlan_xmit_one(skb, dev, NULL, false);
+       if (vxlan->flags & VXLAN_F_COLLECT_METADATA) {
+               if (info && info->mode & IP_TUNNEL_INFO_TX)
+                       vxlan_xmit_one(skb, dev, NULL, false);
+               else
+                       kfree_skb(skb);
                return NETDEV_TX_OK;
        }
 
@@ -2367,29 +2373,43 @@ static void vxlan_set_multicast_list(struct net_device *dev)
 {
 }
 
-static int vxlan_change_mtu(struct net_device *dev, int new_mtu)
+static int __vxlan_change_mtu(struct net_device *dev,
+                             struct net_device *lowerdev,
+                             struct vxlan_rdst *dst, int new_mtu, bool strict)
 {
-       struct vxlan_dev *vxlan = netdev_priv(dev);
-       struct vxlan_rdst *dst = &vxlan->default_dst;
-       struct net_device *lowerdev;
-       int max_mtu;
+       int max_mtu = IP_MAX_MTU;
 
-       lowerdev = __dev_get_by_index(vxlan->net, dst->remote_ifindex);
-       if (lowerdev == NULL)
-               return eth_change_mtu(dev, new_mtu);
+       if (lowerdev)
+               max_mtu = lowerdev->mtu;
 
        if (dst->remote_ip.sa.sa_family == AF_INET6)
-               max_mtu = lowerdev->mtu - VXLAN6_HEADROOM;
+               max_mtu -= VXLAN6_HEADROOM;
        else
-               max_mtu = lowerdev->mtu - VXLAN_HEADROOM;
+               max_mtu -= VXLAN_HEADROOM;
 
-       if (new_mtu < 68 || new_mtu > max_mtu)
+       if (new_mtu < 68)
                return -EINVAL;
 
+       if (new_mtu > max_mtu) {
+               if (strict)
+                       return -EINVAL;
+
+               new_mtu = max_mtu;
+       }
+
        dev->mtu = new_mtu;
        return 0;
 }
 
+static int vxlan_change_mtu(struct net_device *dev, int new_mtu)
+{
+       struct vxlan_dev *vxlan = netdev_priv(dev);
+       struct vxlan_rdst *dst = &vxlan->default_dst;
+       struct net_device *lowerdev = __dev_get_by_index(vxlan->net,
+                                                        dst->remote_ifindex);
+       return __vxlan_change_mtu(dev, lowerdev, dst, new_mtu, true);
+}
+
 static int egress_ipv4_tun_info(struct net_device *dev, struct sk_buff *skb,
                                struct ip_tunnel_info *info,
                                __be16 sport, __be16 dport)
@@ -2523,6 +2543,7 @@ static void vxlan_setup(struct net_device *dev)
        dev->hw_features |= NETIF_F_GSO_SOFTWARE;
        dev->hw_features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX;
        netif_keep_dst(dev);
+       dev->priv_flags &= ~IFF_TX_SKB_SHARING;
        dev->priv_flags |= IFF_LIVE_ADDR_CHANGE | IFF_NO_QUEUE;
 
        INIT_LIST_HEAD(&vxlan->next);
@@ -2765,6 +2786,7 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
        int err;
        bool use_ipv6 = false;
        __be16 default_port = vxlan->cfg.dst_port;
+       struct net_device *lowerdev = NULL;
 
        vxlan->net = src_net;
 
@@ -2785,9 +2807,7 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
        }
 
        if (conf->remote_ifindex) {
-               struct net_device *lowerdev
-                        = __dev_get_by_index(src_net, conf->remote_ifindex);
-
+               lowerdev = __dev_get_by_index(src_net, conf->remote_ifindex);
                dst->remote_ifindex = conf->remote_ifindex;
 
                if (!lowerdev) {
@@ -2811,6 +2831,12 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
                needed_headroom = lowerdev->hard_header_len;
        }
 
+       if (conf->mtu) {
+               err = __vxlan_change_mtu(dev, lowerdev, dst, conf->mtu, false);
+               if (err)
+                       return err;
+       }
+
        if (use_ipv6 || conf->flags & VXLAN_F_COLLECT_METADATA)
                needed_headroom += VXLAN6_HEADROOM;
        else
index 7a72407..6292259 100644 (file)
@@ -1626,7 +1626,7 @@ try:
                if (state & Xpr) {
                        void __iomem *scc_addr;
                        unsigned long ring;
-                       int i;
+                       unsigned int i;
 
                        /*
                         * - the busy condition happens (sometimes);
index 8660677..7438fbe 100644 (file)
@@ -53,7 +53,6 @@ config IWLWIFI_LEDS
 
 config IWLDVM
        tristate "Intel Wireless WiFi DVM Firmware support"
-       depends on m
        help
          This is the driver that supports the DVM firmware. The list
          of the devices that use this firmware is available here:
index c84a029..bce9b34 100644 (file)
@@ -7,6 +7,7 @@
  *
  * Copyright(c) 2014 Intel Corporation. All rights reserved.
  * Copyright(c) 2014 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
  *
  * 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
 
 /* Highest firmware API version supported */
 #define IWL8000_UCODE_API_MAX  20
+#define IWL8265_UCODE_API_MAX  20
 
 /* Oldest version we won't warn about */
 #define IWL8000_UCODE_API_OK   13
+#define IWL8265_UCODE_API_OK   20
 
 /* Lowest firmware API version supported */
 #define IWL8000_UCODE_API_MIN  13
+#define IWL8265_UCODE_API_MIN  20
 
 /* NVM versions */
 #define IWL8000_NVM_VERSION            0x0a1d
 #define IWL8000_MODULE_FIRMWARE(api) \
        IWL8000_FW_PRE "-" __stringify(api) ".ucode"
 
+#define IWL8265_FW_PRE "iwlwifi-8265-"
+#define IWL8265_MODULE_FIRMWARE(api) \
+       IWL8265_FW_PRE __stringify(api) ".ucode"
+
 #define NVM_HW_SECTION_NUM_FAMILY_8000         10
 #define DEFAULT_NVM_FILE_FAMILY_8000B          "nvmData-8000B"
 #define DEFAULT_NVM_FILE_FAMILY_8000C          "nvmData-8000C"
@@ -144,10 +152,7 @@ static const struct iwl_tt_params iwl8000_tt_params = {
        .support_tx_backoff = true,
 };
 
-#define IWL_DEVICE_8000                                                        \
-       .ucode_api_max = IWL8000_UCODE_API_MAX,                         \
-       .ucode_api_ok = IWL8000_UCODE_API_OK,                           \
-       .ucode_api_min = IWL8000_UCODE_API_MIN,                         \
+#define IWL_DEVICE_8000_COMMON                                         \
        .device_family = IWL_DEVICE_FAMILY_8000,                        \
        .max_inst_size = IWL60_RTC_INST_SIZE,                           \
        .max_data_size = IWL60_RTC_DATA_SIZE,                           \
@@ -167,10 +172,28 @@ static const struct iwl_tt_params iwl8000_tt_params = {
        .thermal_params = &iwl8000_tt_params,                           \
        .apmg_not_supported = true
 
+#define IWL_DEVICE_8000                                                        \
+       IWL_DEVICE_8000_COMMON,                                         \
+       .ucode_api_max = IWL8000_UCODE_API_MAX,                         \
+       .ucode_api_ok = IWL8000_UCODE_API_OK,                           \
+       .ucode_api_min = IWL8000_UCODE_API_MIN                          \
+
+#define IWL_DEVICE_8260                                                        \
+       IWL_DEVICE_8000_COMMON,                                         \
+       .ucode_api_max = IWL8000_UCODE_API_MAX,                         \
+       .ucode_api_ok = IWL8000_UCODE_API_OK,                           \
+       .ucode_api_min = IWL8000_UCODE_API_MIN                          \
+
+#define IWL_DEVICE_8265                                                        \
+       IWL_DEVICE_8000_COMMON,                                         \
+       .ucode_api_max = IWL8265_UCODE_API_MAX,                         \
+       .ucode_api_ok = IWL8265_UCODE_API_OK,                           \
+       .ucode_api_min = IWL8265_UCODE_API_MIN                          \
+
 const struct iwl_cfg iwl8260_2n_cfg = {
        .name = "Intel(R) Dual Band Wireless N 8260",
        .fw_name_pre = IWL8000_FW_PRE,
-       IWL_DEVICE_8000,
+       IWL_DEVICE_8260,
        .ht_params = &iwl8000_ht_params,
        .nvm_ver = IWL8000_NVM_VERSION,
        .nvm_calib_ver = IWL8000_TX_POWER_VERSION,
@@ -179,7 +202,7 @@ const struct iwl_cfg iwl8260_2n_cfg = {
 const struct iwl_cfg iwl8260_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 8260",
        .fw_name_pre = IWL8000_FW_PRE,
-       IWL_DEVICE_8000,
+       IWL_DEVICE_8260,
        .ht_params = &iwl8000_ht_params,
        .nvm_ver = IWL8000_NVM_VERSION,
        .nvm_calib_ver = IWL8000_TX_POWER_VERSION,
@@ -188,8 +211,8 @@ const struct iwl_cfg iwl8260_2ac_cfg = {
 
 const struct iwl_cfg iwl8265_2ac_cfg = {
        .name = "Intel(R) Dual Band Wireless AC 8265",
-       .fw_name_pre = IWL8000_FW_PRE,
-       IWL_DEVICE_8000,
+       .fw_name_pre = IWL8265_FW_PRE,
+       IWL_DEVICE_8265,
        .ht_params = &iwl8000_ht_params,
        .nvm_ver = IWL8000_NVM_VERSION,
        .nvm_calib_ver = IWL8000_TX_POWER_VERSION,
@@ -209,7 +232,7 @@ const struct iwl_cfg iwl4165_2ac_cfg = {
 const struct iwl_cfg iwl8260_2ac_sdio_cfg = {
        .name = "Intel(R) Dual Band Wireless-AC 8260",
        .fw_name_pre = IWL8000_FW_PRE,
-       IWL_DEVICE_8000,
+       IWL_DEVICE_8260,
        .ht_params = &iwl8000_ht_params,
        .nvm_ver = IWL8000_NVM_VERSION,
        .nvm_calib_ver = IWL8000_TX_POWER_VERSION,
@@ -236,3 +259,4 @@ const struct iwl_cfg iwl4165_2ac_sdio_cfg = {
 };
 
 MODULE_FIRMWARE(IWL8000_MODULE_FIRMWARE(IWL8000_UCODE_API_OK));
+MODULE_FIRMWARE(IWL8265_MODULE_FIRMWARE(IWL8265_UCODE_API_OK));
index 7acb490..ab4c2a0 100644 (file)
@@ -243,8 +243,10 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first)
        if (drv->trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) {
                char rev_step = 'A' + CSR_HW_REV_STEP(drv->trans->hw_rev);
 
-               snprintf(drv->firmware_name, sizeof(drv->firmware_name),
-                        "%s%c-%s.ucode", name_pre, rev_step, tag);
+               if (rev_step != 'A')
+                       snprintf(drv->firmware_name,
+                                sizeof(drv->firmware_name), "%s%c-%s.ucode",
+                                name_pre, rev_step, tag);
        }
 
        IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n",
index 4ed5180..0ccc697 100644 (file)
@@ -107,7 +107,7 @@ static int iwl_send_tx_ant_cfg(struct iwl_mvm *mvm, u8 valid_tx_ant)
                                    sizeof(tx_ant_cmd), &tx_ant_cmd);
 }
 
-static void iwl_free_fw_paging(struct iwl_mvm *mvm)
+void iwl_free_fw_paging(struct iwl_mvm *mvm)
 {
        int i;
 
@@ -127,6 +127,8 @@ static void iwl_free_fw_paging(struct iwl_mvm *mvm)
                             get_order(mvm->fw_paging_db[i].fw_paging_size));
        }
        kfree(mvm->trans->paging_download_buf);
+       mvm->trans->paging_download_buf = NULL;
+
        memset(mvm->fw_paging_db, 0, sizeof(mvm->fw_paging_db));
 }
 
index 5f3ac8c..ff7c6df 100644 (file)
@@ -1225,6 +1225,9 @@ void iwl_mvm_rx_umac_scan_complete_notif(struct iwl_mvm *mvm,
 void iwl_mvm_rx_umac_scan_iter_complete_notif(struct iwl_mvm *mvm,
                                              struct iwl_rx_cmd_buffer *rxb);
 
+/* Paging */
+void iwl_free_fw_paging(struct iwl_mvm *mvm);
+
 /* MVM debugfs */
 #ifdef CONFIG_IWLWIFI_DEBUGFS
 int iwl_mvm_dbgfs_register(struct iwl_mvm *mvm, struct dentry *dbgfs_dir);
index 89ea70d..e80be9a 100644 (file)
@@ -684,6 +684,8 @@ static void iwl_op_mode_mvm_stop(struct iwl_op_mode *op_mode)
        for (i = 0; i < NVM_MAX_NUM_SECTIONS; i++)
                kfree(mvm->nvm_sections[i].data);
 
+       iwl_free_fw_paging(mvm);
+
        iwl_mvm_tof_clean(mvm);
 
        ieee80211_free_hw(mvm->hw);
index 9a15642..ea1e177 100644 (file)
@@ -1298,6 +1298,10 @@ int iwl_mvm_sched_scan_start(struct iwl_mvm *mvm,
                return -EBUSY;
        }
 
+       /* we don't support "match all" in the firmware */
+       if (!req->n_match_sets)
+               return -EOPNOTSUPP;
+
        ret = iwl_mvm_check_running_scans(mvm, type);
        if (ret)
                return ret;
index 0914ec2..a040edc 100644 (file)
@@ -423,6 +423,15 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb)
                return -1;
        }
 
+       /*
+        * Increase the pending frames counter, so that later when a reply comes
+        * in and the counter is decreased - we don't start getting negative
+        * values.
+        * Note that we don't need to make sure it isn't agg'd, since we're
+        * TXing non-sta
+        */
+       atomic_inc(&mvm->pending_frames[sta_id]);
+
        return 0;
 }
 
index cc3888e..73c9559 100644 (file)
@@ -490,6 +490,15 @@ static inline void iwl_enable_interrupts(struct iwl_trans *trans)
        iwl_write32(trans, CSR_INT_MASK, trans_pcie->inta_mask);
 }
 
+static inline void iwl_enable_fw_load_int(struct iwl_trans *trans)
+{
+       struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
+
+       IWL_DEBUG_ISR(trans, "Enabling FW load interrupt\n");
+       trans_pcie->inta_mask = CSR_INT_BIT_FH_TX;
+       iwl_write32(trans, CSR_INT_MASK, trans_pcie->inta_mask);
+}
+
 static inline void iwl_enable_rfkill_int(struct iwl_trans *trans)
 {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
index ccafbd8..152cf9a 100644 (file)
@@ -1438,9 +1438,11 @@ irqreturn_t iwl_pcie_irq_handler(int irq, void *dev_id)
                         inta & ~trans_pcie->inta_mask);
        }
 
-       /* Re-enable all interrupts */
-       /* only Re-enable if disabled by irq */
-       if (test_bit(STATUS_INT_ENABLED, &trans->status))
+       /* we are loading the firmware, enable FH_TX interrupt only */
+       if (handled & CSR_INT_BIT_FH_TX)
+               iwl_enable_fw_load_int(trans);
+       /* only Re-enable all interrupt if disabled by irq */
+       else if (test_bit(STATUS_INT_ENABLED, &trans->status))
                iwl_enable_interrupts(trans);
        /* Re-enable RF_KILL if it occurred */
        else if (handled & CSR_INT_BIT_RF_KILL)
index d60a467..5a854c6 100644 (file)
@@ -1021,82 +1021,6 @@ static int iwl_pcie_load_given_ucode_8000(struct iwl_trans *trans,
                                               &first_ucode_section);
 }
 
-static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,
-                                  const struct fw_img *fw, bool run_in_rfkill)
-{
-       struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
-       bool hw_rfkill;
-       int ret;
-
-       mutex_lock(&trans_pcie->mutex);
-
-       /* Someone called stop_device, don't try to start_fw */
-       if (trans_pcie->is_down) {
-               IWL_WARN(trans,
-                        "Can't start_fw since the HW hasn't been started\n");
-               ret = EIO;
-               goto out;
-       }
-
-       /* This may fail if AMT took ownership of the device */
-       if (iwl_pcie_prepare_card_hw(trans)) {
-               IWL_WARN(trans, "Exit HW not ready\n");
-               ret = -EIO;
-               goto out;
-       }
-
-       iwl_enable_rfkill_int(trans);
-
-       /* If platform's RF_KILL switch is NOT set to KILL */
-       hw_rfkill = iwl_is_rfkill_set(trans);
-       if (hw_rfkill)
-               set_bit(STATUS_RFKILL, &trans->status);
-       else
-               clear_bit(STATUS_RFKILL, &trans->status);
-       iwl_trans_pcie_rf_kill(trans, hw_rfkill);
-       if (hw_rfkill && !run_in_rfkill) {
-               ret = -ERFKILL;
-               goto out;
-       }
-
-       iwl_write32(trans, CSR_INT, 0xFFFFFFFF);
-
-       ret = iwl_pcie_nic_init(trans);
-       if (ret) {
-               IWL_ERR(trans, "Unable to init nic\n");
-               goto out;
-       }
-
-       /* make sure rfkill handshake bits are cleared */
-       iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
-       iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR,
-                   CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
-
-       /* clear (again), then enable host interrupts */
-       iwl_write32(trans, CSR_INT, 0xFFFFFFFF);
-       iwl_enable_interrupts(trans);
-
-       /* really make sure rfkill handshake bits are cleared */
-       iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
-       iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
-
-       /* Load the given image to the HW */
-       if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000)
-               ret = iwl_pcie_load_given_ucode_8000(trans, fw);
-       else
-               ret = iwl_pcie_load_given_ucode(trans, fw);
-
-out:
-       mutex_unlock(&trans_pcie->mutex);
-       return ret;
-}
-
-static void iwl_trans_pcie_fw_alive(struct iwl_trans *trans, u32 scd_addr)
-{
-       iwl_pcie_reset_ict(trans);
-       iwl_pcie_tx_start(trans, scd_addr);
-}
-
 static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)
 {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
@@ -1127,7 +1051,8 @@ static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)
         * already dead.
         */
        if (test_and_clear_bit(STATUS_DEVICE_ENABLED, &trans->status)) {
-               IWL_DEBUG_INFO(trans, "DEVICE_ENABLED bit was set and is now cleared\n");
+               IWL_DEBUG_INFO(trans,
+                              "DEVICE_ENABLED bit was set and is now cleared\n");
                iwl_pcie_tx_stop(trans);
                iwl_pcie_rx_stop(trans);
 
@@ -1161,7 +1086,6 @@ static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)
        iwl_disable_interrupts(trans);
        spin_unlock(&trans_pcie->irq_lock);
 
-
        /* clear all status bits */
        clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);
        clear_bit(STATUS_INT_ENABLED, &trans->status);
@@ -1194,10 +1118,116 @@ static void _iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)
        if (hw_rfkill != was_hw_rfkill)
                iwl_trans_pcie_rf_kill(trans, hw_rfkill);
 
-       /* re-take ownership to prevent other users from stealing the deivce */
+       /* re-take ownership to prevent other users from stealing the device */
        iwl_pcie_prepare_card_hw(trans);
 }
 
+static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,
+                                  const struct fw_img *fw, bool run_in_rfkill)
+{
+       struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
+       bool hw_rfkill;
+       int ret;
+
+       /* This may fail if AMT took ownership of the device */
+       if (iwl_pcie_prepare_card_hw(trans)) {
+               IWL_WARN(trans, "Exit HW not ready\n");
+               ret = -EIO;
+               goto out;
+       }
+
+       iwl_enable_rfkill_int(trans);
+
+       iwl_write32(trans, CSR_INT, 0xFFFFFFFF);
+
+       /*
+        * We enabled the RF-Kill interrupt and the handler may very
+        * well be running. Disable the interrupts to make sure no other
+        * interrupt can be fired.
+        */
+       iwl_disable_interrupts(trans);
+
+       /* Make sure it finished running */
+       synchronize_irq(trans_pcie->pci_dev->irq);
+
+       mutex_lock(&trans_pcie->mutex);
+
+       /* If platform's RF_KILL switch is NOT set to KILL */
+       hw_rfkill = iwl_is_rfkill_set(trans);
+       if (hw_rfkill)
+               set_bit(STATUS_RFKILL, &trans->status);
+       else
+               clear_bit(STATUS_RFKILL, &trans->status);
+       iwl_trans_pcie_rf_kill(trans, hw_rfkill);
+       if (hw_rfkill && !run_in_rfkill) {
+               ret = -ERFKILL;
+               goto out;
+       }
+
+       /* Someone called stop_device, don't try to start_fw */
+       if (trans_pcie->is_down) {
+               IWL_WARN(trans,
+                        "Can't start_fw since the HW hasn't been started\n");
+               ret = -EIO;
+               goto out;
+       }
+
+       /* make sure rfkill handshake bits are cleared */
+       iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
+       iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR,
+                   CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED);
+
+       /* clear (again), then enable host interrupts */
+       iwl_write32(trans, CSR_INT, 0xFFFFFFFF);
+
+       ret = iwl_pcie_nic_init(trans);
+       if (ret) {
+               IWL_ERR(trans, "Unable to init nic\n");
+               goto out;
+       }
+
+       /*
+        * Now, we load the firmware and don't want to be interrupted, even
+        * by the RF-Kill interrupt (hence mask all the interrupt besides the
+        * FH_TX interrupt which is needed to load the firmware). If the
+        * RF-Kill switch is toggled, we will find out after having loaded
+        * the firmware and return the proper value to the caller.
+        */
+       iwl_enable_fw_load_int(trans);
+
+       /* really make sure rfkill handshake bits are cleared */
+       iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
+       iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
+
+       /* Load the given image to the HW */
+       if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000)
+               ret = iwl_pcie_load_given_ucode_8000(trans, fw);
+       else
+               ret = iwl_pcie_load_given_ucode(trans, fw);
+       iwl_enable_interrupts(trans);
+
+       /* re-check RF-Kill state since we may have missed the interrupt */
+       hw_rfkill = iwl_is_rfkill_set(trans);
+       if (hw_rfkill)
+               set_bit(STATUS_RFKILL, &trans->status);
+       else
+               clear_bit(STATUS_RFKILL, &trans->status);
+
+       iwl_trans_pcie_rf_kill(trans, hw_rfkill);
+       if (hw_rfkill && !run_in_rfkill)
+               ret = -ERFKILL;
+
+out:
+       mutex_unlock(&trans_pcie->mutex);
+       return ret;
+}
+
+static void iwl_trans_pcie_fw_alive(struct iwl_trans *trans, u32 scd_addr)
+{
+       iwl_pcie_reset_ict(trans);
+       iwl_pcie_tx_start(trans, scd_addr);
+}
+
 static void iwl_trans_pcie_stop_device(struct iwl_trans *trans, bool low_power)
 {
        struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
index 74c14ce..28f7010 100644 (file)
@@ -138,6 +138,11 @@ static void _rtl_rc_rate_set_series(struct rtl_priv *rtlpriv,
                    ((wireless_mode == WIRELESS_MODE_N_5G) ||
                     (wireless_mode == WIRELESS_MODE_N_24G)))
                        rate->flags |= IEEE80211_TX_RC_MCS;
+               if (sta && sta->vht_cap.vht_supported &&
+                   (wireless_mode == WIRELESS_MODE_AC_5G ||
+                    wireless_mode == WIRELESS_MODE_AC_24G ||
+                    wireless_mode == WIRELESS_MODE_AC_ONLY))
+                       rate->flags |= IEEE80211_TX_RC_VHT_MCS;
        }
 }
 
index 9ac118e..564ca75 100644 (file)
@@ -175,14 +175,14 @@ int wlcore_set_partition(struct wl1271 *wl,
        if (ret < 0)
                goto out;
 
+       /* We don't need the size of the last partition, as it is
+        * automatically calculated based on the total memory size and
+        * the sizes of the previous partitions.
+        */
        ret = wlcore_raw_write32(wl, HW_PART3_START_ADDR, p->mem3.start);
        if (ret < 0)
                goto out;
 
-       ret = wlcore_raw_write32(wl, HW_PART3_SIZE_ADDR, p->mem3.size);
-       if (ret < 0)
-               goto out;
-
 out:
        return ret;
 }
index 6c257b5..10cf374 100644 (file)
@@ -36,8 +36,8 @@
 #define HW_PART1_START_ADDR             (HW_PARTITION_REGISTERS_ADDR + 12)
 #define HW_PART2_SIZE_ADDR              (HW_PARTITION_REGISTERS_ADDR + 16)
 #define HW_PART2_START_ADDR             (HW_PARTITION_REGISTERS_ADDR + 20)
-#define HW_PART3_SIZE_ADDR              (HW_PARTITION_REGISTERS_ADDR + 24)
-#define HW_PART3_START_ADDR             (HW_PARTITION_REGISTERS_ADDR + 28)
+#define HW_PART3_START_ADDR             (HW_PARTITION_REGISTERS_ADDR + 24)
+
 #define HW_ACCESS_REGISTER_SIZE         4
 
 #define HW_ACCESS_PRAM_MAX_RANGE       0x3c000
index 7e2c43f..5d28e94 100644 (file)
@@ -382,18 +382,18 @@ static const struct nd_cmd_desc __nd_cmd_bus_descs[] = {
        [ND_CMD_ARS_CAP] = {
                .in_num = 2,
                .in_sizes = { 8, 8, },
-               .out_num = 2,
-               .out_sizes = { 4, 4, },
+               .out_num = 4,
+               .out_sizes = { 4, 4, 4, 4, },
        },
        [ND_CMD_ARS_START] = {
-               .in_num = 4,
-               .in_sizes = { 8, 8, 2, 6, },
-               .out_num = 1,
-               .out_sizes = { 4, },
+               .in_num = 5,
+               .in_sizes = { 8, 8, 2, 1, 5, },
+               .out_num = 2,
+               .out_sizes = { 4, 4, },
        },
        [ND_CMD_ARS_STATUS] = {
-               .out_num = 2,
-               .out_sizes = { 4, UINT_MAX, },
+               .out_num = 3,
+               .out_sizes = { 4, 4, UINT_MAX, },
        },
 };
 
@@ -442,8 +442,8 @@ u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
                return in_field[1];
        else if (nvdimm && cmd == ND_CMD_VENDOR && idx == 2)
                return out_field[1];
-       else if (!nvdimm && cmd == ND_CMD_ARS_STATUS && idx == 1)
-               return ND_CMD_ARS_STATUS_MAX;
+       else if (!nvdimm && cmd == ND_CMD_ARS_STATUS && idx == 2)
+               return out_field[1] - 8;
 
        return UINT_MAX;
 }
index 7edf316..8d0b546 100644 (file)
@@ -41,7 +41,7 @@ struct pmem_device {
        phys_addr_t             phys_addr;
        /* when non-zero this device is hosting a 'pfn' instance */
        phys_addr_t             data_offset;
-       unsigned long           pfn_flags;
+       u64                     pfn_flags;
        void __pmem             *virt_addr;
        size_t                  size;
        struct badblocks        bb;
index 5d62373..b586d84 100644 (file)
@@ -17,5 +17,6 @@ config BLK_DEV_NVME_SCSI
          and block devices nodes, as well a a translation for a small
          number of selected SCSI commands to NVMe commands to the NVMe
          driver.  If you don't know what this means you probably want
-         to say N here, and if you know what it means you probably
-         want to say N as well.
+         to say N here, unless you run a distro that abuses the SCSI
+         emulation to provide stable device names for mount by id, like
+         some OpenSuSE and SLES versions.
index c5bf001..03c4641 100644 (file)
@@ -55,8 +55,9 @@ static void nvme_free_ns(struct kref *kref)
        ns->disk->private_data = NULL;
        spin_unlock(&dev_list_lock);
 
-       nvme_put_ctrl(ns->ctrl);
        put_disk(ns->disk);
+       ida_simple_remove(&ns->ctrl->ns_ida, ns->instance);
+       nvme_put_ctrl(ns->ctrl);
        kfree(ns);
 }
 
@@ -183,7 +184,7 @@ int __nvme_submit_user_cmd(struct request_queue *q, struct nvme_command *cmd,
                        goto out_unmap;
                }
 
-               if (meta_buffer) {
+               if (meta_buffer && meta_len) {
                        struct bio_integrity_payload *bip;
 
                        meta = kmalloc(meta_len, GFP_KERNEL);
@@ -373,6 +374,8 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
 
        if (copy_from_user(&io, uio, sizeof(io)))
                return -EFAULT;
+       if (io.flags)
+               return -EINVAL;
 
        switch (io.opcode) {
        case nvme_cmd_write:
@@ -424,6 +427,8 @@ static int nvme_user_cmd(struct nvme_ctrl *ctrl, struct nvme_ns *ns,
                return -EACCES;
        if (copy_from_user(&cmd, ucmd, sizeof(cmd)))
                return -EFAULT;
+       if (cmd.flags)
+               return -EINVAL;
 
        memset(&c, 0, sizeof(c));
        c.common.opcode = cmd.opcode;
@@ -556,6 +561,10 @@ static int nvme_revalidate_disk(struct gendisk *disk)
        u16 old_ms;
        unsigned short bs;
 
+       if (test_bit(NVME_NS_DEAD, &ns->flags)) {
+               set_capacity(disk, 0);
+               return -ENODEV;
+       }
        if (nvme_identify_ns(ns->ctrl, ns->ns_id, &id)) {
                dev_warn(ns->ctrl->dev, "%s: Identify failure nvme%dn%d\n",
                                __func__, ns->ctrl->instance, ns->ns_id);
@@ -831,6 +840,23 @@ int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl)
        return ret;
 }
 
+static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
+               struct request_queue *q)
+{
+       if (ctrl->max_hw_sectors) {
+               u32 max_segments =
+                       (ctrl->max_hw_sectors / (ctrl->page_size >> 9)) + 1;
+
+               blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors);
+               blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX));
+       }
+       if (ctrl->stripe_size)
+               blk_queue_chunk_sectors(q, ctrl->stripe_size >> 9);
+       if (ctrl->vwc & NVME_CTRL_VWC_PRESENT)
+               blk_queue_flush(q, REQ_FLUSH | REQ_FUA);
+       blk_queue_virt_boundary(q, ctrl->page_size - 1);
+}
+
 /*
  * Initialize the cached copies of the Identify data and various controller
  * register in our nvme_ctrl structure.  This should be called as soon as
@@ -888,6 +914,8 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
                }
        }
 
+       nvme_set_queue_limits(ctrl, ctrl->admin_q);
+
        kfree(id);
        return 0;
 }
@@ -1118,10 +1146,13 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
        if (!ns)
                return;
 
+       ns->instance = ida_simple_get(&ctrl->ns_ida, 1, 0, GFP_KERNEL);
+       if (ns->instance < 0)
+               goto out_free_ns;
+
        ns->queue = blk_mq_init_queue(ctrl->tagset);
        if (IS_ERR(ns->queue))
-               goto out_free_ns;
-       queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, ns->queue);
+               goto out_release_instance;
        queue_flag_set_unlocked(QUEUE_FLAG_NONROT, ns->queue);
        ns->queue->queuedata = ns;
        ns->ctrl = ctrl;
@@ -1135,17 +1166,9 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
        ns->disk = disk;
        ns->lba_shift = 9; /* set to a default value for 512 until disk is validated */
 
+
        blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift);
-       if (ctrl->max_hw_sectors) {
-               blk_queue_max_hw_sectors(ns->queue, ctrl->max_hw_sectors);
-               blk_queue_max_segments(ns->queue,
-                       (ctrl->max_hw_sectors / (ctrl->page_size >> 9)) + 1);
-       }
-       if (ctrl->stripe_size)
-               blk_queue_chunk_sectors(ns->queue, ctrl->stripe_size >> 9);
-       if (ctrl->vwc & NVME_CTRL_VWC_PRESENT)
-               blk_queue_flush(ns->queue, REQ_FLUSH | REQ_FUA);
-       blk_queue_virt_boundary(ns->queue, ctrl->page_size - 1);
+       nvme_set_queue_limits(ctrl, ns->queue);
 
        disk->major = nvme_major;
        disk->first_minor = 0;
@@ -1154,7 +1177,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
        disk->queue = ns->queue;
        disk->driverfs_dev = ctrl->device;
        disk->flags = GENHD_FL_EXT_DEVT;
-       sprintf(disk->disk_name, "nvme%dn%d", ctrl->instance, nsid);
+       sprintf(disk->disk_name, "nvme%dn%d", ctrl->instance, ns->instance);
 
        if (nvme_revalidate_disk(ns->disk))
                goto out_free_disk;
@@ -1174,40 +1197,29 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
        kfree(disk);
  out_free_queue:
        blk_cleanup_queue(ns->queue);
+ out_release_instance:
+       ida_simple_remove(&ctrl->ns_ida, ns->instance);
  out_free_ns:
        kfree(ns);
 }
 
 static void nvme_ns_remove(struct nvme_ns *ns)
 {
-       bool kill = nvme_io_incapable(ns->ctrl) &&
-                       !blk_queue_dying(ns->queue);
-
-       lockdep_assert_held(&ns->ctrl->namespaces_mutex);
-
-       if (kill) {
-               blk_set_queue_dying(ns->queue);
+       if (test_and_set_bit(NVME_NS_REMOVING, &ns->flags))
+               return;
 
-               /*
-                * The controller was shutdown first if we got here through
-                * device removal. The shutdown may requeue outstanding
-                * requests. These need to be aborted immediately so
-                * del_gendisk doesn't block indefinitely for their completion.
-                */
-               blk_mq_abort_requeue_list(ns->queue);
-       }
        if (ns->disk->flags & GENHD_FL_UP) {
                if (blk_get_integrity(ns->disk))
                        blk_integrity_unregister(ns->disk);
                sysfs_remove_group(&disk_to_dev(ns->disk)->kobj,
                                        &nvme_ns_attr_group);
                del_gendisk(ns->disk);
-       }
-       if (kill || !blk_queue_dying(ns->queue)) {
                blk_mq_abort_requeue_list(ns->queue);
                blk_cleanup_queue(ns->queue);
        }
+       mutex_lock(&ns->ctrl->namespaces_mutex);
        list_del_init(&ns->list);
+       mutex_unlock(&ns->ctrl->namespaces_mutex);
        nvme_put_ns(ns);
 }
 
@@ -1301,10 +1313,8 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl)
 {
        struct nvme_ns *ns, *next;
 
-       mutex_lock(&ctrl->namespaces_mutex);
        list_for_each_entry_safe(ns, next, &ctrl->namespaces, list)
                nvme_ns_remove(ns);
-       mutex_unlock(&ctrl->namespaces_mutex);
 }
 
 static DEFINE_IDA(nvme_instance_ida);
@@ -1351,6 +1361,7 @@ static void nvme_free_ctrl(struct kref *kref)
 
        put_device(ctrl->device);
        nvme_release_instance(ctrl);
+       ida_destroy(&ctrl->ns_ida);
 
        ctrl->ops->free_ctrl(ctrl);
 }
@@ -1391,6 +1402,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
        }
        get_device(ctrl->device);
        dev_set_drvdata(ctrl->device, ctrl);
+       ida_init(&ctrl->ns_ida);
 
        spin_lock(&dev_list_lock);
        list_add_tail(&ctrl->node, &nvme_ctrl_list);
@@ -1403,6 +1415,38 @@ out:
        return ret;
 }
 
+/**
+ * nvme_kill_queues(): Ends all namespace queues
+ * @ctrl: the dead controller that needs to end
+ *
+ * Call this function when the driver determines it is unable to get the
+ * controller in a state capable of servicing IO.
+ */
+void nvme_kill_queues(struct nvme_ctrl *ctrl)
+{
+       struct nvme_ns *ns;
+
+       mutex_lock(&ctrl->namespaces_mutex);
+       list_for_each_entry(ns, &ctrl->namespaces, list) {
+               if (!kref_get_unless_zero(&ns->kref))
+                       continue;
+
+               /*
+                * Revalidating a dead namespace sets capacity to 0. This will
+                * end buffered writers dirtying pages that can't be synced.
+                */
+               if (!test_and_set_bit(NVME_NS_DEAD, &ns->flags))
+                       revalidate_disk(ns->disk);
+
+               blk_set_queue_dying(ns->queue);
+               blk_mq_abort_requeue_list(ns->queue);
+               blk_mq_start_stopped_hw_queues(ns->queue, true);
+
+               nvme_put_ns(ns);
+       }
+       mutex_unlock(&ctrl->namespaces_mutex);
+}
+
 void nvme_stop_queues(struct nvme_ctrl *ctrl)
 {
        struct nvme_ns *ns;
index 5cd3725..6bb15e4 100644 (file)
@@ -146,9 +146,10 @@ struct nvme_nvm_command {
        };
 };
 
+#define NVME_NVM_LP_MLC_PAIRS 886
 struct nvme_nvm_lp_mlc {
        __u16                   num_pairs;
-       __u8                    pairs[886];
+       __u8                    pairs[NVME_NVM_LP_MLC_PAIRS];
 };
 
 struct nvme_nvm_lp_tbl {
@@ -282,9 +283,14 @@ static int init_grps(struct nvm_id *nvm_id, struct nvme_nvm_id *nvme_nvm_id)
                        memcpy(dst->lptbl.id, src->lptbl.id, 8);
                        dst->lptbl.mlc.num_pairs =
                                        le16_to_cpu(src->lptbl.mlc.num_pairs);
-                       /* 4 bits per pair */
+
+                       if (dst->lptbl.mlc.num_pairs > NVME_NVM_LP_MLC_PAIRS) {
+                               pr_err("nvm: number of MLC pairs not supported\n");
+                               return -EINVAL;
+                       }
+
                        memcpy(dst->lptbl.mlc.pairs, src->lptbl.mlc.pairs,
-                                               dst->lptbl.mlc.num_pairs >> 1);
+                                               dst->lptbl.mlc.num_pairs);
                }
        }
 
index 4fb5bb7..fb15ba5 100644 (file)
@@ -72,6 +72,7 @@ struct nvme_ctrl {
        struct mutex namespaces_mutex;
        struct device *device;  /* char device */
        struct list_head node;
+       struct ida ns_ida;
 
        char name[12];
        char serial[20];
@@ -102,6 +103,7 @@ struct nvme_ns {
        struct request_queue *queue;
        struct gendisk *disk;
        struct kref kref;
+       int instance;
 
        u8 eui[8];
        u8 uuid[16];
@@ -112,6 +114,11 @@ struct nvme_ns {
        bool ext;
        u8 pi_type;
        int type;
+       unsigned long flags;
+
+#define NVME_NS_REMOVING 0
+#define NVME_NS_DEAD     1
+
        u64 mode_select_num_blocks;
        u32 mode_select_block_len;
 };
@@ -139,9 +146,9 @@ static inline bool nvme_io_incapable(struct nvme_ctrl *ctrl)
        u32 val = 0;
 
        if (ctrl->ops->io_incapable(ctrl))
-               return false;
+               return true;
        if (ctrl->ops->reg_read32(ctrl, NVME_REG_CSTS, &val))
-               return false;
+               return true;
        return val & NVME_CSTS_CFS;
 }
 
@@ -240,6 +247,7 @@ void nvme_remove_namespaces(struct nvme_ctrl *ctrl);
 
 void nvme_stop_queues(struct nvme_ctrl *ctrl);
 void nvme_start_queues(struct nvme_ctrl *ctrl);
+void nvme_kill_queues(struct nvme_ctrl *ctrl);
 
 struct request *nvme_alloc_request(struct request_queue *q,
                struct nvme_command *cmd, unsigned int flags);
index 72ef832..680f578 100644 (file)
@@ -86,7 +86,6 @@ struct nvme_queue;
 
 static int nvme_reset(struct nvme_dev *dev);
 static void nvme_process_cq(struct nvme_queue *nvmeq);
-static void nvme_remove_dead_ctrl(struct nvme_dev *dev);
 static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown);
 
 /*
@@ -120,6 +119,7 @@ struct nvme_dev {
        unsigned long flags;
 
 #define NVME_CTRL_RESETTING    0
+#define NVME_CTRL_REMOVING     1
 
        struct nvme_ctrl ctrl;
        struct completion ioq_wait;
@@ -286,6 +286,17 @@ static int nvme_init_request(void *data, struct request *req,
        return 0;
 }
 
+static void nvme_queue_scan(struct nvme_dev *dev)
+{
+       /*
+        * Do not queue new scan work when a controller is reset during
+        * removal.
+        */
+       if (test_bit(NVME_CTRL_REMOVING, &dev->flags))
+               return;
+       queue_work(nvme_workq, &dev->scan_work);
+}
+
 static void nvme_complete_async_event(struct nvme_dev *dev,
                struct nvme_completion *cqe)
 {
@@ -300,7 +311,7 @@ static void nvme_complete_async_event(struct nvme_dev *dev,
        switch (result & 0xff07) {
        case NVME_AER_NOTICE_NS_CHANGED:
                dev_info(dev->dev, "rescanning\n");
-               queue_work(nvme_workq, &dev->scan_work);
+               nvme_queue_scan(dev);
        default:
                dev_warn(dev->dev, "async event result %08x\n", result);
        }
@@ -678,6 +689,14 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
        blk_mq_start_request(req);
 
        spin_lock_irq(&nvmeq->q_lock);
+       if (unlikely(nvmeq->cq_vector < 0)) {
+               if (ns && !test_bit(NVME_NS_DEAD, &ns->flags))
+                       ret = BLK_MQ_RQ_QUEUE_BUSY;
+               else
+                       ret = BLK_MQ_RQ_QUEUE_ERROR;
+               spin_unlock_irq(&nvmeq->q_lock);
+               goto out;
+       }
        __nvme_submit_cmd(nvmeq, &cmnd);
        nvme_process_cq(nvmeq);
        spin_unlock_irq(&nvmeq->q_lock);
@@ -999,7 +1018,7 @@ static void nvme_cancel_queue_ios(struct request *req, void *data, bool reserved
        if (!blk_mq_request_started(req))
                return;
 
-       dev_warn(nvmeq->q_dmadev,
+       dev_dbg_ratelimited(nvmeq->q_dmadev,
                 "Cancelling I/O %d QID %d\n", req->tag, nvmeq->qid);
 
        status = NVME_SC_ABORT_REQ;
@@ -1245,6 +1264,12 @@ static struct blk_mq_ops nvme_mq_ops = {
 static void nvme_dev_remove_admin(struct nvme_dev *dev)
 {
        if (dev->ctrl.admin_q && !blk_queue_dying(dev->ctrl.admin_q)) {
+               /*
+                * If the controller was reset during removal, it's possible
+                * user requests may be waiting on a stopped queue. Start the
+                * queue to flush these to completion.
+                */
+               blk_mq_start_stopped_hw_queues(dev->ctrl.admin_q, true);
                blk_cleanup_queue(dev->ctrl.admin_q);
                blk_mq_free_tag_set(&dev->admin_tagset);
        }
@@ -1685,14 +1710,14 @@ static int nvme_dev_add(struct nvme_dev *dev)
                        return 0;
                dev->ctrl.tagset = &dev->tagset;
        }
-       queue_work(nvme_workq, &dev->scan_work);
+       nvme_queue_scan(dev);
        return 0;
 }
 
-static int nvme_dev_map(struct nvme_dev *dev)
+static int nvme_pci_enable(struct nvme_dev *dev)
 {
        u64 cap;
-       int bars, result = -ENOMEM;
+       int result = -ENOMEM;
        struct pci_dev *pdev = to_pci_dev(dev->dev);
 
        if (pci_enable_device_mem(pdev))
@@ -1700,24 +1725,14 @@ static int nvme_dev_map(struct nvme_dev *dev)
 
        dev->entry[0].vector = pdev->irq;
        pci_set_master(pdev);
-       bars = pci_select_bars(pdev, IORESOURCE_MEM);
-       if (!bars)
-               goto disable_pci;
-
-       if (pci_request_selected_regions(pdev, bars, "nvme"))
-               goto disable_pci;
 
        if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(64)) &&
            dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(32)))
                goto disable;
 
-       dev->bar = ioremap(pci_resource_start(pdev, 0), 8192);
-       if (!dev->bar)
-               goto disable;
-
        if (readl(dev->bar + NVME_REG_CSTS) == -1) {
                result = -ENODEV;
-               goto unmap;
+               goto disable;
        }
 
        /*
@@ -1727,7 +1742,7 @@ static int nvme_dev_map(struct nvme_dev *dev)
        if (!pdev->irq) {
                result = pci_enable_msix(pdev, dev->entry, 1);
                if (result < 0)
-                       goto unmap;
+                       goto disable;
        }
 
        cap = lo_hi_readq(dev->bar + NVME_REG_CAP);
@@ -1754,18 +1769,20 @@ static int nvme_dev_map(struct nvme_dev *dev)
        pci_save_state(pdev);
        return 0;
 
- unmap:
-       iounmap(dev->bar);
-       dev->bar = NULL;
  disable:
-       pci_release_regions(pdev);
- disable_pci:
        pci_disable_device(pdev);
        return result;
 }
 
 static void nvme_dev_unmap(struct nvme_dev *dev)
 {
+       if (dev->bar)
+               iounmap(dev->bar);
+       pci_release_regions(to_pci_dev(dev->dev));
+}
+
+static void nvme_pci_disable(struct nvme_dev *dev)
+{
        struct pci_dev *pdev = to_pci_dev(dev->dev);
 
        if (pdev->msi_enabled)
@@ -1773,12 +1790,6 @@ static void nvme_dev_unmap(struct nvme_dev *dev)
        else if (pdev->msix_enabled)
                pci_disable_msix(pdev);
 
-       if (dev->bar) {
-               iounmap(dev->bar);
-               dev->bar = NULL;
-               pci_release_regions(pdev);
-       }
-
        if (pci_is_enabled(pdev)) {
                pci_disable_pcie_error_reporting(pdev);
                pci_disable_device(pdev);
@@ -1837,7 +1848,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
        nvme_dev_list_remove(dev);
 
        mutex_lock(&dev->shutdown_lock);
-       if (dev->bar) {
+       if (pci_is_enabled(to_pci_dev(dev->dev))) {
                nvme_stop_queues(&dev->ctrl);
                csts = readl(dev->bar + NVME_REG_CSTS);
        }
@@ -1850,7 +1861,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
                nvme_disable_io_queues(dev);
                nvme_disable_admin_queue(dev, shutdown);
        }
-       nvme_dev_unmap(dev);
+       nvme_pci_disable(dev);
 
        for (i = dev->queue_count - 1; i >= 0; i--)
                nvme_clear_queue(dev->queues[i]);
@@ -1894,10 +1905,20 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl)
        kfree(dev);
 }
 
+static void nvme_remove_dead_ctrl(struct nvme_dev *dev, int status)
+{
+       dev_warn(dev->dev, "Removing after probe failure status: %d\n", status);
+
+       kref_get(&dev->ctrl.kref);
+       nvme_dev_disable(dev, false);
+       if (!schedule_work(&dev->remove_work))
+               nvme_put_ctrl(&dev->ctrl);
+}
+
 static void nvme_reset_work(struct work_struct *work)
 {
        struct nvme_dev *dev = container_of(work, struct nvme_dev, reset_work);
-       int result;
+       int result = -ENODEV;
 
        if (WARN_ON(test_bit(NVME_CTRL_RESETTING, &dev->flags)))
                goto out;
@@ -1906,37 +1927,37 @@ static void nvme_reset_work(struct work_struct *work)
         * If we're called to reset a live controller first shut it down before
         * moving on.
         */
-       if (dev->bar)
+       if (dev->ctrl.ctrl_config & NVME_CC_ENABLE)
                nvme_dev_disable(dev, false);
 
        set_bit(NVME_CTRL_RESETTING, &dev->flags);
 
-       result = nvme_dev_map(dev);
+       result = nvme_pci_enable(dev);
        if (result)
                goto out;
 
        result = nvme_configure_admin_queue(dev);
        if (result)
-               goto unmap;
+               goto out;
 
        nvme_init_queue(dev->queues[0], 0);
        result = nvme_alloc_admin_tags(dev);
        if (result)
-               goto disable;
+               goto out;
 
        result = nvme_init_identify(&dev->ctrl);
        if (result)
-               goto free_tags;
+               goto out;
 
        result = nvme_setup_io_queues(dev);
        if (result)
-               goto free_tags;
+               goto out;
 
        dev->ctrl.event_limit = NVME_NR_AEN_COMMANDS;
 
        result = nvme_dev_list_add(dev);
        if (result)
-               goto remove;
+               goto out;
 
        /*
         * Keep the controller around but remove all namespaces if we don't have
@@ -1953,19 +1974,8 @@ static void nvme_reset_work(struct work_struct *work)
        clear_bit(NVME_CTRL_RESETTING, &dev->flags);
        return;
 
- remove:
-       nvme_dev_list_remove(dev);
- free_tags:
-       nvme_dev_remove_admin(dev);
-       blk_put_queue(dev->ctrl.admin_q);
-       dev->ctrl.admin_q = NULL;
-       dev->queues[0]->tags = NULL;
- disable:
-       nvme_disable_admin_queue(dev, false);
- unmap:
-       nvme_dev_unmap(dev);
  out:
-       nvme_remove_dead_ctrl(dev);
+       nvme_remove_dead_ctrl(dev, result);
 }
 
 static void nvme_remove_dead_ctrl_work(struct work_struct *work)
@@ -1973,19 +1983,12 @@ static void nvme_remove_dead_ctrl_work(struct work_struct *work)
        struct nvme_dev *dev = container_of(work, struct nvme_dev, remove_work);
        struct pci_dev *pdev = to_pci_dev(dev->dev);
 
+       nvme_kill_queues(&dev->ctrl);
        if (pci_get_drvdata(pdev))
                pci_stop_and_remove_bus_device_locked(pdev);
        nvme_put_ctrl(&dev->ctrl);
 }
 
-static void nvme_remove_dead_ctrl(struct nvme_dev *dev)
-{
-       dev_warn(dev->dev, "Removing after probe failure\n");
-       kref_get(&dev->ctrl.kref);
-       if (!schedule_work(&dev->remove_work))
-               nvme_put_ctrl(&dev->ctrl);
-}
-
 static int nvme_reset(struct nvme_dev *dev)
 {
        if (!dev->ctrl.admin_q || blk_queue_dying(dev->ctrl.admin_q))
@@ -2037,6 +2040,27 @@ static const struct nvme_ctrl_ops nvme_pci_ctrl_ops = {
        .free_ctrl              = nvme_pci_free_ctrl,
 };
 
+static int nvme_dev_map(struct nvme_dev *dev)
+{
+       int bars;
+       struct pci_dev *pdev = to_pci_dev(dev->dev);
+
+       bars = pci_select_bars(pdev, IORESOURCE_MEM);
+       if (!bars)
+               return -ENODEV;
+       if (pci_request_selected_regions(pdev, bars, "nvme"))
+               return -ENODEV;
+
+       dev->bar = ioremap(pci_resource_start(pdev, 0), 8192);
+       if (!dev->bar)
+               goto release;
+
+       return 0;
+  release:
+       pci_release_regions(pdev);
+       return -ENODEV;
+}
+
 static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
        int node, result = -ENOMEM;
@@ -2061,6 +2085,10 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        dev->dev = get_device(&pdev->dev);
        pci_set_drvdata(pdev, dev);
 
+       result = nvme_dev_map(dev);
+       if (result)
+               goto free;
+
        INIT_LIST_HEAD(&dev->node);
        INIT_WORK(&dev->scan_work, nvme_dev_scan);
        INIT_WORK(&dev->reset_work, nvme_reset_work);
@@ -2084,6 +2112,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        nvme_release_prp_pools(dev);
  put_pci:
        put_device(dev->dev);
+       nvme_dev_unmap(dev);
  free:
        kfree(dev->queues);
        kfree(dev->entry);
@@ -2107,24 +2136,27 @@ static void nvme_shutdown(struct pci_dev *pdev)
        nvme_dev_disable(dev, true);
 }
 
+/*
+ * The driver's remove may be called on a device in a partially initialized
+ * state. This function must not have any dependencies on the device state in
+ * order to proceed.
+ */
 static void nvme_remove(struct pci_dev *pdev)
 {
        struct nvme_dev *dev = pci_get_drvdata(pdev);
 
-       spin_lock(&dev_list_lock);
-       list_del_init(&dev->node);
-       spin_unlock(&dev_list_lock);
-
+       set_bit(NVME_CTRL_REMOVING, &dev->flags);
        pci_set_drvdata(pdev, NULL);
-       flush_work(&dev->reset_work);
        flush_work(&dev->scan_work);
        nvme_remove_namespaces(&dev->ctrl);
        nvme_uninit_ctrl(&dev->ctrl);
        nvme_dev_disable(dev, true);
+       flush_work(&dev->reset_work);
        nvme_dev_remove_admin(dev);
        nvme_free_queues(dev, 0);
        nvme_release_cmb(dev);
        nvme_release_prp_pools(dev);
+       nvme_dev_unmap(dev);
        nvme_put_ctrl(&dev->ctrl);
 }
 
index 6fd4e5a..9d11d98 100644 (file)
@@ -70,6 +70,9 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
        if (pos >= nvmem->size)
                return 0;
 
+       if (count < nvmem->word_size)
+               return -EINVAL;
+
        if (pos + count > nvmem->size)
                count = nvmem->size - pos;
 
@@ -95,6 +98,9 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
        if (pos >= nvmem->size)
                return 0;
 
+       if (count < nvmem->word_size)
+               return -EINVAL;
+
        if (pos + count > nvmem->size)
                count = nvmem->size - pos;
 
index afb67e7..3829e5f 100644 (file)
@@ -21,6 +21,7 @@ static struct regmap_config qfprom_regmap_config = {
        .reg_bits = 32,
        .val_bits = 8,
        .reg_stride = 1,
+       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 static struct nvmem_config econfig = {
index 7ee21ae..e7bfc17 100644 (file)
@@ -635,6 +635,13 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
                msi_base = be32_to_cpup(msi_map + 2);
                rid_len = be32_to_cpup(msi_map + 3);
 
+               if (rid_base & ~map_mask) {
+                       dev_err(parent_dev,
+                               "Invalid msi-map translation - msi-map-mask (0x%x) ignores rid-base (0x%x)\n",
+                               map_mask, rid_base);
+                       return rid_out;
+               }
+
                msi_controller_node = of_find_node_by_phandle(phandle);
 
                matched = (masked_rid >= rid_base &&
@@ -654,7 +661,7 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
        if (!matched)
                return rid_out;
 
-       rid_out = masked_rid + msi_base;
+       rid_out = masked_rid - rid_base + msi_base;
        dev_dbg(dev,
                "msi-map at: %s, using mask %08x, rid-base: %08x, msi-base: %08x, length: %08x, rid: %08x -> %08x\n",
                dev_name(parent_dev), map_mask, rid_base, msi_base,
index 5648317..365dc7e 100644 (file)
@@ -154,6 +154,7 @@ static const struct of_device_id whitelist_phys[] = {
        { .compatible = "marvell,88E1111", },
        { .compatible = "marvell,88e1116", },
        { .compatible = "marvell,88e1118", },
+       { .compatible = "marvell,88e1145", },
        { .compatible = "marvell,88e1149r", },
        { .compatible = "marvell,88e1310", },
        { .compatible = "marvell,88E1510", },
@@ -304,6 +305,7 @@ EXPORT_SYMBOL(of_phy_find_device);
  * @dev: pointer to net_device claiming the phy
  * @phy_np: Pointer to device tree node for the PHY
  * @hndlr: Link state callback for the network device
+ * @flags: flags to pass to the PHY
  * @iface: PHY data interface type
  *
  * If successful, returns a pointer to the phy_device with the embedded
index 75a6054..d1cdd9c 100644 (file)
@@ -14,6 +14,7 @@ config PCI_DRA7XX
 config PCI_MVEBU
        bool "Marvell EBU PCIe controller"
        depends on ARCH_MVEBU || ARCH_DOVE
+       depends on ARM
        depends on OF
 
 config PCIE_DW
index ed34c95..6153853 100644 (file)
 
 #define to_keystone_pcie(x)    container_of(x, struct keystone_pcie, pp)
 
-static inline struct pcie_port *sys_to_pcie(struct pci_sys_data *sys)
-{
-       return sys->private_data;
-}
-
 static inline void update_reg_offset_bit_pos(u32 offset, u32 *reg_offset,
                                             u32 *bit_pos)
 {
@@ -108,7 +103,7 @@ static void ks_dw_pcie_msi_irq_ack(struct irq_data *d)
        struct pcie_port *pp;
 
        msi = irq_data_get_msi_desc(d);
-       pp = sys_to_pcie(msi_desc_to_pci_sysdata(msi));
+       pp = (struct pcie_port *) msi_desc_to_pci_sysdata(msi);
        ks_pcie = to_keystone_pcie(pp);
        offset = d->irq - irq_linear_revmap(pp->irq_domain, 0);
        update_reg_offset_bit_pos(offset, &reg_offset, &bit_pos);
@@ -146,7 +141,7 @@ static void ks_dw_pcie_msi_irq_mask(struct irq_data *d)
        u32 offset;
 
        msi = irq_data_get_msi_desc(d);
-       pp = sys_to_pcie(msi_desc_to_pci_sysdata(msi));
+       pp = (struct pcie_port *) msi_desc_to_pci_sysdata(msi);
        ks_pcie = to_keystone_pcie(pp);
        offset = d->irq - irq_linear_revmap(pp->irq_domain, 0);
 
@@ -167,7 +162,7 @@ static void ks_dw_pcie_msi_irq_unmask(struct irq_data *d)
        u32 offset;
 
        msi = irq_data_get_msi_desc(d);
-       pp = sys_to_pcie(msi_desc_to_pci_sysdata(msi));
+       pp = (struct pcie_port *) msi_desc_to_pci_sysdata(msi);
        ks_pcie = to_keystone_pcie(pp);
        offset = d->irq - irq_linear_revmap(pp->irq_domain, 0);
 
index 3923bed..f39961b 100644 (file)
@@ -77,6 +77,16 @@ static void ls_pcie_fix_class(struct ls_pcie *pcie)
        iowrite16(PCI_CLASS_BRIDGE_PCI, pcie->dbi + PCI_CLASS_DEVICE);
 }
 
+/* Drop MSG TLP except for Vendor MSG */
+static void ls_pcie_drop_msg_tlp(struct ls_pcie *pcie)
+{
+       u32 val;
+
+       val = ioread32(pcie->dbi + PCIE_STRFMR1);
+       val &= 0xDFFFFFFF;
+       iowrite32(val, pcie->dbi + PCIE_STRFMR1);
+}
+
 static int ls1021_pcie_link_up(struct pcie_port *pp)
 {
        u32 state;
@@ -97,7 +107,7 @@ static int ls1021_pcie_link_up(struct pcie_port *pp)
 static void ls1021_pcie_host_init(struct pcie_port *pp)
 {
        struct ls_pcie *pcie = to_ls_pcie(pp);
-       u32 val, index[2];
+       u32 index[2];
 
        pcie->scfg = syscon_regmap_lookup_by_phandle(pp->dev->of_node,
                                                     "fsl,pcie-scfg");
@@ -116,13 +126,7 @@ static void ls1021_pcie_host_init(struct pcie_port *pp)
 
        dw_pcie_setup_rc(pp);
 
-       /*
-        * LS1021A Workaround for internal TKT228622
-        * to fix the INTx hang issue
-        */
-       val = ioread32(pcie->dbi + PCIE_STRFMR1);
-       val &= 0xffff;
-       iowrite32(val, pcie->dbi + PCIE_STRFMR1);
+       ls_pcie_drop_msg_tlp(pcie);
 }
 
 static int ls_pcie_link_up(struct pcie_port *pp)
@@ -147,6 +151,7 @@ static void ls_pcie_host_init(struct pcie_port *pp)
        iowrite32(1, pcie->dbi + PCIE_DBI_RO_WR_EN);
        ls_pcie_fix_class(pcie);
        ls_pcie_clear_multifunction(pcie);
+       ls_pcie_drop_msg_tlp(pcie);
        iowrite32(0, pcie->dbi + PCIE_DBI_RO_WR_EN);
 }
 
index 5816bce..a576aee 100644 (file)
@@ -64,7 +64,6 @@
 #define OARR_SIZE_CFG                BIT(OARR_SIZE_CFG_SHIFT)
 
 #define MAX_NUM_OB_WINDOWS           2
-#define MAX_NUM_PAXC_PF              4
 
 #define IPROC_PCIE_REG_INVALID 0xffff
 
@@ -170,20 +169,6 @@ static inline void iproc_pcie_ob_write(struct iproc_pcie *pcie,
        writel(val, pcie->base + offset + (window * 8));
 }
 
-static inline bool iproc_pcie_device_is_valid(struct iproc_pcie *pcie,
-                                             unsigned int slot,
-                                             unsigned int fn)
-{
-       if (slot > 0)
-               return false;
-
-       /* PAXC can only support limited number of functions */
-       if (pcie->type == IPROC_PCIE_PAXC && fn >= MAX_NUM_PAXC_PF)
-               return false;
-
-       return true;
-}
-
 /**
  * Note access to the configuration registers are protected at the higher layer
  * by 'pci_lock' in drivers/pci/access.c
@@ -199,11 +184,11 @@ static void __iomem *iproc_pcie_map_cfg_bus(struct pci_bus *bus,
        u32 val;
        u16 offset;
 
-       if (!iproc_pcie_device_is_valid(pcie, slot, fn))
-               return NULL;
-
        /* root complex access */
        if (busno == 0) {
+               if (slot > 0 || fn > 0)
+                       return NULL;
+
                iproc_pcie_write_reg(pcie, IPROC_PCIE_CFG_IND_ADDR,
                                     where & CFG_IND_ADDR_MASK);
                offset = iproc_pcie_reg_offset(pcie, IPROC_PCIE_CFG_IND_DATA);
@@ -213,6 +198,14 @@ static void __iomem *iproc_pcie_map_cfg_bus(struct pci_bus *bus,
                        return (pcie->base + offset);
        }
 
+       /*
+        * PAXC is connected to an internally emulated EP within the SoC.  It
+        * allows only one device.
+        */
+       if (pcie->type == IPROC_PCIE_PAXC)
+               if (slot > 0)
+                       return NULL;
+
        /* EP device access */
        val = (busno << CFG_ADDR_BUS_NUM_SHIFT) |
                (slot << CFG_ADDR_DEV_NUM_SHIFT) |
index 602eb42..f89db3a 100644 (file)
@@ -4772,8 +4772,10 @@ int pci_get_new_domain_nr(void)
 void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
 {
        static int use_dt_domains = -1;
-       int domain = of_get_pci_domain_nr(parent->of_node);
+       int domain = -1;
 
+       if (parent)
+               domain = of_get_pci_domain_nr(parent->of_node);
        /*
         * Check DT domain and use_dt_domains values.
         *
index 0bf82a2..48d21e0 100644 (file)
@@ -262,7 +262,6 @@ static struct aer_rpc *aer_alloc_rpc(struct pcie_device *dev)
        rpc->rpd = dev;
        INIT_WORK(&rpc->dpc_handler, aer_isr);
        mutex_init(&rpc->rpc_mutex);
-       init_waitqueue_head(&rpc->wait_release);
 
        /* Use PCIe bus function to store rpc into PCIe device */
        set_service_data(dev, rpc);
@@ -285,8 +284,7 @@ static void aer_remove(struct pcie_device *dev)
                if (rpc->isr)
                        free_irq(dev->irq, dev);
 
-               wait_event(rpc->wait_release, rpc->prod_idx == rpc->cons_idx);
-
+               flush_work(&rpc->dpc_handler);
                aer_disable_rootport(rpc);
                kfree(rpc);
                set_service_data(dev, NULL);
index 84420b7..945c939 100644 (file)
@@ -72,7 +72,6 @@ struct aer_rpc {
                                         * recovery on the same
                                         * root port hierarchy
                                         */
-       wait_queue_head_t wait_release;
 };
 
 struct aer_broadcast_data {
index 7123925..521e39c 100644 (file)
@@ -811,8 +811,6 @@ void aer_isr(struct work_struct *work)
        while (get_e_source(rpc, &e_src))
                aer_isr_one_error(p_device, &e_src);
        mutex_unlock(&rpc->rpc_mutex);
-
-       wake_up(&rpc->wait_release);
 }
 
 /**
index c777b97..5f70fee 100644 (file)
@@ -53,7 +53,7 @@ struct pcifront_device {
 };
 
 struct pcifront_sd {
-       int domain;
+       struct pci_sysdata sd;
        struct pcifront_device *pdev;
 };
 
@@ -67,7 +67,9 @@ static inline void pcifront_init_sd(struct pcifront_sd *sd,
                                    unsigned int domain, unsigned int bus,
                                    struct pcifront_device *pdev)
 {
-       sd->domain = domain;
+       /* Because we do not expose that information via XenBus. */
+       sd->sd.node = first_online_node;
+       sd->sd.domain = domain;
        sd->pdev = pdev;
 }
 
@@ -468,8 +470,8 @@ static int pcifront_scan_root(struct pcifront_device *pdev,
        dev_info(&pdev->xdev->dev, "Creating PCI Frontend Bus %04x:%02x\n",
                 domain, bus);
 
-       bus_entry = kmalloc(sizeof(*bus_entry), GFP_KERNEL);
-       sd = kmalloc(sizeof(*sd), GFP_KERNEL);
+       bus_entry = kzalloc(sizeof(*bus_entry), GFP_KERNEL);
+       sd = kzalloc(sizeof(*sd), GFP_KERNEL);
        if (!bus_entry || !sd) {
                err = -ENOMEM;
                goto err_out;
index e7e117d..0124d17 100644 (file)
@@ -224,6 +224,7 @@ config PHY_MT65XX_USB3
 
 config PHY_HI6220_USB
        tristate "hi6220 USB PHY support"
+       depends on (ARCH_HISI && ARM64) || COMPILE_TEST
        select GENERIC_PHY
        select MFD_SYSCON
        help
index 8c7f27d..e7e574d 100644 (file)
@@ -275,20 +275,21 @@ EXPORT_SYMBOL_GPL(phy_exit);
 
 int phy_power_on(struct phy *phy)
 {
-       int ret;
+       int ret = 0;
 
        if (!phy)
-               return 0;
+               goto out;
 
        if (phy->pwr) {
                ret = regulator_enable(phy->pwr);
                if (ret)
-                       return ret;
+                       goto out;
        }
 
        ret = phy_pm_runtime_get_sync(phy);
        if (ret < 0 && ret != -ENOTSUPP)
-               return ret;
+               goto err_pm_sync;
+
        ret = 0; /* Override possible ret == -ENOTSUPP */
 
        mutex_lock(&phy->mutex);
@@ -296,19 +297,20 @@ int phy_power_on(struct phy *phy)
                ret = phy->ops->power_on(phy);
                if (ret < 0) {
                        dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
-                       goto out;
+                       goto err_pwr_on;
                }
        }
        ++phy->power_count;
        mutex_unlock(&phy->mutex);
        return 0;
 
-out:
+err_pwr_on:
        mutex_unlock(&phy->mutex);
        phy_pm_runtime_put_sync(phy);
+err_pm_sync:
        if (phy->pwr)
                regulator_disable(phy->pwr);
-
+out:
        return ret;
 }
 EXPORT_SYMBOL_GPL(phy_power_on);
index 4a3fc6e..840f3ea 100644 (file)
@@ -715,6 +715,7 @@ static int twl4030_usb_probe(struct platform_device *pdev)
        pm_runtime_use_autosuspend(&pdev->dev);
        pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
        pm_runtime_enable(&pdev->dev);
+       pm_runtime_get_sync(&pdev->dev);
 
        /* Our job is to use irqs and status from the power module
         * to keep the transceiver disabled when nothing's connected.
@@ -750,6 +751,7 @@ static int twl4030_usb_remove(struct platform_device *pdev)
        struct twl4030_usb *twl = platform_get_drvdata(pdev);
        int val;
 
+       usb_remove_phy(&twl->phy);
        pm_runtime_get_sync(twl->dev);
        cancel_delayed_work(&twl->id_workaround_work);
        device_remove_file(twl->dev, &dev_attr_vbus);
@@ -757,6 +759,13 @@ static int twl4030_usb_remove(struct platform_device *pdev)
        /* set transceiver mode to power on defaults */
        twl4030_usb_set_mode(twl, -1);
 
+       /* idle ulpi before powering off */
+       if (cable_present(twl->linkstat))
+               pm_runtime_put_noidle(twl->dev);
+       pm_runtime_mark_last_busy(twl->dev);
+       pm_runtime_put_sync_suspend(twl->dev);
+       pm_runtime_disable(twl->dev);
+
        /* autogate 60MHz ULPI clock,
         * clear dpll clock request for i2c access,
         * disable 32KHz
@@ -771,11 +780,6 @@ static int twl4030_usb_remove(struct platform_device *pdev)
        /* disable complete OTG block */
        twl4030_usb_clear_bits(twl, POWER_CTRL, POWER_CTRL_OTG_ENAB);
 
-       if (cable_present(twl->linkstat))
-               pm_runtime_put_noidle(twl->dev);
-       pm_runtime_mark_last_busy(twl->dev);
-       pm_runtime_put(twl->dev);
-
        return 0;
 }
 
index 16d48a4..e96e86d 100644 (file)
@@ -347,6 +347,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev,
                ret = mtk_pconf_set_pull_select(pctl, pin, true, false, arg);
                break;
        case PIN_CONFIG_INPUT_ENABLE:
+               mtk_pmx_gpio_set_direction(pctldev, NULL, pin, true);
                ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param);
                break;
        case PIN_CONFIG_OUTPUT:
@@ -354,6 +355,7 @@ static int mtk_pconf_parse_conf(struct pinctrl_dev *pctldev,
                ret = mtk_pmx_gpio_set_direction(pctldev, NULL, pin, false);
                break;
        case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
+               mtk_pmx_gpio_set_direction(pctldev, NULL, pin, true);
                ret = mtk_pconf_set_ies_smt(pctl, pin, arg, param);
                break;
        case PIN_CONFIG_DRIVE_STRENGTH:
index e4d4738..3ef798f 100644 (file)
@@ -666,16 +666,19 @@ int mvebu_pinctrl_probe(struct platform_device *pdev)
                struct mvebu_mpp_ctrl_setting *set = &mode->settings[0];
                struct mvebu_pinctrl_group *grp;
                unsigned num_settings;
+               unsigned supp_settings;
 
-               for (num_settings = 0; ; set++) {
+               for (num_settings = 0, supp_settings = 0; ; set++) {
                        if (!set->name)
                                break;
 
+                       num_settings++;
+
                        /* skip unsupported settings for this variant */
                        if (pctl->variant && !(pctl->variant & set->variant))
                                continue;
 
-                       num_settings++;
+                       supp_settings++;
 
                        /* find gpio/gpo/gpi settings */
                        if (strcmp(set->name, "gpio") == 0)
@@ -688,7 +691,7 @@ int mvebu_pinctrl_probe(struct platform_device *pdev)
                }
 
                /* skip modes with no settings for this variant */
-               if (!num_settings)
+               if (!supp_settings)
                        continue;
 
                grp = mvebu_pinctrl_find_group_by_pid(pctl, mode->pid);
index 085e601..1f7469c 100644 (file)
@@ -191,6 +191,7 @@ static void abx500_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
                dev_err(pct->dev, "%s write failed (%d)\n", __func__, ret);
 }
 
+#ifdef CONFIG_DEBUG_FS
 static int abx500_get_pull_updown(struct abx500_pinctrl *pct, int offset,
                                  enum abx500_gpio_pull_updown *pull_updown)
 {
@@ -226,6 +227,7 @@ out:
 
        return ret;
 }
+#endif
 
 static int abx500_set_pull_updown(struct abx500_pinctrl *pct,
                                  int offset, enum abx500_gpio_pull_updown val)
@@ -468,6 +470,7 @@ out:
        return ret;
 }
 
+#ifdef CONFIG_DEBUG_FS
 static int abx500_get_mode(struct pinctrl_dev *pctldev, struct gpio_chip *chip,
                          unsigned gpio)
 {
@@ -553,8 +556,6 @@ out:
        return ret;
 }
 
-#ifdef CONFIG_DEBUG_FS
-
 #include <linux/seq_file.h>
 
 static void abx500_gpio_dbg_show_one(struct seq_file *s,
index d90e205..216f227 100644 (file)
@@ -426,6 +426,7 @@ int pxa2xx_pinctrl_init(struct platform_device *pdev,
 
        return 0;
 }
+EXPORT_SYMBOL(pxa2xx_pinctrl_init);
 
 int pxa2xx_pinctrl_exit(struct platform_device *pdev)
 {
index f67b1e9..5cc97f8 100644 (file)
@@ -514,25 +514,35 @@ static const struct pinconf_ops samsung_pinconf_ops = {
        .pin_config_group_set   = samsung_pinconf_group_set,
 };
 
-/* gpiolib gpio_set callback function */
-static void samsung_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
+/*
+ * The samsung_gpio_set_vlaue() should be called with "bank->slock" held
+ * to avoid race condition.
+ */
+static void samsung_gpio_set_value(struct gpio_chip *gc,
+                                         unsigned offset, int value)
 {
        struct samsung_pin_bank *bank = gpiochip_get_data(gc);
        const struct samsung_pin_bank_type *type = bank->type;
-       unsigned long flags;
        void __iomem *reg;
        u32 data;
 
        reg = bank->drvdata->virt_base + bank->pctl_offset;
 
-       spin_lock_irqsave(&bank->slock, flags);
-
        data = readl(reg + type->reg_offset[PINCFG_TYPE_DAT]);
        data &= ~(1 << offset);
        if (value)
                data |= 1 << offset;
        writel(data, reg + type->reg_offset[PINCFG_TYPE_DAT]);
+}
+
+/* gpiolib gpio_set callback function */
+static void samsung_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
+{
+       struct samsung_pin_bank *bank = gpiochip_get_data(gc);
+       unsigned long flags;
 
+       spin_lock_irqsave(&bank->slock, flags);
+       samsung_gpio_set_value(gc, offset, value);
        spin_unlock_irqrestore(&bank->slock, flags);
 }
 
@@ -553,6 +563,8 @@ static int samsung_gpio_get(struct gpio_chip *gc, unsigned offset)
 }
 
 /*
+ * The samsung_gpio_set_direction() should be called with "bank->slock" held
+ * to avoid race condition.
  * The calls to gpio_direction_output() and gpio_direction_input()
  * leads to this function call.
  */
@@ -564,7 +576,6 @@ static int samsung_gpio_set_direction(struct gpio_chip *gc,
        struct samsung_pinctrl_drv_data *drvdata;
        void __iomem *reg;
        u32 data, mask, shift;
-       unsigned long flags;
 
        bank = gpiochip_get_data(gc);
        type = bank->type;
@@ -581,31 +592,42 @@ static int samsung_gpio_set_direction(struct gpio_chip *gc,
                reg += 4;
        }
 
-       spin_lock_irqsave(&bank->slock, flags);
-
        data = readl(reg);
        data &= ~(mask << shift);
        if (!input)
                data |= FUNC_OUTPUT << shift;
        writel(data, reg);
 
-       spin_unlock_irqrestore(&bank->slock, flags);
-
        return 0;
 }
 
 /* gpiolib gpio_direction_input callback function. */
 static int samsung_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
 {
-       return samsung_gpio_set_direction(gc, offset, true);
+       struct samsung_pin_bank *bank = gpiochip_get_data(gc);
+       unsigned long flags;
+       int ret;
+
+       spin_lock_irqsave(&bank->slock, flags);
+       ret = samsung_gpio_set_direction(gc, offset, true);
+       spin_unlock_irqrestore(&bank->slock, flags);
+       return ret;
 }
 
 /* gpiolib gpio_direction_output callback function. */
 static int samsung_gpio_direction_output(struct gpio_chip *gc, unsigned offset,
                                                        int value)
 {
-       samsung_gpio_set(gc, offset, value);
-       return samsung_gpio_set_direction(gc, offset, false);
+       struct samsung_pin_bank *bank = gpiochip_get_data(gc);
+       unsigned long flags;
+       int ret;
+
+       spin_lock_irqsave(&bank->slock, flags);
+       samsung_gpio_set_value(gc, offset, value);
+       ret = samsung_gpio_set_direction(gc, offset, false);
+       spin_unlock_irqrestore(&bank->slock, flags);
+
+       return ret;
 }
 
 /*
index 77d4cf0..11760bb 100644 (file)
@@ -492,6 +492,7 @@ static const struct sunxi_pinctrl_desc sun8i_h3_pinctrl_data = {
        .pins = sun8i_h3_pins,
        .npins = ARRAY_SIZE(sun8i_h3_pins),
        .irq_banks = 2,
+       .irq_read_needs_mux = true
 };
 
 static int sun8i_h3_pinctrl_probe(struct platform_device *pdev)
index 20f0ad9..e20f23e 100644 (file)
@@ -41,8 +41,7 @@ static const struct key_entry intel_hid_keymap[] = {
        { KE_KEY, 4, { KEY_HOME } },
        { KE_KEY, 5, { KEY_END } },
        { KE_KEY, 6, { KEY_PAGEUP } },
-       { KE_KEY, 4, { KEY_PAGEDOWN } },
-       { KE_KEY, 4, { KEY_HOME } },
+       { KE_KEY, 7, { KEY_PAGEDOWN } },
        { KE_KEY, 8, { KEY_RFKILL } },
        { KE_KEY, 9, { KEY_POWER } },
        { KE_KEY, 11, { KEY_SLEEP } },
index 02bc5a6..aa45424 100644 (file)
@@ -49,7 +49,7 @@ struct scu_ipc_data {
 
 static int scu_reg_access(u32 cmd, struct scu_ipc_data  *data)
 {
-       int count = data->count;
+       unsigned int count = data->count;
 
        if (count == 0 || count == 3 || count > 4)
                return -EINVAL;
index 9429e66..8eafc6f 100644 (file)
@@ -21,6 +21,9 @@
 
 #include <linux/power/bq27xxx_battery.h>
 
+static DEFINE_IDR(battery_id);
+static DEFINE_MUTEX(battery_mutex);
+
 static irqreturn_t bq27xxx_battery_irq_handler_thread(int irq, void *data)
 {
        struct bq27xxx_device_info *di = data;
@@ -70,19 +73,33 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client,
 {
        struct bq27xxx_device_info *di;
        int ret;
+       char *name;
+       int num;
+
+       /* Get new ID for the new battery device */
+       mutex_lock(&battery_mutex);
+       num = idr_alloc(&battery_id, client, 0, 0, GFP_KERNEL);
+       mutex_unlock(&battery_mutex);
+       if (num < 0)
+               return num;
+
+       name = devm_kasprintf(&client->dev, GFP_KERNEL, "%s-%d", id->name, num);
+       if (!name)
+               goto err_mem;
 
        di = devm_kzalloc(&client->dev, sizeof(*di), GFP_KERNEL);
        if (!di)
-               return -ENOMEM;
+               goto err_mem;
 
+       di->id = num;
        di->dev = &client->dev;
        di->chip = id->driver_data;
-       di->name = id->name;
+       di->name = name;
        di->bus.read = bq27xxx_battery_i2c_read;
 
        ret = bq27xxx_battery_setup(di);
        if (ret)
-               return ret;
+               goto err_failed;
 
        /* Schedule a polling after about 1 min */
        schedule_delayed_work(&di->work, 60 * HZ);
@@ -103,6 +120,16 @@ static int bq27xxx_battery_i2c_probe(struct i2c_client *client,
        }
 
        return 0;
+
+err_mem:
+       ret = -ENOMEM;
+
+err_failed:
+       mutex_lock(&battery_mutex);
+       idr_remove(&battery_id, num);
+       mutex_unlock(&battery_mutex);
+
+       return ret;
 }
 
 static int bq27xxx_battery_i2c_remove(struct i2c_client *client)
@@ -111,6 +138,10 @@ static int bq27xxx_battery_i2c_remove(struct i2c_client *client)
 
        bq27xxx_battery_teardown(di);
 
+       mutex_lock(&battery_mutex);
+       idr_remove(&battery_id, di->id);
+       mutex_unlock(&battery_mutex);
+
        return 0;
 }
 
index 41605da..c78db05 100644 (file)
@@ -3035,6 +3035,7 @@ static void dasd_setup_queue(struct dasd_block *block)
                max = block->base->discipline->max_blocks << block->s2b_shift;
        }
        queue_flag_set_unlocked(QUEUE_FLAG_NONROT, block->request_queue);
+       block->request_queue->limits.max_dev_sectors = max;
        blk_queue_logical_block_size(block->request_queue,
                                     block->bp_block);
        blk_queue_max_hw_sectors(block->request_queue, max);
index 184b1db..286782c 100644 (file)
@@ -264,8 +264,10 @@ void dasd_alias_disconnect_device_from_lcu(struct dasd_device *device)
                spin_unlock_irqrestore(&lcu->lock, flags);
                cancel_work_sync(&lcu->suc_data.worker);
                spin_lock_irqsave(&lcu->lock, flags);
-               if (device == lcu->suc_data.device)
+               if (device == lcu->suc_data.device) {
+                       dasd_put_device(device);
                        lcu->suc_data.device = NULL;
+               }
        }
        was_pending = 0;
        if (device == lcu->ruac_data.device) {
@@ -273,8 +275,10 @@ void dasd_alias_disconnect_device_from_lcu(struct dasd_device *device)
                was_pending = 1;
                cancel_delayed_work_sync(&lcu->ruac_data.dwork);
                spin_lock_irqsave(&lcu->lock, flags);
-               if (device == lcu->ruac_data.device)
+               if (device == lcu->ruac_data.device) {
+                       dasd_put_device(device);
                        lcu->ruac_data.device = NULL;
+               }
        }
        private->lcu = NULL;
        spin_unlock_irqrestore(&lcu->lock, flags);
@@ -549,8 +553,10 @@ static void lcu_update_work(struct work_struct *work)
        if ((rc && (rc != -EOPNOTSUPP)) || (lcu->flags & NEED_UAC_UPDATE)) {
                DBF_DEV_EVENT(DBF_WARNING, device, "could not update"
                            " alias data in lcu (rc = %d), retry later", rc);
-               schedule_delayed_work(&lcu->ruac_data.dwork, 30*HZ);
+               if (!schedule_delayed_work(&lcu->ruac_data.dwork, 30*HZ))
+                       dasd_put_device(device);
        } else {
+               dasd_put_device(device);
                lcu->ruac_data.device = NULL;
                lcu->flags &= ~UPDATE_PENDING;
        }
@@ -593,8 +599,10 @@ static int _schedule_lcu_update(struct alias_lcu *lcu,
         */
        if (!usedev)
                return -EINVAL;
+       dasd_get_device(usedev);
        lcu->ruac_data.device = usedev;
-       schedule_delayed_work(&lcu->ruac_data.dwork, 0);
+       if (!schedule_delayed_work(&lcu->ruac_data.dwork, 0))
+               dasd_put_device(usedev);
        return 0;
 }
 
@@ -723,7 +731,7 @@ static int reset_summary_unit_check(struct alias_lcu *lcu,
        ASCEBC((char *) &cqr->magic, 4);
        ccw = cqr->cpaddr;
        ccw->cmd_code = DASD_ECKD_CCW_RSCK;
-       ccw->flags = ;
+       ccw->flags = CCW_FLAG_SLI;
        ccw->count = 16;
        ccw->cda = (__u32)(addr_t) cqr->data;
        ((char *)cqr->data)[0] = reason;
@@ -930,6 +938,7 @@ static void summary_unit_check_handling_work(struct work_struct *work)
        /* 3. read new alias configuration */
        _schedule_lcu_update(lcu, device);
        lcu->suc_data.device = NULL;
+       dasd_put_device(device);
        spin_unlock_irqrestore(&lcu->lock, flags);
 }
 
@@ -989,6 +998,8 @@ void dasd_alias_handle_summary_unit_check(struct dasd_device *device,
        }
        lcu->suc_data.reason = reason;
        lcu->suc_data.device = device;
+       dasd_get_device(device);
        spin_unlock(&lcu->lock);
-       schedule_work(&lcu->suc_data.worker);
+       if (!schedule_work(&lcu->suc_data.worker))
+               dasd_put_device(device);
 };
index cb61f30..277b5c8 100644 (file)
@@ -67,7 +67,7 @@ static const u8 DASD_DIAG_CMS1[] = { 0xc3, 0xd4, 0xe2, 0xf1 };/* EBCDIC CMS1 */
  * and function code cmd.
  * In case of an exception return 3. Otherwise return result of bitwise OR of
  * resulting condition code and DIAG return code. */
-static inline int dia250(void *iob, int cmd)
+static inline int __dia250(void *iob, int cmd)
 {
        register unsigned long reg2 asm ("2") = (unsigned long) iob;
        typedef union {
@@ -77,7 +77,6 @@ static inline int dia250(void *iob, int cmd)
        int rc;
 
        rc = 3;
-       diag_stat_inc(DIAG_STAT_X250);
        asm volatile(
                "       diag    2,%2,0x250\n"
                "0:     ipm     %0\n"
@@ -91,6 +90,12 @@ static inline int dia250(void *iob, int cmd)
        return rc;
 }
 
+static inline int dia250(void *iob, int cmd)
+{
+       diag_stat_inc(DIAG_STAT_X250);
+       return __dia250(iob, cmd);
+}
+
 /* Initialize block I/O to DIAG device using the specified blocksize and
  * block offset. On success, return zero and set end_block to contain the
  * number of blocks on the device minus the specified offset. Return non-zero
index 3613581..93880ed 100644 (file)
@@ -562,7 +562,7 @@ static int mode_select_handle_sense(struct scsi_device *sdev,
                        /*
                         * Command Lock contention
                         */
-                       err = SCSI_DH_RETRY;
+                       err = SCSI_DH_IMM_RETRY;
                break;
        default:
                break;
@@ -612,6 +612,8 @@ retry:
                err = mode_select_handle_sense(sdev, h->sense);
                if (err == SCSI_DH_RETRY && retry_cnt--)
                        goto retry;
+               if (err == SCSI_DH_IMM_RETRY)
+                       goto retry;
        }
        if (err == SCSI_DH_OK) {
                h->state = RDAC_STATE_ACTIVE;
index b676618..d1dd161 100644 (file)
@@ -1,6 +1,6 @@
 config SCSI_HISI_SAS
        tristate "HiSilicon SAS"
-       depends on HAS_DMA
+       depends on HAS_DMA && HAS_IOMEM
        depends on ARM64 || COMPILE_TEST
        select SCSI_SAS_LIBSAS
        select BLK_DEV_INTEGRITY
index 057fdeb..eea24d7 100644 (file)
@@ -1289,13 +1289,10 @@ static int slot_complete_v1_hw(struct hisi_hba *hisi_hba,
                goto out;
        }
 
-       if (cmplt_hdr_data & CMPLT_HDR_ERR_RCRD_XFRD_MSK) {
-               if (!(cmplt_hdr_data & CMPLT_HDR_CMD_CMPLT_MSK) ||
-                   !(cmplt_hdr_data & CMPLT_HDR_RSPNS_XFRD_MSK))
-                       ts->stat = SAS_DATA_OVERRUN;
-               else
-                       slot_err_v1_hw(hisi_hba, task, slot);
+       if (cmplt_hdr_data & CMPLT_HDR_ERR_RCRD_XFRD_MSK &&
+               !(cmplt_hdr_data & CMPLT_HDR_RSPNS_XFRD_MSK)) {
 
+               slot_err_v1_hw(hisi_hba, task, slot);
                goto out;
        }
 
index 3b3e099..d6a691e 100644 (file)
@@ -4002,6 +4002,7 @@ static ssize_t ipr_store_update_fw(struct device *dev,
        struct ipr_sglist *sglist;
        char fname[100];
        char *src;
+       char *endline;
        int result, dnld_size;
 
        if (!capable(CAP_SYS_ADMIN))
@@ -4009,6 +4010,10 @@ static ssize_t ipr_store_update_fw(struct device *dev,
 
        snprintf(fname, sizeof(fname), "%s", buf);
 
+       endline = strchr(fname, '\n');
+       if (endline)
+               *endline = '\0';
+
        if (request_firmware(&fw_entry, fname, &ioa_cfg->pdev->dev)) {
                dev_err(&ioa_cfg->pdev->dev, "Firmware file %s not found\n", fname);
                return -EIO;
index 52a8765..692a757 100644 (file)
@@ -2204,7 +2204,7 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
        /* Clear outstanding commands array. */
        for (que = 0; que < ha->max_req_queues; que++) {
                req = ha->req_q_map[que];
-               if (!req)
+               if (!req || !test_bit(que, ha->req_qid_map))
                        continue;
                req->out_ptr = (void *)(req->ring + req->length);
                *req->out_ptr = 0;
@@ -2221,7 +2221,7 @@ qla2x00_init_rings(scsi_qla_host_t *vha)
 
        for (que = 0; que < ha->max_rsp_queues; que++) {
                rsp = ha->rsp_q_map[que];
-               if (!rsp)
+               if (!rsp || !test_bit(que, ha->rsp_qid_map))
                        continue;
                rsp->in_ptr = (void *)(rsp->ring + rsp->length);
                *rsp->in_ptr = 0;
@@ -4981,7 +4981,7 @@ qla25xx_init_queues(struct qla_hw_data *ha)
 
        for (i = 1; i < ha->max_rsp_queues; i++) {
                rsp = ha->rsp_q_map[i];
-               if (rsp) {
+               if (rsp && test_bit(i, ha->rsp_qid_map)) {
                        rsp->options &= ~BIT_0;
                        ret = qla25xx_init_rsp_que(base_vha, rsp);
                        if (ret != QLA_SUCCESS)
@@ -4996,8 +4996,8 @@ qla25xx_init_queues(struct qla_hw_data *ha)
        }
        for (i = 1; i < ha->max_req_queues; i++) {
                req = ha->req_q_map[i];
-               if (req) {
-               /* Clear outstanding commands array. */
+               if (req && test_bit(i, ha->req_qid_map)) {
+                       /* Clear outstanding commands array. */
                        req->options &= ~BIT_0;
                        ret = qla25xx_init_req_que(base_vha, req);
                        if (ret != QLA_SUCCESS)
index d4d65eb..4af9547 100644 (file)
@@ -3063,9 +3063,9 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
                    "MSI-X: Failed to enable support "
                    "-- %d/%d\n Retry with %d vectors.\n",
                    ha->msix_count, ret, ret);
+               ha->msix_count = ret;
+               ha->max_rsp_queues = ha->msix_count - 1;
        }
-       ha->msix_count = ret;
-       ha->max_rsp_queues = ha->msix_count - 1;
        ha->msix_entries = kzalloc(sizeof(struct qla_msix_entry) *
                                ha->msix_count, GFP_KERNEL);
        if (!ha->msix_entries) {
index c5dd594..cf7ba52 100644 (file)
@@ -600,7 +600,7 @@ qla25xx_delete_queues(struct scsi_qla_host *vha)
        /* Delete request queues */
        for (cnt = 1; cnt < ha->max_req_queues; cnt++) {
                req = ha->req_q_map[cnt];
-               if (req) {
+               if (req && test_bit(cnt, ha->req_qid_map)) {
                        ret = qla25xx_delete_req_que(vha, req);
                        if (ret != QLA_SUCCESS) {
                                ql_log(ql_log_warn, vha, 0x00ea,
@@ -614,7 +614,7 @@ qla25xx_delete_queues(struct scsi_qla_host *vha)
        /* Delete response queues */
        for (cnt = 1; cnt < ha->max_rsp_queues; cnt++) {
                rsp = ha->rsp_q_map[cnt];
-               if (rsp) {
+               if (rsp && test_bit(cnt, ha->rsp_qid_map)) {
                        ret = qla25xx_delete_rsp_que(vha, rsp);
                        if (ret != QLA_SUCCESS) {
                                ql_log(ql_log_warn, vha, 0x00eb,
index f1788db..f6c7ce3 100644 (file)
@@ -409,6 +409,9 @@ static void qla2x00_free_queues(struct qla_hw_data *ha)
        int cnt;
 
        for (cnt = 0; cnt < ha->max_req_queues; cnt++) {
+               if (!test_bit(cnt, ha->req_qid_map))
+                       continue;
+
                req = ha->req_q_map[cnt];
                qla2x00_free_req_que(ha, req);
        }
@@ -416,6 +419,9 @@ static void qla2x00_free_queues(struct qla_hw_data *ha)
        ha->req_q_map = NULL;
 
        for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) {
+               if (!test_bit(cnt, ha->rsp_qid_map))
+                       continue;
+
                rsp = ha->rsp_q_map[cnt];
                qla2x00_free_rsp_que(ha, rsp);
        }
index 8075a4c..ee967be 100644 (file)
@@ -105,7 +105,7 @@ static void qlt_response_pkt(struct scsi_qla_host *ha, response_t *pkt);
 static int qlt_issue_task_mgmt(struct qla_tgt_sess *sess, uint32_t lun,
        int fn, void *iocb, int flags);
 static void qlt_send_term_exchange(struct scsi_qla_host *ha, struct qla_tgt_cmd
-       *cmd, struct atio_from_isp *atio, int ha_locked);
+       *cmd, struct atio_from_isp *atio, int ha_locked, int ul_abort);
 static void qlt_reject_free_srr_imm(struct scsi_qla_host *ha,
        struct qla_tgt_srr_imm *imm, int ha_lock);
 static void qlt_abort_cmd_on_host_reset(struct scsi_qla_host *vha,
@@ -1756,7 +1756,7 @@ void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *mcmd)
                qlt_send_notify_ack(vha, &mcmd->orig_iocb.imm_ntfy,
                    0, 0, 0, 0, 0, 0);
        else {
-               if (mcmd->se_cmd.se_tmr_req->function == TMR_ABORT_TASK)
+               if (mcmd->orig_iocb.atio.u.raw.entry_type == ABTS_RECV_24XX)
                        qlt_24xx_send_abts_resp(vha, &mcmd->orig_iocb.abts,
                            mcmd->fc_tm_rsp, false);
                else
@@ -2665,7 +2665,7 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type,
                        /* no need to terminate. FW already freed exchange. */
                        qlt_abort_cmd_on_host_reset(cmd->vha, cmd);
                else
-                       qlt_send_term_exchange(vha, cmd, &cmd->atio, 1);
+                       qlt_send_term_exchange(vha, cmd, &cmd->atio, 1, 0);
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
                return 0;
        }
@@ -3173,7 +3173,8 @@ static int __qlt_send_term_exchange(struct scsi_qla_host *vha,
 }
 
 static void qlt_send_term_exchange(struct scsi_qla_host *vha,
-       struct qla_tgt_cmd *cmd, struct atio_from_isp *atio, int ha_locked)
+       struct qla_tgt_cmd *cmd, struct atio_from_isp *atio, int ha_locked,
+       int ul_abort)
 {
        unsigned long flags = 0;
        int rc;
@@ -3193,8 +3194,7 @@ static void qlt_send_term_exchange(struct scsi_qla_host *vha,
                qlt_alloc_qfull_cmd(vha, atio, 0, 0);
 
 done:
-       if (cmd && (!cmd->aborted ||
-           !cmd->cmd_sent_to_fw)) {
+       if (cmd && !ul_abort && !cmd->aborted) {
                if (cmd->sg_mapped)
                        qlt_unmap_sg(vha, cmd);
                vha->hw->tgt.tgt_ops->free_cmd(cmd);
@@ -3253,21 +3253,38 @@ static void qlt_chk_exch_leak_thresh_hold(struct scsi_qla_host *vha)
 
 }
 
-void qlt_abort_cmd(struct qla_tgt_cmd *cmd)
+int qlt_abort_cmd(struct qla_tgt_cmd *cmd)
 {
        struct qla_tgt *tgt = cmd->tgt;
        struct scsi_qla_host *vha = tgt->vha;
        struct se_cmd *se_cmd = &cmd->se_cmd;
+       unsigned long flags;
 
        ql_dbg(ql_dbg_tgt_mgt, vha, 0xf014,
            "qla_target(%d): terminating exchange for aborted cmd=%p "
            "(se_cmd=%p, tag=%llu)", vha->vp_idx, cmd, &cmd->se_cmd,
            se_cmd->tag);
 
+       spin_lock_irqsave(&cmd->cmd_lock, flags);
+       if (cmd->aborted) {
+               spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+               /*
+                * It's normal to see 2 calls in this path:
+                *  1) XFER Rdy completion + CMD_T_ABORT
+                *  2) TCM TMR - drain_state_list
+                */
+               ql_dbg(ql_dbg_tgt_mgt, vha, 0xffff,
+                       "multiple abort. %p transport_state %x, t_state %x,"
+                       " se_cmd_flags %x \n", cmd, cmd->se_cmd.transport_state,
+                       cmd->se_cmd.t_state,cmd->se_cmd.se_cmd_flags);
+               return EIO;
+       }
        cmd->aborted = 1;
        cmd->cmd_flags |= BIT_6;
+       spin_unlock_irqrestore(&cmd->cmd_lock, flags);
 
-       qlt_send_term_exchange(vha, cmd, &cmd->atio, 0);
+       qlt_send_term_exchange(vha, cmd, &cmd->atio, 0, 1);
+       return 0;
 }
 EXPORT_SYMBOL(qlt_abort_cmd);
 
@@ -3282,6 +3299,9 @@ void qlt_free_cmd(struct qla_tgt_cmd *cmd)
 
        BUG_ON(cmd->cmd_in_wq);
 
+       if (cmd->sg_mapped)
+               qlt_unmap_sg(cmd->vha, cmd);
+
        if (!cmd->q_full)
                qlt_decr_num_pend_cmds(cmd->vha);
 
@@ -3399,7 +3419,7 @@ static int qlt_term_ctio_exchange(struct scsi_qla_host *vha, void *ctio,
                term = 1;
 
        if (term)
-               qlt_send_term_exchange(vha, cmd, &cmd->atio, 1);
+               qlt_send_term_exchange(vha, cmd, &cmd->atio, 1, 0);
 
        return term;
 }
@@ -3580,12 +3600,13 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha, uint32_t handle,
                case CTIO_PORT_LOGGED_OUT:
                case CTIO_PORT_UNAVAILABLE:
                {
-                       int logged_out = (status & 0xFFFF);
+                       int logged_out =
+                               (status & 0xFFFF) == CTIO_PORT_LOGGED_OUT;
+
                        ql_dbg(ql_dbg_tgt_mgt, vha, 0xf059,
                            "qla_target(%d): CTIO with %s status %x "
                            "received (state %x, se_cmd %p)\n", vha->vp_idx,
-                           (logged_out == CTIO_PORT_LOGGED_OUT) ?
-                           "PORT LOGGED OUT" : "PORT UNAVAILABLE",
+                           logged_out ? "PORT LOGGED OUT" : "PORT UNAVAILABLE",
                            status, cmd->state, se_cmd);
 
                        if (logged_out && cmd->sess) {
@@ -3754,6 +3775,7 @@ static void __qlt_do_work(struct qla_tgt_cmd *cmd)
                goto out_term;
        }
 
+       spin_lock_init(&cmd->cmd_lock);
        cdb = &atio->u.isp24.fcp_cmnd.cdb[0];
        cmd->se_cmd.tag = atio->u.isp24.exchange_addr;
        cmd->unpacked_lun = scsilun_to_int(
@@ -3796,7 +3818,7 @@ out_term:
         */
        cmd->cmd_flags |= BIT_2;
        spin_lock_irqsave(&ha->hardware_lock, flags);
-       qlt_send_term_exchange(vha, NULL, &cmd->atio, 1);
+       qlt_send_term_exchange(vha, NULL, &cmd->atio, 1, 0);
 
        qlt_decr_num_pend_cmds(vha);
        percpu_ida_free(&sess->se_sess->sess_tag_pool, cmd->se_cmd.map_tag);
@@ -3918,7 +3940,7 @@ static void qlt_create_sess_from_atio(struct work_struct *work)
 
 out_term:
        spin_lock_irqsave(&ha->hardware_lock, flags);
-       qlt_send_term_exchange(vha, NULL, &op->atio, 1);
+       qlt_send_term_exchange(vha, NULL, &op->atio, 1, 0);
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
        kfree(op);
 
@@ -3982,7 +4004,8 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha,
 
        cmd->cmd_in_wq = 1;
        cmd->cmd_flags |= BIT_0;
-       cmd->se_cmd.cpuid = -1;
+       cmd->se_cmd.cpuid = ha->msix_count ?
+               ha->tgt.rspq_vector_cpuid : WORK_CPU_UNBOUND;
 
        spin_lock(&vha->cmd_list_lock);
        list_add_tail(&cmd->cmd_list, &vha->qla_cmd_list);
@@ -3990,7 +4013,6 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha,
 
        INIT_WORK(&cmd->work, qlt_do_work);
        if (ha->msix_count) {
-               cmd->se_cmd.cpuid = ha->tgt.rspq_vector_cpuid;
                if (cmd->atio.u.isp24.fcp_cmnd.rddata)
                        queue_work_on(smp_processor_id(), qla_tgt_wq,
                            &cmd->work);
@@ -4771,7 +4793,7 @@ out_reject:
                dump_stack();
        } else {
                cmd->cmd_flags |= BIT_9;
-               qlt_send_term_exchange(vha, cmd, &cmd->atio, 1);
+               qlt_send_term_exchange(vha, cmd, &cmd->atio, 1, 0);
        }
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
 }
@@ -4950,7 +4972,7 @@ static void qlt_prepare_srr_imm(struct scsi_qla_host *vha,
                                    sctio, sctio->srr_id);
                                list_del(&sctio->srr_list_entry);
                                qlt_send_term_exchange(vha, sctio->cmd,
-                                   &sctio->cmd->atio, 1);
+                                   &sctio->cmd->atio, 1, 0);
                                kfree(sctio);
                        }
                }
@@ -5123,7 +5145,7 @@ static int __qlt_send_busy(struct scsi_qla_host *vha,
            atio->u.isp24.fcp_hdr.s_id);
        spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
        if (!sess) {
-               qlt_send_term_exchange(vha, NULL, atio, 1);
+               qlt_send_term_exchange(vha, NULL, atio, 1, 0);
                return 0;
        }
        /* Sending marker isn't necessary, since we called from ISR */
@@ -5406,7 +5428,7 @@ static void qlt_24xx_atio_pkt(struct scsi_qla_host *vha,
 #if 1 /* With TERM EXCHANGE some FC cards refuse to boot */
                                qlt_send_busy(vha, atio, SAM_STAT_BUSY);
 #else
-                               qlt_send_term_exchange(vha, NULL, atio, 1);
+                               qlt_send_term_exchange(vha, NULL, atio, 1, 0);
 #endif
 
                                if (!ha_locked)
@@ -5523,7 +5545,7 @@ static void qlt_response_pkt(struct scsi_qla_host *vha, response_t *pkt)
 #if 1 /* With TERM EXCHANGE some FC cards refuse to boot */
                                qlt_send_busy(vha, atio, 0);
 #else
-                               qlt_send_term_exchange(vha, NULL, atio, 1);
+                               qlt_send_term_exchange(vha, NULL, atio, 1, 0);
 #endif
                        } else {
                                if (tgt->tgt_stop) {
@@ -5532,7 +5554,7 @@ static void qlt_response_pkt(struct scsi_qla_host *vha, response_t *pkt)
                                            "command to target, sending TERM "
                                            "EXCHANGE for rsp\n");
                                        qlt_send_term_exchange(vha, NULL,
-                                           atio, 1);
+                                           atio, 1, 0);
                                } else {
                                        ql_dbg(ql_dbg_tgt, vha, 0xe060,
                                            "qla_target(%d): Unable to send "
@@ -5960,7 +5982,7 @@ static void qlt_tmr_work(struct qla_tgt *tgt,
        return;
 
 out_term:
-       qlt_send_term_exchange(vha, NULL, &prm->tm_iocb2, 0);
+       qlt_send_term_exchange(vha, NULL, &prm->tm_iocb2, 1, 0);
        if (sess)
                ha->tgt.tgt_ops->put_sess(sess);
        spin_unlock_irqrestore(&ha->tgt.sess_lock, flags);
index 71b2865..22a6a76 100644 (file)
@@ -943,6 +943,36 @@ struct qla_tgt_sess {
        qlt_plogi_ack_t *plogi_link[QLT_PLOGI_LINK_MAX];
 };
 
+typedef enum {
+       /*
+        * BIT_0 - Atio Arrival / schedule to work
+        * BIT_1 - qlt_do_work
+        * BIT_2 - qlt_do work failed
+        * BIT_3 - xfer rdy/tcm_qla2xxx_write_pending
+        * BIT_4 - read respond/tcm_qla2xx_queue_data_in
+        * BIT_5 - status respond / tcm_qla2xx_queue_status
+        * BIT_6 - tcm request to abort/Term exchange.
+        *      pre_xmit_response->qlt_send_term_exchange
+        * BIT_7 - SRR received (qlt_handle_srr->qlt_xmit_response)
+        * BIT_8 - SRR received (qlt_handle_srr->qlt_rdy_to_xfer)
+        * BIT_9 - SRR received (qla_handle_srr->qlt_send_term_exchange)
+        * BIT_10 - Data in - hanlde_data->tcm_qla2xxx_handle_data
+
+        * BIT_12 - good completion - qlt_ctio_do_completion -->free_cmd
+        * BIT_13 - Bad completion -
+        *      qlt_ctio_do_completion --> qlt_term_ctio_exchange
+        * BIT_14 - Back end data received/sent.
+        * BIT_15 - SRR prepare ctio
+        * BIT_16 - complete free
+        * BIT_17 - flush - qlt_abort_cmd_on_host_reset
+        * BIT_18 - completion w/abort status
+        * BIT_19 - completion w/unknown status
+        * BIT_20 - tcm_qla2xxx_free_cmd
+        */
+       CMD_FLAG_DATA_WORK = BIT_11,
+       CMD_FLAG_DATA_WORK_FREE = BIT_21,
+} cmd_flags_t;
+
 struct qla_tgt_cmd {
        struct se_cmd se_cmd;
        struct qla_tgt_sess *sess;
@@ -952,6 +982,7 @@ struct qla_tgt_cmd {
        /* Sense buffer that will be mapped into outgoing status */
        unsigned char sense_buffer[TRANSPORT_SENSE_BUFFER];
 
+       spinlock_t cmd_lock;
        /* to save extra sess dereferences */
        unsigned int conf_compl_supported:1;
        unsigned int sg_mapped:1;
@@ -986,30 +1017,8 @@ struct qla_tgt_cmd {
 
        uint64_t jiffies_at_alloc;
        uint64_t jiffies_at_free;
-       /* BIT_0 - Atio Arrival / schedule to work
-        * BIT_1 - qlt_do_work
-        * BIT_2 - qlt_do work failed
-        * BIT_3 - xfer rdy/tcm_qla2xxx_write_pending
-        * BIT_4 - read respond/tcm_qla2xx_queue_data_in
-        * BIT_5 - status respond / tcm_qla2xx_queue_status
-        * BIT_6 - tcm request to abort/Term exchange.
-        *      pre_xmit_response->qlt_send_term_exchange
-        * BIT_7 - SRR received (qlt_handle_srr->qlt_xmit_response)
-        * BIT_8 - SRR received (qlt_handle_srr->qlt_rdy_to_xfer)
-        * BIT_9 - SRR received (qla_handle_srr->qlt_send_term_exchange)
-        * BIT_10 - Data in - hanlde_data->tcm_qla2xxx_handle_data
-        * BIT_11 - Data actually going to TCM : tcm_qla2xx_handle_data_work
-        * BIT_12 - good completion - qlt_ctio_do_completion -->free_cmd
-        * BIT_13 - Bad completion -
-        *      qlt_ctio_do_completion --> qlt_term_ctio_exchange
-        * BIT_14 - Back end data received/sent.
-        * BIT_15 - SRR prepare ctio
-        * BIT_16 - complete free
-        * BIT_17 - flush - qlt_abort_cmd_on_host_reset
-        * BIT_18 - completion w/abort status
-        * BIT_19 - completion w/unknown status
-        */
-       uint32_t cmd_flags;
+
+       cmd_flags_t cmd_flags;
 };
 
 struct qla_tgt_sess_work_param {
@@ -1148,7 +1157,7 @@ static inline void sid_to_portid(const uint8_t *s_id, port_id_t *p)
 extern void qlt_response_pkt_all_vps(struct scsi_qla_host *, response_t *);
 extern int qlt_rdy_to_xfer(struct qla_tgt_cmd *);
 extern int qlt_xmit_response(struct qla_tgt_cmd *, int, uint8_t);
-extern void qlt_abort_cmd(struct qla_tgt_cmd *);
+extern int qlt_abort_cmd(struct qla_tgt_cmd *);
 extern void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *);
 extern void qlt_free_mcmd(struct qla_tgt_mgmt_cmd *);
 extern void qlt_free_cmd(struct qla_tgt_cmd *cmd);
index ddbe2e7..c3e6225 100644 (file)
@@ -395,6 +395,10 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
        if (ent->t263.queue_type == T263_QUEUE_TYPE_REQ) {
                for (i = 0; i < vha->hw->max_req_queues; i++) {
                        struct req_que *req = vha->hw->req_q_map[i];
+
+                       if (!test_bit(i, vha->hw->req_qid_map))
+                               continue;
+
                        if (req || !buf) {
                                length = req ?
                                    req->length : REQUEST_ENTRY_CNT_24XX;
@@ -408,6 +412,10 @@ qla27xx_fwdt_entry_t263(struct scsi_qla_host *vha,
        } else if (ent->t263.queue_type == T263_QUEUE_TYPE_RSP) {
                for (i = 0; i < vha->hw->max_rsp_queues; i++) {
                        struct rsp_que *rsp = vha->hw->rsp_q_map[i];
+
+                       if (!test_bit(i, vha->hw->rsp_qid_map))
+                               continue;
+
                        if (rsp || !buf) {
                                length = rsp ?
                                    rsp->length : RESPONSE_ENTRY_CNT_MQ;
@@ -634,6 +642,10 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
        if (ent->t274.queue_type == T274_QUEUE_TYPE_REQ_SHAD) {
                for (i = 0; i < vha->hw->max_req_queues; i++) {
                        struct req_que *req = vha->hw->req_q_map[i];
+
+                       if (!test_bit(i, vha->hw->req_qid_map))
+                               continue;
+
                        if (req || !buf) {
                                qla27xx_insert16(i, buf, len);
                                qla27xx_insert16(1, buf, len);
@@ -645,6 +657,10 @@ qla27xx_fwdt_entry_t274(struct scsi_qla_host *vha,
        } else if (ent->t274.queue_type == T274_QUEUE_TYPE_RSP_SHAD) {
                for (i = 0; i < vha->hw->max_rsp_queues; i++) {
                        struct rsp_que *rsp = vha->hw->rsp_q_map[i];
+
+                       if (!test_bit(i, vha->hw->rsp_qid_map))
+                               continue;
+
                        if (rsp || !buf) {
                                qla27xx_insert16(i, buf, len);
                                qla27xx_insert16(1, buf, len);
index faf0a12..1808a01 100644 (file)
@@ -298,6 +298,10 @@ static void tcm_qla2xxx_free_cmd(struct qla_tgt_cmd *cmd)
 {
        cmd->vha->tgt_counters.core_qla_free_cmd++;
        cmd->cmd_in_wq = 1;
+
+       BUG_ON(cmd->cmd_flags & BIT_20);
+       cmd->cmd_flags |= BIT_20;
+
        INIT_WORK(&cmd->work, tcm_qla2xxx_complete_free);
        queue_work_on(smp_processor_id(), tcm_qla2xxx_free_wq, &cmd->work);
 }
@@ -374,6 +378,20 @@ static int tcm_qla2xxx_write_pending(struct se_cmd *se_cmd)
 {
        struct qla_tgt_cmd *cmd = container_of(se_cmd,
                                struct qla_tgt_cmd, se_cmd);
+
+       if (cmd->aborted) {
+               /* Cmd can loop during Q-full.  tcm_qla2xxx_aborted_task
+                * can get ahead of this cmd. tcm_qla2xxx_aborted_task
+                * already kick start the free.
+                */
+               pr_debug("write_pending aborted cmd[%p] refcount %d "
+                       "transport_state %x, t_state %x, se_cmd_flags %x\n",
+                       cmd,cmd->se_cmd.cmd_kref.refcount.counter,
+                       cmd->se_cmd.transport_state,
+                       cmd->se_cmd.t_state,
+                       cmd->se_cmd.se_cmd_flags);
+               return 0;
+       }
        cmd->cmd_flags |= BIT_3;
        cmd->bufflen = se_cmd->data_length;
        cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
@@ -405,7 +423,7 @@ static int tcm_qla2xxx_write_pending_status(struct se_cmd *se_cmd)
            se_cmd->t_state == TRANSPORT_COMPLETE_QF_WP) {
                spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
                wait_for_completion_timeout(&se_cmd->t_transport_stop_comp,
-                                           3 * HZ);
+                                               50);
                return 0;
        }
        spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
@@ -444,6 +462,9 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd,
        if (bidi)
                flags |= TARGET_SCF_BIDI_OP;
 
+       if (se_cmd->cpuid != WORK_CPU_UNBOUND)
+               flags |= TARGET_SCF_USE_CPUID;
+
        sess = cmd->sess;
        if (!sess) {
                pr_err("Unable to locate struct qla_tgt_sess from qla_tgt_cmd\n");
@@ -465,13 +486,25 @@ static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t *vha, struct qla_tgt_cmd *cmd,
 static void tcm_qla2xxx_handle_data_work(struct work_struct *work)
 {
        struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
+       unsigned long flags;
 
        /*
         * Ensure that the complete FCP WRITE payload has been received.
         * Otherwise return an exception via CHECK_CONDITION status.
         */
        cmd->cmd_in_wq = 0;
-       cmd->cmd_flags |= BIT_11;
+
+       spin_lock_irqsave(&cmd->cmd_lock, flags);
+       cmd->cmd_flags |= CMD_FLAG_DATA_WORK;
+       if (cmd->aborted) {
+               cmd->cmd_flags |= CMD_FLAG_DATA_WORK_FREE;
+               spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+
+               tcm_qla2xxx_free_cmd(cmd);
+               return;
+       }
+       spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+
        cmd->vha->tgt_counters.qla_core_ret_ctio++;
        if (!cmd->write_data_transferred) {
                /*
@@ -546,6 +579,20 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd)
        struct qla_tgt_cmd *cmd = container_of(se_cmd,
                                struct qla_tgt_cmd, se_cmd);
 
+       if (cmd->aborted) {
+               /* Cmd can loop during Q-full.  tcm_qla2xxx_aborted_task
+                * can get ahead of this cmd. tcm_qla2xxx_aborted_task
+                * already kick start the free.
+                */
+               pr_debug("queue_data_in aborted cmd[%p] refcount %d "
+                       "transport_state %x, t_state %x, se_cmd_flags %x\n",
+                       cmd,cmd->se_cmd.cmd_kref.refcount.counter,
+                       cmd->se_cmd.transport_state,
+                       cmd->se_cmd.t_state,
+                       cmd->se_cmd.se_cmd_flags);
+               return 0;
+       }
+
        cmd->cmd_flags |= BIT_4;
        cmd->bufflen = se_cmd->data_length;
        cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
@@ -637,11 +684,34 @@ static void tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
        qlt_xmit_tm_rsp(mcmd);
 }
 
+
+#define DATA_WORK_NOT_FREE(_flags) \
+       (( _flags & (CMD_FLAG_DATA_WORK|CMD_FLAG_DATA_WORK_FREE)) == \
+        CMD_FLAG_DATA_WORK)
 static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd)
 {
        struct qla_tgt_cmd *cmd = container_of(se_cmd,
                                struct qla_tgt_cmd, se_cmd);
-       qlt_abort_cmd(cmd);
+       unsigned long flags;
+
+       if (qlt_abort_cmd(cmd))
+               return;
+
+       spin_lock_irqsave(&cmd->cmd_lock, flags);
+       if ((cmd->state == QLA_TGT_STATE_NEW)||
+               ((cmd->state == QLA_TGT_STATE_DATA_IN) &&
+                DATA_WORK_NOT_FREE(cmd->cmd_flags)) ) {
+
+               cmd->cmd_flags |= CMD_FLAG_DATA_WORK_FREE;
+               spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+               /* Cmd have not reached firmware.
+                * Use this trigger to free it. */
+               tcm_qla2xxx_free_cmd(cmd);
+               return;
+       }
+       spin_unlock_irqrestore(&cmd->cmd_lock, flags);
+       return;
+
 }
 
 static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport *,
index 47b9d13..bbfbfd9 100644 (file)
@@ -205,6 +205,8 @@ static struct {
        {"Intel", "Multi-Flex", NULL, BLIST_NO_RSOC},
        {"iRiver", "iFP Mass Driver", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36},
        {"LASOUND", "CDX7405", "3.10", BLIST_MAX5LUN | BLIST_SINGLELUN},
+       {"Marvell", "Console", NULL, BLIST_SKIP_VPD_PAGES},
+       {"Marvell", "91xx Config", "1.01", BLIST_SKIP_VPD_PAGES},
        {"MATSHITA", "PD-1", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
        {"MATSHITA", "DMC-LC5", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36},
        {"MATSHITA", "DMC-LC40", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36},
index fa6b2c4..8c6e318 100644 (file)
@@ -1344,6 +1344,7 @@ scsi_prep_return(struct request_queue *q, struct request *req, int ret)
 
        switch (ret) {
        case BLKPREP_KILL:
+       case BLKPREP_INVALID:
                req->errors = DID_NO_CONNECT << 16;
                /* release the command and kill it */
                if (req->special) {
index 4f18a85..00bc721 100644 (file)
@@ -1272,16 +1272,18 @@ static void __scsi_remove_target(struct scsi_target *starget)
 void scsi_remove_target(struct device *dev)
 {
        struct Scsi_Host *shost = dev_to_shost(dev->parent);
-       struct scsi_target *starget;
+       struct scsi_target *starget, *last_target = NULL;
        unsigned long flags;
 
 restart:
        spin_lock_irqsave(shost->host_lock, flags);
        list_for_each_entry(starget, &shost->__targets, siblings) {
-               if (starget->state == STARGET_DEL)
+               if (starget->state == STARGET_DEL ||
+                   starget == last_target)
                        continue;
                if (starget->dev.parent == dev || &starget->dev == dev) {
                        kref_get(&starget->reap_ref);
+                       last_target = starget;
                        spin_unlock_irqrestore(shost->host_lock, flags);
                        __scsi_remove_target(starget);
                        scsi_target_reap(starget);
index bb669d3..d749da7 100644 (file)
@@ -761,7 +761,7 @@ static int sd_setup_discard_cmnd(struct scsi_cmnd *cmd)
                break;
 
        default:
-               ret = BLKPREP_KILL;
+               ret = BLKPREP_INVALID;
                goto out;
        }
 
@@ -839,7 +839,7 @@ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd)
        int ret;
 
        if (sdkp->device->no_write_same)
-               return BLKPREP_KILL;
+               return BLKPREP_INVALID;
 
        BUG_ON(bio_offset(bio) || bio_iovec(bio).bv_len != sdp->sector_size);
 
index 55627d0..292c04e 100644 (file)
@@ -42,6 +42,7 @@
 #include <scsi/scsi_devinfo.h>
 #include <scsi/scsi_dbg.h>
 #include <scsi/scsi_transport_fc.h>
+#include <scsi/scsi_transport.h>
 
 /*
  * All wire protocol details (storage protocol between the guest and the host)
@@ -477,19 +478,18 @@ struct hv_host_device {
 struct storvsc_scan_work {
        struct work_struct work;
        struct Scsi_Host *host;
-       uint lun;
+       u8 lun;
+       u8 tgt_id;
 };
 
 static void storvsc_device_scan(struct work_struct *work)
 {
        struct storvsc_scan_work *wrk;
-       uint lun;
        struct scsi_device *sdev;
 
        wrk = container_of(work, struct storvsc_scan_work, work);
-       lun = wrk->lun;
 
-       sdev = scsi_device_lookup(wrk->host, 0, 0, lun);
+       sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk->lun);
        if (!sdev)
                goto done;
        scsi_rescan_device(&sdev->sdev_gendev);
@@ -540,7 +540,7 @@ static void storvsc_remove_lun(struct work_struct *work)
        if (!scsi_host_get(wrk->host))
                goto done;
 
-       sdev = scsi_device_lookup(wrk->host, 0, 0, wrk->lun);
+       sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk->lun);
 
        if (sdev) {
                scsi_remove_device(sdev);
@@ -940,6 +940,7 @@ static void storvsc_handle_error(struct vmscsi_request *vm_srb,
 
        wrk->host = host;
        wrk->lun = vm_srb->lun;
+       wrk->tgt_id = vm_srb->target_id;
        INIT_WORK(&wrk->work, process_err_fn);
        schedule_work(&wrk->work);
 }
@@ -1770,6 +1771,11 @@ static int __init storvsc_drv_init(void)
        fc_transport_template = fc_attach_transport(&fc_transport_functions);
        if (!fc_transport_template)
                return -ENODEV;
+
+       /*
+        * Install Hyper-V specific timeout handler.
+        */
+       fc_transport_template->eh_timed_out = storvsc_eh_timed_out;
 #endif
 
        ret = vmbus_driver_register(&storvsc_drv);
index 91a0030..a9bac3b 100644 (file)
@@ -34,7 +34,7 @@ static struct pm_clk_notifier_block platform_bus_notifier = {
 
 static int __init sh_pm_runtime_init(void)
 {
-       if (IS_ENABLED(CONFIG_ARCH_SHMOBILE)) {
+       if (IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_ARCH_SHMOBILE)) {
                if (!of_find_compatible_node(NULL, NULL,
                                             "renesas,cpg-mstp-clocks"))
                        return 0;
index aebad36..8feac59 100644 (file)
@@ -1571,6 +1571,7 @@ static int atmel_spi_probe(struct platform_device *pdev)
 
        as->use_cs_gpios = true;
        if (atmel_spi_is_v2(as) &&
+           pdev->dev.of_node &&
            !of_get_property(pdev->dev.of_node, "cs-gpios", NULL)) {
                as->use_cs_gpios = false;
                master->num_chipselect = 4;
index 7de6f84..ecc73c0 100644 (file)
@@ -73,8 +73,8 @@
 
 /* Bitfields in CNTL1 */
 #define BCM2835_AUX_SPI_CNTL1_CSHIGH   0x00000700
-#define BCM2835_AUX_SPI_CNTL1_IDLE     0x00000080
-#define BCM2835_AUX_SPI_CNTL1_TXEMPTY  0x00000040
+#define BCM2835_AUX_SPI_CNTL1_TXEMPTY  0x00000080
+#define BCM2835_AUX_SPI_CNTL1_IDLE     0x00000040
 #define BCM2835_AUX_SPI_CNTL1_MSBF_IN  0x00000002
 #define BCM2835_AUX_SPI_CNTL1_KEEP_IN  0x00000001
 
index 7fd6a4c..7cb0c19 100644 (file)
@@ -84,7 +84,7 @@ struct fsl_espi_transfer {
 /* SPCOM register values */
 #define SPCOM_CS(x)            ((x) << 30)
 #define SPCOM_TRANLEN(x)       ((x) << 0)
-#define        SPCOM_TRANLEN_MAX       0xFFFF  /* Max transaction length */
+#define        SPCOM_TRANLEN_MAX       0x10000 /* Max transaction length */
 
 #define AUTOSUSPEND_TIMEOUT 2000
 
@@ -233,7 +233,7 @@ static int fsl_espi_bufs(struct spi_device *spi, struct spi_transfer *t)
        reinit_completion(&mpc8xxx_spi->done);
 
        /* Set SPCOM[CS] and SPCOM[TRANLEN] field */
-       if ((t->len - 1) > SPCOM_TRANLEN_MAX) {
+       if (t->len > SPCOM_TRANLEN_MAX) {
                dev_err(mpc8xxx_spi->dev, "Transaction length (%d)"
                                " beyond the SPCOM[TRANLEN] field\n", t->len);
                return -EINVAL;
index d98c33c..c688efa 100644 (file)
@@ -204,8 +204,8 @@ static bool spi_imx_can_dma(struct spi_master *master, struct spi_device *spi,
 {
        struct spi_imx_data *spi_imx = spi_master_get_devdata(master);
 
-       if (spi_imx->dma_is_inited &&
-           transfer->len > spi_imx->wml * sizeof(u32))
+       if (spi_imx->dma_is_inited && transfer->len >= spi_imx->wml &&
+           (transfer->len % spi_imx->wml) == 0)
                return true;
        return false;
 }
@@ -919,8 +919,6 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
        struct dma_async_tx_descriptor *desc_tx = NULL, *desc_rx = NULL;
        int ret;
        unsigned long timeout;
-       u32 dma;
-       int left;
        struct spi_master *master = spi_imx->bitbang.master;
        struct sg_table *tx = &transfer->tx_sg, *rx = &transfer->rx_sg;
 
@@ -929,7 +927,7 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
                                        tx->sgl, tx->nents, DMA_MEM_TO_DEV,
                                        DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
                if (!desc_tx)
-                       goto no_dma;
+                       goto tx_nodma;
 
                desc_tx->callback = spi_imx_dma_tx_callback;
                desc_tx->callback_param = (void *)spi_imx;
@@ -941,7 +939,7 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
                                        rx->sgl, rx->nents, DMA_DEV_TO_MEM,
                                        DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
                if (!desc_rx)
-                       goto no_dma;
+                       goto rx_nodma;
 
                desc_rx->callback = spi_imx_dma_rx_callback;
                desc_rx->callback_param = (void *)spi_imx;
@@ -954,13 +952,6 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
        /* Trigger the cspi module. */
        spi_imx->dma_finished = 0;
 
-       dma = readl(spi_imx->base + MX51_ECSPI_DMA);
-       dma = dma & (~MX51_ECSPI_DMA_RXT_WML_MASK);
-       /* Change RX_DMA_LENGTH trigger dma fetch tail data */
-       left = transfer->len % spi_imx->wml;
-       if (left)
-               writel(dma | (left << MX51_ECSPI_DMA_RXT_WML_OFFSET),
-                               spi_imx->base + MX51_ECSPI_DMA);
        /*
         * Set these order to avoid potential RX overflow. The overflow may
         * happen if we enable SPI HW before starting RX DMA due to rescheduling
@@ -992,10 +983,6 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
                        spi_imx->devtype_data->reset(spi_imx);
                        dmaengine_terminate_all(master->dma_rx);
                }
-               dma &= ~MX51_ECSPI_DMA_RXT_WML_MASK;
-               writel(dma |
-                      spi_imx->wml << MX51_ECSPI_DMA_RXT_WML_OFFSET,
-                      spi_imx->base + MX51_ECSPI_DMA);
        }
 
        spi_imx->dma_finished = 1;
@@ -1008,7 +995,9 @@ static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
 
        return ret;
 
-no_dma:
+rx_nodma:
+       dmaengine_terminate_all(master->dma_tx);
+tx_nodma:
        pr_warn_once("%s %s: DMA not available, falling back to PIO\n",
                     dev_driver_string(&master->dev),
                     dev_name(&master->dev));
index 894616f..cf4bb36 100644 (file)
@@ -761,6 +761,7 @@ static int spi_test_run_iter(struct spi_device *spi,
                test.iterate_transfer_mask = 1;
 
        /* count number of transfers with tx/rx_buf != NULL */
+       rx_count = tx_count = 0;
        for (i = 0; i < test.transfer_count; i++) {
                if (test.transfers[i].tx_buf)
                        tx_count++;
index 7273820..0caa3c8 100644 (file)
@@ -1490,6 +1490,8 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
        return status;
 
 disable_pm:
+       pm_runtime_dont_use_autosuspend(&pdev->dev);
+       pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
 free_master:
        spi_master_put(master);
@@ -1501,6 +1503,7 @@ static int omap2_mcspi_remove(struct platform_device *pdev)
        struct spi_master *master = platform_get_drvdata(pdev);
        struct omap2_mcspi *mcspi = spi_master_get_devdata(master);
 
+       pm_runtime_dont_use_autosuspend(mcspi->dev);
        pm_runtime_put_sync(mcspi->dev);
        pm_runtime_disable(&pdev->dev);
 
index 79a8bc4..7cb1b2d 100644 (file)
@@ -749,6 +749,7 @@ static int rockchip_spi_probe(struct platform_device *pdev)
        return 0;
 
 err_register_master:
+       pm_runtime_disable(&pdev->dev);
        if (rs->dma_tx.ch)
                dma_release_channel(rs->dma_tx.ch);
        if (rs->dma_rx.ch)
@@ -778,6 +779,8 @@ static int rockchip_spi_remove(struct platform_device *pdev)
        if (rs->dma_rx.ch)
                dma_release_channel(rs->dma_rx.ch);
 
+       spi_master_put(master);
+
        return 0;
 }
 
index 0c67586..d8e4219 100644 (file)
@@ -83,6 +83,7 @@ config SSB_SDIOHOST
 config SSB_HOST_SOC
        bool "Support for SSB bus on SoC"
        depends on SSB && BCM47XX_NVRAM
+       select SSB_SPROM
        help
          Host interface for a SSB directly mapped into memory. This is
          for some Broadcom SoCs from the BCM47xx and BCM53xx lines.
index 1469768..d48a5c2 100644 (file)
@@ -31,6 +31,8 @@ source "drivers/staging/media/mn88473/Kconfig"
 
 source "drivers/staging/media/omap4iss/Kconfig"
 
+source "drivers/staging/media/timb/Kconfig"
+
 # Keep LIRC at the end, as it has sub-menus
 source "drivers/staging/media/lirc/Kconfig"
 
index 34c557b..fb94f04 100644 (file)
@@ -5,3 +5,4 @@ obj-$(CONFIG_VIDEO_DM365_VPFE)  += davinci_vpfe/
 obj-$(CONFIG_VIDEO_OMAP4)      += omap4iss/
 obj-$(CONFIG_DVB_MN88472)       += mn88472/
 obj-$(CONFIG_DVB_MN88473)       += mn88473/
+obj-$(CONFIG_VIDEO_TIMBERDALE)  += timb/
index 7b7e7b2..3cc9be7 100644 (file)
@@ -538,7 +538,7 @@ struct vpfe_isif_raw_config {
 };
 
 /**********************************************************************
-      IPIPE API Structures
+*      IPIPE API Structures
 **********************************************************************/
 
 /* IPIPE module configurations */
index 3ec7e65..db49af9 100644 (file)
@@ -147,7 +147,7 @@ static int vpfe_prepare_pipeline(struct vpfe_video_device *video)
        mutex_lock(&mdev->graph_mutex);
        ret = media_entity_graph_walk_init(&graph, entity->graph_obj.mdev);
        if (ret) {
-               mutex_unlock(&video->lock);
+               mutex_unlock(&mdev->graph_mutex);
                return -ENOMEM;
        }
        media_entity_graph_walk_start(&graph, entity);
index d009bcb..68ede6c 100644 (file)
@@ -193,7 +193,7 @@ static int lirc_claim(void)
                        return 0;
                }
        }
-       out(LIRC_LP_CONTROL, LP_PSELECP|LP_PINITP);
+       out(LIRC_LP_CONTROL, LP_PSELECP | LP_PINITP);
        is_claimed = 1;
        return 1;
 }
@@ -264,7 +264,7 @@ static void lirc_lirc_irq_handler(void *blah)
                init = 1;
        }
 
-       timeout = timer/10;     /* timeout after 1/10 sec. */
+       timeout = timer / 10;   /* timeout after 1/10 sec. */
        signal = 1;
        level = lirc_get_timer();
        do {
@@ -286,15 +286,15 @@ static void lirc_lirc_irq_handler(void *blah)
                /* adjust value to usecs */
                __u64 helper;
 
-               helper = ((__u64) signal)*1000000;
+               helper = ((__u64)signal) * 1000000;
                do_div(helper, timer);
-               signal = (long) helper;
+               signal = (long)helper;
 
                if (signal > LIRC_SFH506_DELAY)
                        data = signal - LIRC_SFH506_DELAY;
                else
                        data = 1;
-               rbuf_write(PULSE_BIT|data); /* pulse */
+               rbuf_write(PULSE_BIT | data); /* pulse */
        }
        lastkt = ktime_get();
 #else
@@ -331,7 +331,7 @@ static ssize_t lirc_read(struct file *filep, char __user *buf, size_t n,
        set_current_state(TASK_INTERRUPTIBLE);
        while (count < n) {
                if (rptr != wptr) {
-                       if (copy_to_user(buf+count, &rbuf[rptr],
+                       if (copy_to_user(buf + count, &rbuf[rptr],
                                         sizeof(int))) {
                                result = -EFAULT;
                                break;
@@ -393,9 +393,9 @@ static ssize_t lirc_write(struct file *filep, const char __user *buf, size_t n,
        for (i = 0; i < count; i++) {
                __u64 helper;
 
-               helper = ((__u64) wbuf[i])*timer;
+               helper = ((__u64)wbuf[i]) * timer;
                do_div(helper, 1000000);
-               wbuf[i] = (int) helper;
+               wbuf[i] = (int)helper;
        }
 
        local_irq_save(flags);
@@ -647,7 +647,7 @@ static int __init lirc_parallel_init(void)
                goto exit_device_put;
 
        pport = parport_find_base(io);
-       if (pport == NULL) {
+       if (!pport) {
                pr_notice("no port at %x found\n", io);
                result = -ENXIO;
                goto exit_device_put;
@@ -656,7 +656,7 @@ static int __init lirc_parallel_init(void)
                                           pf, kf, lirc_lirc_irq_handler, 0,
                                           NULL);
        parport_put_port(pport);
-       if (ppdevice == NULL) {
+       if (!ppdevice) {
                pr_notice("parport_register_device() failed\n");
                result = -ENXIO;
                goto exit_device_put;
@@ -664,7 +664,7 @@ static int __init lirc_parallel_init(void)
        if (parport_claim(ppdevice) != 0)
                goto skip_init;
        is_claimed = 1;
-       out(LIRC_LP_CONTROL, LP_PSELECP|LP_PINITP);
+       out(LIRC_LP_CONTROL, LP_PSELECP | LP_PINITP);
 
 #ifdef LIRC_TIMER
        if (debug)
@@ -730,7 +730,7 @@ module_param(irq, int, S_IRUGO);
 MODULE_PARM_DESC(irq, "Interrupt (7 or 5)");
 
 module_param(tx_mask, int, S_IRUGO);
-MODULE_PARM_DESC(tx_maxk, "Transmitter mask (default: 0x01)");
+MODULE_PARM_DESC(tx_mask, "Transmitter mask (default: 0x01)");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Enable debugging messages");
diff --git a/drivers/staging/media/timb/Kconfig b/drivers/staging/media/timb/Kconfig
new file mode 100644 (file)
index 0000000..e413fec
--- /dev/null
@@ -0,0 +1,11 @@
+config VIDEO_TIMBERDALE
+       tristate "Support for timberdale Video In/LogiWIN"
+       depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API && HAS_DMA
+       depends on (MFD_TIMBERDALE && TIMB_DMA) || COMPILE_TEST
+       select VIDEO_ADV7180
+       select VIDEOBUF_DMA_CONTIG
+       ---help---
+         Add support for the Video In peripherial of the timberdale FPGA.
+
+         This driver is deprecated and will be removed soon unless someone
+         will start the work to convert this driver to the vb2 framework.
diff --git a/drivers/staging/media/timb/Makefile b/drivers/staging/media/timb/Makefile
new file mode 100644 (file)
index 0000000..4c989c2
--- /dev/null
@@ -0,0 +1 @@
+obj-$(CONFIG_VIDEO_TIMBERDALE) += timblogiw.o
index 3327c49..713c63d 100644 (file)
@@ -898,7 +898,7 @@ static ssize_t unmap_zeroes_data_store(struct config_item *item,
        da->unmap_zeroes_data = flag;
        pr_debug("dev[%p]: SE Device Thin Provisioning LBPRZ bit: %d\n",
                 da->da_dev, flag);
-       return 0;
+       return count;
 }
 
 /*
index cacd97a..da457e2 100644 (file)
@@ -828,6 +828,50 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
        return dev;
 }
 
+/*
+ * Check if the underlying struct block_device request_queue supports
+ * the QUEUE_FLAG_DISCARD bit for UNMAP/WRITE_SAME in SCSI + TRIM
+ * in ATA and we need to set TPE=1
+ */
+bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
+                                      struct request_queue *q, int block_size)
+{
+       if (!blk_queue_discard(q))
+               return false;
+
+       attrib->max_unmap_lba_count = (q->limits.max_discard_sectors << 9) /
+                                                               block_size;
+       /*
+        * Currently hardcoded to 1 in Linux/SCSI code..
+        */
+       attrib->max_unmap_block_desc_count = 1;
+       attrib->unmap_granularity = q->limits.discard_granularity / block_size;
+       attrib->unmap_granularity_alignment = q->limits.discard_alignment /
+                                                               block_size;
+       attrib->unmap_zeroes_data = q->limits.discard_zeroes_data;
+       return true;
+}
+EXPORT_SYMBOL(target_configure_unmap_from_queue);
+
+/*
+ * Convert from blocksize advertised to the initiator to the 512 byte
+ * units unconditionally used by the Linux block layer.
+ */
+sector_t target_to_linux_sector(struct se_device *dev, sector_t lb)
+{
+       switch (dev->dev_attrib.block_size) {
+       case 4096:
+               return lb << 3;
+       case 2048:
+               return lb << 2;
+       case 1024:
+               return lb << 1;
+       default:
+               return lb;
+       }
+}
+EXPORT_SYMBOL(target_to_linux_sector);
+
 int target_configure_device(struct se_device *dev)
 {
        struct se_hba *hba = dev->se_hba;
index e319570..75f0f08 100644 (file)
@@ -160,25 +160,11 @@ static int fd_configure_device(struct se_device *dev)
                        " block_device blocks: %llu logical_block_size: %d\n",
                        dev_size, div_u64(dev_size, fd_dev->fd_block_size),
                        fd_dev->fd_block_size);
-               /*
-                * Check if the underlying struct block_device request_queue supports
-                * the QUEUE_FLAG_DISCARD bit for UNMAP/WRITE_SAME in SCSI + TRIM
-                * in ATA and we need to set TPE=1
-                */
-               if (blk_queue_discard(q)) {
-                       dev->dev_attrib.max_unmap_lba_count =
-                               q->limits.max_discard_sectors;
-                       /*
-                        * Currently hardcoded to 1 in Linux/SCSI code..
-                        */
-                       dev->dev_attrib.max_unmap_block_desc_count = 1;
-                       dev->dev_attrib.unmap_granularity =
-                               q->limits.discard_granularity >> 9;
-                       dev->dev_attrib.unmap_granularity_alignment =
-                               q->limits.discard_alignment;
+
+               if (target_configure_unmap_from_queue(&dev->dev_attrib, q,
+                                                     fd_dev->fd_block_size))
                        pr_debug("IFILE: BLOCK Discard support available,"
-                                       " disabled by default\n");
-               }
+                                " disabled by default\n");
                /*
                 * Enable write same emulation for IBLOCK and use 0xFFFF as
                 * the smaller WRITE_SAME(10) only has a two-byte block count.
@@ -490,9 +476,12 @@ fd_execute_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
        if (S_ISBLK(inode->i_mode)) {
                /* The backend is block device, use discard */
                struct block_device *bdev = inode->i_bdev;
+               struct se_device *dev = cmd->se_dev;
 
-               ret = blkdev_issue_discard(bdev, lba,
-                               nolb, GFP_KERNEL, 0);
+               ret = blkdev_issue_discard(bdev,
+                                          target_to_linux_sector(dev, lba),
+                                          target_to_linux_sector(dev,  nolb),
+                                          GFP_KERNEL, 0);
                if (ret < 0) {
                        pr_warn("FILEIO: blkdev_issue_discard() failed: %d\n",
                                ret);
index 5a2899f..abe4eb9 100644 (file)
@@ -121,29 +121,11 @@ static int iblock_configure_device(struct se_device *dev)
        dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q);
        dev->dev_attrib.hw_queue_depth = q->nr_requests;
 
-       /*
-        * Check if the underlying struct block_device request_queue supports
-        * the QUEUE_FLAG_DISCARD bit for UNMAP/WRITE_SAME in SCSI + TRIM
-        * in ATA and we need to set TPE=1
-        */
-       if (blk_queue_discard(q)) {
-               dev->dev_attrib.max_unmap_lba_count =
-                               q->limits.max_discard_sectors;
-
-               /*
-                * Currently hardcoded to 1 in Linux/SCSI code..
-                */
-               dev->dev_attrib.max_unmap_block_desc_count = 1;
-               dev->dev_attrib.unmap_granularity =
-                               q->limits.discard_granularity >> 9;
-               dev->dev_attrib.unmap_granularity_alignment =
-                               q->limits.discard_alignment;
-               dev->dev_attrib.unmap_zeroes_data =
-                               q->limits.discard_zeroes_data;
-
+       if (target_configure_unmap_from_queue(&dev->dev_attrib, q,
+                                             dev->dev_attrib.hw_block_size))
                pr_debug("IBLOCK: BLOCK Discard support available,"
-                               " disabled by default\n");
-       }
+                        " disabled by default\n");
+
        /*
         * Enable write same emulation for IBLOCK and use 0xFFFF as
         * the smaller WRITE_SAME(10) only has a two-byte block count.
@@ -415,9 +397,13 @@ static sense_reason_t
 iblock_execute_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
 {
        struct block_device *bdev = IBLOCK_DEV(cmd->se_dev)->ibd_bd;
+       struct se_device *dev = cmd->se_dev;
        int ret;
 
-       ret = blkdev_issue_discard(bdev, lba, nolb, GFP_KERNEL, 0);
+       ret = blkdev_issue_discard(bdev,
+                                  target_to_linux_sector(dev, lba),
+                                  target_to_linux_sector(dev,  nolb),
+                                  GFP_KERNEL, 0);
        if (ret < 0) {
                pr_err("blkdev_issue_discard() failed: %d\n", ret);
                return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
@@ -433,8 +419,10 @@ iblock_execute_write_same(struct se_cmd *cmd)
        struct scatterlist *sg;
        struct bio *bio;
        struct bio_list list;
-       sector_t block_lba = cmd->t_task_lba;
-       sector_t sectors = sbc_get_write_same_sectors(cmd);
+       struct se_device *dev = cmd->se_dev;
+       sector_t block_lba = target_to_linux_sector(dev, cmd->t_task_lba);
+       sector_t sectors = target_to_linux_sector(dev,
+                                       sbc_get_write_same_sectors(cmd));
 
        if (cmd->prot_op) {
                pr_err("WRITE_SAME: Protection information with IBLOCK"
@@ -648,12 +636,12 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
                  enum dma_data_direction data_direction)
 {
        struct se_device *dev = cmd->se_dev;
+       sector_t block_lba = target_to_linux_sector(dev, cmd->t_task_lba);
        struct iblock_req *ibr;
        struct bio *bio, *bio_start;
        struct bio_list list;
        struct scatterlist *sg;
        u32 sg_num = sgl_nents;
-       sector_t block_lba;
        unsigned bio_cnt;
        int rw = 0;
        int i;
@@ -679,24 +667,6 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
                rw = READ;
        }
 
-       /*
-        * Convert the blocksize advertised to the initiator to the 512 byte
-        * units unconditionally used by the Linux block layer.
-        */
-       if (dev->dev_attrib.block_size == 4096)
-               block_lba = (cmd->t_task_lba << 3);
-       else if (dev->dev_attrib.block_size == 2048)
-               block_lba = (cmd->t_task_lba << 2);
-       else if (dev->dev_attrib.block_size == 1024)
-               block_lba = (cmd->t_task_lba << 1);
-       else if (dev->dev_attrib.block_size == 512)
-               block_lba = cmd->t_task_lba;
-       else {
-               pr_err("Unsupported SCSI -> BLOCK LBA conversion:"
-                               " %u\n", dev->dev_attrib.block_size);
-               return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
-       }
-
        ibr = kzalloc(sizeof(struct iblock_req), GFP_KERNEL);
        if (!ibr)
                goto fail;
index dae0750..db4412f 100644 (file)
@@ -141,7 +141,6 @@ void        transport_dump_vpd_proto_id(struct t10_vpd *, unsigned char *, int);
 int    transport_dump_vpd_assoc(struct t10_vpd *, unsigned char *, int);
 int    transport_dump_vpd_ident_type(struct t10_vpd *, unsigned char *, int);
 int    transport_dump_vpd_ident(struct t10_vpd *, unsigned char *, int);
-bool   target_stop_cmd(struct se_cmd *cmd, unsigned long *flags);
 void   transport_clear_lun_ref(struct se_lun *);
 void   transport_send_task_abort(struct se_cmd *);
 sense_reason_t target_cmd_size_check(struct se_cmd *cmd, unsigned int size);
index fcdcb11..82a663b 100644 (file)
@@ -68,23 +68,25 @@ void core_tmr_release_req(struct se_tmr_req *tmr)
 
        if (dev) {
                spin_lock_irqsave(&dev->se_tmr_lock, flags);
-               list_del(&tmr->tmr_list);
+               list_del_init(&tmr->tmr_list);
                spin_unlock_irqrestore(&dev->se_tmr_lock, flags);
        }
 
        kfree(tmr);
 }
 
-static void core_tmr_handle_tas_abort(
-       struct se_node_acl *tmr_nacl,
-       struct se_cmd *cmd,
-       int tas)
+static void core_tmr_handle_tas_abort(struct se_cmd *cmd, int tas)
 {
-       bool remove = true;
+       unsigned long flags;
+       bool remove = true, send_tas;
        /*
         * TASK ABORTED status (TAS) bit support
         */
-       if ((tmr_nacl && (tmr_nacl != cmd->se_sess->se_node_acl)) && tas) {
+       spin_lock_irqsave(&cmd->t_state_lock, flags);
+       send_tas = (cmd->transport_state & CMD_T_TAS);
+       spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+
+       if (send_tas) {
                remove = false;
                transport_send_task_abort(cmd);
        }
@@ -107,6 +109,46 @@ static int target_check_cdb_and_preempt(struct list_head *list,
        return 1;
 }
 
+static bool __target_check_io_state(struct se_cmd *se_cmd,
+                                   struct se_session *tmr_sess, int tas)
+{
+       struct se_session *sess = se_cmd->se_sess;
+
+       assert_spin_locked(&sess->sess_cmd_lock);
+       WARN_ON_ONCE(!irqs_disabled());
+       /*
+        * If command already reached CMD_T_COMPLETE state within
+        * target_complete_cmd() or CMD_T_FABRIC_STOP due to shutdown,
+        * this se_cmd has been passed to fabric driver and will
+        * not be aborted.
+        *
+        * Otherwise, obtain a local se_cmd->cmd_kref now for TMR
+        * ABORT_TASK + LUN_RESET for CMD_T_ABORTED processing as
+        * long as se_cmd->cmd_kref is still active unless zero.
+        */
+       spin_lock(&se_cmd->t_state_lock);
+       if (se_cmd->transport_state & (CMD_T_COMPLETE | CMD_T_FABRIC_STOP)) {
+               pr_debug("Attempted to abort io tag: %llu already complete or"
+                       " fabric stop, skipping\n", se_cmd->tag);
+               spin_unlock(&se_cmd->t_state_lock);
+               return false;
+       }
+       if (sess->sess_tearing_down || se_cmd->cmd_wait_set) {
+               pr_debug("Attempted to abort io tag: %llu already shutdown,"
+                       " skipping\n", se_cmd->tag);
+               spin_unlock(&se_cmd->t_state_lock);
+               return false;
+       }
+       se_cmd->transport_state |= CMD_T_ABORTED;
+
+       if ((tmr_sess != se_cmd->se_sess) && tas)
+               se_cmd->transport_state |= CMD_T_TAS;
+
+       spin_unlock(&se_cmd->t_state_lock);
+
+       return kref_get_unless_zero(&se_cmd->cmd_kref);
+}
+
 void core_tmr_abort_task(
        struct se_device *dev,
        struct se_tmr_req *tmr,
@@ -130,34 +172,22 @@ void core_tmr_abort_task(
                if (tmr->ref_task_tag != ref_tag)
                        continue;
 
-               if (!kref_get_unless_zero(&se_cmd->cmd_kref))
-                       continue;
-
                printk("ABORT_TASK: Found referenced %s task_tag: %llu\n",
                        se_cmd->se_tfo->get_fabric_name(), ref_tag);
 
-               spin_lock(&se_cmd->t_state_lock);
-               if (se_cmd->transport_state & CMD_T_COMPLETE) {
-                       printk("ABORT_TASK: ref_tag: %llu already complete,"
-                              " skipping\n", ref_tag);
-                       spin_unlock(&se_cmd->t_state_lock);
+               if (!__target_check_io_state(se_cmd, se_sess, 0)) {
                        spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
-
                        target_put_sess_cmd(se_cmd);
-
                        goto out;
                }
-               se_cmd->transport_state |= CMD_T_ABORTED;
-               spin_unlock(&se_cmd->t_state_lock);
-
                list_del_init(&se_cmd->se_cmd_list);
                spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
 
                cancel_work_sync(&se_cmd->work);
                transport_wait_for_tasks(se_cmd);
 
-               target_put_sess_cmd(se_cmd);
                transport_cmd_finish_abort(se_cmd, true);
+               target_put_sess_cmd(se_cmd);
 
                printk("ABORT_TASK: Sending TMR_FUNCTION_COMPLETE for"
                                " ref_tag: %llu\n", ref_tag);
@@ -178,9 +208,11 @@ static void core_tmr_drain_tmr_list(
        struct list_head *preempt_and_abort_list)
 {
        LIST_HEAD(drain_tmr_list);
+       struct se_session *sess;
        struct se_tmr_req *tmr_p, *tmr_pp;
        struct se_cmd *cmd;
        unsigned long flags;
+       bool rc;
        /*
         * Release all pending and outgoing TMRs aside from the received
         * LUN_RESET tmr..
@@ -206,17 +238,39 @@ static void core_tmr_drain_tmr_list(
                if (target_check_cdb_and_preempt(preempt_and_abort_list, cmd))
                        continue;
 
+               sess = cmd->se_sess;
+               if (WARN_ON_ONCE(!sess))
+                       continue;
+
+               spin_lock(&sess->sess_cmd_lock);
                spin_lock(&cmd->t_state_lock);
-               if (!(cmd->transport_state & CMD_T_ACTIVE)) {
+               if (!(cmd->transport_state & CMD_T_ACTIVE) ||
+                    (cmd->transport_state & CMD_T_FABRIC_STOP)) {
                        spin_unlock(&cmd->t_state_lock);
+                       spin_unlock(&sess->sess_cmd_lock);
                        continue;
                }
                if (cmd->t_state == TRANSPORT_ISTATE_PROCESSING) {
                        spin_unlock(&cmd->t_state_lock);
+                       spin_unlock(&sess->sess_cmd_lock);
                        continue;
                }
+               if (sess->sess_tearing_down || cmd->cmd_wait_set) {
+                       spin_unlock(&cmd->t_state_lock);
+                       spin_unlock(&sess->sess_cmd_lock);
+                       continue;
+               }
+               cmd->transport_state |= CMD_T_ABORTED;
                spin_unlock(&cmd->t_state_lock);
 
+               rc = kref_get_unless_zero(&cmd->cmd_kref);
+               if (!rc) {
+                       printk("LUN_RESET TMR: non-zero kref_get_unless_zero\n");
+                       spin_unlock(&sess->sess_cmd_lock);
+                       continue;
+               }
+               spin_unlock(&sess->sess_cmd_lock);
+
                list_move_tail(&tmr_p->tmr_list, &drain_tmr_list);
        }
        spin_unlock_irqrestore(&dev->se_tmr_lock, flags);
@@ -230,20 +284,26 @@ static void core_tmr_drain_tmr_list(
                        (preempt_and_abort_list) ? "Preempt" : "", tmr_p,
                        tmr_p->function, tmr_p->response, cmd->t_state);
 
+               cancel_work_sync(&cmd->work);
+               transport_wait_for_tasks(cmd);
+
                transport_cmd_finish_abort(cmd, 1);
+               target_put_sess_cmd(cmd);
        }
 }
 
 static void core_tmr_drain_state_list(
        struct se_device *dev,
        struct se_cmd *prout_cmd,
-       struct se_node_acl *tmr_nacl,
+       struct se_session *tmr_sess,
        int tas,
        struct list_head *preempt_and_abort_list)
 {
        LIST_HEAD(drain_task_list);
+       struct se_session *sess;
        struct se_cmd *cmd, *next;
        unsigned long flags;
+       int rc;
 
        /*
         * Complete outstanding commands with TASK_ABORTED SAM status.
@@ -282,6 +342,16 @@ static void core_tmr_drain_state_list(
                if (prout_cmd == cmd)
                        continue;
 
+               sess = cmd->se_sess;
+               if (WARN_ON_ONCE(!sess))
+                       continue;
+
+               spin_lock(&sess->sess_cmd_lock);
+               rc = __target_check_io_state(cmd, tmr_sess, tas);
+               spin_unlock(&sess->sess_cmd_lock);
+               if (!rc)
+                       continue;
+
                list_move_tail(&cmd->state_list, &drain_task_list);
                cmd->state_active = false;
        }
@@ -289,7 +359,7 @@ static void core_tmr_drain_state_list(
 
        while (!list_empty(&drain_task_list)) {
                cmd = list_entry(drain_task_list.next, struct se_cmd, state_list);
-               list_del(&cmd->state_list);
+               list_del_init(&cmd->state_list);
 
                pr_debug("LUN_RESET: %s cmd: %p"
                        " ITT/CmdSN: 0x%08llx/0x%08x, i_state: %d, t_state: %d"
@@ -313,16 +383,11 @@ static void core_tmr_drain_state_list(
                 * loop above, but we do it down here given that
                 * cancel_work_sync may block.
                 */
-               if (cmd->t_state == TRANSPORT_COMPLETE)
-                       cancel_work_sync(&cmd->work);
-
-               spin_lock_irqsave(&cmd->t_state_lock, flags);
-               target_stop_cmd(cmd, &flags);
-
-               cmd->transport_state |= CMD_T_ABORTED;
-               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+               cancel_work_sync(&cmd->work);
+               transport_wait_for_tasks(cmd);
 
-               core_tmr_handle_tas_abort(tmr_nacl, cmd, tas);
+               core_tmr_handle_tas_abort(cmd, tas);
+               target_put_sess_cmd(cmd);
        }
 }
 
@@ -334,6 +399,7 @@ int core_tmr_lun_reset(
 {
        struct se_node_acl *tmr_nacl = NULL;
        struct se_portal_group *tmr_tpg = NULL;
+       struct se_session *tmr_sess = NULL;
        int tas;
         /*
         * TASK_ABORTED status bit, this is configurable via ConfigFS
@@ -352,8 +418,9 @@ int core_tmr_lun_reset(
         * or struct se_device passthrough..
         */
        if (tmr && tmr->task_cmd && tmr->task_cmd->se_sess) {
-               tmr_nacl = tmr->task_cmd->se_sess->se_node_acl;
-               tmr_tpg = tmr->task_cmd->se_sess->se_tpg;
+               tmr_sess = tmr->task_cmd->se_sess;
+               tmr_nacl = tmr_sess->se_node_acl;
+               tmr_tpg = tmr_sess->se_tpg;
                if (tmr_nacl && tmr_tpg) {
                        pr_debug("LUN_RESET: TMR caller fabric: %s"
                                " initiator port %s\n",
@@ -366,7 +433,7 @@ int core_tmr_lun_reset(
                dev->transport->name, tas);
 
        core_tmr_drain_tmr_list(dev, tmr, preempt_and_abort_list);
-       core_tmr_drain_state_list(dev, prout_cmd, tmr_nacl, tas,
+       core_tmr_drain_state_list(dev, prout_cmd, tmr_sess, tas,
                                preempt_and_abort_list);
 
        /*
index 9f3608e..867bc6d 100644 (file)
@@ -534,9 +534,6 @@ void transport_deregister_session(struct se_session *se_sess)
 }
 EXPORT_SYMBOL(transport_deregister_session);
 
-/*
- * Called with cmd->t_state_lock held.
- */
 static void target_remove_from_state_list(struct se_cmd *cmd)
 {
        struct se_device *dev = cmd->se_dev;
@@ -561,10 +558,6 @@ static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists,
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&cmd->t_state_lock, flags);
-       if (write_pending)
-               cmd->t_state = TRANSPORT_WRITE_PENDING;
-
        if (remove_from_lists) {
                target_remove_from_state_list(cmd);
 
@@ -574,6 +567,10 @@ static int transport_cmd_check_stop(struct se_cmd *cmd, bool remove_from_lists,
                cmd->se_lun = NULL;
        }
 
+       spin_lock_irqsave(&cmd->t_state_lock, flags);
+       if (write_pending)
+               cmd->t_state = TRANSPORT_WRITE_PENDING;
+
        /*
         * Determine if frontend context caller is requesting the stopping of
         * this command for frontend exceptions.
@@ -627,6 +624,8 @@ static void transport_lun_remove_cmd(struct se_cmd *cmd)
 
 void transport_cmd_finish_abort(struct se_cmd *cmd, int remove)
 {
+       bool ack_kref = (cmd->se_cmd_flags & SCF_ACK_KREF);
+
        if (cmd->se_cmd_flags & SCF_SE_LUN_CMD)
                transport_lun_remove_cmd(cmd);
        /*
@@ -638,7 +637,7 @@ void transport_cmd_finish_abort(struct se_cmd *cmd, int remove)
 
        if (transport_cmd_check_stop_to_fabric(cmd))
                return;
-       if (remove)
+       if (remove && ack_kref)
                transport_put_cmd(cmd);
 }
 
@@ -694,19 +693,10 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status)
        }
 
        /*
-        * See if we are waiting to complete for an exception condition.
-        */
-       if (cmd->transport_state & CMD_T_REQUEST_STOP) {
-               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
-               complete(&cmd->task_stop_comp);
-               return;
-       }
-
-       /*
         * Check for case where an explicit ABORT_TASK has been received
         * and transport_wait_for_tasks() will be waiting for completion..
         */
-       if (cmd->transport_state & CMD_T_ABORTED &&
+       if (cmd->transport_state & CMD_T_ABORTED ||
            cmd->transport_state & CMD_T_STOP) {
                spin_unlock_irqrestore(&cmd->t_state_lock, flags);
                complete_all(&cmd->t_transport_stop_comp);
@@ -721,10 +711,10 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status)
        cmd->transport_state |= (CMD_T_COMPLETE | CMD_T_ACTIVE);
        spin_unlock_irqrestore(&cmd->t_state_lock, flags);
 
-       if (cmd->cpuid == -1)
-               queue_work(target_completion_wq, &cmd->work);
-       else
+       if (cmd->se_cmd_flags & SCF_USE_CPUID)
                queue_work_on(cmd->cpuid, target_completion_wq, &cmd->work);
+       else
+               queue_work(target_completion_wq, &cmd->work);
 }
 EXPORT_SYMBOL(target_complete_cmd);
 
@@ -1203,7 +1193,6 @@ void transport_init_se_cmd(
        INIT_LIST_HEAD(&cmd->state_list);
        init_completion(&cmd->t_transport_stop_comp);
        init_completion(&cmd->cmd_wait_comp);
-       init_completion(&cmd->task_stop_comp);
        spin_lock_init(&cmd->t_state_lock);
        kref_init(&cmd->cmd_kref);
        cmd->transport_state = CMD_T_DEV_ACTIVE;
@@ -1437,6 +1426,12 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
         */
        transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess,
                                data_length, data_dir, task_attr, sense);
+
+       if (flags & TARGET_SCF_USE_CPUID)
+               se_cmd->se_cmd_flags |= SCF_USE_CPUID;
+       else
+               se_cmd->cpuid = WORK_CPU_UNBOUND;
+
        if (flags & TARGET_SCF_UNKNOWN_SIZE)
                se_cmd->unknown_data_length = 1;
        /*
@@ -1635,33 +1630,6 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess,
 EXPORT_SYMBOL(target_submit_tmr);
 
 /*
- * If the cmd is active, request it to be stopped and sleep until it
- * has completed.
- */
-bool target_stop_cmd(struct se_cmd *cmd, unsigned long *flags)
-       __releases(&cmd->t_state_lock)
-       __acquires(&cmd->t_state_lock)
-{
-       bool was_active = false;
-
-       if (cmd->transport_state & CMD_T_BUSY) {
-               cmd->transport_state |= CMD_T_REQUEST_STOP;
-               spin_unlock_irqrestore(&cmd->t_state_lock, *flags);
-
-               pr_debug("cmd %p waiting to complete\n", cmd);
-               wait_for_completion(&cmd->task_stop_comp);
-               pr_debug("cmd %p stopped successfully\n", cmd);
-
-               spin_lock_irqsave(&cmd->t_state_lock, *flags);
-               cmd->transport_state &= ~CMD_T_REQUEST_STOP;
-               cmd->transport_state &= ~CMD_T_BUSY;
-               was_active = true;
-       }
-
-       return was_active;
-}
-
-/*
  * Handle SAM-esque emulation for generic transport request failures.
  */
 void transport_generic_request_failure(struct se_cmd *cmd,
@@ -1859,19 +1827,21 @@ static bool target_handle_task_attr(struct se_cmd *cmd)
        return true;
 }
 
+static int __transport_check_aborted_status(struct se_cmd *, int);
+
 void target_execute_cmd(struct se_cmd *cmd)
 {
        /*
-        * If the received CDB has aleady been aborted stop processing it here.
-        */
-       if (transport_check_aborted_status(cmd, 1))
-               return;
-
-       /*
         * Determine if frontend context caller is requesting the stopping of
         * this command for frontend exceptions.
+        *
+        * If the received CDB has aleady been aborted stop processing it here.
         */
        spin_lock_irq(&cmd->t_state_lock);
+       if (__transport_check_aborted_status(cmd, 1)) {
+               spin_unlock_irq(&cmd->t_state_lock);
+               return;
+       }
        if (cmd->transport_state & CMD_T_STOP) {
                pr_debug("%s:%d CMD_T_STOP for ITT: 0x%08llx\n",
                        __func__, __LINE__, cmd->tag);
@@ -2222,20 +2192,14 @@ static inline void transport_free_pages(struct se_cmd *cmd)
 }
 
 /**
- * transport_release_cmd - free a command
- * @cmd:       command to free
+ * transport_put_cmd - release a reference to a command
+ * @cmd:       command to release
  *
- * This routine unconditionally frees a command, and reference counting
- * or list removal must be done in the caller.
+ * This routine releases our reference to the command and frees it if possible.
  */
-static int transport_release_cmd(struct se_cmd *cmd)
+static int transport_put_cmd(struct se_cmd *cmd)
 {
        BUG_ON(!cmd->se_tfo);
-
-       if (cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)
-               core_tmr_release_req(cmd->se_tmr_req);
-       if (cmd->t_task_cdb != cmd->__t_task_cdb)
-               kfree(cmd->t_task_cdb);
        /*
         * If this cmd has been setup with target_get_sess_cmd(), drop
         * the kref and call ->release_cmd() in kref callback.
@@ -2243,18 +2207,6 @@ static int transport_release_cmd(struct se_cmd *cmd)
        return target_put_sess_cmd(cmd);
 }
 
-/**
- * transport_put_cmd - release a reference to a command
- * @cmd:       command to release
- *
- * This routine releases our reference to the command and frees it if possible.
- */
-static int transport_put_cmd(struct se_cmd *cmd)
-{
-       transport_free_pages(cmd);
-       return transport_release_cmd(cmd);
-}
-
 void *transport_kmap_data_sg(struct se_cmd *cmd)
 {
        struct scatterlist *sg = cmd->t_data_sg;
@@ -2450,34 +2402,58 @@ static void transport_write_pending_qf(struct se_cmd *cmd)
        }
 }
 
-int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
+static bool
+__transport_wait_for_tasks(struct se_cmd *, bool, bool *, bool *,
+                          unsigned long *flags);
+
+static void target_wait_free_cmd(struct se_cmd *cmd, bool *aborted, bool *tas)
 {
        unsigned long flags;
+
+       spin_lock_irqsave(&cmd->t_state_lock, flags);
+       __transport_wait_for_tasks(cmd, true, aborted, tas, &flags);
+       spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+}
+
+int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
+{
        int ret = 0;
+       bool aborted = false, tas = false;
 
        if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD)) {
                if (wait_for_tasks && (cmd->se_cmd_flags & SCF_SCSI_TMR_CDB))
-                        transport_wait_for_tasks(cmd);
+                       target_wait_free_cmd(cmd, &aborted, &tas);
 
-               ret = transport_release_cmd(cmd);
+               if (!aborted || tas)
+                       ret = transport_put_cmd(cmd);
        } else {
                if (wait_for_tasks)
-                       transport_wait_for_tasks(cmd);
+                       target_wait_free_cmd(cmd, &aborted, &tas);
                /*
                 * Handle WRITE failure case where transport_generic_new_cmd()
                 * has already added se_cmd to state_list, but fabric has
                 * failed command before I/O submission.
                 */
-               if (cmd->state_active) {
-                       spin_lock_irqsave(&cmd->t_state_lock, flags);
+               if (cmd->state_active)
                        target_remove_from_state_list(cmd);
-                       spin_unlock_irqrestore(&cmd->t_state_lock, flags);
-               }
 
                if (cmd->se_lun)
                        transport_lun_remove_cmd(cmd);
 
-               ret = transport_put_cmd(cmd);
+               if (!aborted || tas)
+                       ret = transport_put_cmd(cmd);
+       }
+       /*
+        * If the task has been internally aborted due to TMR ABORT_TASK
+        * or LUN_RESET, target_core_tmr.c is responsible for performing
+        * the remaining calls to target_put_sess_cmd(), and not the
+        * callers of this function.
+        */
+       if (aborted) {
+               pr_debug("Detected CMD_T_ABORTED for ITT: %llu\n", cmd->tag);
+               wait_for_completion(&cmd->cmd_wait_comp);
+               cmd->se_tfo->release_cmd(cmd);
+               ret = 1;
        }
        return ret;
 }
@@ -2517,26 +2493,46 @@ out:
 }
 EXPORT_SYMBOL(target_get_sess_cmd);
 
+static void target_free_cmd_mem(struct se_cmd *cmd)
+{
+       transport_free_pages(cmd);
+
+       if (cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)
+               core_tmr_release_req(cmd->se_tmr_req);
+       if (cmd->t_task_cdb != cmd->__t_task_cdb)
+               kfree(cmd->t_task_cdb);
+}
+
 static void target_release_cmd_kref(struct kref *kref)
 {
        struct se_cmd *se_cmd = container_of(kref, struct se_cmd, cmd_kref);
        struct se_session *se_sess = se_cmd->se_sess;
        unsigned long flags;
+       bool fabric_stop;
 
        spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
        if (list_empty(&se_cmd->se_cmd_list)) {
                spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
+               target_free_cmd_mem(se_cmd);
                se_cmd->se_tfo->release_cmd(se_cmd);
                return;
        }
-       if (se_sess->sess_tearing_down && se_cmd->cmd_wait_set) {
+
+       spin_lock(&se_cmd->t_state_lock);
+       fabric_stop = (se_cmd->transport_state & CMD_T_FABRIC_STOP);
+       spin_unlock(&se_cmd->t_state_lock);
+
+       if (se_cmd->cmd_wait_set || fabric_stop) {
+               list_del_init(&se_cmd->se_cmd_list);
                spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
+               target_free_cmd_mem(se_cmd);
                complete(&se_cmd->cmd_wait_comp);
                return;
        }
-       list_del(&se_cmd->se_cmd_list);
+       list_del_init(&se_cmd->se_cmd_list);
        spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
 
+       target_free_cmd_mem(se_cmd);
        se_cmd->se_tfo->release_cmd(se_cmd);
 }
 
@@ -2548,6 +2544,7 @@ int target_put_sess_cmd(struct se_cmd *se_cmd)
        struct se_session *se_sess = se_cmd->se_sess;
 
        if (!se_sess) {
+               target_free_cmd_mem(se_cmd);
                se_cmd->se_tfo->release_cmd(se_cmd);
                return 1;
        }
@@ -2564,6 +2561,7 @@ void target_sess_cmd_list_set_waiting(struct se_session *se_sess)
 {
        struct se_cmd *se_cmd;
        unsigned long flags;
+       int rc;
 
        spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
        if (se_sess->sess_tearing_down) {
@@ -2573,8 +2571,15 @@ void target_sess_cmd_list_set_waiting(struct se_session *se_sess)
        se_sess->sess_tearing_down = 1;
        list_splice_init(&se_sess->sess_cmd_list, &se_sess->sess_wait_list);
 
-       list_for_each_entry(se_cmd, &se_sess->sess_wait_list, se_cmd_list)
-               se_cmd->cmd_wait_set = 1;
+       list_for_each_entry(se_cmd, &se_sess->sess_wait_list, se_cmd_list) {
+               rc = kref_get_unless_zero(&se_cmd->cmd_kref);
+               if (rc) {
+                       se_cmd->cmd_wait_set = 1;
+                       spin_lock(&se_cmd->t_state_lock);
+                       se_cmd->transport_state |= CMD_T_FABRIC_STOP;
+                       spin_unlock(&se_cmd->t_state_lock);
+               }
+       }
 
        spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
 }
@@ -2587,15 +2592,25 @@ void target_wait_for_sess_cmds(struct se_session *se_sess)
 {
        struct se_cmd *se_cmd, *tmp_cmd;
        unsigned long flags;
+       bool tas;
 
        list_for_each_entry_safe(se_cmd, tmp_cmd,
                                &se_sess->sess_wait_list, se_cmd_list) {
-               list_del(&se_cmd->se_cmd_list);
+               list_del_init(&se_cmd->se_cmd_list);
 
                pr_debug("Waiting for se_cmd: %p t_state: %d, fabric state:"
                        " %d\n", se_cmd, se_cmd->t_state,
                        se_cmd->se_tfo->get_cmd_state(se_cmd));
 
+               spin_lock_irqsave(&se_cmd->t_state_lock, flags);
+               tas = (se_cmd->transport_state & CMD_T_TAS);
+               spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
+
+               if (!target_put_sess_cmd(se_cmd)) {
+                       if (tas)
+                               target_put_sess_cmd(se_cmd);
+               }
+
                wait_for_completion(&se_cmd->cmd_wait_comp);
                pr_debug("After cmd_wait_comp: se_cmd: %p t_state: %d"
                        " fabric state: %d\n", se_cmd, se_cmd->t_state,
@@ -2617,53 +2632,75 @@ void transport_clear_lun_ref(struct se_lun *lun)
        wait_for_completion(&lun->lun_ref_comp);
 }
 
-/**
- * transport_wait_for_tasks - wait for completion to occur
- * @cmd:       command to wait
- *
- * Called from frontend fabric context to wait for storage engine
- * to pause and/or release frontend generated struct se_cmd.
- */
-bool transport_wait_for_tasks(struct se_cmd *cmd)
+static bool
+__transport_wait_for_tasks(struct se_cmd *cmd, bool fabric_stop,
+                          bool *aborted, bool *tas, unsigned long *flags)
+       __releases(&cmd->t_state_lock)
+       __acquires(&cmd->t_state_lock)
 {
-       unsigned long flags;
 
-       spin_lock_irqsave(&cmd->t_state_lock, flags);
+       assert_spin_locked(&cmd->t_state_lock);
+       WARN_ON_ONCE(!irqs_disabled());
+
+       if (fabric_stop)
+               cmd->transport_state |= CMD_T_FABRIC_STOP;
+
+       if (cmd->transport_state & CMD_T_ABORTED)
+               *aborted = true;
+
+       if (cmd->transport_state & CMD_T_TAS)
+               *tas = true;
+
        if (!(cmd->se_cmd_flags & SCF_SE_LUN_CMD) &&
-           !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) {
-               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+           !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB))
                return false;
-       }
 
        if (!(cmd->se_cmd_flags & SCF_SUPPORTED_SAM_OPCODE) &&
-           !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) {
-               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+           !(cmd->se_cmd_flags & SCF_SCSI_TMR_CDB))
                return false;
-       }
 
-       if (!(cmd->transport_state & CMD_T_ACTIVE)) {
-               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+       if (!(cmd->transport_state & CMD_T_ACTIVE))
+               return false;
+
+       if (fabric_stop && *aborted)
                return false;
-       }
 
        cmd->transport_state |= CMD_T_STOP;
 
-       pr_debug("wait_for_tasks: Stopping %p ITT: 0x%08llx i_state: %d, t_state: %d, CMD_T_STOP\n",
-               cmd, cmd->tag, cmd->se_tfo->get_cmd_state(cmd), cmd->t_state);
+       pr_debug("wait_for_tasks: Stopping %p ITT: 0x%08llx i_state: %d,"
+                " t_state: %d, CMD_T_STOP\n", cmd, cmd->tag,
+                cmd->se_tfo->get_cmd_state(cmd), cmd->t_state);
 
-       spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+       spin_unlock_irqrestore(&cmd->t_state_lock, *flags);
 
        wait_for_completion(&cmd->t_transport_stop_comp);
 
-       spin_lock_irqsave(&cmd->t_state_lock, flags);
+       spin_lock_irqsave(&cmd->t_state_lock, *flags);
        cmd->transport_state &= ~(CMD_T_ACTIVE | CMD_T_STOP);
 
-       pr_debug("wait_for_tasks: Stopped wait_for_completion(&cmd->t_transport_stop_comp) for ITT: 0x%08llx\n",
-               cmd->tag);
+       pr_debug("wait_for_tasks: Stopped wait_for_completion(&cmd->"
+                "t_transport_stop_comp) for ITT: 0x%08llx\n", cmd->tag);
 
+       return true;
+}
+
+/**
+ * transport_wait_for_tasks - wait for completion to occur
+ * @cmd:       command to wait
+ *
+ * Called from frontend fabric context to wait for storage engine
+ * to pause and/or release frontend generated struct se_cmd.
+ */
+bool transport_wait_for_tasks(struct se_cmd *cmd)
+{
+       unsigned long flags;
+       bool ret, aborted = false, tas = false;
+
+       spin_lock_irqsave(&cmd->t_state_lock, flags);
+       ret = __transport_wait_for_tasks(cmd, false, &aborted, &tas, &flags);
        spin_unlock_irqrestore(&cmd->t_state_lock, flags);
 
-       return true;
+       return ret;
 }
 EXPORT_SYMBOL(transport_wait_for_tasks);
 
@@ -2845,28 +2882,49 @@ transport_send_check_condition_and_sense(struct se_cmd *cmd,
 }
 EXPORT_SYMBOL(transport_send_check_condition_and_sense);
 
-int transport_check_aborted_status(struct se_cmd *cmd, int send_status)
+static int __transport_check_aborted_status(struct se_cmd *cmd, int send_status)
+       __releases(&cmd->t_state_lock)
+       __acquires(&cmd->t_state_lock)
 {
+       assert_spin_locked(&cmd->t_state_lock);
+       WARN_ON_ONCE(!irqs_disabled());
+
        if (!(cmd->transport_state & CMD_T_ABORTED))
                return 0;
-
        /*
         * If cmd has been aborted but either no status is to be sent or it has
         * already been sent, just return
         */
-       if (!send_status || !(cmd->se_cmd_flags & SCF_SEND_DELAYED_TAS))
+       if (!send_status || !(cmd->se_cmd_flags & SCF_SEND_DELAYED_TAS)) {
+               if (send_status)
+                       cmd->se_cmd_flags |= SCF_SEND_DELAYED_TAS;
                return 1;
+       }
 
-       pr_debug("Sending delayed SAM_STAT_TASK_ABORTED status for CDB: 0x%02x ITT: 0x%08llx\n",
-                cmd->t_task_cdb[0], cmd->tag);
+       pr_debug("Sending delayed SAM_STAT_TASK_ABORTED status for CDB:"
+               " 0x%02x ITT: 0x%08llx\n", cmd->t_task_cdb[0], cmd->tag);
 
        cmd->se_cmd_flags &= ~SCF_SEND_DELAYED_TAS;
        cmd->scsi_status = SAM_STAT_TASK_ABORTED;
        trace_target_cmd_complete(cmd);
+
+       spin_unlock_irq(&cmd->t_state_lock);
        cmd->se_tfo->queue_status(cmd);
+       spin_lock_irq(&cmd->t_state_lock);
 
        return 1;
 }
+
+int transport_check_aborted_status(struct se_cmd *cmd, int send_status)
+{
+       int ret;
+
+       spin_lock_irq(&cmd->t_state_lock);
+       ret = __transport_check_aborted_status(cmd, send_status);
+       spin_unlock_irq(&cmd->t_state_lock);
+
+       return ret;
+}
 EXPORT_SYMBOL(transport_check_aborted_status);
 
 void transport_send_task_abort(struct se_cmd *cmd)
@@ -2888,11 +2946,17 @@ void transport_send_task_abort(struct se_cmd *cmd)
         */
        if (cmd->data_direction == DMA_TO_DEVICE) {
                if (cmd->se_tfo->write_pending_status(cmd) != 0) {
-                       cmd->transport_state |= CMD_T_ABORTED;
+                       spin_lock_irqsave(&cmd->t_state_lock, flags);
+                       if (cmd->se_cmd_flags & SCF_SEND_DELAYED_TAS) {
+                               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+                               goto send_abort;
+                       }
                        cmd->se_cmd_flags |= SCF_SEND_DELAYED_TAS;
+                       spin_unlock_irqrestore(&cmd->t_state_lock, flags);
                        return;
                }
        }
+send_abort:
        cmd->scsi_status = SAM_STAT_TASK_ABORTED;
 
        transport_lun_remove_cmd(cmd);
@@ -2909,8 +2973,17 @@ static void target_tmr_work(struct work_struct *work)
        struct se_cmd *cmd = container_of(work, struct se_cmd, work);
        struct se_device *dev = cmd->se_dev;
        struct se_tmr_req *tmr = cmd->se_tmr_req;
+       unsigned long flags;
        int ret;
 
+       spin_lock_irqsave(&cmd->t_state_lock, flags);
+       if (cmd->transport_state & CMD_T_ABORTED) {
+               tmr->response = TMR_FUNCTION_REJECTED;
+               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+               goto check_stop;
+       }
+       spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+
        switch (tmr->function) {
        case TMR_ABORT_TASK:
                core_tmr_abort_task(dev, tmr, cmd->se_sess);
@@ -2943,9 +3016,17 @@ static void target_tmr_work(struct work_struct *work)
                break;
        }
 
+       spin_lock_irqsave(&cmd->t_state_lock, flags);
+       if (cmd->transport_state & CMD_T_ABORTED) {
+               spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+               goto check_stop;
+       }
        cmd->t_state = TRANSPORT_ISTATE_PROCESSING;
+       spin_unlock_irqrestore(&cmd->t_state_lock, flags);
+
        cmd->se_tfo->queue_tm_rsp(cmd);
 
+check_stop:
        transport_cmd_check_stop_to_fabric(cmd);
 }
 
index dd600e5..94f5154 100644 (file)
@@ -903,7 +903,7 @@ static int tcmu_configure_device(struct se_device *dev)
        info->version = __stringify(TCMU_MAILBOX_VERSION);
 
        info->mem[0].name = "tcm-user command & data buffer";
-       info->mem[0].addr = (phys_addr_t) udev->mb_addr;
+       info->mem[0].addr = (phys_addr_t)(uintptr_t)udev->mb_addr;
        info->mem[0].size = TCMU_RING_SIZE;
        info->mem[0].memtype = UIO_MEM_VIRTUAL;
 
index 8cc4ac6..7c92c09 100644 (file)
@@ -195,7 +195,7 @@ config IMX_THERMAL
          passive trip is crossed.
 
 config SPEAR_THERMAL
-       bool "SPEAr thermal sensor driver"
+       tristate "SPEAr thermal sensor driver"
        depends on PLAT_SPEAR || COMPILE_TEST
        depends on OF
        help
@@ -237,8 +237,8 @@ config DOVE_THERMAL
          framework.
 
 config DB8500_THERMAL
-       bool "DB8500 thermal management"
-       depends on ARCH_U8500
+       tristate "DB8500 thermal management"
+       depends on MFD_DB8500_PRCMU
        default y
        help
          Adds DB8500 thermal management implementation according to the thermal
index e3fbc5a..6ceac4f 100644 (file)
@@ -377,26 +377,28 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_device,
  * get_load() - get load for a cpu since last updated
  * @cpufreq_device:    &struct cpufreq_cooling_device for this cpu
  * @cpu:       cpu number
+ * @cpu_idx:   index of the cpu in cpufreq_device->allowed_cpus
  *
  * Return: The average load of cpu @cpu in percentage since this
  * function was last called.
  */
-static u32 get_load(struct cpufreq_cooling_device *cpufreq_device, int cpu)
+static u32 get_load(struct cpufreq_cooling_device *cpufreq_device, int cpu,
+                   int cpu_idx)
 {
        u32 load;
        u64 now, now_idle, delta_time, delta_idle;
 
        now_idle = get_cpu_idle_time(cpu, &now, 0);
-       delta_idle = now_idle - cpufreq_device->time_in_idle[cpu];
-       delta_time = now - cpufreq_device->time_in_idle_timestamp[cpu];
+       delta_idle = now_idle - cpufreq_device->time_in_idle[cpu_idx];
+       delta_time = now - cpufreq_device->time_in_idle_timestamp[cpu_idx];
 
        if (delta_time <= delta_idle)
                load = 0;
        else
                load = div64_u64(100 * (delta_time - delta_idle), delta_time);
 
-       cpufreq_device->time_in_idle[cpu] = now_idle;
-       cpufreq_device->time_in_idle_timestamp[cpu] = now;
+       cpufreq_device->time_in_idle[cpu_idx] = now_idle;
+       cpufreq_device->time_in_idle_timestamp[cpu_idx] = now;
 
        return load;
 }
@@ -598,7 +600,7 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev,
                u32 load;
 
                if (cpu_online(cpu))
-                       load = get_load(cpufreq_device, cpu);
+                       load = get_load(cpufreq_device, cpu, i);
                else
                        load = 0;
 
index be4eedc..9043f8f 100644 (file)
@@ -475,14 +475,10 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data,
 
        sensor_np = of_node_get(dev->of_node);
 
-       for_each_child_of_node(np, child) {
+       for_each_available_child_of_node(np, child) {
                struct of_phandle_args sensor_specs;
                int ret, id;
 
-               /* Check whether child is enabled or not */
-               if (!of_device_is_available(child))
-                       continue;
-
                /* For now, thermal framework supports only 1 sensor per zone */
                ret = of_parse_phandle_with_args(child, "thermal-sensors",
                                                 "#thermal-sensor-cells",
@@ -881,16 +877,12 @@ int __init of_parse_thermal_zones(void)
                return 0; /* Run successfully on systems without thermal DT */
        }
 
-       for_each_child_of_node(np, child) {
+       for_each_available_child_of_node(np, child) {
                struct thermal_zone_device *zone;
                struct thermal_zone_params *tzp;
                int i, mask = 0;
                u32 prop;
 
-               /* Check whether child is enabled or not */
-               if (!of_device_is_available(child))
-                       continue;
-
                tz = thermal_of_build_thermal_zone(child);
                if (IS_ERR(tz)) {
                        pr_err("failed to build thermal zone %s: %ld\n",
@@ -968,13 +960,9 @@ void of_thermal_destroy_zones(void)
                return;
        }
 
-       for_each_child_of_node(np, child) {
+       for_each_available_child_of_node(np, child) {
                struct thermal_zone_device *zone;
 
-               /* Check whether child is enabled or not */
-               if (!of_device_is_available(child))
-                       continue;
-
                zone = thermal_zone_get_zone_by_name(child->name);
                if (IS_ERR(zone))
                        continue;
index 44b9c48..0e735ac 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/reboot.h>
@@ -75,8 +76,10 @@ struct rcar_thermal_priv {
 #define rcar_has_irq_support(priv)     ((priv)->common->base)
 #define rcar_id_to_shift(priv)         ((priv)->id * 8)
 
+#define USE_OF_THERMAL 1
 static const struct of_device_id rcar_thermal_dt_ids[] = {
        { .compatible = "renesas,rcar-thermal", },
+       { .compatible = "renesas,rcar-gen2-thermal", .data = (void *)USE_OF_THERMAL },
        {},
 };
 MODULE_DEVICE_TABLE(of, rcar_thermal_dt_ids);
@@ -200,9 +203,9 @@ err_out_unlock:
        return ret;
 }
 
-static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
+static int rcar_thermal_get_current_temp(struct rcar_thermal_priv *priv,
+                                        int *temp)
 {
-       struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
        int tmp;
        int ret;
 
@@ -226,6 +229,20 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
        return 0;
 }
 
+static int rcar_thermal_of_get_temp(void *data, int *temp)
+{
+       struct rcar_thermal_priv *priv = data;
+
+       return rcar_thermal_get_current_temp(priv, temp);
+}
+
+static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
+{
+       struct rcar_thermal_priv *priv = rcar_zone_to_priv(zone);
+
+       return rcar_thermal_get_current_temp(priv, temp);
+}
+
 static int rcar_thermal_get_trip_type(struct thermal_zone_device *zone,
                                      int trip, enum thermal_trip_type *type)
 {
@@ -282,6 +299,10 @@ static int rcar_thermal_notify(struct thermal_zone_device *zone,
        return 0;
 }
 
+static const struct thermal_zone_of_device_ops rcar_thermal_zone_of_ops = {
+       .get_temp       = rcar_thermal_of_get_temp,
+};
+
 static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
        .get_temp       = rcar_thermal_get_temp,
        .get_trip_type  = rcar_thermal_get_trip_type,
@@ -318,14 +339,20 @@ static void rcar_thermal_work(struct work_struct *work)
 
        priv = container_of(work, struct rcar_thermal_priv, work.work);
 
-       rcar_thermal_get_temp(priv->zone, &cctemp);
+       ret = rcar_thermal_get_current_temp(priv, &cctemp);
+       if (ret < 0)
+               return;
+
        ret = rcar_thermal_update_temp(priv);
        if (ret < 0)
                return;
 
        rcar_thermal_irq_enable(priv);
 
-       rcar_thermal_get_temp(priv->zone, &nctemp);
+       ret = rcar_thermal_get_current_temp(priv, &nctemp);
+       if (ret < 0)
+               return;
+
        if (nctemp != cctemp)
                thermal_zone_device_update(priv->zone);
 }
@@ -403,6 +430,8 @@ static int rcar_thermal_probe(struct platform_device *pdev)
        struct rcar_thermal_priv *priv;
        struct device *dev = &pdev->dev;
        struct resource *res, *irq;
+       const struct of_device_id *of_id = of_match_device(rcar_thermal_dt_ids, dev);
+       unsigned long of_data = (unsigned long)of_id->data;
        int mres = 0;
        int i;
        int ret = -ENODEV;
@@ -463,7 +492,13 @@ static int rcar_thermal_probe(struct platform_device *pdev)
                if (ret < 0)
                        goto error_unregister;
 
-               priv->zone = thermal_zone_device_register("rcar_thermal",
+               if (of_data == USE_OF_THERMAL)
+                       priv->zone = thermal_zone_of_sensor_register(
+                                               dev, i, priv,
+                                               &rcar_thermal_zone_of_ops);
+               else
+                       priv->zone = thermal_zone_device_register(
+                                               "rcar_thermal",
                                                1, 0, priv,
                                                &rcar_thermal_zone_ops, NULL, 0,
                                                idle);
index 534dd91..81b35aa 100644 (file)
@@ -54,8 +54,7 @@ static struct thermal_zone_device_ops ops = {
        .get_temp = thermal_get_temp,
 };
 
-#ifdef CONFIG_PM
-static int spear_thermal_suspend(struct device *dev)
+static int __maybe_unused spear_thermal_suspend(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev);
@@ -72,7 +71,7 @@ static int spear_thermal_suspend(struct device *dev)
        return 0;
 }
 
-static int spear_thermal_resume(struct device *dev)
+static int __maybe_unused spear_thermal_resume(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
        struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev);
@@ -94,7 +93,6 @@ static int spear_thermal_resume(struct device *dev)
 
        return 0;
 }
-#endif
 
 static SIMPLE_DEV_PM_OPS(spear_thermal_pm_ops, spear_thermal_suspend,
                spear_thermal_resume);
index b311004..2348fa6 100644 (file)
@@ -681,7 +681,14 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty)
 /* this is called once with whichever end is closed last */
 static void pty_unix98_shutdown(struct tty_struct *tty)
 {
-       devpts_kill_index(tty->driver_data, tty->index);
+       struct inode *ptmx_inode;
+
+       if (tty->driver->subtype == PTY_TYPE_MASTER)
+               ptmx_inode = tty->driver_data;
+       else
+               ptmx_inode = tty->link->driver_data;
+       devpts_kill_index(ptmx_inode, tty->index);
+       devpts_del_ref(ptmx_inode);
 }
 
 static const struct tty_operations ptm_unix98_ops = {
@@ -773,6 +780,18 @@ static int ptmx_open(struct inode *inode, struct file *filp)
        set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
        tty->driver_data = inode;
 
+       /*
+        * In the case where all references to ptmx inode are dropped and we
+        * still have /dev/tty opened pointing to the master/slave pair (ptmx
+        * is closed/released before /dev/tty), we must make sure that the inode
+        * is still valid when we call the final pty_unix98_shutdown, thus we
+        * hold an additional reference to the ptmx inode. For the same /dev/tty
+        * last close case, we also need to make sure the super_block isn't
+        * destroyed (devpts instance unmounted), before /dev/tty is closed and
+        * on its release devpts_kill_index is called.
+        */
+       devpts_add_ref(inode);
+
        tty_add_file(tty, filp);
 
        slave_inode = devpts_pty_new(inode,
index e71ec78..7cd6f9a 100644 (file)
@@ -1941,6 +1941,7 @@ pci_wch_ch38x_setup(struct serial_private *priv,
 #define PCIE_VENDOR_ID_WCH             0x1c00
 #define PCIE_DEVICE_ID_WCH_CH382_2S1P  0x3250
 #define PCIE_DEVICE_ID_WCH_CH384_4S    0x3470
+#define PCIE_DEVICE_ID_WCH_CH382_2S    0x3253
 
 #define PCI_VENDOR_ID_PERICOM                  0x12D8
 #define PCI_DEVICE_ID_PERICOM_PI7C9X7951       0x7951
@@ -2637,6 +2638,14 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
                .subdevice      = PCI_ANY_ID,
                .setup          = pci_wch_ch353_setup,
        },
+       /* WCH CH382 2S card (16850 clone) */
+       {
+               .vendor         = PCIE_VENDOR_ID_WCH,
+               .device         = PCIE_DEVICE_ID_WCH_CH382_2S,
+               .subvendor      = PCI_ANY_ID,
+               .subdevice      = PCI_ANY_ID,
+               .setup          = pci_wch_ch38x_setup,
+       },
        /* WCH CH382 2S1P card (16850 clone) */
        {
                .vendor         = PCIE_VENDOR_ID_WCH,
@@ -2955,6 +2964,7 @@ enum pci_board_num_t {
        pbn_fintek_4,
        pbn_fintek_8,
        pbn_fintek_12,
+       pbn_wch382_2,
        pbn_wch384_4,
        pbn_pericom_PI7C9X7951,
        pbn_pericom_PI7C9X7952,
@@ -3775,6 +3785,13 @@ static struct pciserial_board pci_boards[] = {
                .base_baud      = 115200,
                .first_offset   = 0x40,
        },
+       [pbn_wch382_2] = {
+               .flags          = FL_BASE0,
+               .num_ports      = 2,
+               .base_baud      = 115200,
+               .uart_offset    = 8,
+               .first_offset   = 0xC0,
+       },
        [pbn_wch384_4] = {
                .flags          = FL_BASE0,
                .num_ports      = 4,
@@ -5574,6 +5591,10 @@ static struct pci_device_id serial_pci_tbl[] = {
                PCI_ANY_ID, PCI_ANY_ID,
                0, 0, pbn_b0_bt_2_115200 },
 
+       {       PCIE_VENDOR_ID_WCH, PCIE_DEVICE_ID_WCH_CH382_2S,
+               PCI_ANY_ID, PCI_ANY_ID,
+               0, 0, pbn_wch382_2 },
+
        {       PCIE_VENDOR_ID_WCH, PCIE_DEVICE_ID_WCH_CH384_4S,
                PCI_ANY_ID, PCI_ANY_ID,
                0, 0, pbn_wch384_4 },
index b645f92..fa49eb1 100644 (file)
@@ -1165,7 +1165,7 @@ serial_omap_type(struct uart_port *port)
 
 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
 
-static void wait_for_xmitr(struct uart_omap_port *up)
+static void __maybe_unused wait_for_xmitr(struct uart_omap_port *up)
 {
        unsigned int status, tmout = 10000;
 
@@ -1343,7 +1343,7 @@ static inline void serial_omap_add_console_port(struct uart_omap_port *up)
 
 /* Enable or disable the rs485 support */
 static int
-serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
+serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
 {
        struct uart_omap_port *up = to_uart_omap_port(port);
        unsigned int mode;
@@ -1356,8 +1356,12 @@ serial_omap_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf)
        up->ier = 0;
        serial_out(up, UART_IER, 0);
 
+       /* Clamp the delays to [0, 100ms] */
+       rs485->delay_rts_before_send = min(rs485->delay_rts_before_send, 100U);
+       rs485->delay_rts_after_send  = min(rs485->delay_rts_after_send, 100U);
+
        /* store new config */
-       port->rs485 = *rs485conf;
+       port->rs485 = *rs485;
 
        /*
         * Just as a precaution, only allow rs485
index 5cec01c..a7eacef 100644 (file)
@@ -2066,13 +2066,12 @@ retry_open:
                if (tty) {
                        mutex_unlock(&tty_mutex);
                        retval = tty_lock_interruptible(tty);
+                       tty_kref_put(tty);  /* drop kref from tty_driver_lookup_tty() */
                        if (retval) {
                                if (retval == -EINTR)
                                        retval = -ERESTARTSYS;
                                goto err_unref;
                        }
-                       /* safe to drop the kref from tty_driver_lookup_tty() */
-                       tty_kref_put(tty);
                        retval = tty_reopen(tty);
                        if (retval < 0) {
                                tty_unlock(tty);
index d2f3c4c..dfa9ec0 100644 (file)
@@ -21,10 +21,15 @@ EXPORT_SYMBOL(tty_lock);
 
 int tty_lock_interruptible(struct tty_struct *tty)
 {
+       int ret;
+
        if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
                return -EIO;
        tty_kref_get(tty);
-       return mutex_lock_interruptible(&tty->legacy_mutex);
+       ret = mutex_lock_interruptible(&tty->legacy_mutex);
+       if (ret)
+               tty_kref_put(tty);
+       return ret;
 }
 
 void __lockfunc tty_unlock(struct tty_struct *tty)
index b59195e..b635ab6 100644 (file)
@@ -85,8 +85,8 @@ static int ci_hdrc_pci_probe(struct pci_dev *pdev,
 
        /* register a nop PHY */
        ci->phy = usb_phy_generic_register();
-       if (!ci->phy)
-               return -ENOMEM;
+       if (IS_ERR(ci->phy))
+               return PTR_ERR(ci->phy);
 
        memset(res, 0, sizeof(res));
        res[0].start    = pci_resource_start(pdev, 0);
index a4f7db2..df47110 100644 (file)
@@ -100,6 +100,9 @@ static ssize_t ci_port_test_write(struct file *file, const char __user *ubuf,
        if (sscanf(buf, "%u", &mode) != 1)
                return -EINVAL;
 
+       if (mode > 255)
+               return -EBADRQC;
+
        pm_runtime_get_sync(ci->dev);
        spin_lock_irqsave(&ci->lock, flags);
        ret = hw_port_test_set(ci, mode);
index 45f86da..03b6743 100644 (file)
@@ -158,7 +158,7 @@ static void ci_otg_work(struct work_struct *work)
 int ci_hdrc_otg_init(struct ci_hdrc *ci)
 {
        INIT_WORK(&ci->work, ci_otg_work);
-       ci->wq = create_singlethread_workqueue("ci_otg");
+       ci->wq = create_freezable_workqueue("ci_otg");
        if (!ci->wq) {
                dev_err(ci->dev, "can't create workqueue\n");
                return -ENODEV;
index 350dcd9..51b4369 100644 (file)
@@ -5401,6 +5401,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
        }
 
        bos = udev->bos;
+       udev->bos = NULL;
 
        for (i = 0; i < SET_CONFIG_TRIES; ++i) {
 
@@ -5493,11 +5494,8 @@ done:
        usb_set_usb2_hardware_lpm(udev, 1);
        usb_unlocked_enable_lpm(udev);
        usb_enable_ltm(udev);
-       /* release the new BOS descriptor allocated  by hub_port_init() */
-       if (udev->bos != bos) {
-               usb_release_bos_descriptor(udev);
-               udev->bos = bos;
-       }
+       usb_release_bos_descriptor(udev);
+       udev->bos = bos;
        return 0;
 
 re_enumerate:
index fd95ba6..f0decc0 100644 (file)
@@ -1,5 +1,6 @@
 config USB_DWC2
        tristate "DesignWare USB2 DRD Core Support"
+       depends on HAS_DMA
        depends on USB || USB_GADGET
        help
          Say Y here if your system has a Dual Role Hi-Speed USB
index e991d55..46c4ba7 100644 (file)
@@ -619,6 +619,12 @@ void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
                         __func__, hsotg->dr_mode);
                break;
        }
+
+       /*
+        * NOTE: This is required for some rockchip soc based
+        * platforms.
+        */
+       msleep(50);
 }
 
 /*
index 36606fc..a41274a 100644 (file)
@@ -1174,14 +1174,11 @@ static int dwc2_process_non_isoc_desc(struct dwc2_hsotg *hsotg,
        failed = dwc2_update_non_isoc_urb_state_ddma(hsotg, chan, qtd, dma_desc,
                                                     halt_status, n_bytes,
                                                     xfer_done);
-       if (*xfer_done && urb->status != -EINPROGRESS)
-               failed = 1;
-
-       if (failed) {
+       if (failed || (*xfer_done && urb->status != -EINPROGRESS)) {
                dwc2_host_complete(hsotg, qtd, urb->status);
                dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh);
-               dev_vdbg(hsotg->dev, "failed=%1x xfer_done=%1x status=%08x\n",
-                        failed, *xfer_done, urb->status);
+               dev_vdbg(hsotg->dev, "failed=%1x xfer_done=%1x\n",
+                        failed, *xfer_done);
                return failed;
        }
 
@@ -1236,21 +1233,23 @@ static void dwc2_complete_non_isoc_xfer_ddma(struct dwc2_hsotg *hsotg,
 
        list_for_each_safe(qtd_item, qtd_tmp, &qh->qtd_list) {
                int i;
+               int qtd_desc_count;
 
                qtd = list_entry(qtd_item, struct dwc2_qtd, qtd_list_entry);
                xfer_done = 0;
+               qtd_desc_count = qtd->n_desc;
 
-               for (i = 0; i < qtd->n_desc; i++) {
+               for (i = 0; i < qtd_desc_count; i++) {
                        if (dwc2_process_non_isoc_desc(hsotg, chan, chnum, qtd,
                                                       desc_num, halt_status,
-                                                      &xfer_done)) {
-                               qtd = NULL;
-                               break;
-                       }
+                                                      &xfer_done))
+                               goto stop_scan;
+
                        desc_num++;
                }
        }
 
+stop_scan:
        if (qh->ep_type != USB_ENDPOINT_XFER_CONTROL) {
                /*
                 * Resetting the data toggle for bulk and interrupt endpoints
@@ -1258,7 +1257,7 @@ static void dwc2_complete_non_isoc_xfer_ddma(struct dwc2_hsotg *hsotg,
                 */
                if (halt_status == DWC2_HC_XFER_STALL)
                        qh->data_toggle = DWC2_HC_PID_DATA0;
-               else if (qtd)
+               else
                        dwc2_hcd_save_data_toggle(hsotg, chan, chnum, qtd);
        }
 
index f825380..cadba8b 100644 (file)
@@ -525,11 +525,19 @@ void dwc2_hcd_save_data_toggle(struct dwc2_hsotg *hsotg,
        u32 pid = (hctsiz & TSIZ_SC_MC_PID_MASK) >> TSIZ_SC_MC_PID_SHIFT;
 
        if (chan->ep_type != USB_ENDPOINT_XFER_CONTROL) {
+               if (WARN(!chan || !chan->qh,
+                        "chan->qh must be specified for non-control eps\n"))
+                       return;
+
                if (pid == TSIZ_SC_MC_PID_DATA0)
                        chan->qh->data_toggle = DWC2_HC_PID_DATA0;
                else
                        chan->qh->data_toggle = DWC2_HC_PID_DATA1;
        } else {
+               if (WARN(!qtd,
+                        "qtd must be specified for control eps\n"))
+                       return;
+
                if (pid == TSIZ_SC_MC_PID_DATA0)
                        qtd->data_toggle = DWC2_HC_PID_DATA0;
                else
index 2913068..e4f8b90 100644 (file)
@@ -856,7 +856,6 @@ struct dwc3 {
        unsigned                pullups_connected:1;
        unsigned                resize_fifos:1;
        unsigned                setup_packet_pending:1;
-       unsigned                start_config_issued:1;
        unsigned                three_stage_setup:1;
        unsigned                usb3_lpm_capable:1;
 
index 3a9354a..8d6b75c 100644 (file)
@@ -555,7 +555,6 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
        int ret;
        u32 reg;
 
-       dwc->start_config_issued = false;
        cfg = le16_to_cpu(ctrl->wValue);
 
        switch (state) {
@@ -737,10 +736,6 @@ static int dwc3_ep0_std_request(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)
                dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_ISOCH_DELAY");
                ret = dwc3_ep0_set_isoch_delay(dwc, ctrl);
                break;
-       case USB_REQ_SET_INTERFACE:
-               dwc3_trace(trace_dwc3_ep0, "USB_REQ_SET_INTERFACE");
-               dwc->start_config_issued = false;
-               /* Fall through */
        default:
                dwc3_trace(trace_dwc3_ep0, "Forwarding to gadget driver");
                ret = dwc3_ep0_delegate_req(dwc, ctrl);
index 7d1dd82..2363bad 100644 (file)
@@ -385,24 +385,66 @@ static void dwc3_free_trb_pool(struct dwc3_ep *dep)
        dep->trb_pool_dma = 0;
 }
 
+static int dwc3_gadget_set_xfer_resource(struct dwc3 *dwc, struct dwc3_ep *dep);
+
+/**
+ * dwc3_gadget_start_config - Configure EP resources
+ * @dwc: pointer to our controller context structure
+ * @dep: endpoint that is being enabled
+ *
+ * The assignment of transfer resources cannot perfectly follow the
+ * data book due to the fact that the controller driver does not have
+ * all knowledge of the configuration in advance. It is given this
+ * information piecemeal by the composite gadget framework after every
+ * SET_CONFIGURATION and SET_INTERFACE. Trying to follow the databook
+ * programming model in this scenario can cause errors. For two
+ * reasons:
+ *
+ * 1) The databook says to do DEPSTARTCFG for every SET_CONFIGURATION
+ * and SET_INTERFACE (8.1.5). This is incorrect in the scenario of
+ * multiple interfaces.
+ *
+ * 2) The databook does not mention doing more DEPXFERCFG for new
+ * endpoint on alt setting (8.1.6).
+ *
+ * The following simplified method is used instead:
+ *
+ * All hardware endpoints can be assigned a transfer resource and this
+ * setting will stay persistent until either a core reset or
+ * hibernation. So whenever we do a DEPSTARTCFG(0) we can go ahead and
+ * do DEPXFERCFG for every hardware endpoint as well. We are
+ * guaranteed that there are as many transfer resources as endpoints.
+ *
+ * This function is called for each endpoint when it is being enabled
+ * but is triggered only when called for EP0-out, which always happens
+ * first, and which should only happen in one of the above conditions.
+ */
 static int dwc3_gadget_start_config(struct dwc3 *dwc, struct dwc3_ep *dep)
 {
        struct dwc3_gadget_ep_cmd_params params;
        u32                     cmd;
+       int                     i;
+       int                     ret;
+
+       if (dep->number)
+               return 0;
 
        memset(&params, 0x00, sizeof(params));
+       cmd = DWC3_DEPCMD_DEPSTARTCFG;
 
-       if (dep->number != 1) {
-               cmd = DWC3_DEPCMD_DEPSTARTCFG;
-               /* XferRscIdx == 0 for ep0 and 2 for the remaining */
-               if (dep->number > 1) {
-                       if (dwc->start_config_issued)
-                               return 0;
-                       dwc->start_config_issued = true;
-                       cmd |= DWC3_DEPCMD_PARAM(2);
-               }
+       ret = dwc3_send_gadget_ep_cmd(dwc, 0, cmd, &params);
+       if (ret)
+               return ret;
 
-               return dwc3_send_gadget_ep_cmd(dwc, 0, cmd, &params);
+       for (i = 0; i < DWC3_ENDPOINTS_NUM; i++) {
+               struct dwc3_ep *dep = dwc->eps[i];
+
+               if (!dep)
+                       continue;
+
+               ret = dwc3_gadget_set_xfer_resource(dwc, dep);
+               if (ret)
+                       return ret;
        }
 
        return 0;
@@ -516,10 +558,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
                struct dwc3_trb *trb_st_hw;
                struct dwc3_trb *trb_link;
 
-               ret = dwc3_gadget_set_xfer_resource(dwc, dep);
-               if (ret)
-                       return ret;
-
                dep->endpoint.desc = desc;
                dep->comp_desc = comp_desc;
                dep->type = usb_endpoint_type(desc);
@@ -1636,8 +1674,6 @@ static int dwc3_gadget_start(struct usb_gadget *g,
        }
        dwc3_writel(dwc->regs, DWC3_DCFG, reg);
 
-       dwc->start_config_issued = false;
-
        /* Start with SuperSpeed Default */
        dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
 
@@ -2237,7 +2273,6 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc)
        dwc3_writel(dwc->regs, DWC3_DCTL, reg);
 
        dwc3_disconnect_gadget(dwc);
-       dwc->start_config_issued = false;
 
        dwc->gadget.speed = USB_SPEED_UNKNOWN;
        dwc->setup_packet_pending = false;
@@ -2288,7 +2323,6 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
 
        dwc3_stop_active_transfers(dwc);
        dwc3_clear_stall_all_ep(dwc);
-       dwc->start_config_issued = false;
 
        /* Reset device address to zero */
        reg = dwc3_readl(dwc->regs, DWC3_DCFG);
index 7e179f8..87fb0fd 100644 (file)
@@ -130,7 +130,8 @@ struct dev_data {
                                        setup_can_stall : 1,
                                        setup_out_ready : 1,
                                        setup_out_error : 1,
-                                       setup_abort : 1;
+                                       setup_abort : 1,
+                                       gadget_registered : 1;
        unsigned                        setup_wLength;
 
        /* the rest is basically write-once */
@@ -1179,7 +1180,8 @@ dev_release (struct inode *inode, struct file *fd)
 
        /* closing ep0 === shutdown all */
 
-       usb_gadget_unregister_driver (&gadgetfs_driver);
+       if (dev->gadget_registered)
+               usb_gadget_unregister_driver (&gadgetfs_driver);
 
        /* at this point "good" hardware has disconnected the
         * device from USB; the host won't see it any more.
@@ -1847,6 +1849,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
                 * kick in after the ep0 descriptor is closed.
                 */
                value = len;
+               dev->gadget_registered = true;
        }
        return value;
 
index 53c0692..93d28cb 100644 (file)
@@ -2340,7 +2340,7 @@ static struct qe_udc *qe_udc_config(struct platform_device *ofdev)
 {
        struct qe_udc *udc;
        struct device_node *np = ofdev->dev.of_node;
-       unsigned int tmp_addr = 0;
+       unsigned long tmp_addr = 0;
        struct usb_device_para __iomem *usbpram;
        unsigned int i;
        u64 size;
index 4dff60d..0d32052 100644 (file)
@@ -369,9 +369,20 @@ static inline void set_max_speed(struct net2280_ep *ep, u32 max)
        static const u32 ep_enhanced[9] = { 0x10, 0x60, 0x30, 0x80,
                                          0x50, 0x20, 0x70, 0x40, 0x90 };
 
-       if (ep->dev->enhanced_mode)
+       if (ep->dev->enhanced_mode) {
                reg = ep_enhanced[ep->num];
-       else{
+               switch (ep->dev->gadget.speed) {
+               case USB_SPEED_SUPER:
+                       reg += 2;
+                       break;
+               case USB_SPEED_FULL:
+                       reg += 1;
+                       break;
+               case USB_SPEED_HIGH:
+               default:
+                       break;
+               }
+       } else {
                reg = (ep->num + 1) * 0x10;
                if (ep->dev->gadget.speed != USB_SPEED_HIGH)
                        reg += 1;
index fd73a3e..b86a6f0 100644 (file)
@@ -413,9 +413,10 @@ int usb_add_gadget_udc_release(struct device *parent, struct usb_gadget *gadget,
                if (!driver->udc_name || strcmp(driver->udc_name,
                                                dev_name(&udc->dev)) == 0) {
                        ret = udc_bind_to_driver(udc, driver);
+                       if (ret != -EPROBE_DEFER)
+                               list_del(&driver->pending);
                        if (ret)
                                goto err4;
-                       list_del(&driver->pending);
                        break;
                }
        }
index 795a45b..58487a4 100644 (file)
@@ -662,7 +662,7 @@ static int musb_tx_dma_set_mode_mentor(struct dma_controller *dma,
                csr &= ~(MUSB_TXCSR_AUTOSET | MUSB_TXCSR_DMAMODE);
                csr |= MUSB_TXCSR_DMAENAB; /* against programmer's guide */
        }
-       channel->desired_mode = mode;
+       channel->desired_mode = *mode;
        musb_writew(epio, MUSB_TXCSR, csr);
 
        return 0;
@@ -2003,10 +2003,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
                                qh->offset,
                                urb->transfer_buffer_length);
 
-                       done = musb_rx_dma_in_inventra_cppi41(c, hw_ep, qh,
-                                                             urb, xfer_len,
-                                                             iso_err);
-                       if (done)
+                       if (musb_rx_dma_in_inventra_cppi41(c, hw_ep, qh, urb,
+                                                          xfer_len, iso_err))
                                goto finish;
                        else
                                dev_err(musb->controller, "error: rx_dma failed\n");
index 970a30e..72b387d 100644 (file)
@@ -757,14 +757,8 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
        otg->host = host;
        dev_dbg(otg->usb_phy->dev, "host driver registered w/ tranceiver\n");
 
-       /*
-        * Kick the state machine work, if peripheral is not supported
-        * or peripheral is already registered with us.
-        */
-       if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) {
-               pm_runtime_get_sync(otg->usb_phy->dev);
-               schedule_work(&motg->sm_work);
-       }
+       pm_runtime_get_sync(otg->usb_phy->dev);
+       schedule_work(&motg->sm_work);
 
        return 0;
 }
@@ -827,14 +821,8 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
        dev_dbg(otg->usb_phy->dev,
                "peripheral driver registered w/ tranceiver\n");
 
-       /*
-        * Kick the state machine work, if host is not supported
-        * or host is already registered with us.
-        */
-       if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) {
-               pm_runtime_get_sync(otg->usb_phy->dev);
-               schedule_work(&motg->sm_work);
-       }
+       pm_runtime_get_sync(otg->usb_phy->dev);
+       schedule_work(&motg->sm_work);
 
        return 0;
 }
index f612dda..56ecb8b 100644 (file)
@@ -475,22 +475,6 @@ config USB_SERIAL_MOS7840
          To compile this driver as a module, choose M here: the
          module will be called mos7840.  If unsure, choose N.
 
-config USB_SERIAL_MXUPORT11
-       tristate "USB Moxa UPORT 11x0 Serial Driver"
-       ---help---
-         Say Y here if you want to use a MOXA UPort 11x0 Serial hub.
-
-         This driver supports:
-
-         - UPort 1110  : 1 port RS-232 USB to Serial Hub.
-         - UPort 1130  : 1 port RS-422/485 USB to Serial Hub.
-         - UPort 1130I : 1 port RS-422/485 USB to Serial Hub with Isolation.
-         - UPort 1150  : 1 port RS-232/422/485 USB to Serial Hub.
-         - UPort 1150I : 1 port RS-232/422/485 USB to Serial Hub with Isolation.
-
-         To compile this driver as a module, choose M here: the
-         module will be called mxu11x0.
-
 config USB_SERIAL_MXUPORT
        tristate "USB Moxa UPORT Serial Driver"
        ---help---
index f3fa5e5..349d9df 100644 (file)
@@ -38,7 +38,6 @@ obj-$(CONFIG_USB_SERIAL_METRO)                        += metro-usb.o
 obj-$(CONFIG_USB_SERIAL_MOS7720)               += mos7720.o
 obj-$(CONFIG_USB_SERIAL_MOS7840)               += mos7840.o
 obj-$(CONFIG_USB_SERIAL_MXUPORT)               += mxuport.o
-obj-$(CONFIG_USB_SERIAL_MXUPORT11)             += mxu11x0.o
 obj-$(CONFIG_USB_SERIAL_NAVMAN)                        += navman.o
 obj-$(CONFIG_USB_SERIAL_OMNINET)               += omninet.o
 obj-$(CONFIG_USB_SERIAL_OPTICON)               += opticon.o
index 987813b..73a366d 100644 (file)
@@ -163,6 +163,9 @@ static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
        { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
        { USB_DEVICE(0x18EF, 0xE025) }, /* ELV Marble Sound Board 1 */
+       { USB_DEVICE(0x1901, 0x0190) }, /* GE B850 CP2105 Recorder interface */
+       { USB_DEVICE(0x1901, 0x0193) }, /* GE B650 CP2104 PMC interface */
+       { USB_DEVICE(0x19CF, 0x3000) }, /* Parrot NMEA GPS Flight Recorder */
        { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */
        { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */
        { USB_DEVICE(0x1BA4, 0x0002) }, /* Silicon Labs 358x factory default */
diff --git a/drivers/usb/serial/mxu11x0.c b/drivers/usb/serial/mxu11x0.c
deleted file mode 100644 (file)
index 6196073..0000000
+++ /dev/null
@@ -1,1006 +0,0 @@
-/*
- * USB Moxa UPORT 11x0 Serial Driver
- *
- * Copyright (C) 2007 MOXA Technologies Co., Ltd.
- * Copyright (C) 2015 Mathieu Othacehe <m.othacehe@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- *
- * Supports the following Moxa USB to serial converters:
- *  UPort 1110,  1 port RS-232 USB to Serial Hub.
- *  UPort 1130,  1 port RS-422/485 USB to Serial Hub.
- *  UPort 1130I, 1 port RS-422/485 USB to Serial Hub with isolation
- *    protection.
- *  UPort 1150,  1 port RS-232/422/485 USB to Serial Hub.
- *  UPort 1150I, 1 port RS-232/422/485 USB to Serial Hub with isolation
- *  protection.
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/firmware.h>
-#include <linux/jiffies.h>
-#include <linux/serial.h>
-#include <linux/serial_reg.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/mutex.h>
-#include <linux/tty.h>
-#include <linux/tty_driver.h>
-#include <linux/tty_flip.h>
-#include <linux/uaccess.h>
-#include <linux/usb.h>
-#include <linux/usb/serial.h>
-
-/* Vendor and product ids */
-#define MXU1_VENDOR_ID                         0x110a
-#define MXU1_1110_PRODUCT_ID                   0x1110
-#define MXU1_1130_PRODUCT_ID                   0x1130
-#define MXU1_1150_PRODUCT_ID                   0x1150
-#define MXU1_1151_PRODUCT_ID                   0x1151
-#define MXU1_1131_PRODUCT_ID                   0x1131
-
-/* Commands */
-#define MXU1_GET_VERSION                       0x01
-#define MXU1_GET_PORT_STATUS                   0x02
-#define MXU1_GET_PORT_DEV_INFO                 0x03
-#define MXU1_GET_CONFIG                                0x04
-#define MXU1_SET_CONFIG                                0x05
-#define MXU1_OPEN_PORT                         0x06
-#define MXU1_CLOSE_PORT                                0x07
-#define MXU1_START_PORT                                0x08
-#define MXU1_STOP_PORT                         0x09
-#define MXU1_TEST_PORT                         0x0A
-#define MXU1_PURGE_PORT                                0x0B
-#define MXU1_RESET_EXT_DEVICE                  0x0C
-#define MXU1_GET_OUTQUEUE                      0x0D
-#define MXU1_WRITE_DATA                                0x80
-#define MXU1_READ_DATA                         0x81
-#define MXU1_REQ_TYPE_CLASS                    0x82
-
-/* Module identifiers */
-#define MXU1_I2C_PORT                          0x01
-#define MXU1_IEEE1284_PORT                     0x02
-#define MXU1_UART1_PORT                                0x03
-#define MXU1_UART2_PORT                                0x04
-#define MXU1_RAM_PORT                          0x05
-
-/* Modem status */
-#define MXU1_MSR_DELTA_CTS                     0x01
-#define MXU1_MSR_DELTA_DSR                     0x02
-#define MXU1_MSR_DELTA_RI                      0x04
-#define MXU1_MSR_DELTA_CD                      0x08
-#define MXU1_MSR_CTS                           0x10
-#define MXU1_MSR_DSR                           0x20
-#define MXU1_MSR_RI                            0x40
-#define MXU1_MSR_CD                            0x80
-#define MXU1_MSR_DELTA_MASK                    0x0F
-#define MXU1_MSR_MASK                          0xF0
-
-/* Line status */
-#define MXU1_LSR_OVERRUN_ERROR                 0x01
-#define MXU1_LSR_PARITY_ERROR                  0x02
-#define MXU1_LSR_FRAMING_ERROR                 0x04
-#define MXU1_LSR_BREAK                         0x08
-#define MXU1_LSR_ERROR                         0x0F
-#define MXU1_LSR_RX_FULL                       0x10
-#define MXU1_LSR_TX_EMPTY                      0x20
-
-/* Modem control */
-#define MXU1_MCR_LOOP                          0x04
-#define MXU1_MCR_DTR                           0x10
-#define MXU1_MCR_RTS                           0x20
-
-/* Mask settings */
-#define MXU1_UART_ENABLE_RTS_IN                        0x0001
-#define MXU1_UART_DISABLE_RTS                  0x0002
-#define MXU1_UART_ENABLE_PARITY_CHECKING       0x0008
-#define MXU1_UART_ENABLE_DSR_OUT               0x0010
-#define MXU1_UART_ENABLE_CTS_OUT               0x0020
-#define MXU1_UART_ENABLE_X_OUT                 0x0040
-#define MXU1_UART_ENABLE_XA_OUT                        0x0080
-#define MXU1_UART_ENABLE_X_IN                  0x0100
-#define MXU1_UART_ENABLE_DTR_IN                        0x0800
-#define MXU1_UART_DISABLE_DTR                  0x1000
-#define MXU1_UART_ENABLE_MS_INTS               0x2000
-#define MXU1_UART_ENABLE_AUTO_START_DMA                0x4000
-#define MXU1_UART_SEND_BREAK_SIGNAL            0x8000
-
-/* Parity */
-#define MXU1_UART_NO_PARITY                    0x00
-#define MXU1_UART_ODD_PARITY                   0x01
-#define MXU1_UART_EVEN_PARITY                  0x02
-#define MXU1_UART_MARK_PARITY                  0x03
-#define MXU1_UART_SPACE_PARITY                 0x04
-
-/* Stop bits */
-#define MXU1_UART_1_STOP_BITS                  0x00
-#define MXU1_UART_1_5_STOP_BITS                        0x01
-#define MXU1_UART_2_STOP_BITS                  0x02
-
-/* Bits per character */
-#define MXU1_UART_5_DATA_BITS                  0x00
-#define MXU1_UART_6_DATA_BITS                  0x01
-#define MXU1_UART_7_DATA_BITS                  0x02
-#define MXU1_UART_8_DATA_BITS                  0x03
-
-/* Operation modes */
-#define MXU1_UART_232                          0x00
-#define MXU1_UART_485_RECEIVER_DISABLED                0x01
-#define MXU1_UART_485_RECEIVER_ENABLED         0x02
-
-/* Pipe transfer mode and timeout */
-#define MXU1_PIPE_MODE_CONTINUOUS              0x01
-#define MXU1_PIPE_MODE_MASK                    0x03
-#define MXU1_PIPE_TIMEOUT_MASK                 0x7C
-#define MXU1_PIPE_TIMEOUT_ENABLE               0x80
-
-/* Config struct */
-struct mxu1_uart_config {
-       __be16  wBaudRate;
-       __be16  wFlags;
-       u8      bDataBits;
-       u8      bParity;
-       u8      bStopBits;
-       char    cXon;
-       char    cXoff;
-       u8      bUartMode;
-} __packed;
-
-/* Purge modes */
-#define MXU1_PURGE_OUTPUT                      0x00
-#define MXU1_PURGE_INPUT                       0x80
-
-/* Read/Write data */
-#define MXU1_RW_DATA_ADDR_SFR                  0x10
-#define MXU1_RW_DATA_ADDR_IDATA                        0x20
-#define MXU1_RW_DATA_ADDR_XDATA                        0x30
-#define MXU1_RW_DATA_ADDR_CODE                 0x40
-#define MXU1_RW_DATA_ADDR_GPIO                 0x50
-#define MXU1_RW_DATA_ADDR_I2C                  0x60
-#define MXU1_RW_DATA_ADDR_FLASH                        0x70
-#define MXU1_RW_DATA_ADDR_DSP                  0x80
-
-#define MXU1_RW_DATA_UNSPECIFIED               0x00
-#define MXU1_RW_DATA_BYTE                      0x01
-#define MXU1_RW_DATA_WORD                      0x02
-#define MXU1_RW_DATA_DOUBLE_WORD               0x04
-
-struct mxu1_write_data_bytes {
-       u8      bAddrType;
-       u8      bDataType;
-       u8      bDataCounter;
-       __be16  wBaseAddrHi;
-       __be16  wBaseAddrLo;
-       u8      bData[0];
-} __packed;
-
-/* Interrupt codes */
-#define MXU1_CODE_HARDWARE_ERROR               0xFF
-#define MXU1_CODE_DATA_ERROR                   0x03
-#define MXU1_CODE_MODEM_STATUS                 0x04
-
-static inline int mxu1_get_func_from_code(unsigned char code)
-{
-       return code & 0x0f;
-}
-
-/* Download firmware max packet size */
-#define MXU1_DOWNLOAD_MAX_PACKET_SIZE          64
-
-/* Firmware image header */
-struct mxu1_firmware_header {
-       __le16 wLength;
-       u8 bCheckSum;
-} __packed;
-
-#define MXU1_UART_BASE_ADDR        0xFFA0
-#define MXU1_UART_OFFSET_MCR       0x0004
-
-#define MXU1_BAUD_BASE              923077
-
-#define MXU1_TRANSFER_TIMEOUT      2
-#define MXU1_DOWNLOAD_TIMEOUT       1000
-#define MXU1_DEFAULT_CLOSING_WAIT   4000 /* in .01 secs */
-
-struct mxu1_port {
-       u8 msr;
-       u8 mcr;
-       u8 uart_mode;
-       spinlock_t spinlock; /* Protects msr */
-       struct mutex mutex; /* Protects mcr */
-       bool send_break;
-};
-
-struct mxu1_device {
-       u16 mxd_model;
-};
-
-static const struct usb_device_id mxu1_idtable[] = {
-       { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1110_PRODUCT_ID) },
-       { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1130_PRODUCT_ID) },
-       { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1150_PRODUCT_ID) },
-       { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1151_PRODUCT_ID) },
-       { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1131_PRODUCT_ID) },
-       { }
-};
-
-MODULE_DEVICE_TABLE(usb, mxu1_idtable);
-
-/* Write the given buffer out to the control pipe.  */
-static int mxu1_send_ctrl_data_urb(struct usb_serial *serial,
-                                  u8 request,
-                                  u16 value, u16 index,
-                                  void *data, size_t size)
-{
-       int status;
-
-       status = usb_control_msg(serial->dev,
-                                usb_sndctrlpipe(serial->dev, 0),
-                                request,
-                                (USB_DIR_OUT | USB_TYPE_VENDOR |
-                                 USB_RECIP_DEVICE), value, index,
-                                data, size,
-                                USB_CTRL_SET_TIMEOUT);
-       if (status < 0) {
-               dev_err(&serial->interface->dev,
-                       "%s - usb_control_msg failed: %d\n",
-                       __func__, status);
-               return status;
-       }
-
-       if (status != size) {
-               dev_err(&serial->interface->dev,
-                       "%s - short write (%d / %zd)\n",
-                       __func__, status, size);
-               return -EIO;
-       }
-
-       return 0;
-}
-
-/* Send a vendor request without any data */
-static int mxu1_send_ctrl_urb(struct usb_serial *serial,
-                             u8 request, u16 value, u16 index)
-{
-       return mxu1_send_ctrl_data_urb(serial, request, value, index,
-                                      NULL, 0);
-}
-
-static int mxu1_download_firmware(struct usb_serial *serial,
-                                 const struct firmware *fw_p)
-{
-       int status = 0;
-       int buffer_size;
-       int pos;
-       int len;
-       int done;
-       u8 cs = 0;
-       u8 *buffer;
-       struct usb_device *dev = serial->dev;
-       struct mxu1_firmware_header *header;
-       unsigned int pipe;
-
-       pipe = usb_sndbulkpipe(dev, serial->port[0]->bulk_out_endpointAddress);
-
-       buffer_size = fw_p->size + sizeof(*header);
-       buffer = kmalloc(buffer_size, GFP_KERNEL);
-       if (!buffer)
-               return -ENOMEM;
-
-       memcpy(buffer, fw_p->data, fw_p->size);
-       memset(buffer + fw_p->size, 0xff, buffer_size - fw_p->size);
-
-       for (pos = sizeof(*header); pos < buffer_size; pos++)
-               cs = (u8)(cs + buffer[pos]);
-
-       header = (struct mxu1_firmware_header *)buffer;
-       header->wLength = cpu_to_le16(buffer_size - sizeof(*header));
-       header->bCheckSum = cs;
-
-       dev_dbg(&dev->dev, "%s - downloading firmware\n", __func__);
-
-       for (pos = 0; pos < buffer_size; pos += done) {
-               len = min(buffer_size - pos, MXU1_DOWNLOAD_MAX_PACKET_SIZE);
-
-               status = usb_bulk_msg(dev, pipe, buffer + pos, len, &done,
-                               MXU1_DOWNLOAD_TIMEOUT);
-               if (status)
-                       break;
-       }
-
-       kfree(buffer);
-
-       if (status) {
-               dev_err(&dev->dev, "failed to download firmware: %d\n", status);
-               return status;
-       }
-
-       msleep_interruptible(100);
-       usb_reset_device(dev);
-
-       dev_dbg(&dev->dev, "%s - download successful\n", __func__);
-
-       return 0;
-}
-
-static int mxu1_port_probe(struct usb_serial_port *port)
-{
-       struct mxu1_port *mxport;
-       struct mxu1_device *mxdev;
-
-       if (!port->interrupt_in_urb) {
-               dev_err(&port->dev, "no interrupt urb\n");
-               return -ENODEV;
-       }
-
-       mxport = kzalloc(sizeof(struct mxu1_port), GFP_KERNEL);
-       if (!mxport)
-               return -ENOMEM;
-
-       spin_lock_init(&mxport->spinlock);
-       mutex_init(&mxport->mutex);
-
-       mxdev = usb_get_serial_data(port->serial);
-
-       switch (mxdev->mxd_model) {
-       case MXU1_1110_PRODUCT_ID:
-       case MXU1_1150_PRODUCT_ID:
-       case MXU1_1151_PRODUCT_ID:
-               mxport->uart_mode = MXU1_UART_232;
-               break;
-       case MXU1_1130_PRODUCT_ID:
-       case MXU1_1131_PRODUCT_ID:
-               mxport->uart_mode = MXU1_UART_485_RECEIVER_DISABLED;
-               break;
-       }
-
-       usb_set_serial_port_data(port, mxport);
-
-       port->port.closing_wait =
-                       msecs_to_jiffies(MXU1_DEFAULT_CLOSING_WAIT * 10);
-       port->port.drain_delay = 1;
-
-       return 0;
-}
-
-static int mxu1_port_remove(struct usb_serial_port *port)
-{
-       struct mxu1_port *mxport;
-
-       mxport = usb_get_serial_port_data(port);
-       kfree(mxport);
-
-       return 0;
-}
-
-static int mxu1_startup(struct usb_serial *serial)
-{
-       struct mxu1_device *mxdev;
-       struct usb_device *dev = serial->dev;
-       struct usb_host_interface *cur_altsetting;
-       char fw_name[32];
-       const struct firmware *fw_p = NULL;
-       int err;
-
-       dev_dbg(&serial->interface->dev, "%s - product 0x%04X, num configurations %d, configuration value %d\n",
-               __func__, le16_to_cpu(dev->descriptor.idProduct),
-               dev->descriptor.bNumConfigurations,
-               dev->actconfig->desc.bConfigurationValue);
-
-       /* create device structure */
-       mxdev = kzalloc(sizeof(struct mxu1_device), GFP_KERNEL);
-       if (!mxdev)
-               return -ENOMEM;
-
-       usb_set_serial_data(serial, mxdev);
-
-       mxdev->mxd_model = le16_to_cpu(dev->descriptor.idProduct);
-
-       cur_altsetting = serial->interface->cur_altsetting;
-
-       /* if we have only 1 configuration, download firmware */
-       if (cur_altsetting->desc.bNumEndpoints == 1) {
-
-               snprintf(fw_name,
-                        sizeof(fw_name),
-                        "moxa/moxa-%04x.fw",
-                        mxdev->mxd_model);
-
-               err = request_firmware(&fw_p, fw_name, &serial->interface->dev);
-               if (err) {
-                       dev_err(&serial->interface->dev, "failed to request firmware: %d\n",
-                               err);
-                       goto err_free_mxdev;
-               }
-
-               err = mxu1_download_firmware(serial, fw_p);
-               if (err)
-                       goto err_release_firmware;
-
-               /* device is being reset */
-               err = -ENODEV;
-               goto err_release_firmware;
-       }
-
-       return 0;
-
-err_release_firmware:
-       release_firmware(fw_p);
-err_free_mxdev:
-       kfree(mxdev);
-
-       return err;
-}
-
-static void mxu1_release(struct usb_serial *serial)
-{
-       struct mxu1_device *mxdev;
-
-       mxdev = usb_get_serial_data(serial);
-       kfree(mxdev);
-}
-
-static int mxu1_write_byte(struct usb_serial_port *port, u32 addr,
-                          u8 mask, u8 byte)
-{
-       int status;
-       size_t size;
-       struct mxu1_write_data_bytes *data;
-
-       dev_dbg(&port->dev, "%s - addr 0x%08X, mask 0x%02X, byte 0x%02X\n",
-               __func__, addr, mask, byte);
-
-       size = sizeof(struct mxu1_write_data_bytes) + 2;
-       data = kzalloc(size, GFP_KERNEL);
-       if (!data)
-               return -ENOMEM;
-
-       data->bAddrType = MXU1_RW_DATA_ADDR_XDATA;
-       data->bDataType = MXU1_RW_DATA_BYTE;
-       data->bDataCounter = 1;
-       data->wBaseAddrHi = cpu_to_be16(addr >> 16);
-       data->wBaseAddrLo = cpu_to_be16(addr);
-       data->bData[0] = mask;
-       data->bData[1] = byte;
-
-       status = mxu1_send_ctrl_data_urb(port->serial, MXU1_WRITE_DATA, 0,
-                                        MXU1_RAM_PORT, data, size);
-       if (status < 0)
-               dev_err(&port->dev, "%s - failed: %d\n", __func__, status);
-
-       kfree(data);
-
-       return status;
-}
-
-static int mxu1_set_mcr(struct usb_serial_port *port, unsigned int mcr)
-{
-       int status;
-
-       status = mxu1_write_byte(port,
-                                MXU1_UART_BASE_ADDR + MXU1_UART_OFFSET_MCR,
-                                MXU1_MCR_RTS | MXU1_MCR_DTR | MXU1_MCR_LOOP,
-                                mcr);
-       return status;
-}
-
-static void mxu1_set_termios(struct tty_struct *tty,
-                            struct usb_serial_port *port,
-                            struct ktermios *old_termios)
-{
-       struct mxu1_port *mxport = usb_get_serial_port_data(port);
-       struct mxu1_uart_config *config;
-       tcflag_t cflag, iflag;
-       speed_t baud;
-       int status;
-       unsigned int mcr;
-
-       cflag = tty->termios.c_cflag;
-       iflag = tty->termios.c_iflag;
-
-       if (old_termios &&
-           !tty_termios_hw_change(&tty->termios, old_termios) &&
-           tty->termios.c_iflag == old_termios->c_iflag) {
-               dev_dbg(&port->dev, "%s - nothing to change\n", __func__);
-               return;
-       }
-
-       dev_dbg(&port->dev,
-               "%s - cflag 0x%08x, iflag 0x%08x\n", __func__, cflag, iflag);
-
-       if (old_termios) {
-               dev_dbg(&port->dev, "%s - old cflag 0x%08x, old iflag 0x%08x\n",
-                       __func__,
-                       old_termios->c_cflag,
-                       old_termios->c_iflag);
-       }
-
-       config = kzalloc(sizeof(*config), GFP_KERNEL);
-       if (!config)
-               return;
-
-       /* these flags must be set */
-       config->wFlags |= MXU1_UART_ENABLE_MS_INTS;
-       config->wFlags |= MXU1_UART_ENABLE_AUTO_START_DMA;
-       if (mxport->send_break)
-               config->wFlags |= MXU1_UART_SEND_BREAK_SIGNAL;
-       config->bUartMode = mxport->uart_mode;
-
-       switch (C_CSIZE(tty)) {
-       case CS5:
-               config->bDataBits = MXU1_UART_5_DATA_BITS;
-               break;
-       case CS6:
-               config->bDataBits = MXU1_UART_6_DATA_BITS;
-               break;
-       case CS7:
-               config->bDataBits = MXU1_UART_7_DATA_BITS;
-               break;
-       default:
-       case CS8:
-               config->bDataBits = MXU1_UART_8_DATA_BITS;
-               break;
-       }
-
-       if (C_PARENB(tty)) {
-               config->wFlags |= MXU1_UART_ENABLE_PARITY_CHECKING;
-               if (C_CMSPAR(tty)) {
-                       if (C_PARODD(tty))
-                               config->bParity = MXU1_UART_MARK_PARITY;
-                       else
-                               config->bParity = MXU1_UART_SPACE_PARITY;
-               } else {
-                       if (C_PARODD(tty))
-                               config->bParity = MXU1_UART_ODD_PARITY;
-                       else
-                               config->bParity = MXU1_UART_EVEN_PARITY;
-               }
-       } else {
-               config->bParity = MXU1_UART_NO_PARITY;
-       }
-
-       if (C_CSTOPB(tty))
-               config->bStopBits = MXU1_UART_2_STOP_BITS;
-       else
-               config->bStopBits = MXU1_UART_1_STOP_BITS;
-
-       if (C_CRTSCTS(tty)) {
-               /* RTS flow control must be off to drop RTS for baud rate B0 */
-               if (C_BAUD(tty) != B0)
-                       config->wFlags |= MXU1_UART_ENABLE_RTS_IN;
-               config->wFlags |= MXU1_UART_ENABLE_CTS_OUT;
-       }
-
-       if (I_IXOFF(tty) || I_IXON(tty)) {
-               config->cXon  = START_CHAR(tty);
-               config->cXoff = STOP_CHAR(tty);
-
-               if (I_IXOFF(tty))
-                       config->wFlags |= MXU1_UART_ENABLE_X_IN;
-
-               if (I_IXON(tty))
-                       config->wFlags |= MXU1_UART_ENABLE_X_OUT;
-       }
-
-       baud = tty_get_baud_rate(tty);
-       if (!baud)
-               baud = 9600;
-       config->wBaudRate = MXU1_BAUD_BASE / baud;
-
-       dev_dbg(&port->dev, "%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d\n",
-               __func__, baud, config->wBaudRate, config->wFlags,
-               config->bDataBits, config->bParity, config->bStopBits,
-               config->cXon, config->cXoff, config->bUartMode);
-
-       cpu_to_be16s(&config->wBaudRate);
-       cpu_to_be16s(&config->wFlags);
-
-       status = mxu1_send_ctrl_data_urb(port->serial, MXU1_SET_CONFIG, 0,
-                                        MXU1_UART1_PORT, config,
-                                        sizeof(*config));
-       if (status)
-               dev_err(&port->dev, "cannot set config: %d\n", status);
-
-       mutex_lock(&mxport->mutex);
-       mcr = mxport->mcr;
-
-       if (C_BAUD(tty) == B0)
-               mcr &= ~(MXU1_MCR_DTR | MXU1_MCR_RTS);
-       else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
-               mcr |= MXU1_MCR_DTR | MXU1_MCR_RTS;
-
-       status = mxu1_set_mcr(port, mcr);
-       if (status)
-               dev_err(&port->dev, "cannot set modem control: %d\n", status);
-       else
-               mxport->mcr = mcr;
-
-       mutex_unlock(&mxport->mutex);
-
-       kfree(config);
-}
-
-static int mxu1_get_serial_info(struct usb_serial_port *port,
-                               struct serial_struct __user *ret_arg)
-{
-       struct serial_struct ret_serial;
-       unsigned cwait;
-
-       if (!ret_arg)
-               return -EFAULT;
-
-       cwait = port->port.closing_wait;
-       if (cwait != ASYNC_CLOSING_WAIT_NONE)
-               cwait = jiffies_to_msecs(cwait) / 10;
-
-       memset(&ret_serial, 0, sizeof(ret_serial));
-
-       ret_serial.type = PORT_16550A;
-       ret_serial.line = port->minor;
-       ret_serial.port = 0;
-       ret_serial.xmit_fifo_size = port->bulk_out_size;
-       ret_serial.baud_base = MXU1_BAUD_BASE;
-       ret_serial.close_delay = 5*HZ;
-       ret_serial.closing_wait = cwait;
-
-       if (copy_to_user(ret_arg, &ret_serial, sizeof(*ret_arg)))
-               return -EFAULT;
-
-       return 0;
-}
-
-
-static int mxu1_set_serial_info(struct usb_serial_port *port,
-                               struct serial_struct __user *new_arg)
-{
-       struct serial_struct new_serial;
-       unsigned cwait;
-
-       if (copy_from_user(&new_serial, new_arg, sizeof(new_serial)))
-               return -EFAULT;
-
-       cwait = new_serial.closing_wait;
-       if (cwait != ASYNC_CLOSING_WAIT_NONE)
-               cwait = msecs_to_jiffies(10 * new_serial.closing_wait);
-
-       port->port.closing_wait = cwait;
-
-       return 0;
-}
-
-static int mxu1_ioctl(struct tty_struct *tty,
-                     unsigned int cmd, unsigned long arg)
-{
-       struct usb_serial_port *port = tty->driver_data;
-
-       switch (cmd) {
-       case TIOCGSERIAL:
-               return mxu1_get_serial_info(port,
-                                           (struct serial_struct __user *)arg);
-       case TIOCSSERIAL:
-               return mxu1_set_serial_info(port,
-                                           (struct serial_struct __user *)arg);
-       }
-
-       return -ENOIOCTLCMD;
-}
-
-static int mxu1_tiocmget(struct tty_struct *tty)
-{
-       struct usb_serial_port *port = tty->driver_data;
-       struct mxu1_port *mxport = usb_get_serial_port_data(port);
-       unsigned int result;
-       unsigned int msr;
-       unsigned int mcr;
-       unsigned long flags;
-
-       mutex_lock(&mxport->mutex);
-       spin_lock_irqsave(&mxport->spinlock, flags);
-
-       msr = mxport->msr;
-       mcr = mxport->mcr;
-
-       spin_unlock_irqrestore(&mxport->spinlock, flags);
-       mutex_unlock(&mxport->mutex);
-
-       result = ((mcr & MXU1_MCR_DTR)  ? TIOCM_DTR     : 0) |
-                ((mcr & MXU1_MCR_RTS)  ? TIOCM_RTS     : 0) |
-                ((mcr & MXU1_MCR_LOOP) ? TIOCM_LOOP    : 0) |
-                ((msr & MXU1_MSR_CTS)  ? TIOCM_CTS     : 0) |
-                ((msr & MXU1_MSR_CD)   ? TIOCM_CAR     : 0) |
-                ((msr & MXU1_MSR_RI)   ? TIOCM_RI      : 0) |
-                ((msr & MXU1_MSR_DSR)  ? TIOCM_DSR     : 0);
-
-       dev_dbg(&port->dev, "%s - 0x%04X\n", __func__, result);
-
-       return result;
-}
-
-static int mxu1_tiocmset(struct tty_struct *tty,
-                        unsigned int set, unsigned int clear)
-{
-       struct usb_serial_port *port = tty->driver_data;
-       struct mxu1_port *mxport = usb_get_serial_port_data(port);
-       int err;
-       unsigned int mcr;
-
-       mutex_lock(&mxport->mutex);
-       mcr = mxport->mcr;
-
-       if (set & TIOCM_RTS)
-               mcr |= MXU1_MCR_RTS;
-       if (set & TIOCM_DTR)
-               mcr |= MXU1_MCR_DTR;
-       if (set & TIOCM_LOOP)
-               mcr |= MXU1_MCR_LOOP;
-
-       if (clear & TIOCM_RTS)
-               mcr &= ~MXU1_MCR_RTS;
-       if (clear & TIOCM_DTR)
-               mcr &= ~MXU1_MCR_DTR;
-       if (clear & TIOCM_LOOP)
-               mcr &= ~MXU1_MCR_LOOP;
-
-       err = mxu1_set_mcr(port, mcr);
-       if (!err)
-               mxport->mcr = mcr;
-
-       mutex_unlock(&mxport->mutex);
-
-       return err;
-}
-
-static void mxu1_break(struct tty_struct *tty, int break_state)
-{
-       struct usb_serial_port *port = tty->driver_data;
-       struct mxu1_port *mxport = usb_get_serial_port_data(port);
-
-       if (break_state == -1)
-               mxport->send_break = true;
-       else
-               mxport->send_break = false;
-
-       mxu1_set_termios(tty, port, NULL);
-}
-
-static int mxu1_open(struct tty_struct *tty, struct usb_serial_port *port)
-{
-       struct mxu1_port *mxport = usb_get_serial_port_data(port);
-       struct usb_serial *serial = port->serial;
-       int status;
-       u16 open_settings;
-
-       open_settings = (MXU1_PIPE_MODE_CONTINUOUS |
-                        MXU1_PIPE_TIMEOUT_ENABLE |
-                        (MXU1_TRANSFER_TIMEOUT << 2));
-
-       mxport->msr = 0;
-
-       status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
-       if (status) {
-               dev_err(&port->dev, "failed to submit interrupt urb: %d\n",
-                       status);
-               return status;
-       }
-
-       if (tty)
-               mxu1_set_termios(tty, port, NULL);
-
-       status = mxu1_send_ctrl_urb(serial, MXU1_OPEN_PORT,
-                                   open_settings, MXU1_UART1_PORT);
-       if (status) {
-               dev_err(&port->dev, "cannot send open command: %d\n", status);
-               goto unlink_int_urb;
-       }
-
-       status = mxu1_send_ctrl_urb(serial, MXU1_START_PORT,
-                                   0, MXU1_UART1_PORT);
-       if (status) {
-               dev_err(&port->dev, "cannot send start command: %d\n", status);
-               goto unlink_int_urb;
-       }
-
-       status = mxu1_send_ctrl_urb(serial, MXU1_PURGE_PORT,
-                                   MXU1_PURGE_INPUT, MXU1_UART1_PORT);
-       if (status) {
-               dev_err(&port->dev, "cannot clear input buffers: %d\n",
-                       status);
-
-               goto unlink_int_urb;
-       }
-
-       status = mxu1_send_ctrl_urb(serial, MXU1_PURGE_PORT,
-                                   MXU1_PURGE_OUTPUT, MXU1_UART1_PORT);
-       if (status) {
-               dev_err(&port->dev, "cannot clear output buffers: %d\n",
-                       status);
-
-               goto unlink_int_urb;
-       }
-
-       /*
-        * reset the data toggle on the bulk endpoints to work around bug in
-        * host controllers where things get out of sync some times
-        */
-       usb_clear_halt(serial->dev, port->write_urb->pipe);
-       usb_clear_halt(serial->dev, port->read_urb->pipe);
-
-       if (tty)
-               mxu1_set_termios(tty, port, NULL);
-
-       status = mxu1_send_ctrl_urb(serial, MXU1_OPEN_PORT,
-                                   open_settings, MXU1_UART1_PORT);
-       if (status) {
-               dev_err(&port->dev, "cannot send open command: %d\n", status);
-               goto unlink_int_urb;
-       }
-
-       status = mxu1_send_ctrl_urb(serial, MXU1_START_PORT,
-                                   0, MXU1_UART1_PORT);
-       if (status) {
-               dev_err(&port->dev, "cannot send start command: %d\n", status);
-               goto unlink_int_urb;
-       }
-
-       status = usb_serial_generic_open(tty, port);
-       if (status)
-               goto unlink_int_urb;
-
-       return 0;
-
-unlink_int_urb:
-       usb_kill_urb(port->interrupt_in_urb);
-
-       return status;
-}
-
-static void mxu1_close(struct usb_serial_port *port)
-{
-       int status;
-
-       usb_serial_generic_close(port);
-       usb_kill_urb(port->interrupt_in_urb);
-
-       status = mxu1_send_ctrl_urb(port->serial, MXU1_CLOSE_PORT,
-                                   0, MXU1_UART1_PORT);
-       if (status) {
-               dev_err(&port->dev, "failed to send close port command: %d\n",
-                       status);
-       }
-}
-
-static void mxu1_handle_new_msr(struct usb_serial_port *port, u8 msr)
-{
-       struct mxu1_port *mxport = usb_get_serial_port_data(port);
-       struct async_icount *icount;
-       unsigned long flags;
-
-       dev_dbg(&port->dev, "%s - msr 0x%02X\n", __func__, msr);
-
-       spin_lock_irqsave(&mxport->spinlock, flags);
-       mxport->msr = msr & MXU1_MSR_MASK;
-       spin_unlock_irqrestore(&mxport->spinlock, flags);
-
-       if (msr & MXU1_MSR_DELTA_MASK) {
-               icount = &port->icount;
-               if (msr & MXU1_MSR_DELTA_CTS)
-                       icount->cts++;
-               if (msr & MXU1_MSR_DELTA_DSR)
-                       icount->dsr++;
-               if (msr & MXU1_MSR_DELTA_CD)
-                       icount->dcd++;
-               if (msr & MXU1_MSR_DELTA_RI)
-                       icount->rng++;
-
-               wake_up_interruptible(&port->port.delta_msr_wait);
-       }
-}
-
-static void mxu1_interrupt_callback(struct urb *urb)
-{
-       struct usb_serial_port *port = urb->context;
-       unsigned char *data = urb->transfer_buffer;
-       int length = urb->actual_length;
-       int function;
-       int status;
-       u8 msr;
-
-       switch (urb->status) {
-       case 0:
-               break;
-       case -ECONNRESET:
-       case -ENOENT:
-       case -ESHUTDOWN:
-               dev_dbg(&port->dev, "%s - urb shutting down: %d\n",
-                       __func__, urb->status);
-               return;
-       default:
-               dev_dbg(&port->dev, "%s - nonzero urb status: %d\n",
-                       __func__, urb->status);
-               goto exit;
-       }
-
-       if (length != 2) {
-               dev_dbg(&port->dev, "%s - bad packet size: %d\n",
-                       __func__, length);
-               goto exit;
-       }
-
-       if (data[0] == MXU1_CODE_HARDWARE_ERROR) {
-               dev_err(&port->dev, "hardware error: %d\n", data[1]);
-               goto exit;
-       }
-
-       function = mxu1_get_func_from_code(data[0]);
-
-       dev_dbg(&port->dev, "%s - function %d, data 0x%02X\n",
-                __func__, function, data[1]);
-
-       switch (function) {
-       case MXU1_CODE_DATA_ERROR:
-               dev_dbg(&port->dev, "%s - DATA ERROR, data 0x%02X\n",
-                        __func__, data[1]);
-               break;
-
-       case MXU1_CODE_MODEM_STATUS:
-               msr = data[1];
-               mxu1_handle_new_msr(port, msr);
-               break;
-
-       default:
-               dev_err(&port->dev, "unknown interrupt code: 0x%02X\n",
-                       data[1]);
-               break;
-       }
-
-exit:
-       status = usb_submit_urb(urb, GFP_ATOMIC);
-       if (status) {
-               dev_err(&port->dev, "resubmit interrupt urb failed: %d\n",
-                       status);
-       }
-}
-
-static struct usb_serial_driver mxu11x0_device = {
-       .driver = {
-               .owner          = THIS_MODULE,
-               .name           = "mxu11x0",
-       },
-       .description            = "MOXA UPort 11x0",
-       .id_table               = mxu1_idtable,
-       .num_ports              = 1,
-       .port_probe             = mxu1_port_probe,
-       .port_remove            = mxu1_port_remove,
-       .attach                 = mxu1_startup,
-       .release                = mxu1_release,
-       .open                   = mxu1_open,
-       .close                  = mxu1_close,
-       .ioctl                  = mxu1_ioctl,
-       .set_termios            = mxu1_set_termios,
-       .tiocmget               = mxu1_tiocmget,
-       .tiocmset               = mxu1_tiocmset,
-       .tiocmiwait             = usb_serial_generic_tiocmiwait,
-       .get_icount             = usb_serial_generic_get_icount,
-       .break_ctl              = mxu1_break,
-       .read_int_callback      = mxu1_interrupt_callback,
-};
-
-static struct usb_serial_driver *const serial_drivers[] = {
-       &mxu11x0_device, NULL
-};
-
-module_usb_serial_driver(serial_drivers, mxu1_idtable);
-
-MODULE_AUTHOR("Mathieu Othacehe <m.othacehe@gmail.com>");
-MODULE_DESCRIPTION("MOXA UPort 11x0 USB to Serial Hub Driver");
-MODULE_LICENSE("GPL");
-MODULE_FIRMWARE("moxa/moxa-1110.fw");
-MODULE_FIRMWARE("moxa/moxa-1130.fw");
-MODULE_FIRMWARE("moxa/moxa-1131.fw");
-MODULE_FIRMWARE("moxa/moxa-1150.fw");
-MODULE_FIRMWARE("moxa/moxa-1151.fw");
index db86e51..348e198 100644 (file)
@@ -270,6 +270,7 @@ static void option_instat_callback(struct urb *urb);
 #define TELIT_PRODUCT_UE910_V2                 0x1012
 #define TELIT_PRODUCT_LE922_USBCFG0            0x1042
 #define TELIT_PRODUCT_LE922_USBCFG3            0x1043
+#define TELIT_PRODUCT_LE922_USBCFG5            0x1045
 #define TELIT_PRODUCT_LE920                    0x1200
 #define TELIT_PRODUCT_LE910                    0x1201
 
@@ -315,6 +316,7 @@ static void option_instat_callback(struct urb *urb);
 #define TOSHIBA_PRODUCT_G450                   0x0d45
 
 #define ALINK_VENDOR_ID                                0x1e0e
+#define SIMCOM_PRODUCT_SIM7100E                        0x9001 /* Yes, ALINK_VENDOR_ID */
 #define ALINK_PRODUCT_PH300                    0x9100
 #define ALINK_PRODUCT_3GU                      0x9200
 
@@ -607,6 +609,10 @@ static const struct option_blacklist_info zte_1255_blacklist = {
        .reserved = BIT(3) | BIT(4),
 };
 
+static const struct option_blacklist_info simcom_sim7100e_blacklist = {
+       .reserved = BIT(5) | BIT(6),
+};
+
 static const struct option_blacklist_info telit_le910_blacklist = {
        .sendsetup = BIT(0),
        .reserved = BIT(1) | BIT(2),
@@ -1122,9 +1128,13 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) },
        { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
        { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */
+       { USB_DEVICE_AND_INTERFACE_INFO(QUALCOMM_VENDOR_ID, 0x6001, 0xff, 0xff, 0xff), /* 4G LTE usb-modem U901 */
+         .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
        { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
        { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x0023)}, /* ONYX 3G device */
        { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9000)}, /* SIMCom SIM5218 */
+       { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x9003), /* Quectel UC20 */
+         .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
        { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6001) },
        { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_CMU_300) },
        { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6003),
@@ -1176,6 +1186,8 @@ static const struct usb_device_id option_ids[] = {
                .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG3),
                .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 },
+       { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG5, 0xff),
+               .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
                .driver_info = (kernel_ulong_t)&telit_le910_blacklist },
        { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
@@ -1645,6 +1657,8 @@ static const struct usb_device_id option_ids[] = {
        { USB_DEVICE(ALINK_VENDOR_ID, 0x9000) },
        { USB_DEVICE(ALINK_VENDOR_ID, ALINK_PRODUCT_PH300) },
        { USB_DEVICE_AND_INTERFACE_INFO(ALINK_VENDOR_ID, ALINK_PRODUCT_3GU, 0xff, 0xff, 0xff) },
+       { USB_DEVICE(ALINK_VENDOR_ID, SIMCOM_PRODUCT_SIM7100E),
+         .driver_info = (kernel_ulong_t)&simcom_sim7100e_blacklist },
        { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200),
          .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist
        },
index 9919d2a..1bc6089 100644 (file)
@@ -157,14 +157,17 @@ static const struct usb_device_id id_table[] = {
        {DEVICE_SWI(0x1199, 0x9056)},   /* Sierra Wireless Modem */
        {DEVICE_SWI(0x1199, 0x9060)},   /* Sierra Wireless Modem */
        {DEVICE_SWI(0x1199, 0x9061)},   /* Sierra Wireless Modem */
-       {DEVICE_SWI(0x1199, 0x9070)},   /* Sierra Wireless MC74xx/EM74xx */
-       {DEVICE_SWI(0x1199, 0x9071)},   /* Sierra Wireless MC74xx/EM74xx */
+       {DEVICE_SWI(0x1199, 0x9070)},   /* Sierra Wireless MC74xx */
+       {DEVICE_SWI(0x1199, 0x9071)},   /* Sierra Wireless MC74xx */
+       {DEVICE_SWI(0x1199, 0x9078)},   /* Sierra Wireless EM74xx */
+       {DEVICE_SWI(0x1199, 0x9079)},   /* Sierra Wireless EM74xx */
        {DEVICE_SWI(0x413c, 0x81a2)},   /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */
        {DEVICE_SWI(0x413c, 0x81a3)},   /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */
        {DEVICE_SWI(0x413c, 0x81a4)},   /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */
        {DEVICE_SWI(0x413c, 0x81a8)},   /* Dell Wireless 5808 Gobi(TM) 4G LTE Mobile Broadband Card */
        {DEVICE_SWI(0x413c, 0x81a9)},   /* Dell Wireless 5808e Gobi(TM) 4G LTE Mobile Broadband Card */
        {DEVICE_SWI(0x413c, 0x81b1)},   /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card */
+       {DEVICE_SWI(0x413c, 0x81b3)},   /* Dell Wireless 5809e Gobi(TM) 4G LTE Mobile Broadband Card (rev3) */
 
        /* Huawei devices */
        {DEVICE_HWI(0x03f0, 0x581d)},   /* HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e) */
index 2760a7b..8c80a48 100644 (file)
@@ -446,7 +446,8 @@ static long vfio_pci_ioctl(void *device_data,
                info.num_regions = VFIO_PCI_NUM_REGIONS;
                info.num_irqs = VFIO_PCI_NUM_IRQS;
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               return copy_to_user((void __user *)arg, &info, minsz) ?
+                       -EFAULT : 0;
 
        } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) {
                struct pci_dev *pdev = vdev->pdev;
@@ -520,7 +521,8 @@ static long vfio_pci_ioctl(void *device_data,
                        return -EINVAL;
                }
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               return copy_to_user((void __user *)arg, &info, minsz) ?
+                       -EFAULT : 0;
 
        } else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) {
                struct vfio_irq_info info;
@@ -555,7 +557,8 @@ static long vfio_pci_ioctl(void *device_data,
                else
                        info.flags |= VFIO_IRQ_INFO_NORESIZE;
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               return copy_to_user((void __user *)arg, &info, minsz) ?
+                       -EFAULT : 0;
 
        } else if (cmd == VFIO_DEVICE_SET_IRQS) {
                struct vfio_irq_set hdr;
index 418cdd9..e65b142 100644 (file)
@@ -219,7 +219,8 @@ static long vfio_platform_ioctl(void *device_data,
                info.num_regions = vdev->num_regions;
                info.num_irqs = vdev->num_irqs;
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               return copy_to_user((void __user *)arg, &info, minsz) ?
+                       -EFAULT : 0;
 
        } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) {
                struct vfio_region_info info;
@@ -240,7 +241,8 @@ static long vfio_platform_ioctl(void *device_data,
                info.size = vdev->regions[info.index].size;
                info.flags = vdev->regions[info.index].flags;
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               return copy_to_user((void __user *)arg, &info, minsz) ?
+                       -EFAULT : 0;
 
        } else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) {
                struct vfio_irq_info info;
@@ -259,7 +261,8 @@ static long vfio_platform_ioctl(void *device_data,
                info.flags = vdev->irqs[info.index].flags;
                info.count = vdev->irqs[info.index].count;
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               return copy_to_user((void __user *)arg, &info, minsz) ?
+                       -EFAULT : 0;
 
        } else if (cmd == VFIO_DEVICE_SET_IRQS) {
                struct vfio_irq_set hdr;
index 6f1ea3d..75b24e9 100644 (file)
@@ -999,7 +999,8 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
 
                info.iova_pgsizes = vfio_pgsize_bitmap(iommu);
 
-               return copy_to_user((void __user *)arg, &info, minsz);
+               return copy_to_user((void __user *)arg, &info, minsz) ?
+                       -EFAULT : 0;
 
        } else if (cmd == VFIO_IOMMU_MAP_DMA) {
                struct vfio_iommu_type1_dma_map map;
@@ -1032,7 +1033,8 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
                if (ret)
                        return ret;
 
-               return copy_to_user((void __user *)arg, &unmap, minsz);
+               return copy_to_user((void __user *)arg, &unmap, minsz) ?
+                       -EFAULT : 0;
        }
 
        return -ENOTTY;
index ad2146a..236553e 100644 (file)
@@ -1156,6 +1156,8 @@ int vhost_init_used(struct vhost_virtqueue *vq)
 {
        __virtio16 last_used_idx;
        int r;
+       bool is_le = vq->is_le;
+
        if (!vq->private_data) {
                vq->is_le = virtio_legacy_is_little_endian();
                return 0;
@@ -1165,15 +1167,20 @@ int vhost_init_used(struct vhost_virtqueue *vq)
 
        r = vhost_update_used_flags(vq);
        if (r)
-               return r;
+               goto err;
        vq->signalled_used_valid = false;
-       if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx))
-               return -EFAULT;
+       if (!access_ok(VERIFY_READ, &vq->used->idx, sizeof vq->used->idx)) {
+               r = -EFAULT;
+               goto err;
+       }
        r = __get_user(last_used_idx, &vq->used->idx);
        if (r)
-               return r;
+               goto err;
        vq->last_used_idx = vhost16_to_cpu(vq, last_used_idx);
        return 0;
+err:
+       vq->is_le = is_le;
+       return r;
 }
 EXPORT_SYMBOL_GPL(vhost_init_used);
 
index 92f3949..6e92917 100644 (file)
@@ -709,6 +709,7 @@ static int con2fb_acquire_newinfo(struct vc_data *vc, struct fb_info *info,
        }
 
        if (!err) {
+               ops->cur_blink_jiffies = HZ / 5;
                info->fbcon_par = ops;
 
                if (vc)
@@ -956,6 +957,7 @@ static const char *fbcon_startup(void)
        ops->currcon = -1;
        ops->graphics = 1;
        ops->cur_rotate = -1;
+       ops->cur_blink_jiffies = HZ / 5;
        info->fbcon_par = ops;
        p->con_rotate = initial_rotation;
        set_blitting_type(vc, info);
index 0081725..6b2a06d 100644 (file)
@@ -152,7 +152,7 @@ static void lcdc_write(unsigned int val, unsigned int addr)
 
 struct da8xx_fb_par {
        struct device           *dev;
-       resource_size_t p_palette_base;
+       dma_addr_t              p_palette_base;
        unsigned char *v_palette_base;
        dma_addr_t              vram_phys;
        unsigned long           vram_size;
@@ -1428,7 +1428,7 @@ static int fb_probe(struct platform_device *device)
 
        par->vram_virt = dma_alloc_coherent(NULL,
                                            par->vram_size,
-                                           (resource_size_t *) &par->vram_phys,
+                                           &par->vram_phys,
                                            GFP_KERNEL | GFP_DMA);
        if (!par->vram_virt) {
                dev_err(&device->dev,
@@ -1448,7 +1448,7 @@ static int fb_probe(struct platform_device *device)
 
        /* allocate palette buffer */
        par->v_palette_base = dma_zalloc_coherent(NULL, PALETTE_SIZE,
-                                                 (resource_size_t *)&par->p_palette_base,
+                                                 &par->p_palette_base,
                                                  GFP_KERNEL | GFP_DMA);
        if (!par->v_palette_base) {
                dev_err(&device->dev,
index 95873f2..de2f3e7 100644 (file)
@@ -829,8 +829,7 @@ static int s6e8ax0_probe(struct mipi_dsim_lcd_device *dsim_dev)
        return 0;
 }
 
-#ifdef CONFIG_PM
-static int s6e8ax0_suspend(struct mipi_dsim_lcd_device *dsim_dev)
+static int __maybe_unused s6e8ax0_suspend(struct mipi_dsim_lcd_device *dsim_dev)
 {
        struct s6e8ax0 *lcd = dev_get_drvdata(&dsim_dev->dev);
 
@@ -843,7 +842,7 @@ static int s6e8ax0_suspend(struct mipi_dsim_lcd_device *dsim_dev)
        return 0;
 }
 
-static int s6e8ax0_resume(struct mipi_dsim_lcd_device *dsim_dev)
+static int __maybe_unused s6e8ax0_resume(struct mipi_dsim_lcd_device *dsim_dev)
 {
        struct s6e8ax0 *lcd = dev_get_drvdata(&dsim_dev->dev);
 
@@ -855,10 +854,6 @@ static int s6e8ax0_resume(struct mipi_dsim_lcd_device *dsim_dev)
 
        return 0;
 }
-#else
-#define s6e8ax0_suspend                NULL
-#define s6e8ax0_resume         NULL
-#endif
 
 static struct mipi_dsim_lcd_driver s6e8ax0_dsim_ddi_driver = {
        .name = "s6e8ax0",
@@ -867,8 +862,8 @@ static struct mipi_dsim_lcd_driver s6e8ax0_dsim_ddi_driver = {
        .power_on = s6e8ax0_power_on,
        .set_sequence = s6e8ax0_set_sequence,
        .probe = s6e8ax0_probe,
-       .suspend = s6e8ax0_suspend,
-       .resume = s6e8ax0_resume,
+       .suspend = IS_ENABLED(CONFIG_PM) ? s6e8ax0_suspend : NULL,
+       .resume = IS_ENABLED(CONFIG_PM) ? s6e8ax0_resume : NULL,
 };
 
 static int s6e8ax0_init(void)
index cee8860..bb2f1e8 100644 (file)
@@ -902,6 +902,21 @@ static int imxfb_probe(struct platform_device *pdev)
                goto failed_getclock;
        }
 
+       /*
+        * The LCDC controller does not have an enable bit. The
+        * controller starts directly when the clocks are enabled.
+        * If the clocks are enabled when the controller is not yet
+        * programmed with proper register values (enabled at the
+        * bootloader, for example) then it just goes into some undefined
+        * state.
+        * To avoid this issue, let's enable and disable LCDC IPG clock
+        * so that we force some kind of 'reset' to the LCDC block.
+        */
+       ret = clk_prepare_enable(fbi->clk_ipg);
+       if (ret)
+               goto failed_getclock;
+       clk_disable_unprepare(fbi->clk_ipg);
+
        fbi->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
        if (IS_ERR(fbi->clk_ahb)) {
                ret = PTR_ERR(fbi->clk_ahb);
index de54a47..b6f83d5 100644 (file)
@@ -503,8 +503,7 @@ static int mmphw_probe(struct platform_device *pdev)
        ctrl->reg_base = devm_ioremap_nocache(ctrl->dev,
                        res->start, resource_size(res));
        if (ctrl->reg_base == NULL) {
-               dev_err(ctrl->dev, "%s: res %x - %x map failed\n", __func__,
-                       res->start, res->end);
+               dev_err(ctrl->dev, "%s: res %pR map failed\n", __func__, res);
                ret = -ENOMEM;
                goto failed;
        }
index c9293ae..a970edc 100644 (file)
@@ -123,11 +123,11 @@ static int ocfb_setupfb(struct ocfb_dev *fbdev)
 
        /* Horizontal timings */
        ocfb_writereg(fbdev, OCFB_HTIM, (var->hsync_len - 1) << 24 |
-                     (var->right_margin - 1) << 16 | (var->xres - 1));
+                     (var->left_margin - 1) << 16 | (var->xres - 1));
 
        /* Vertical timings */
        ocfb_writereg(fbdev, OCFB_VTIM, (var->vsync_len - 1) << 24 |
-                     (var->lower_margin - 1) << 16 | (var->yres - 1));
+                     (var->upper_margin - 1) << 16 | (var->yres - 1));
 
        /* Total length of frame */
        hlen = var->left_margin + var->right_margin + var->hsync_len +
index 4837442..e014d04 100644 (file)
@@ -915,4 +915,5 @@ static inline u16 DISPC_MFLAG_THRESHOLD_OFFSET(enum omap_plane plane)
                return 0;
        }
 }
+
 #endif
index b9066af..0184a84 100644 (file)
@@ -412,6 +412,44 @@ void dispc_wb_set_channel_in(enum dss_writeback_channel channel);
 int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
                bool mem_to_mem, const struct omap_video_timings *timings);
 
+u32 dispc_read_irqstatus(void);
+void dispc_clear_irqstatus(u32 mask);
+u32 dispc_read_irqenable(void);
+void dispc_write_irqenable(u32 mask);
+
+int dispc_request_irq(irq_handler_t handler, void *dev_id);
+void dispc_free_irq(void *dev_id);
+
+int dispc_runtime_get(void);
+void dispc_runtime_put(void);
+
+void dispc_mgr_enable(enum omap_channel channel, bool enable);
+bool dispc_mgr_is_enabled(enum omap_channel channel);
+u32 dispc_mgr_get_vsync_irq(enum omap_channel channel);
+u32 dispc_mgr_get_framedone_irq(enum omap_channel channel);
+u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel);
+bool dispc_mgr_go_busy(enum omap_channel channel);
+void dispc_mgr_go(enum omap_channel channel);
+void dispc_mgr_set_lcd_config(enum omap_channel channel,
+               const struct dss_lcd_mgr_config *config);
+void dispc_mgr_set_timings(enum omap_channel channel,
+               const struct omap_video_timings *timings);
+void dispc_mgr_setup(enum omap_channel channel,
+               const struct omap_overlay_manager_info *info);
+
+int dispc_ovl_check(enum omap_plane plane, enum omap_channel channel,
+               const struct omap_overlay_info *oi,
+               const struct omap_video_timings *timings,
+               int *x_predecim, int *y_predecim);
+
+int dispc_ovl_enable(enum omap_plane plane, bool enable);
+bool dispc_ovl_enabled(enum omap_plane plane);
+void dispc_ovl_set_channel_out(enum omap_plane plane,
+               enum omap_channel channel);
+int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
+               bool replication, const struct omap_video_timings *mgr_timings,
+               bool mem_to_mem);
+
 /* VENC */
 int venc_init_platform_driver(void) __init;
 void venc_uninit_platform_driver(void);
@@ -465,4 +503,44 @@ int dss_pll_write_config_type_b(struct dss_pll *pll,
                const struct dss_pll_clock_info *cinfo);
 int dss_pll_wait_reset_done(struct dss_pll *pll);
 
+/* compat */
+
+struct dss_mgr_ops {
+       int (*connect)(struct omap_overlay_manager *mgr,
+               struct omap_dss_device *dst);
+       void (*disconnect)(struct omap_overlay_manager *mgr,
+               struct omap_dss_device *dst);
+
+       void (*start_update)(struct omap_overlay_manager *mgr);
+       int (*enable)(struct omap_overlay_manager *mgr);
+       void (*disable)(struct omap_overlay_manager *mgr);
+       void (*set_timings)(struct omap_overlay_manager *mgr,
+                       const struct omap_video_timings *timings);
+       void (*set_lcd_config)(struct omap_overlay_manager *mgr,
+                       const struct dss_lcd_mgr_config *config);
+       int (*register_framedone_handler)(struct omap_overlay_manager *mgr,
+                       void (*handler)(void *), void *data);
+       void (*unregister_framedone_handler)(struct omap_overlay_manager *mgr,
+                       void (*handler)(void *), void *data);
+};
+
+int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops);
+void dss_uninstall_mgr_ops(void);
+
+int dss_mgr_connect(struct omap_overlay_manager *mgr,
+               struct omap_dss_device *dst);
+void dss_mgr_disconnect(struct omap_overlay_manager *mgr,
+               struct omap_dss_device *dst);
+void dss_mgr_set_timings(struct omap_overlay_manager *mgr,
+               const struct omap_video_timings *timings);
+void dss_mgr_set_lcd_config(struct omap_overlay_manager *mgr,
+               const struct dss_lcd_mgr_config *config);
+int dss_mgr_enable(struct omap_overlay_manager *mgr);
+void dss_mgr_disable(struct omap_overlay_manager *mgr);
+void dss_mgr_start_update(struct omap_overlay_manager *mgr);
+int dss_mgr_register_framedone_handler(struct omap_overlay_manager *mgr,
+               void (*handler)(void *), void *data);
+void dss_mgr_unregister_framedone_handler(struct omap_overlay_manager *mgr,
+               void (*handler)(void *), void *data);
+
 #endif
index c0c11fa..7760fc1 100644 (file)
@@ -679,7 +679,7 @@ int virtio_pci_modern_probe(struct virtio_pci_device *vp_dev)
 
        pci_read_config_dword(pci_dev,
                              notify + offsetof(struct virtio_pci_notify_cap,
-                                               cap.length),
+                                               cap.offset),
                              &notify_offset);
 
        /* We don't know how many VQs we'll map, ahead of the time.
index 0f6d851..80825a7 100644 (file)
@@ -1569,6 +1569,17 @@ config WATCHDOG_RIO
          machines.  The watchdog timeout period is normally one minute but
          can be changed with a boot-time parameter.
 
+config WATCHDOG_SUN4V
+       tristate "Sun4v Watchdog support"
+       select WATCHDOG_CORE
+       depends on SPARC64
+       help
+         Say Y here to support the hypervisor watchdog capability embedded
+         in the SPARC sun4v architecture.
+
+         To compile this driver as a module, choose M here. The module will
+         be called sun4v_wdt.
+
 # XTENSA Architecture
 
 # Xen Architecture
index f566753..f6a6a38 100644 (file)
@@ -179,6 +179,7 @@ obj-$(CONFIG_SH_WDT) += shwdt.o
 
 obj-$(CONFIG_WATCHDOG_RIO)             += riowd.o
 obj-$(CONFIG_WATCHDOG_CP1XXX)          += cpwd.o
+obj-$(CONFIG_WATCHDOG_SUN4V)           += sun4v_wdt.o
 
 # XTENSA Architecture
 
diff --git a/drivers/watchdog/sun4v_wdt.c b/drivers/watchdog/sun4v_wdt.c
new file mode 100644 (file)
index 0000000..1467fe5
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ *     sun4v watchdog timer
+ *     (c) Copyright 2016 Oracle Corporation
+ *
+ *     Implement a simple watchdog driver using the built-in sun4v hypervisor
+ *     watchdog support. If time expires, the hypervisor stops or bounces
+ *     the guest domain.
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License
+ *     as published by the Free Software Foundation; either version
+ *     2 of the License, or (at your option) any later version.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/watchdog.h>
+#include <asm/hypervisor.h>
+#include <asm/mdesc.h>
+
+#define WDT_TIMEOUT                    60
+#define WDT_MAX_TIMEOUT                        31536000
+#define WDT_MIN_TIMEOUT                        1
+#define WDT_DEFAULT_RESOLUTION_MS      1000    /* 1 second */
+
+static unsigned int timeout;
+module_param(timeout, uint, 0);
+MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default="
+       __MODULE_STRING(WDT_TIMEOUT) ")");
+
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, S_IRUGO);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
+       __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+static int sun4v_wdt_stop(struct watchdog_device *wdd)
+{
+       sun4v_mach_set_watchdog(0, NULL);
+
+       return 0;
+}
+
+static int sun4v_wdt_ping(struct watchdog_device *wdd)
+{
+       int hverr;
+
+       /*
+        * HV watchdog timer will round up the timeout
+        * passed in to the nearest multiple of the
+        * watchdog resolution in milliseconds.
+        */
+       hverr = sun4v_mach_set_watchdog(wdd->timeout * 1000, NULL);
+       if (hverr == HV_EINVAL)
+               return -EINVAL;
+
+       return 0;
+}
+
+static int sun4v_wdt_set_timeout(struct watchdog_device *wdd,
+                                unsigned int timeout)
+{
+       wdd->timeout = timeout;
+
+       return 0;
+}
+
+static const struct watchdog_info sun4v_wdt_ident = {
+       .options =      WDIOF_SETTIMEOUT |
+                       WDIOF_MAGICCLOSE |
+                       WDIOF_KEEPALIVEPING,
+       .identity =     "sun4v hypervisor watchdog",
+       .firmware_version = 0,
+};
+
+static struct watchdog_ops sun4v_wdt_ops = {
+       .owner =        THIS_MODULE,
+       .start =        sun4v_wdt_ping,
+       .stop =         sun4v_wdt_stop,
+       .ping =         sun4v_wdt_ping,
+       .set_timeout =  sun4v_wdt_set_timeout,
+};
+
+static struct watchdog_device wdd = {
+       .info = &sun4v_wdt_ident,
+       .ops = &sun4v_wdt_ops,
+       .min_timeout = WDT_MIN_TIMEOUT,
+       .max_timeout = WDT_MAX_TIMEOUT,
+       .timeout = WDT_TIMEOUT,
+};
+
+static int __init sun4v_wdt_init(void)
+{
+       struct mdesc_handle *handle;
+       u64 node;
+       const u64 *value;
+       int err = 0;
+       unsigned long major = 1, minor = 1;
+
+       /*
+        * There are 2 properties that can be set from the control
+        * domain for the watchdog.
+        * watchdog-resolution
+        * watchdog-max-timeout
+        *
+        * We can expect a handle to be returned otherwise something
+        * serious is wrong. Correct to return -ENODEV here.
+        */
+
+       handle = mdesc_grab();
+       if (!handle)
+               return -ENODEV;
+
+       node = mdesc_node_by_name(handle, MDESC_NODE_NULL, "platform");
+       err = -ENODEV;
+       if (node == MDESC_NODE_NULL)
+               goto out_release;
+
+       /*
+        * This is a safe way to validate if we are on the right
+        * platform.
+        */
+       if (sun4v_hvapi_register(HV_GRP_CORE, major, &minor))
+               goto out_hv_unreg;
+
+       /* Allow value of watchdog-resolution up to 1s (default) */
+       value = mdesc_get_property(handle, node, "watchdog-resolution", NULL);
+       err = -EINVAL;
+       if (value) {
+               if (*value == 0 ||
+                   *value > WDT_DEFAULT_RESOLUTION_MS)
+                       goto out_hv_unreg;
+       }
+
+       value = mdesc_get_property(handle, node, "watchdog-max-timeout", NULL);
+       if (value) {
+               /*
+                * If the property value (in ms) is smaller than
+                * min_timeout, return -EINVAL.
+                */
+               if (*value < wdd.min_timeout * 1000)
+                       goto out_hv_unreg;
+
+               /*
+                * If the property value is smaller than
+                * default max_timeout  then set watchdog max_timeout to
+                * the value of the property in seconds.
+                */
+               if (*value < wdd.max_timeout * 1000)
+                       wdd.max_timeout = *value  / 1000;
+       }
+
+       watchdog_init_timeout(&wdd, timeout, NULL);
+
+       watchdog_set_nowayout(&wdd, nowayout);
+
+       err = watchdog_register_device(&wdd);
+       if (err)
+               goto out_hv_unreg;
+
+       pr_info("initialized (timeout=%ds, nowayout=%d)\n",
+                wdd.timeout, nowayout);
+
+       mdesc_release(handle);
+
+       return 0;
+
+out_hv_unreg:
+       sun4v_hvapi_unregister(HV_GRP_CORE);
+
+out_release:
+       mdesc_release(handle);
+       return err;
+}
+
+static void __exit sun4v_wdt_exit(void)
+{
+       sun4v_hvapi_unregister(HV_GRP_CORE);
+       watchdog_unregister_device(&wdd);
+}
+
+module_init(sun4v_wdt_init);
+module_exit(sun4v_wdt_exit);
+
+MODULE_AUTHOR("Wim Coekaerts <wim.coekaerts@oracle.com>");
+MODULE_DESCRIPTION("sun4v watchdog driver");
+MODULE_LICENSE("GPL");
index 73dafdc..fb02214 100644 (file)
@@ -227,8 +227,9 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
        /*
         * PCI_COMMAND_MEMORY must be enabled, otherwise we may not be able
         * to access the BARs where the MSI-X entries reside.
+        * But VF devices are unique in which the PF needs to be checked.
         */
-       pci_read_config_word(dev, PCI_COMMAND, &cmd);
+       pci_read_config_word(pci_physfn(dev), PCI_COMMAND, &cmd);
        if (dev->msi_enabled || !(cmd & PCI_COMMAND_MEMORY))
                return -ENXIO;
 
@@ -332,6 +333,9 @@ void xen_pcibk_do_op(struct work_struct *data)
        struct xen_pcibk_dev_data *dev_data = NULL;
        struct xen_pci_op *op = &pdev->op;
        int test_intx = 0;
+#ifdef CONFIG_PCI_MSI
+       unsigned int nr = 0;
+#endif
 
        *op = pdev->sh_info->op;
        barrier();
@@ -360,6 +364,7 @@ void xen_pcibk_do_op(struct work_struct *data)
                        op->err = xen_pcibk_disable_msi(pdev, dev, op);
                        break;
                case XEN_PCI_OP_enable_msix:
+                       nr = op->value;
                        op->err = xen_pcibk_enable_msix(pdev, dev, op);
                        break;
                case XEN_PCI_OP_disable_msix:
@@ -382,7 +387,7 @@ void xen_pcibk_do_op(struct work_struct *data)
        if (op->cmd == XEN_PCI_OP_enable_msix && op->err == 0) {
                unsigned int i;
 
-               for (i = 0; i < op->value; i++)
+               for (i = 0; i < nr; i++)
                        pdev->sh_info->op.msix_entries[i].vector =
                                op->msix_entries[i].vector;
        }
index ad4eb10..c46ee18 100644 (file)
@@ -849,15 +849,31 @@ static int scsiback_map(struct vscsibk_info *info)
 }
 
 /*
+  Check for a translation entry being present
+*/
+static struct v2p_entry *scsiback_chk_translation_entry(
+       struct vscsibk_info *info, struct ids_tuple *v)
+{
+       struct list_head *head = &(info->v2p_entry_lists);
+       struct v2p_entry *entry;
+
+       list_for_each_entry(entry, head, l)
+               if ((entry->v.chn == v->chn) &&
+                   (entry->v.tgt == v->tgt) &&
+                   (entry->v.lun == v->lun))
+                       return entry;
+
+       return NULL;
+}
+
+/*
   Add a new translation entry
 */
 static int scsiback_add_translation_entry(struct vscsibk_info *info,
                                          char *phy, struct ids_tuple *v)
 {
        int err = 0;
-       struct v2p_entry *entry;
        struct v2p_entry *new;
-       struct list_head *head = &(info->v2p_entry_lists);
        unsigned long flags;
        char *lunp;
        unsigned long long unpacked_lun;
@@ -917,15 +933,10 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info,
        spin_lock_irqsave(&info->v2p_lock, flags);
 
        /* Check double assignment to identical virtual ID */
-       list_for_each_entry(entry, head, l) {
-               if ((entry->v.chn == v->chn) &&
-                   (entry->v.tgt == v->tgt) &&
-                   (entry->v.lun == v->lun)) {
-                       pr_warn("Virtual ID is already used. Assignment was not performed.\n");
-                       err = -EEXIST;
-                       goto out;
-               }
-
+       if (scsiback_chk_translation_entry(info, v)) {
+               pr_warn("Virtual ID is already used. Assignment was not performed.\n");
+               err = -EEXIST;
+               goto out;
        }
 
        /* Create a new translation entry and add to the list */
@@ -933,18 +944,18 @@ static int scsiback_add_translation_entry(struct vscsibk_info *info,
        new->v = *v;
        new->tpg = tpg;
        new->lun = unpacked_lun;
-       list_add_tail(&new->l, head);
+       list_add_tail(&new->l, &info->v2p_entry_lists);
 
 out:
        spin_unlock_irqrestore(&info->v2p_lock, flags);
 
 out_free:
-       mutex_lock(&tpg->tv_tpg_mutex);
-       tpg->tv_tpg_fe_count--;
-       mutex_unlock(&tpg->tv_tpg_mutex);
-
-       if (err)
+       if (err) {
+               mutex_lock(&tpg->tv_tpg_mutex);
+               tpg->tv_tpg_fe_count--;
+               mutex_unlock(&tpg->tv_tpg_mutex);
                kfree(new);
+       }
 
        return err;
 }
@@ -956,39 +967,40 @@ static void __scsiback_del_translation_entry(struct v2p_entry *entry)
 }
 
 /*
-  Delete the translation entry specfied
+  Delete the translation entry specified
 */
 static int scsiback_del_translation_entry(struct vscsibk_info *info,
                                          struct ids_tuple *v)
 {
        struct v2p_entry *entry;
-       struct list_head *head = &(info->v2p_entry_lists);
        unsigned long flags;
+       int ret = 0;
 
        spin_lock_irqsave(&info->v2p_lock, flags);
        /* Find out the translation entry specified */
-       list_for_each_entry(entry, head, l) {
-               if ((entry->v.chn == v->chn) &&
-                   (entry->v.tgt == v->tgt) &&
-                   (entry->v.lun == v->lun)) {
-                       goto found;
-               }
-       }
-
-       spin_unlock_irqrestore(&info->v2p_lock, flags);
-       return 1;
-
-found:
-       /* Delete the translation entry specfied */
-       __scsiback_del_translation_entry(entry);
+       entry = scsiback_chk_translation_entry(info, v);
+       if (entry)
+               __scsiback_del_translation_entry(entry);
+       else
+               ret = -ENOENT;
 
        spin_unlock_irqrestore(&info->v2p_lock, flags);
-       return 0;
+       return ret;
 }
 
 static void scsiback_do_add_lun(struct vscsibk_info *info, const char *state,
                                char *phy, struct ids_tuple *vir, int try)
 {
+       struct v2p_entry *entry;
+       unsigned long flags;
+
+       if (try) {
+               spin_lock_irqsave(&info->v2p_lock, flags);
+               entry = scsiback_chk_translation_entry(info, vir);
+               spin_unlock_irqrestore(&info->v2p_lock, flags);
+               if (entry)
+                       return;
+       }
        if (!scsiback_add_translation_entry(info, phy, vir)) {
                if (xenbus_printf(XBT_NIL, info->dev->nodename, state,
                                  "%d", XenbusStateInitialised)) {
index 9433e46..912b64e 100644 (file)
@@ -188,6 +188,8 @@ static int queue_reply(struct list_head *queue, const void *data, size_t len)
 
        if (len == 0)
                return 0;
+       if (len > XENSTORE_PAYLOAD_MAX)
+               return -EINVAL;
 
        rb = kmalloc(sizeof(*rb) + len, GFP_KERNEL);
        if (rb == NULL)
index 0548c53..22fc7c8 100644 (file)
@@ -511,8 +511,6 @@ affs_do_readpage_ofs(struct page *page, unsigned to)
        pr_debug("%s(%lu, %ld, 0, %d)\n", __func__, inode->i_ino,
                 page->index, to);
        BUG_ON(to > PAGE_CACHE_SIZE);
-       kmap(page);
-       data = page_address(page);
        bsize = AFFS_SB(sb)->s_data_blksize;
        tmp = page->index << PAGE_CACHE_SHIFT;
        bidx = tmp / bsize;
@@ -524,14 +522,15 @@ affs_do_readpage_ofs(struct page *page, unsigned to)
                        return PTR_ERR(bh);
                tmp = min(bsize - boff, to - pos);
                BUG_ON(pos + tmp > to || tmp > bsize);
+               data = kmap_atomic(page);
                memcpy(data + pos, AFFS_DATA(bh) + boff, tmp);
+               kunmap_atomic(data);
                affs_brelse(bh);
                bidx++;
                pos += tmp;
                boff = 0;
        }
        flush_dcache_page(page);
-       kunmap(page);
        return 0;
 }
 
index 051ea48..7d914c6 100644 (file)
@@ -653,7 +653,7 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
 
        if ((current->flags & PF_RANDOMIZE) &&
                !(current->personality & ADDR_NO_RANDOMIZE)) {
-               random_variable = (unsigned long) get_random_int();
+               random_variable = get_random_long();
                random_variable &= STACK_RND_MASK;
                random_variable <<= PAGE_SHIFT;
        }
index 39b3a17..826b164 100644 (file)
@@ -1201,7 +1201,11 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
                bdev->bd_disk = disk;
                bdev->bd_queue = disk->queue;
                bdev->bd_contains = bdev;
-               bdev->bd_inode->i_flags = disk->fops->direct_access ? S_DAX : 0;
+               if (IS_ENABLED(CONFIG_BLK_DEV_DAX) && disk->fops->direct_access)
+                       bdev->bd_inode->i_flags = S_DAX;
+               else
+                       bdev->bd_inode->i_flags = 0;
+
                if (!partno) {
                        ret = -ENXIO;
                        bdev->bd_part = disk_get_part(disk, partno);
@@ -1693,13 +1697,24 @@ static int blkdev_releasepage(struct page *page, gfp_t wait)
        return try_to_free_buffers(page);
 }
 
+static int blkdev_writepages(struct address_space *mapping,
+                            struct writeback_control *wbc)
+{
+       if (dax_mapping(mapping)) {
+               struct block_device *bdev = I_BDEV(mapping->host);
+
+               return dax_writeback_mapping_range(mapping, bdev, wbc);
+       }
+       return generic_writepages(mapping, wbc);
+}
+
 static const struct address_space_operations def_blk_aops = {
        .readpage       = blkdev_readpage,
        .readpages      = blkdev_readpages,
        .writepage      = blkdev_writepage,
        .write_begin    = blkdev_write_begin,
        .write_end      = blkdev_write_end,
-       .writepages     = generic_writepages,
+       .writepages     = blkdev_writepages,
        .releasepage    = blkdev_releasepage,
        .direct_IO      = blkdev_direct_IO,
        .is_dirty_writeback = buffer_check_dirty_writeback,
index b90cd37..f6dac40 100644 (file)
@@ -1406,7 +1406,8 @@ char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
                        read_extent_buffer(eb, dest + bytes_left,
                                           name_off, name_len);
                if (eb != eb_in) {
-                       btrfs_tree_read_unlock_blocking(eb);
+                       if (!path->skip_locking)
+                               btrfs_tree_read_unlock_blocking(eb);
                        free_extent_buffer(eb);
                }
                ret = btrfs_find_item(fs_root, path, parent, 0,
@@ -1426,9 +1427,10 @@ char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
                eb = path->nodes[0];
                /* make sure we can use eb after releasing the path */
                if (eb != eb_in) {
-                       atomic_inc(&eb->refs);
-                       btrfs_tree_read_lock(eb);
-                       btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
+                       if (!path->skip_locking)
+                               btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK);
+                       path->nodes[0] = NULL;
+                       path->locks[0] = 0;
                }
                btrfs_release_path(path);
                iref = btrfs_item_ptr(eb, slot, struct btrfs_inode_ref);
index c473c42..3346cd8 100644 (file)
@@ -637,11 +637,7 @@ int btrfs_submit_compressed_read(struct inode *inode, struct bio *bio,
        faili = nr_pages - 1;
        cb->nr_pages = nr_pages;
 
-       /* In the parent-locked case, we only locked the range we are
-        * interested in.  In all other cases, we can opportunistically
-        * cache decompressed data that goes beyond the requested range. */
-       if (!(bio_flags & EXTENT_BIO_PARENT_LOCKED))
-               add_ra_bio_pages(inode, em_start + em_len, cb);
+       add_ra_bio_pages(inode, em_start + em_len, cb);
 
        /* include any pages we added in add_ra-bio_pages */
        uncompressed_len = bio->bi_vcnt * PAGE_CACHE_SIZE;
index 0be47e4..b57daa8 100644 (file)
@@ -1689,7 +1689,7 @@ int btrfs_should_delete_dir_index(struct list_head *del_list,
  *
  */
 int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
-                                   struct list_head *ins_list)
+                                   struct list_head *ins_list, bool *emitted)
 {
        struct btrfs_dir_item *di;
        struct btrfs_delayed_item *curr, *next;
@@ -1733,6 +1733,7 @@ int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
 
                if (over)
                        return 1;
+               *emitted = true;
        }
        return 0;
 }
index f70119f..0167853 100644 (file)
@@ -144,7 +144,7 @@ void btrfs_put_delayed_items(struct list_head *ins_list,
 int btrfs_should_delete_dir_index(struct list_head *del_list,
                                  u64 index);
 int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
-                                   struct list_head *ins_list);
+                                   struct list_head *ins_list, bool *emitted);
 
 /* for init */
 int __init btrfs_delayed_inode_init(void);
index 2e7c97a..392592d 100644 (file)
@@ -2897,12 +2897,11 @@ static int __do_readpage(struct extent_io_tree *tree,
        struct block_device *bdev;
        int ret;
        int nr = 0;
-       int parent_locked = *bio_flags & EXTENT_BIO_PARENT_LOCKED;
        size_t pg_offset = 0;
        size_t iosize;
        size_t disk_io_size;
        size_t blocksize = inode->i_sb->s_blocksize;
-       unsigned long this_bio_flag = *bio_flags & EXTENT_BIO_PARENT_LOCKED;
+       unsigned long this_bio_flag = 0;
 
        set_page_extent_mapped(page);
 
@@ -2942,18 +2941,16 @@ static int __do_readpage(struct extent_io_tree *tree,
                        kunmap_atomic(userpage);
                        set_extent_uptodate(tree, cur, cur + iosize - 1,
                                            &cached, GFP_NOFS);
-                       if (!parent_locked)
-                               unlock_extent_cached(tree, cur,
-                                                    cur + iosize - 1,
-                                                    &cached, GFP_NOFS);
+                       unlock_extent_cached(tree, cur,
+                                            cur + iosize - 1,
+                                            &cached, GFP_NOFS);
                        break;
                }
                em = __get_extent_map(inode, page, pg_offset, cur,
                                      end - cur + 1, get_extent, em_cached);
                if (IS_ERR_OR_NULL(em)) {
                        SetPageError(page);
-                       if (!parent_locked)
-                               unlock_extent(tree, cur, end);
+                       unlock_extent(tree, cur, end);
                        break;
                }
                extent_offset = cur - em->start;
@@ -3038,12 +3035,9 @@ static int __do_readpage(struct extent_io_tree *tree,
 
                        set_extent_uptodate(tree, cur, cur + iosize - 1,
                                            &cached, GFP_NOFS);
-                       if (parent_locked)
-                               free_extent_state(cached);
-                       else
-                               unlock_extent_cached(tree, cur,
-                                                    cur + iosize - 1,
-                                                    &cached, GFP_NOFS);
+                       unlock_extent_cached(tree, cur,
+                                            cur + iosize - 1,
+                                            &cached, GFP_NOFS);
                        cur = cur + iosize;
                        pg_offset += iosize;
                        continue;
@@ -3052,8 +3046,7 @@ static int __do_readpage(struct extent_io_tree *tree,
                if (test_range_bit(tree, cur, cur_end,
                                   EXTENT_UPTODATE, 1, NULL)) {
                        check_page_uptodate(tree, page);
-                       if (!parent_locked)
-                               unlock_extent(tree, cur, cur + iosize - 1);
+                       unlock_extent(tree, cur, cur + iosize - 1);
                        cur = cur + iosize;
                        pg_offset += iosize;
                        continue;
@@ -3063,8 +3056,7 @@ static int __do_readpage(struct extent_io_tree *tree,
                 */
                if (block_start == EXTENT_MAP_INLINE) {
                        SetPageError(page);
-                       if (!parent_locked)
-                               unlock_extent(tree, cur, cur + iosize - 1);
+                       unlock_extent(tree, cur, cur + iosize - 1);
                        cur = cur + iosize;
                        pg_offset += iosize;
                        continue;
@@ -3083,8 +3075,7 @@ static int __do_readpage(struct extent_io_tree *tree,
                        *bio_flags = this_bio_flag;
                } else {
                        SetPageError(page);
-                       if (!parent_locked)
-                               unlock_extent(tree, cur, cur + iosize - 1);
+                       unlock_extent(tree, cur, cur + iosize - 1);
                }
                cur = cur + iosize;
                pg_offset += iosize;
@@ -3213,20 +3204,6 @@ int extent_read_full_page(struct extent_io_tree *tree, struct page *page,
        return ret;
 }
 
-int extent_read_full_page_nolock(struct extent_io_tree *tree, struct page *page,
-                                get_extent_t *get_extent, int mirror_num)
-{
-       struct bio *bio = NULL;
-       unsigned long bio_flags = EXTENT_BIO_PARENT_LOCKED;
-       int ret;
-
-       ret = __do_readpage(tree, page, get_extent, NULL, &bio, mirror_num,
-                           &bio_flags, READ, NULL);
-       if (bio)
-               ret = submit_one_bio(READ, bio, mirror_num, bio_flags);
-       return ret;
-}
-
 static noinline void update_nr_written(struct page *page,
                                      struct writeback_control *wbc,
                                      unsigned long nr_written)
index 0377413..880d529 100644 (file)
@@ -29,7 +29,6 @@
  */
 #define EXTENT_BIO_COMPRESSED 1
 #define EXTENT_BIO_TREE_LOG 2
-#define EXTENT_BIO_PARENT_LOCKED 4
 #define EXTENT_BIO_FLAG_SHIFT 16
 
 /* these are bit numbers for test/set bit */
@@ -210,8 +209,6 @@ static inline int lock_extent(struct extent_io_tree *tree, u64 start, u64 end)
 int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end);
 int extent_read_full_page(struct extent_io_tree *tree, struct page *page,
                          get_extent_t *get_extent, int mirror_num);
-int extent_read_full_page_nolock(struct extent_io_tree *tree, struct page *page,
-                                get_extent_t *get_extent, int mirror_num);
 int __init extent_io_init(void);
 void extent_io_exit(void);
 
index 5f06eb1..d96f5cf 100644 (file)
@@ -5717,6 +5717,7 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
        char *name_ptr;
        int name_len;
        int is_curr = 0;        /* ctx->pos points to the current index? */
+       bool emitted;
 
        /* FIXME, use a real flag for deciding about the key type */
        if (root->fs_info->tree_root == root)
@@ -5745,6 +5746,7 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
        if (ret < 0)
                goto err;
 
+       emitted = false;
        while (1) {
                leaf = path->nodes[0];
                slot = path->slots[0];
@@ -5824,6 +5826,7 @@ skip:
 
                        if (over)
                                goto nopos;
+                       emitted = true;
                        di_len = btrfs_dir_name_len(leaf, di) +
                                 btrfs_dir_data_len(leaf, di) + sizeof(*di);
                        di_cur += di_len;
@@ -5836,11 +5839,20 @@ next:
        if (key_type == BTRFS_DIR_INDEX_KEY) {
                if (is_curr)
                        ctx->pos++;
-               ret = btrfs_readdir_delayed_dir_index(ctx, &ins_list);
+               ret = btrfs_readdir_delayed_dir_index(ctx, &ins_list, &emitted);
                if (ret)
                        goto nopos;
        }
 
+       /*
+        * If we haven't emitted any dir entry, we must not touch ctx->pos as
+        * it was was set to the termination value in previous call. We assume
+        * that "." and ".." were emitted if we reach this point and set the
+        * termination value as well for an empty directory.
+        */
+       if (ctx->pos > 2 && !emitted)
+               goto nopos;
+
        /* Reached end of directory/root. Bump pos past the last item. */
        ctx->pos++;
 
@@ -7974,6 +7986,7 @@ static void btrfs_endio_direct_read(struct bio *bio)
 
        kfree(dip);
 
+       dio_bio->bi_error = bio->bi_error;
        dio_end_io(dio_bio, bio->bi_error);
 
        if (io_bio->end_io)
@@ -8028,6 +8041,7 @@ static void btrfs_endio_direct_write(struct bio *bio)
 
        kfree(dip);
 
+       dio_bio->bi_error = bio->bi_error;
        dio_end_io(dio_bio, bio->bi_error);
        bio_put(bio);
 }
index 952172c..48aee98 100644 (file)
@@ -2794,24 +2794,29 @@ out:
 static struct page *extent_same_get_page(struct inode *inode, pgoff_t index)
 {
        struct page *page;
-       struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree;
 
        page = grab_cache_page(inode->i_mapping, index);
        if (!page)
-               return NULL;
+               return ERR_PTR(-ENOMEM);
 
        if (!PageUptodate(page)) {
-               if (extent_read_full_page_nolock(tree, page, btrfs_get_extent,
-                                                0))
-                       return NULL;
+               int ret;
+
+               ret = btrfs_readpage(NULL, page);
+               if (ret)
+                       return ERR_PTR(ret);
                lock_page(page);
                if (!PageUptodate(page)) {
                        unlock_page(page);
                        page_cache_release(page);
-                       return NULL;
+                       return ERR_PTR(-EIO);
+               }
+               if (page->mapping != inode->i_mapping) {
+                       unlock_page(page);
+                       page_cache_release(page);
+                       return ERR_PTR(-EAGAIN);
                }
        }
-       unlock_page(page);
 
        return page;
 }
@@ -2823,17 +2828,31 @@ static int gather_extent_pages(struct inode *inode, struct page **pages,
        pgoff_t index = off >> PAGE_CACHE_SHIFT;
 
        for (i = 0; i < num_pages; i++) {
+again:
                pages[i] = extent_same_get_page(inode, index + i);
-               if (!pages[i])
-                       return -ENOMEM;
+               if (IS_ERR(pages[i])) {
+                       int err = PTR_ERR(pages[i]);
+
+                       if (err == -EAGAIN)
+                               goto again;
+                       pages[i] = NULL;
+                       return err;
+               }
        }
        return 0;
 }
 
-static inline void lock_extent_range(struct inode *inode, u64 off, u64 len)
+static int lock_extent_range(struct inode *inode, u64 off, u64 len,
+                            bool retry_range_locking)
 {
-       /* do any pending delalloc/csum calc on src, one way or
-          another, and lock file content */
+       /*
+        * Do any pending delalloc/csum calculations on inode, one way or
+        * another, and lock file content.
+        * The locking order is:
+        *
+        *   1) pages
+        *   2) range in the inode's io tree
+        */
        while (1) {
                struct btrfs_ordered_extent *ordered;
                lock_extent(&BTRFS_I(inode)->io_tree, off, off + len - 1);
@@ -2851,8 +2870,11 @@ static inline void lock_extent_range(struct inode *inode, u64 off, u64 len)
                unlock_extent(&BTRFS_I(inode)->io_tree, off, off + len - 1);
                if (ordered)
                        btrfs_put_ordered_extent(ordered);
+               if (!retry_range_locking)
+                       return -EAGAIN;
                btrfs_wait_ordered_range(inode, off, len);
        }
+       return 0;
 }
 
 static void btrfs_double_inode_unlock(struct inode *inode1, struct inode *inode2)
@@ -2877,15 +2899,24 @@ static void btrfs_double_extent_unlock(struct inode *inode1, u64 loff1,
        unlock_extent(&BTRFS_I(inode2)->io_tree, loff2, loff2 + len - 1);
 }
 
-static void btrfs_double_extent_lock(struct inode *inode1, u64 loff1,
-                                    struct inode *inode2, u64 loff2, u64 len)
+static int btrfs_double_extent_lock(struct inode *inode1, u64 loff1,
+                                   struct inode *inode2, u64 loff2, u64 len,
+                                   bool retry_range_locking)
 {
+       int ret;
+
        if (inode1 < inode2) {
                swap(inode1, inode2);
                swap(loff1, loff2);
        }
-       lock_extent_range(inode1, loff1, len);
-       lock_extent_range(inode2, loff2, len);
+       ret = lock_extent_range(inode1, loff1, len, retry_range_locking);
+       if (ret)
+               return ret;
+       ret = lock_extent_range(inode2, loff2, len, retry_range_locking);
+       if (ret)
+               unlock_extent(&BTRFS_I(inode1)->io_tree, loff1,
+                             loff1 + len - 1);
+       return ret;
 }
 
 struct cmp_pages {
@@ -2901,11 +2932,15 @@ static void btrfs_cmp_data_free(struct cmp_pages *cmp)
 
        for (i = 0; i < cmp->num_pages; i++) {
                pg = cmp->src_pages[i];
-               if (pg)
+               if (pg) {
+                       unlock_page(pg);
                        page_cache_release(pg);
+               }
                pg = cmp->dst_pages[i];
-               if (pg)
+               if (pg) {
+                       unlock_page(pg);
                        page_cache_release(pg);
+               }
        }
        kfree(cmp->src_pages);
        kfree(cmp->dst_pages);
@@ -2966,6 +3001,8 @@ static int btrfs_cmp_data(struct inode *src, u64 loff, struct inode *dst,
 
                src_page = cmp->src_pages[i];
                dst_page = cmp->dst_pages[i];
+               ASSERT(PageLocked(src_page));
+               ASSERT(PageLocked(dst_page));
 
                addr = kmap_atomic(src_page);
                dst_addr = kmap_atomic(dst_page);
@@ -3078,14 +3115,46 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
                goto out_unlock;
        }
 
+again:
        ret = btrfs_cmp_data_prepare(src, loff, dst, dst_loff, olen, &cmp);
        if (ret)
                goto out_unlock;
 
        if (same_inode)
-               lock_extent_range(src, same_lock_start, same_lock_len);
+               ret = lock_extent_range(src, same_lock_start, same_lock_len,
+                                       false);
        else
-               btrfs_double_extent_lock(src, loff, dst, dst_loff, len);
+               ret = btrfs_double_extent_lock(src, loff, dst, dst_loff, len,
+                                              false);
+       /*
+        * If one of the inodes has dirty pages in the respective range or
+        * ordered extents, we need to flush dellaloc and wait for all ordered
+        * extents in the range. We must unlock the pages and the ranges in the
+        * io trees to avoid deadlocks when flushing delalloc (requires locking
+        * pages) and when waiting for ordered extents to complete (they require
+        * range locking).
+        */
+       if (ret == -EAGAIN) {
+               /*
+                * Ranges in the io trees already unlocked. Now unlock all
+                * pages before waiting for all IO to complete.
+                */
+               btrfs_cmp_data_free(&cmp);
+               if (same_inode) {
+                       btrfs_wait_ordered_range(src, same_lock_start,
+                                                same_lock_len);
+               } else {
+                       btrfs_wait_ordered_range(src, loff, len);
+                       btrfs_wait_ordered_range(dst, dst_loff, len);
+               }
+               goto again;
+       }
+       ASSERT(ret == 0);
+       if (WARN_ON(ret)) {
+               /* ranges in the io trees already unlocked */
+               btrfs_cmp_data_free(&cmp);
+               return ret;
+       }
 
        /* pass original length for comparison so we stay within i_size */
        ret = btrfs_cmp_data(src, loff, dst, dst_loff, olen, &cmp);
@@ -3795,9 +3864,15 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
                u64 lock_start = min_t(u64, off, destoff);
                u64 lock_len = max_t(u64, off, destoff) + len - lock_start;
 
-               lock_extent_range(src, lock_start, lock_len);
+               ret = lock_extent_range(src, lock_start, lock_len, true);
        } else {
-               btrfs_double_extent_lock(src, off, inode, destoff, len);
+               ret = btrfs_double_extent_lock(src, off, inode, destoff, len,
+                                              true);
+       }
+       ASSERT(ret == 0);
+       if (WARN_ON(ret)) {
+               /* ranges in the io trees already unlocked */
+               goto out_unlock;
        }
 
        ret = btrfs_clone(src, inode, off, olen, len, destoff, 0);
index 7cf8509..2c849b0 100644 (file)
@@ -310,8 +310,16 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root)
                set_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state);
 
                err = btrfs_insert_fs_root(root->fs_info, root);
+               /*
+                * The root might have been inserted already, as before we look
+                * for orphan roots, log replay might have happened, which
+                * triggers a transaction commit and qgroup accounting, which
+                * in turn reads and inserts fs roots while doing backref
+                * walking.
+                */
+               if (err == -EEXIST)
+                       err = 0;
                if (err) {
-                       BUG_ON(err == -EEXIST);
                        btrfs_free_fs_root(root);
                        break;
                }
index c222137..19adeb0 100644 (file)
@@ -1756,6 +1756,10 @@ int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)
        u32 pool;
        int ret, flags;
 
+       /* does not support pool namespace yet */
+       if (ci->i_pool_ns_len)
+               return -EIO;
+
        if (ceph_test_mount_opt(ceph_inode_to_client(&ci->vfs_inode),
                                NOPOOLPERM))
                return 0;
index cdbf8cf..6fe0ad2 100644 (file)
@@ -2753,7 +2753,8 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
                             void *inline_data, int inline_len,
                             struct ceph_buffer *xattr_buf,
                             struct ceph_mds_session *session,
-                            struct ceph_cap *cap, int issued)
+                            struct ceph_cap *cap, int issued,
+                            u32 pool_ns_len)
        __releases(ci->i_ceph_lock)
        __releases(mdsc->snap_rwsem)
 {
@@ -2873,6 +2874,8 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
        if (newcaps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) {
                /* file layout may have changed */
                ci->i_layout = grant->layout;
+               ci->i_pool_ns_len = pool_ns_len;
+
                /* size/truncate_seq? */
                queue_trunc = ceph_fill_file_size(inode, issued,
                                        le32_to_cpu(grant->truncate_seq),
@@ -3411,6 +3414,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
        u32  inline_len = 0;
        void *snaptrace;
        size_t snaptrace_len;
+       u32 pool_ns_len = 0;
        void *p, *end;
 
        dout("handle_caps from mds%d\n", mds);
@@ -3463,6 +3467,21 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                p += inline_len;
        }
 
+       if (le16_to_cpu(msg->hdr.version) >= 8) {
+               u64 flush_tid;
+               u32 caller_uid, caller_gid;
+               u32 osd_epoch_barrier;
+               /* version >= 5 */
+               ceph_decode_32_safe(&p, end, osd_epoch_barrier, bad);
+               /* version >= 6 */
+               ceph_decode_64_safe(&p, end, flush_tid, bad);
+               /* version >= 7 */
+               ceph_decode_32_safe(&p, end, caller_uid, bad);
+               ceph_decode_32_safe(&p, end, caller_gid, bad);
+               /* version >= 8 */
+               ceph_decode_32_safe(&p, end, pool_ns_len, bad);
+       }
+
        /* lookup ino */
        inode = ceph_find_inode(sb, vino);
        ci = ceph_inode(inode);
@@ -3518,7 +3537,8 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                                  &cap, &issued);
                handle_cap_grant(mdsc, inode, h,
                                 inline_version, inline_data, inline_len,
-                                msg->middle, session, cap, issued);
+                                msg->middle, session, cap, issued,
+                                pool_ns_len);
                if (realm)
                        ceph_put_snap_realm(mdsc, realm);
                goto done_unlocked;
@@ -3542,7 +3562,8 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                issued |= __ceph_caps_dirty(ci);
                handle_cap_grant(mdsc, inode, h,
                                 inline_version, inline_data, inline_len,
-                                msg->middle, session, cap, issued);
+                                msg->middle, session, cap, issued,
+                                pool_ns_len);
                goto done_unlocked;
 
        case CEPH_CAP_OP_FLUSH_ACK:
index fb4ba2e..5849b88 100644 (file)
@@ -396,6 +396,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
        ci->i_symlink = NULL;
 
        memset(&ci->i_dir_layout, 0, sizeof(ci->i_dir_layout));
+       ci->i_pool_ns_len = 0;
 
        ci->i_fragtree = RB_ROOT;
        mutex_init(&ci->i_fragtree_mutex);
@@ -756,6 +757,7 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
                if (ci->i_layout.fl_pg_pool != info->layout.fl_pg_pool)
                        ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;
                ci->i_layout = info->layout;
+               ci->i_pool_ns_len = iinfo->pool_ns_len;
 
                queue_trunc = ceph_fill_file_size(inode, issued,
                                        le32_to_cpu(info->truncate_seq),
index e7b130a..911d64d 100644 (file)
@@ -100,6 +100,14 @@ static int parse_reply_info_in(void **p, void *end,
        } else
                info->inline_version = CEPH_INLINE_NONE;
 
+       if (features & CEPH_FEATURE_FS_FILE_LAYOUT_V2) {
+               ceph_decode_32_safe(p, end, info->pool_ns_len, bad);
+               ceph_decode_need(p, end, info->pool_ns_len, bad);
+               *p += info->pool_ns_len;
+       } else {
+               info->pool_ns_len = 0;
+       }
+
        return 0;
 bad:
        return err;
@@ -2298,6 +2306,14 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
                ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
                                  CEPH_CAP_PIN);
 
+       /* deny access to directories with pool_ns layouts */
+       if (req->r_inode && S_ISDIR(req->r_inode->i_mode) &&
+           ceph_inode(req->r_inode)->i_pool_ns_len)
+               return -EIO;
+       if (req->r_locked_dir &&
+           ceph_inode(req->r_locked_dir)->i_pool_ns_len)
+               return -EIO;
+
        /* issue */
        mutex_lock(&mdsc->mutex);
        __register_request(mdsc, req, dir);
index ccf11ef..37712cc 100644 (file)
@@ -44,6 +44,7 @@ struct ceph_mds_reply_info_in {
        u64 inline_version;
        u32 inline_len;
        char *inline_data;
+       u32 pool_ns_len;
 };
 
 /*
index 75b7d12..9c458eb 100644 (file)
@@ -287,6 +287,7 @@ struct ceph_inode_info {
 
        struct ceph_dir_layout i_dir_layout;
        struct ceph_file_layout i_layout;
+       size_t i_pool_ns_len;
        char *i_symlink;
 
        /* for dirs */
index 7dc886c..e956cba 100644 (file)
@@ -175,7 +175,7 @@ char *cifs_compose_mount_options(const char *sb_mountdata,
         * string to the length of the original string to allow for worst case.
         */
        md_len = strlen(sb_mountdata) + INET6_ADDRSTRLEN;
-       mountdata = kzalloc(md_len + 1, GFP_KERNEL);
+       mountdata = kzalloc(md_len + sizeof("ip=") + 1, GFP_KERNEL);
        if (mountdata == NULL) {
                rc = -ENOMEM;
                goto compose_mount_options_err;
index afa09fc..e682b36 100644 (file)
@@ -714,7 +714,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
 
        ses->auth_key.response = kmalloc(baselen + tilen, GFP_KERNEL);
        if (!ses->auth_key.response) {
-               rc = ENOMEM;
+               rc = -ENOMEM;
                ses->auth_key.len = 0;
                goto setup_ntlmv2_rsp_ret;
        }
index c48ca13..2eea403 100644 (file)
@@ -1013,7 +1013,6 @@ const struct file_operations cifs_file_strict_ops = {
        .llseek = cifs_llseek,
        .unlocked_ioctl = cifs_ioctl,
        .clone_file_range = cifs_clone_file_range,
-       .clone_file_range = cifs_clone_file_range,
        .setlease = cifs_setlease,
        .fallocate = cifs_fallocate,
 };
index 68c4547..83aac8b 100644 (file)
  * so that it will fit. We use hash_64 to convert the value to 31 bits, and
  * then add 1, to ensure that we don't end up with a 0 as the value.
  */
-#if BITS_PER_LONG == 64
 static inline ino_t
 cifs_uniqueid_to_ino_t(u64 fileid)
 {
+       if ((sizeof(ino_t)) < (sizeof(u64)))
+               return (ino_t)hash_64(fileid, (sizeof(ino_t) * 8) - 1) + 1;
+
        return (ino_t)fileid;
+
 }
-#else
-static inline ino_t
-cifs_uniqueid_to_ino_t(u64 fileid)
-{
-       return (ino_t)hash_64(fileid, (sizeof(ino_t) * 8) - 1) + 1;
-}
-#endif
 
 extern struct file_system_type cifs_fs_type;
 extern const struct address_space_operations cifs_addr_ops;
index 90b4f9f..76fcb50 100644 (file)
@@ -1396,11 +1396,10 @@ openRetry:
  * current bigbuf.
  */
 static int
-cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid)
+discard_remaining_data(struct TCP_Server_Info *server)
 {
        unsigned int rfclen = get_rfc1002_length(server->smallbuf);
        int remaining = rfclen + 4 - server->total_read;
-       struct cifs_readdata *rdata = mid->callback_data;
 
        while (remaining > 0) {
                int length;
@@ -1414,10 +1413,20 @@ cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid)
                remaining -= length;
        }
 
-       dequeue_mid(mid, rdata->result);
        return 0;
 }
 
+static int
+cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid)
+{
+       int length;
+       struct cifs_readdata *rdata = mid->callback_data;
+
+       length = discard_remaining_data(server);
+       dequeue_mid(mid, rdata->result);
+       return length;
+}
+
 int
 cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
 {
@@ -1446,6 +1455,12 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
                return length;
        server->total_read += length;
 
+       if (server->ops->is_status_pending &&
+           server->ops->is_status_pending(buf, server, 0)) {
+               discard_remaining_data(server);
+               return -1;
+       }
+
        /* Was the SMB read successful? */
        rdata->result = server->ops->map_error(buf, false);
        if (rdata->result != 0) {
index 4fbd92d..a763cd3 100644 (file)
@@ -2999,8 +2999,7 @@ ip_rfc1001_connect(struct TCP_Server_Info *server)
        if (ses_init_buf) {
                ses_init_buf->trailer.session_req.called_len = 32;
 
-               if (server->server_RFC1001_name &&
-                   server->server_RFC1001_name[0] != 0)
+               if (server->server_RFC1001_name[0] != 0)
                        rfc1002mangle(ses_init_buf->trailer.
                                      session_req.called_name,
                                      server->server_RFC1001_name,
index 10f8d5c..42e1f44 100644 (file)
@@ -1106,21 +1106,25 @@ parse_lease_state(struct TCP_Server_Info *server, struct smb2_create_rsp *rsp,
 {
        char *data_offset;
        struct create_context *cc;
-       unsigned int next = 0;
+       unsigned int next;
+       unsigned int remaining;
        char *name;
 
        data_offset = (char *)rsp + 4 + le32_to_cpu(rsp->CreateContextsOffset);
+       remaining = le32_to_cpu(rsp->CreateContextsLength);
        cc = (struct create_context *)data_offset;
-       do {
-               cc = (struct create_context *)((char *)cc + next);
+       while (remaining >= sizeof(struct create_context)) {
                name = le16_to_cpu(cc->NameOffset) + (char *)cc;
-               if (le16_to_cpu(cc->NameLength) != 4 ||
-                   strncmp(name, "RqLs", 4)) {
-                       next = le32_to_cpu(cc->Next);
-                       continue;
-               }
-               return server->ops->parse_lease_buf(cc, epoch);
-       } while (next != 0);
+               if (le16_to_cpu(cc->NameLength) == 4 &&
+                   strncmp(name, "RqLs", 4) == 0)
+                       return server->ops->parse_lease_buf(cc, epoch);
+
+               next = le32_to_cpu(cc->Next);
+               if (!next)
+                       break;
+               remaining -= next;
+               cc = (struct create_context *)((char *)cc + next);
+       }
 
        return 0;
 }
index fc2e314..bbb2ad7 100644 (file)
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -79,15 +79,14 @@ struct page *read_dax_sector(struct block_device *bdev, sector_t n)
 }
 
 /*
- * dax_clear_blocks() is called from within transaction context from XFS,
+ * dax_clear_sectors() is called from within transaction context from XFS,
  * and hence this means the stack from this point must follow GFP_NOFS
  * semantics for all operations.
  */
-int dax_clear_blocks(struct inode *inode, sector_t block, long _size)
+int dax_clear_sectors(struct block_device *bdev, sector_t _sector, long _size)
 {
-       struct block_device *bdev = inode->i_sb->s_bdev;
        struct blk_dax_ctl dax = {
-               .sector = block << (inode->i_blkbits - 9),
+               .sector = _sector,
                .size = _size,
        };
 
@@ -109,7 +108,7 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long _size)
        wmb_pmem();
        return 0;
 }
-EXPORT_SYMBOL_GPL(dax_clear_blocks);
+EXPORT_SYMBOL_GPL(dax_clear_sectors);
 
 /* the clear_pmem() calls are ordered by a wmb_pmem() in the caller */
 static void dax_new_buf(void __pmem *addr, unsigned size, unsigned first,
@@ -485,11 +484,10 @@ static int dax_writeback_one(struct block_device *bdev,
  * end]. This is required by data integrity operations to ensure file data is
  * on persistent storage prior to completion of the operation.
  */
-int dax_writeback_mapping_range(struct address_space *mapping, loff_t start,
-               loff_t end)
+int dax_writeback_mapping_range(struct address_space *mapping,
+               struct block_device *bdev, struct writeback_control *wbc)
 {
        struct inode *inode = mapping->host;
-       struct block_device *bdev = inode->i_sb->s_bdev;
        pgoff_t start_index, end_index, pmd_index;
        pgoff_t indices[PAGEVEC_SIZE];
        struct pagevec pvec;
@@ -500,8 +498,11 @@ int dax_writeback_mapping_range(struct address_space *mapping, loff_t start,
        if (WARN_ON_ONCE(inode->i_blkbits != PAGE_SHIFT))
                return -EIO;
 
-       start_index = start >> PAGE_CACHE_SHIFT;
-       end_index = end >> PAGE_CACHE_SHIFT;
+       if (!mapping->nrexceptional || wbc->sync_mode != WB_SYNC_ALL)
+               return 0;
+
+       start_index = wbc->range_start >> PAGE_CACHE_SHIFT;
+       end_index = wbc->range_end >> PAGE_CACHE_SHIFT;
        pmd_index = DAX_PMD_INDEX(start_index);
 
        rcu_read_lock();
@@ -1055,6 +1056,7 @@ EXPORT_SYMBOL_GPL(dax_pmd_fault);
 int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
        struct file *file = vma->vm_file;
+       int error;
 
        /*
         * We pass NO_SECTOR to dax_radix_entry() because we expect that a
@@ -1064,7 +1066,13 @@ int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
         * saves us from having to make a call to get_block() here to look
         * up the sector.
         */
-       dax_radix_entry(file->f_mapping, vmf->pgoff, NO_SECTOR, false, true);
+       error = dax_radix_entry(file->f_mapping, vmf->pgoff, NO_SECTOR, false,
+                       true);
+
+       if (error == -ENOMEM)
+               return VM_FAULT_OOM;
+       if (error)
+               return VM_FAULT_SIGBUS;
        return VM_FAULT_NOPAGE;
 }
 EXPORT_SYMBOL_GPL(dax_pfn_mkwrite);
index 92d5140..2398f9f 100644 (file)
@@ -269,9 +269,6 @@ static inline int dname_external(const struct dentry *dentry)
        return dentry->d_name.name != dentry->d_iname;
 }
 
-/*
- * Make sure other CPUs see the inode attached before the type is set.
- */
 static inline void __d_set_inode_and_type(struct dentry *dentry,
                                          struct inode *inode,
                                          unsigned type_flags)
@@ -279,28 +276,18 @@ static inline void __d_set_inode_and_type(struct dentry *dentry,
        unsigned flags;
 
        dentry->d_inode = inode;
-       smp_wmb();
        flags = READ_ONCE(dentry->d_flags);
        flags &= ~(DCACHE_ENTRY_TYPE | DCACHE_FALLTHRU);
        flags |= type_flags;
        WRITE_ONCE(dentry->d_flags, flags);
 }
 
-/*
- * Ideally, we want to make sure that other CPUs see the flags cleared before
- * the inode is detached, but this is really a violation of RCU principles
- * since the ordering suggests we should always set inode before flags.
- *
- * We should instead replace or discard the entire dentry - but that sucks
- * performancewise on mass deletion/rename.
- */
 static inline void __d_clear_type_and_inode(struct dentry *dentry)
 {
        unsigned flags = READ_ONCE(dentry->d_flags);
 
        flags &= ~(DCACHE_ENTRY_TYPE | DCACHE_FALLTHRU);
        WRITE_ONCE(dentry->d_flags, flags);
-       smp_wmb();
        dentry->d_inode = NULL;
 }
 
@@ -370,9 +357,11 @@ static void dentry_unlink_inode(struct dentry * dentry)
        __releases(dentry->d_inode->i_lock)
 {
        struct inode *inode = dentry->d_inode;
+
+       raw_write_seqcount_begin(&dentry->d_seq);
        __d_clear_type_and_inode(dentry);
        hlist_del_init(&dentry->d_u.d_alias);
-       dentry_rcuwalk_invalidate(dentry);
+       raw_write_seqcount_end(&dentry->d_seq);
        spin_unlock(&dentry->d_lock);
        spin_unlock(&inode->i_lock);
        if (!inode->i_nlink)
@@ -1758,8 +1747,9 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode)
        spin_lock(&dentry->d_lock);
        if (inode)
                hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
+       raw_write_seqcount_begin(&dentry->d_seq);
        __d_set_inode_and_type(dentry, inode, add_flags);
-       dentry_rcuwalk_invalidate(dentry);
+       raw_write_seqcount_end(&dentry->d_seq);
        spin_unlock(&dentry->d_lock);
        fsnotify_d_instantiate(dentry, inode);
 }
index 1f107fd..655f21f 100644 (file)
@@ -575,6 +575,26 @@ void devpts_kill_index(struct inode *ptmx_inode, int idx)
        mutex_unlock(&allocated_ptys_lock);
 }
 
+/*
+ * pty code needs to hold extra references in case of last /dev/tty close
+ */
+
+void devpts_add_ref(struct inode *ptmx_inode)
+{
+       struct super_block *sb = pts_sb_from_inode(ptmx_inode);
+
+       atomic_inc(&sb->s_active);
+       ihold(ptmx_inode);
+}
+
+void devpts_del_ref(struct inode *ptmx_inode)
+{
+       struct super_block *sb = pts_sb_from_inode(ptmx_inode);
+
+       iput(ptmx_inode);
+       deactivate_super(sb);
+}
+
 /**
  * devpts_pty_new -- create a new inode in /dev/pts/
  * @ptmx_inode: inode of the master
index 1b2f7ff..d6a9012 100644 (file)
@@ -472,8 +472,8 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio)
                dio->io_error = -EIO;
 
        if (dio->is_async && dio->rw == READ && dio->should_dirty) {
-               bio_check_pages_dirty(bio);     /* transfers ownership */
                err = bio->bi_error;
+               bio_check_pages_dirty(bio);     /* transfers ownership */
        } else {
                bio_for_each_segment_all(bvec, bio, i) {
                        struct page *page = bvec->bv_page;
index c424e48..d48e0d2 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/efi.h>
 #include <linux/fs.h>
 #include <linux/slab.h>
+#include <linux/mount.h>
 
 #include "internal.h"
 
@@ -103,9 +104,78 @@ out_free:
        return size;
 }
 
+static int
+efivarfs_ioc_getxflags(struct file *file, void __user *arg)
+{
+       struct inode *inode = file->f_mapping->host;
+       unsigned int i_flags;
+       unsigned int flags = 0;
+
+       i_flags = inode->i_flags;
+       if (i_flags & S_IMMUTABLE)
+               flags |= FS_IMMUTABLE_FL;
+
+       if (copy_to_user(arg, &flags, sizeof(flags)))
+               return -EFAULT;
+       return 0;
+}
+
+static int
+efivarfs_ioc_setxflags(struct file *file, void __user *arg)
+{
+       struct inode *inode = file->f_mapping->host;
+       unsigned int flags;
+       unsigned int i_flags = 0;
+       int error;
+
+       if (!inode_owner_or_capable(inode))
+               return -EACCES;
+
+       if (copy_from_user(&flags, arg, sizeof(flags)))
+               return -EFAULT;
+
+       if (flags & ~FS_IMMUTABLE_FL)
+               return -EOPNOTSUPP;
+
+       if (!capable(CAP_LINUX_IMMUTABLE))
+               return -EPERM;
+
+       if (flags & FS_IMMUTABLE_FL)
+               i_flags |= S_IMMUTABLE;
+
+
+       error = mnt_want_write_file(file);
+       if (error)
+               return error;
+
+       inode_lock(inode);
+       inode_set_flags(inode, i_flags, S_IMMUTABLE);
+       inode_unlock(inode);
+
+       mnt_drop_write_file(file);
+
+       return 0;
+}
+
+long
+efivarfs_file_ioctl(struct file *file, unsigned int cmd, unsigned long p)
+{
+       void __user *arg = (void __user *)p;
+
+       switch (cmd) {
+       case FS_IOC_GETFLAGS:
+               return efivarfs_ioc_getxflags(file, arg);
+       case FS_IOC_SETFLAGS:
+               return efivarfs_ioc_setxflags(file, arg);
+       }
+
+       return -ENOTTY;
+}
+
 const struct file_operations efivarfs_file_operations = {
        .open   = simple_open,
        .read   = efivarfs_file_read,
        .write  = efivarfs_file_write,
        .llseek = no_llseek,
+       .unlocked_ioctl = efivarfs_file_ioctl,
 };
index 3381b9d..e2ab6d0 100644 (file)
@@ -15,7 +15,8 @@
 #include "internal.h"
 
 struct inode *efivarfs_get_inode(struct super_block *sb,
-                               const struct inode *dir, int mode, dev_t dev)
+                               const struct inode *dir, int mode,
+                               dev_t dev, bool is_removable)
 {
        struct inode *inode = new_inode(sb);
 
@@ -23,6 +24,7 @@ struct inode *efivarfs_get_inode(struct super_block *sb,
                inode->i_ino = get_next_ino();
                inode->i_mode = mode;
                inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+               inode->i_flags = is_removable ? 0 : S_IMMUTABLE;
                switch (mode & S_IFMT) {
                case S_IFREG:
                        inode->i_fop = &efivarfs_file_operations;
@@ -102,22 +104,17 @@ static void efivarfs_hex_to_guid(const char *str, efi_guid_t *guid)
 static int efivarfs_create(struct inode *dir, struct dentry *dentry,
                          umode_t mode, bool excl)
 {
-       struct inode *inode;
+       struct inode *inode = NULL;
        struct efivar_entry *var;
        int namelen, i = 0, err = 0;
+       bool is_removable = false;
 
        if (!efivarfs_valid_name(dentry->d_name.name, dentry->d_name.len))
                return -EINVAL;
 
-       inode = efivarfs_get_inode(dir->i_sb, dir, mode, 0);
-       if (!inode)
-               return -ENOMEM;
-
        var = kzalloc(sizeof(struct efivar_entry), GFP_KERNEL);
-       if (!var) {
-               err = -ENOMEM;
-               goto out;
-       }
+       if (!var)
+               return -ENOMEM;
 
        /* length of the variable name itself: remove GUID and separator */
        namelen = dentry->d_name.len - EFI_VARIABLE_GUID_LEN - 1;
@@ -125,6 +122,16 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
        efivarfs_hex_to_guid(dentry->d_name.name + namelen + 1,
                        &var->var.VendorGuid);
 
+       if (efivar_variable_is_removable(var->var.VendorGuid,
+                                        dentry->d_name.name, namelen))
+               is_removable = true;
+
+       inode = efivarfs_get_inode(dir->i_sb, dir, mode, 0, is_removable);
+       if (!inode) {
+               err = -ENOMEM;
+               goto out;
+       }
+
        for (i = 0; i < namelen; i++)
                var->var.VariableName[i] = dentry->d_name.name[i];
 
@@ -138,7 +145,8 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
 out:
        if (err) {
                kfree(var);
-               iput(inode);
+               if (inode)
+                       iput(inode);
        }
        return err;
 }
index b5ff16a..b450518 100644 (file)
@@ -15,7 +15,8 @@ extern const struct file_operations efivarfs_file_operations;
 extern const struct inode_operations efivarfs_dir_inode_operations;
 extern bool efivarfs_valid_name(const char *str, int len);
 extern struct inode *efivarfs_get_inode(struct super_block *sb,
-                       const struct inode *dir, int mode, dev_t dev);
+                       const struct inode *dir, int mode, dev_t dev,
+                       bool is_removable);
 
 extern struct list_head efivarfs_list;
 
index b8a564f..dd029d1 100644 (file)
@@ -118,8 +118,9 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
        struct dentry *dentry, *root = sb->s_root;
        unsigned long size = 0;
        char *name;
-       int len, i;
+       int len;
        int err = -ENOMEM;
+       bool is_removable = false;
 
        entry = kzalloc(sizeof(*entry), GFP_KERNEL);
        if (!entry)
@@ -128,15 +129,17 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
        memcpy(entry->var.VariableName, name16, name_size);
        memcpy(&(entry->var.VendorGuid), &vendor, sizeof(efi_guid_t));
 
-       len = ucs2_strlen(entry->var.VariableName);
+       len = ucs2_utf8size(entry->var.VariableName);
 
        /* name, plus '-', plus GUID, plus NUL*/
        name = kmalloc(len + 1 + EFI_VARIABLE_GUID_LEN + 1, GFP_KERNEL);
        if (!name)
                goto fail;
 
-       for (i = 0; i < len; i++)
-               name[i] = entry->var.VariableName[i] & 0xFF;
+       ucs2_as_utf8(name, entry->var.VariableName, len);
+
+       if (efivar_variable_is_removable(entry->var.VendorGuid, name, len))
+               is_removable = true;
 
        name[len] = '-';
 
@@ -144,7 +147,8 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
 
        name[len + EFI_VARIABLE_GUID_LEN+1] = '\0';
 
-       inode = efivarfs_get_inode(sb, d_inode(root), S_IFREG | 0644, 0);
+       inode = efivarfs_get_inode(sb, d_inode(root), S_IFREG | 0644, 0,
+                                  is_removable);
        if (!inode)
                goto fail_name;
 
@@ -200,7 +204,7 @@ static int efivarfs_fill_super(struct super_block *sb, void *data, int silent)
        sb->s_d_op              = &efivarfs_d_ops;
        sb->s_time_gran         = 1;
 
-       inode = efivarfs_get_inode(sb, NULL, S_IFDIR | 0755, 0);
+       inode = efivarfs_get_inode(sb, NULL, S_IFDIR | 0755, 0, true);
        if (!inode)
                return -ENOMEM;
        inode->i_op = &efivarfs_dir_inode_operations;
index 2c88d68..c1400b1 100644 (file)
@@ -80,23 +80,6 @@ static int ext2_dax_pmd_fault(struct vm_area_struct *vma, unsigned long addr,
        return ret;
 }
 
-static int ext2_dax_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
-{
-       struct inode *inode = file_inode(vma->vm_file);
-       struct ext2_inode_info *ei = EXT2_I(inode);
-       int ret;
-
-       sb_start_pagefault(inode->i_sb);
-       file_update_time(vma->vm_file);
-       down_read(&ei->dax_sem);
-
-       ret = __dax_mkwrite(vma, vmf, ext2_get_block, NULL);
-
-       up_read(&ei->dax_sem);
-       sb_end_pagefault(inode->i_sb);
-       return ret;
-}
-
 static int ext2_dax_pfn_mkwrite(struct vm_area_struct *vma,
                struct vm_fault *vmf)
 {
@@ -124,7 +107,7 @@ static int ext2_dax_pfn_mkwrite(struct vm_area_struct *vma,
 static const struct vm_operations_struct ext2_dax_vm_ops = {
        .fault          = ext2_dax_fault,
        .pmd_fault      = ext2_dax_pmd_fault,
-       .page_mkwrite   = ext2_dax_mkwrite,
+       .page_mkwrite   = ext2_dax_fault,
        .pfn_mkwrite    = ext2_dax_pfn_mkwrite,
 };
 
index 338eefd..6bd58e6 100644 (file)
@@ -737,8 +737,10 @@ static int ext2_get_blocks(struct inode *inode,
                 * so that it's not found by another thread before it's
                 * initialised
                 */
-               err = dax_clear_blocks(inode, le32_to_cpu(chain[depth-1].key),
-                                               1 << inode->i_blkbits);
+               err = dax_clear_sectors(inode->i_sb->s_bdev,
+                               le32_to_cpu(chain[depth-1].key) <<
+                               (inode->i_blkbits - 9),
+                               1 << inode->i_blkbits);
                if (err) {
                        mutex_unlock(&ei->truncate_mutex);
                        goto cleanup;
@@ -874,6 +876,14 @@ ext2_direct_IO(struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
 static int
 ext2_writepages(struct address_space *mapping, struct writeback_control *wbc)
 {
+#ifdef CONFIG_FS_DAX
+       if (dax_mapping(mapping)) {
+               return dax_writeback_mapping_range(mapping,
+                                                  mapping->host->i_sb->s_bdev,
+                                                  wbc);
+       }
+#endif
+
        return mpage_writepages(mapping, wbc, ext2_get_block);
 }
 
@@ -1296,7 +1306,7 @@ void ext2_set_inode_flags(struct inode *inode)
                inode->i_flags |= S_NOATIME;
        if (flags & EXT2_DIRSYNC_FL)
                inode->i_flags |= S_DIRSYNC;
-       if (test_opt(inode->i_sb, DAX))
+       if (test_opt(inode->i_sb, DAX) && S_ISREG(inode->i_mode))
                inode->i_flags |= S_DAX;
 }
 
index ec0668a..fe1f50f 100644 (file)
@@ -191,7 +191,6 @@ static int ext4_init_block_bitmap(struct super_block *sb,
        /* If checksum is bad mark all blocks used to prevent allocation
         * essentially implementing a per-group read-only flag. */
        if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) {
-               ext4_error(sb, "Checksum bad for group %u", block_group);
                grp = ext4_get_group_info(sb, block_group);
                if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp))
                        percpu_counter_sub(&sbi->s_freeclusters_counter,
@@ -442,14 +441,16 @@ ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
        }
        ext4_lock_group(sb, block_group);
        if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
-
                err = ext4_init_block_bitmap(sb, bh, block_group, desc);
                set_bitmap_uptodate(bh);
                set_buffer_uptodate(bh);
                ext4_unlock_group(sb, block_group);
                unlock_buffer(bh);
-               if (err)
+               if (err) {
+                       ext4_error(sb, "Failed to init block bitmap for group "
+                                  "%u: %d", block_group, err);
                        goto out;
+               }
                goto verify;
        }
        ext4_unlock_group(sb, block_group);
index c802120..38f7562 100644 (file)
@@ -467,3 +467,59 @@ uint32_t ext4_validate_encryption_key_size(uint32_t mode, uint32_t size)
                return size;
        return 0;
 }
+
+/*
+ * Validate dentries for encrypted directories to make sure we aren't
+ * potentially caching stale data after a key has been added or
+ * removed.
+ */
+static int ext4_d_revalidate(struct dentry *dentry, unsigned int flags)
+{
+       struct inode *dir = d_inode(dentry->d_parent);
+       struct ext4_crypt_info *ci = EXT4_I(dir)->i_crypt_info;
+       int dir_has_key, cached_with_key;
+
+       if (!ext4_encrypted_inode(dir))
+               return 0;
+
+       if (ci && ci->ci_keyring_key &&
+           (ci->ci_keyring_key->flags & ((1 << KEY_FLAG_INVALIDATED) |
+                                         (1 << KEY_FLAG_REVOKED) |
+                                         (1 << KEY_FLAG_DEAD))))
+               ci = NULL;
+
+       /* this should eventually be an flag in d_flags */
+       cached_with_key = dentry->d_fsdata != NULL;
+       dir_has_key = (ci != NULL);
+
+       /*
+        * If the dentry was cached without the key, and it is a
+        * negative dentry, it might be a valid name.  We can't check
+        * if the key has since been made available due to locking
+        * reasons, so we fail the validation so ext4_lookup() can do
+        * this check.
+        *
+        * We also fail the validation if the dentry was created with
+        * the key present, but we no longer have the key, or vice versa.
+        */
+       if ((!cached_with_key && d_is_negative(dentry)) ||
+           (!cached_with_key && dir_has_key) ||
+           (cached_with_key && !dir_has_key)) {
+#if 0                          /* Revalidation debug */
+               char buf[80];
+               char *cp = simple_dname(dentry, buf, sizeof(buf));
+
+               if (IS_ERR(cp))
+                       cp = (char *) "???";
+               pr_err("revalidate: %s %p %d %d %d\n", cp, dentry->d_fsdata,
+                      cached_with_key, d_is_negative(dentry),
+                      dir_has_key);
+#endif
+               return 0;
+       }
+       return 1;
+}
+
+const struct dentry_operations ext4_encrypted_d_ops = {
+       .d_revalidate = ext4_d_revalidate,
+};
index 1d1bca7..33f5e2a 100644 (file)
@@ -111,6 +111,12 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
        int dir_has_error = 0;
        struct ext4_str fname_crypto_str = {.name = NULL, .len = 0};
 
+       if (ext4_encrypted_inode(inode)) {
+               err = ext4_get_encryption_info(inode);
+               if (err && err != -ENOKEY)
+                       return err;
+       }
+
        if (is_dx_dir(inode)) {
                err = ext4_dx_readdir(file, ctx);
                if (err != ERR_BAD_DX_DIR) {
@@ -157,8 +163,11 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
                                        index, 1);
                        file->f_ra.prev_pos = (loff_t)index << PAGE_CACHE_SHIFT;
                        bh = ext4_bread(NULL, inode, map.m_lblk, 0);
-                       if (IS_ERR(bh))
-                               return PTR_ERR(bh);
+                       if (IS_ERR(bh)) {
+                               err = PTR_ERR(bh);
+                               bh = NULL;
+                               goto errout;
+                       }
                }
 
                if (!bh) {
index 0662b28..157b458 100644 (file)
@@ -2302,6 +2302,7 @@ struct page *ext4_encrypt(struct inode *inode,
 int ext4_decrypt(struct page *page);
 int ext4_encrypted_zeroout(struct inode *inode, ext4_lblk_t lblk,
                           ext4_fsblk_t pblk, ext4_lblk_t len);
+extern const struct dentry_operations ext4_encrypted_d_ops;
 
 #ifdef CONFIG_EXT4_FS_ENCRYPTION
 int ext4_init_crypto(void);
index 0ffabaf..3753ceb 100644 (file)
@@ -3928,7 +3928,7 @@ static int
 convert_initialized_extent(handle_t *handle, struct inode *inode,
                           struct ext4_map_blocks *map,
                           struct ext4_ext_path **ppath, int flags,
-                          unsigned int allocated, ext4_fsblk_t newblock)
+                          unsigned int allocated)
 {
        struct ext4_ext_path *path = *ppath;
        struct ext4_extent *ex;
@@ -4347,7 +4347,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
                            (flags & EXT4_GET_BLOCKS_CONVERT_UNWRITTEN)) {
                                allocated = convert_initialized_extent(
                                                handle, inode, map, &path,
-                                               flags, allocated, newblock);
+                                               flags, allocated);
                                goto out2;
                        } else if (!ext4_ext_is_unwritten(ex))
                                goto out;
index 1126436..4cd318f 100644 (file)
@@ -262,23 +262,8 @@ static int ext4_dax_pmd_fault(struct vm_area_struct *vma, unsigned long addr,
        return result;
 }
 
-static int ext4_dax_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
-{
-       int err;
-       struct inode *inode = file_inode(vma->vm_file);
-
-       sb_start_pagefault(inode->i_sb);
-       file_update_time(vma->vm_file);
-       down_read(&EXT4_I(inode)->i_mmap_sem);
-       err = __dax_mkwrite(vma, vmf, ext4_dax_mmap_get_block, NULL);
-       up_read(&EXT4_I(inode)->i_mmap_sem);
-       sb_end_pagefault(inode->i_sb);
-
-       return err;
-}
-
 /*
- * Handle write fault for VM_MIXEDMAP mappings. Similarly to ext4_dax_mkwrite()
+ * Handle write fault for VM_MIXEDMAP mappings. Similarly to ext4_dax_fault()
  * handler we check for races agaist truncate. Note that since we cycle through
  * i_mmap_sem, we are sure that also any hole punching that began before we
  * were called is finished by now and so if it included part of the file we
@@ -311,7 +296,7 @@ static int ext4_dax_pfn_mkwrite(struct vm_area_struct *vma,
 static const struct vm_operations_struct ext4_dax_vm_ops = {
        .fault          = ext4_dax_fault,
        .pmd_fault      = ext4_dax_pmd_fault,
-       .page_mkwrite   = ext4_dax_mkwrite,
+       .page_mkwrite   = ext4_dax_fault,
        .pfn_mkwrite    = ext4_dax_pfn_mkwrite,
 };
 #else
@@ -350,6 +335,7 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
        struct super_block *sb = inode->i_sb;
        struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
        struct vfsmount *mnt = filp->f_path.mnt;
+       struct inode *dir = filp->f_path.dentry->d_parent->d_inode;
        struct path path;
        char buf[64], *cp;
        int ret;
@@ -393,6 +379,14 @@ static int ext4_file_open(struct inode * inode, struct file * filp)
                if (ext4_encryption_info(inode) == NULL)
                        return -ENOKEY;
        }
+       if (ext4_encrypted_inode(dir) &&
+           !ext4_is_child_context_consistent_with_parent(dir, inode)) {
+               ext4_warning(inode->i_sb,
+                            "Inconsistent encryption contexts: %lu/%lu\n",
+                            (unsigned long) dir->i_ino,
+                            (unsigned long) inode->i_ino);
+               return -EPERM;
+       }
        /*
         * Set up the jbd2_inode if we are opening the inode for
         * writing and the journal is present
index 3fcfd50..acc0ad5 100644 (file)
@@ -76,7 +76,6 @@ static int ext4_init_inode_bitmap(struct super_block *sb,
        /* If checksum is bad mark all blocks and inodes use to prevent
         * allocation, essentially implementing a per-group read-only flag. */
        if (!ext4_group_desc_csum_verify(sb, block_group, gdp)) {
-               ext4_error(sb, "Checksum bad for group %u", block_group);
                grp = ext4_get_group_info(sb, block_group);
                if (!EXT4_MB_GRP_BBITMAP_CORRUPT(grp))
                        percpu_counter_sub(&sbi->s_freeclusters_counter,
@@ -191,8 +190,11 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
                set_buffer_verified(bh);
                ext4_unlock_group(sb, block_group);
                unlock_buffer(bh);
-               if (err)
+               if (err) {
+                       ext4_error(sb, "Failed to init inode bitmap for group "
+                                  "%u: %d", block_group, err);
                        goto out;
+               }
                return bh;
        }
        ext4_unlock_group(sb, block_group);
index 83bc8bf..aee960b 100644 (file)
@@ -686,6 +686,34 @@ out_sem:
        return retval;
 }
 
+/*
+ * Update EXT4_MAP_FLAGS in bh->b_state. For buffer heads attached to pages
+ * we have to be careful as someone else may be manipulating b_state as well.
+ */
+static void ext4_update_bh_state(struct buffer_head *bh, unsigned long flags)
+{
+       unsigned long old_state;
+       unsigned long new_state;
+
+       flags &= EXT4_MAP_FLAGS;
+
+       /* Dummy buffer_head? Set non-atomically. */
+       if (!bh->b_page) {
+               bh->b_state = (bh->b_state & ~EXT4_MAP_FLAGS) | flags;
+               return;
+       }
+       /*
+        * Someone else may be modifying b_state. Be careful! This is ugly but
+        * once we get rid of using bh as a container for mapping information
+        * to pass to / from get_block functions, this can go away.
+        */
+       do {
+               old_state = READ_ONCE(bh->b_state);
+               new_state = (old_state & ~EXT4_MAP_FLAGS) | flags;
+       } while (unlikely(
+                cmpxchg(&bh->b_state, old_state, new_state) != old_state));
+}
+
 /* Maximum number of blocks we map for direct IO at once. */
 #define DIO_MAX_BLOCKS 4096
 
@@ -722,7 +750,7 @@ static int _ext4_get_block(struct inode *inode, sector_t iblock,
                ext4_io_end_t *io_end = ext4_inode_aio(inode);
 
                map_bh(bh, inode->i_sb, map.m_pblk);
-               bh->b_state = (bh->b_state & ~EXT4_MAP_FLAGS) | map.m_flags;
+               ext4_update_bh_state(bh, map.m_flags);
                if (io_end && io_end->flag & EXT4_IO_END_UNWRITTEN)
                        set_buffer_defer_completion(bh);
                bh->b_size = inode->i_sb->s_blocksize * map.m_len;
@@ -1685,7 +1713,7 @@ int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
                return ret;
 
        map_bh(bh, inode->i_sb, map.m_pblk);
-       bh->b_state = (bh->b_state & ~EXT4_MAP_FLAGS) | map.m_flags;
+       ext4_update_bh_state(bh, map.m_flags);
 
        if (buffer_unwritten(bh)) {
                /* A delayed write to unwritten bh should be marked
@@ -2450,6 +2478,10 @@ static int ext4_writepages(struct address_space *mapping,
 
        trace_ext4_writepages(inode, wbc);
 
+       if (dax_mapping(mapping))
+               return dax_writeback_mapping_range(mapping, inode->i_sb->s_bdev,
+                                                  wbc);
+
        /*
         * No pages to write? This is mainly a kludge to avoid starting
         * a transaction for special inodes like journal inode on last iput()
@@ -3253,29 +3285,29 @@ static ssize_t ext4_ext_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
         * case, we allocate an io_end structure to hook to the iocb.
         */
        iocb->private = NULL;
-       ext4_inode_aio_set(inode, NULL);
-       if (!is_sync_kiocb(iocb)) {
-               io_end = ext4_init_io_end(inode, GFP_NOFS);
-               if (!io_end) {
-                       ret = -ENOMEM;
-                       goto retake_lock;
-               }
-               /*
-                * Grab reference for DIO. Will be dropped in ext4_end_io_dio()
-                */
-               iocb->private = ext4_get_io_end(io_end);
-               /*
-                * we save the io structure for current async direct
-                * IO, so that later ext4_map_blocks() could flag the
-                * io structure whether there is a unwritten extents
-                * needs to be converted when IO is completed.
-                */
-               ext4_inode_aio_set(inode, io_end);
-       }
-
        if (overwrite) {
                get_block_func = ext4_get_block_overwrite;
        } else {
+               ext4_inode_aio_set(inode, NULL);
+               if (!is_sync_kiocb(iocb)) {
+                       io_end = ext4_init_io_end(inode, GFP_NOFS);
+                       if (!io_end) {
+                               ret = -ENOMEM;
+                               goto retake_lock;
+                       }
+                       /*
+                        * Grab reference for DIO. Will be dropped in
+                        * ext4_end_io_dio()
+                        */
+                       iocb->private = ext4_get_io_end(io_end);
+                       /*
+                        * we save the io structure for current async direct
+                        * IO, so that later ext4_map_blocks() could flag the
+                        * io structure whether there is a unwritten extents
+                        * needs to be converted when IO is completed.
+                        */
+                       ext4_inode_aio_set(inode, io_end);
+               }
                get_block_func = ext4_get_block_write;
                dio_flags = DIO_LOCKING;
        }
@@ -4127,7 +4159,7 @@ void ext4_set_inode_flags(struct inode *inode)
                new_fl |= S_NOATIME;
        if (flags & EXT4_DIRSYNC_FL)
                new_fl |= S_DIRSYNC;
-       if (test_opt(inode->i_sb, DAX))
+       if (test_opt(inode->i_sb, DAX) && S_ISREG(inode->i_mode))
                new_fl |= S_DAX;
        inode_set_flags(inode, new_fl,
                        S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_DAX);
index 0f6c369..eae5917 100644 (file)
@@ -208,7 +208,7 @@ static int ext4_ioctl_setflags(struct inode *inode,
 {
        struct ext4_inode_info *ei = EXT4_I(inode);
        handle_t *handle = NULL;
-       int err = EPERM, migrate = 0;
+       int err = -EPERM, migrate = 0;
        struct ext4_iloc iloc;
        unsigned int oldflags, mask, i;
        unsigned int jflag;
@@ -583,6 +583,11 @@ group_extend_out:
                                 "Online defrag not supported with bigalloc");
                        err = -EOPNOTSUPP;
                        goto mext_out;
+               } else if (IS_DAX(inode)) {
+                       ext4_msg(sb, KERN_ERR,
+                                "Online defrag not supported with DAX");
+                       err = -EOPNOTSUPP;
+                       goto mext_out;
                }
 
                err = mnt_want_write_file(filp);
index 61eaf74..4424b7b 100644 (file)
@@ -2285,7 +2285,7 @@ static int ext4_mb_seq_groups_show(struct seq_file *seq, void *v)
        if (group == 0)
                seq_puts(seq, "#group: free  frags first ["
                              " 2^0   2^1   2^2   2^3   2^4   2^5   2^6  "
-                             " 2^7   2^8   2^9   2^10  2^11  2^12  2^13  ]");
+                             " 2^7   2^8   2^9   2^10  2^11  2^12  2^13  ]\n");
 
        i = (sb->s_blocksize_bits + 2) * sizeof(sg.info.bb_counters[0]) +
                sizeof(struct ext4_group_info);
index fb6f117..4098acc 100644 (file)
@@ -265,11 +265,12 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
        ext4_lblk_t orig_blk_offset, donor_blk_offset;
        unsigned long blocksize = orig_inode->i_sb->s_blocksize;
        unsigned int tmp_data_size, data_size, replaced_size;
-       int err2, jblocks, retries = 0;
+       int i, err2, jblocks, retries = 0;
        int replaced_count = 0;
        int from = data_offset_in_page << orig_inode->i_blkbits;
        int blocks_per_page = PAGE_CACHE_SIZE >> orig_inode->i_blkbits;
        struct super_block *sb = orig_inode->i_sb;
+       struct buffer_head *bh = NULL;
 
        /*
         * It needs twice the amount of ordinary journal buffers because
@@ -380,8 +381,17 @@ data_copy:
        }
        /* Perform all necessary steps similar write_begin()/write_end()
         * but keeping in mind that i_size will not change */
-       *err = __block_write_begin(pagep[0], from, replaced_size,
-                                  ext4_get_block);
+       if (!page_has_buffers(pagep[0]))
+               create_empty_buffers(pagep[0], 1 << orig_inode->i_blkbits, 0);
+       bh = page_buffers(pagep[0]);
+       for (i = 0; i < data_offset_in_page; i++)
+               bh = bh->b_this_page;
+       for (i = 0; i < block_len_in_page; i++) {
+               *err = ext4_get_block(orig_inode, orig_blk_offset + i, bh, 0);
+               if (*err < 0)
+                       break;
+               bh = bh->b_this_page;
+       }
        if (!*err)
                *err = block_commit_write(pagep[0], from, from + replaced_size);
 
index 06574dd..48e4b89 100644 (file)
@@ -1558,6 +1558,24 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
        struct ext4_dir_entry_2 *de;
        struct buffer_head *bh;
 
+       if (ext4_encrypted_inode(dir)) {
+               int res = ext4_get_encryption_info(dir);
+
+               /*
+                * This should be a properly defined flag for
+                * dentry->d_flags when we uplift this to the VFS.
+                * d_fsdata is set to (void *) 1 if if the dentry is
+                * created while the directory was encrypted and we
+                * don't have access to the key.
+                */
+              dentry->d_fsdata = NULL;
+              if (ext4_encryption_info(dir))
+                      dentry->d_fsdata = (void *) 1;
+              d_set_d_op(dentry, &ext4_encrypted_d_ops);
+              if (res && res != -ENOKEY)
+                      return ERR_PTR(res);
+       }
+
        if (dentry->d_name.len > EXT4_NAME_LEN)
                return ERR_PTR(-ENAMETOOLONG);
 
@@ -1585,11 +1603,15 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
                        return ERR_PTR(-EFSCORRUPTED);
                }
                if (!IS_ERR(inode) && ext4_encrypted_inode(dir) &&
-                   (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
-                    S_ISLNK(inode->i_mode)) &&
+                   (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
                    !ext4_is_child_context_consistent_with_parent(dir,
                                                                  inode)) {
+                       int nokey = ext4_encrypted_inode(inode) &&
+                               !ext4_encryption_info(inode);
+
                        iput(inode);
+                       if (nokey)
+                               return ERR_PTR(-ENOKEY);
                        ext4_warning(inode->i_sb,
                                     "Inconsistent encryption contexts: %lu/%lu\n",
                                     (unsigned long) dir->i_ino,
index ad62d7a..34038e3 100644 (file)
@@ -198,7 +198,7 @@ static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned long flexbg_size)
        if (flex_gd == NULL)
                goto out3;
 
-       if (flexbg_size >= UINT_MAX / sizeof(struct ext4_new_flex_group_data))
+       if (flexbg_size >= UINT_MAX / sizeof(struct ext4_new_group_data))
                goto out2;
        flex_gd->count = flexbg_size;
 
index 6915c95..5c46ed9 100644 (file)
@@ -223,6 +223,9 @@ static void wb_wait_for_completion(struct backing_dev_info *bdi,
 #define WB_FRN_HIST_MAX_SLOTS  (WB_FRN_HIST_THR_SLOTS / 2 + 1)
                                        /* one round can affect upto 5 slots */
 
+static atomic_t isw_nr_in_flight = ATOMIC_INIT(0);
+static struct workqueue_struct *isw_wq;
+
 void __inode_attach_wb(struct inode *inode, struct page *page)
 {
        struct backing_dev_info *bdi = inode_to_bdi(inode);
@@ -424,6 +427,8 @@ skip_switch:
 
        iput(inode);
        kfree(isw);
+
+       atomic_dec(&isw_nr_in_flight);
 }
 
 static void inode_switch_wbs_rcu_fn(struct rcu_head *rcu_head)
@@ -433,7 +438,7 @@ static void inode_switch_wbs_rcu_fn(struct rcu_head *rcu_head)
 
        /* needs to grab bh-unsafe locks, bounce to work item */
        INIT_WORK(&isw->work, inode_switch_wbs_work_fn);
-       schedule_work(&isw->work);
+       queue_work(isw_wq, &isw->work);
 }
 
 /**
@@ -469,7 +474,8 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
 
        /* while holding I_WB_SWITCH, no one else can update the association */
        spin_lock(&inode->i_lock);
-       if (inode->i_state & (I_WB_SWITCH | I_FREEING) ||
+       if (!(inode->i_sb->s_flags & MS_ACTIVE) ||
+           inode->i_state & (I_WB_SWITCH | I_FREEING) ||
            inode_to_wb(inode) == isw->new_wb) {
                spin_unlock(&inode->i_lock);
                goto out_free;
@@ -480,6 +486,8 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
        ihold(inode);
        isw->inode = inode;
 
+       atomic_inc(&isw_nr_in_flight);
+
        /*
         * In addition to synchronizing among switchers, I_WB_SWITCH tells
         * the RCU protected stat update paths to grab the mapping's
@@ -840,6 +848,33 @@ restart:
                wb_put(last_wb);
 }
 
+/**
+ * cgroup_writeback_umount - flush inode wb switches for umount
+ *
+ * This function is called when a super_block is about to be destroyed and
+ * flushes in-flight inode wb switches.  An inode wb switch goes through
+ * RCU and then workqueue, so the two need to be flushed in order to ensure
+ * that all previously scheduled switches are finished.  As wb switches are
+ * rare occurrences and synchronize_rcu() can take a while, perform
+ * flushing iff wb switches are in flight.
+ */
+void cgroup_writeback_umount(void)
+{
+       if (atomic_read(&isw_nr_in_flight)) {
+               synchronize_rcu();
+               flush_workqueue(isw_wq);
+       }
+}
+
+static int __init cgroup_writeback_init(void)
+{
+       isw_wq = alloc_workqueue("inode_switch_wbs", 0, 0);
+       if (!isw_wq)
+               return -ENOMEM;
+       return 0;
+}
+fs_initcall(cgroup_writeback_init);
+
 #else  /* CONFIG_CGROUP_WRITEBACK */
 
 static struct bdi_writeback *
index 506765a..bb8d67e 100644 (file)
@@ -376,12 +376,11 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
        struct inode *inode = d_inode(dentry);
        dnode_secno dno;
        int r;
-       int rep = 0;
        int err;
 
        hpfs_lock(dir->i_sb);
        hpfs_adjust_length(name, &len);
-again:
+
        err = -ENOENT;
        de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh);
        if (!de)
@@ -401,33 +400,9 @@ again:
                hpfs_error(dir->i_sb, "there was error when removing dirent");
                err = -EFSERROR;
                break;
-       case 2:         /* no space for deleting, try to truncate file */
-
+       case 2:         /* no space for deleting */
                err = -ENOSPC;
-               if (rep++)
-                       break;
-
-               dentry_unhash(dentry);
-               if (!d_unhashed(dentry)) {
-                       hpfs_unlock(dir->i_sb);
-                       return -ENOSPC;
-               }
-               if (generic_permission(inode, MAY_WRITE) ||
-                   !S_ISREG(inode->i_mode) ||
-                   get_write_access(inode)) {
-                       d_rehash(dentry);
-               } else {
-                       struct iattr newattrs;
-                       /*pr_info("truncating file before delete.\n");*/
-                       newattrs.ia_size = 0;
-                       newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
-                       err = notify_change(dentry, &newattrs, NULL);
-                       put_write_access(inode);
-                       if (!err)
-                               goto again;
-               }
-               hpfs_unlock(dir->i_sb);
-               return -ENOSPC;
+               break;
        default:
                drop_nlink(inode);
                err = 0;
index 9f62db3..69b8b52 100644 (file)
@@ -154,6 +154,12 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
        inode->i_rdev = 0;
        inode->dirtied_when = 0;
 
+#ifdef CONFIG_CGROUP_WRITEBACK
+       inode->i_wb_frn_winner = 0;
+       inode->i_wb_frn_avg_time = 0;
+       inode->i_wb_frn_history = 0;
+#endif
+
        if (security_inode_alloc(inode))
                goto out;
        spin_lock_init(&inode->i_lock);
index 3ea3655..8918ac9 100644 (file)
@@ -2,10 +2,6 @@
        JFFS2 LOCKING DOCUMENTATION
        ---------------------------
 
-At least theoretically, JFFS2 does not require the Big Kernel Lock
-(BKL), which was always helpfully obtained for it by Linux 2.4 VFS
-code. It has its own locking, as described below.
-
 This document attempts to describe the existing locking rules for
 JFFS2. It is not expected to remain perfectly up to date, but ought to
 be fairly close.
@@ -69,6 +65,7 @@ Ordering constraints:
           any f->sem held.
        2. Never attempt to lock two file mutexes in one thread.
           No ordering rules have been made for doing so.
+       3. Never lock a page cache page with f->sem held.
 
 
        erase_completion_lock spinlock
index 0ae91ad..b288c8a 100644 (file)
@@ -50,7 +50,8 @@ next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c)
 
 
 static void jffs2_build_inode_pass1(struct jffs2_sb_info *c,
-                                   struct jffs2_inode_cache *ic)
+                                   struct jffs2_inode_cache *ic,
+                                   int *dir_hardlinks)
 {
        struct jffs2_full_dirent *fd;
 
@@ -69,19 +70,21 @@ static void jffs2_build_inode_pass1(struct jffs2_sb_info *c,
                        dbg_fsbuild("child \"%s\" (ino #%u) of dir ino #%u doesn't exist!\n",
                                  fd->name, fd->ino, ic->ino);
                        jffs2_mark_node_obsolete(c, fd->raw);
+                       /* Clear the ic/raw union so it doesn't cause problems later. */
+                       fd->ic = NULL;
                        continue;
                }
 
+               /* From this point, fd->raw is no longer used so we can set fd->ic */
+               fd->ic = child_ic;
+               child_ic->pino_nlink++;
+               /* If we appear (at this stage) to have hard-linked directories,
+                * set a flag to trigger a scan later */
                if (fd->type == DT_DIR) {
-                       if (child_ic->pino_nlink) {
-                               JFFS2_ERROR("child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n",
-                                           fd->name, fd->ino, ic->ino);
-                               /* TODO: What do we do about it? */
-                       } else {
-                               child_ic->pino_nlink = ic->ino;
-                       }
-               } else
-                       child_ic->pino_nlink++;
+                       child_ic->flags |= INO_FLAGS_IS_DIR;
+                       if (child_ic->pino_nlink > 1)
+                               *dir_hardlinks = 1;
+               }
 
                dbg_fsbuild("increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino);
                /* Can't free scan_dents so far. We might need them in pass 2 */
@@ -95,8 +98,7 @@ static void jffs2_build_inode_pass1(struct jffs2_sb_info *c,
 */
 static int jffs2_build_filesystem(struct jffs2_sb_info *c)
 {
-       int ret;
-       int i;
+       int ret, i, dir_hardlinks = 0;
        struct jffs2_inode_cache *ic;
        struct jffs2_full_dirent *fd;
        struct jffs2_full_dirent *dead_fds = NULL;
@@ -120,7 +122,7 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
        /* Now scan the directory tree, increasing nlink according to every dirent found. */
        for_each_inode(i, c, ic) {
                if (ic->scan_dents) {
-                       jffs2_build_inode_pass1(c, ic);
+                       jffs2_build_inode_pass1(c, ic, &dir_hardlinks);
                        cond_resched();
                }
        }
@@ -156,6 +158,20 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
        }
 
        dbg_fsbuild("pass 2a complete\n");
+
+       if (dir_hardlinks) {
+               /* If we detected directory hardlinks earlier, *hopefully*
+                * they are gone now because some of the links were from
+                * dead directories which still had some old dirents lying
+                * around and not yet garbage-collected, but which have
+                * been discarded above. So clear the pino_nlink field
+                * in each directory, so that the final scan below can
+                * print appropriate warnings. */
+               for_each_inode(i, c, ic) {
+                       if (ic->flags & INO_FLAGS_IS_DIR)
+                               ic->pino_nlink = 0;
+               }
+       }
        dbg_fsbuild("freeing temporary data structures\n");
 
        /* Finally, we can scan again and free the dirent structs */
@@ -163,6 +179,33 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
                while(ic->scan_dents) {
                        fd = ic->scan_dents;
                        ic->scan_dents = fd->next;
+                       /* We do use the pino_nlink field to count nlink of
+                        * directories during fs build, so set it to the
+                        * parent ino# now. Now that there's hopefully only
+                        * one. */
+                       if (fd->type == DT_DIR) {
+                               if (!fd->ic) {
+                                       /* We'll have complained about it and marked the coresponding
+                                          raw node obsolete already. Just skip it. */
+                                       continue;
+                               }
+
+                               /* We *have* to have set this in jffs2_build_inode_pass1() */
+                               BUG_ON(!(fd->ic->flags & INO_FLAGS_IS_DIR));
+
+                               /* We clear ic->pino_nlink ∀ directories' ic *only* if dir_hardlinks
+                                * is set. Otherwise, we know this should never trigger anyway, so
+                                * we don't do the check. And ic->pino_nlink still contains the nlink
+                                * value (which is 1). */
+                               if (dir_hardlinks && fd->ic->pino_nlink) {
+                                       JFFS2_ERROR("child dir \"%s\" (ino #%u) of dir ino #%u is also hard linked from dir ino #%u\n",
+                                                   fd->name, fd->ino, ic->ino, fd->ic->pino_nlink);
+                                       /* Should we unlink it from its previous parent? */
+                               }
+
+                               /* For directories, ic->pino_nlink holds that parent inode # */
+                               fd->ic->pino_nlink = ic->ino;
+                       }
                        jffs2_free_full_dirent(fd);
                }
                ic->scan_dents = NULL;
@@ -241,11 +284,7 @@ static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c,
 
                        /* Reduce nlink of the child. If it's now zero, stick it on the
                           dead_fds list to be cleaned up later. Else just free the fd */
-
-                       if (fd->type == DT_DIR)
-                               child_ic->pino_nlink = 0;
-                       else
-                               child_ic->pino_nlink--;
+                       child_ic->pino_nlink--;
 
                        if (!child_ic->pino_nlink) {
                                dbg_fsbuild("inode #%u (\"%s\") now has no links; adding to dead_fds list.\n",
index d211b8e..30c4c9e 100644 (file)
@@ -843,9 +843,14 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
 
                pr_notice("%s(): Link succeeded, unlink failed (err %d). You now have a hard link\n",
                          __func__, ret);
-               /* Might as well let the VFS know */
-               d_instantiate(new_dentry, d_inode(old_dentry));
-               ihold(d_inode(old_dentry));
+               /*
+                * We can't keep the target in dcache after that.
+                * For one thing, we can't afford dentry aliases for directories.
+                * For another, if there was a victim, we _can't_ set new inode
+                * for that sucker and we have to trigger mount eviction - the
+                * caller won't do it on its own since we are returning an error.
+                */
+               d_invalidate(new_dentry);
                new_dir_i->i_mtime = new_dir_i->i_ctime = ITIME(now);
                return ret;
        }
index c5ac594..cad86ba 100644 (file)
@@ -137,39 +137,33 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
        struct page *pg;
        struct inode *inode = mapping->host;
        struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
-       struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
-       struct jffs2_raw_inode ri;
-       uint32_t alloc_len = 0;
        pgoff_t index = pos >> PAGE_CACHE_SHIFT;
        uint32_t pageofs = index << PAGE_CACHE_SHIFT;
        int ret = 0;
 
-       jffs2_dbg(1, "%s()\n", __func__);
-
-       if (pageofs > inode->i_size) {
-               ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
-                                         ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
-               if (ret)
-                       return ret;
-       }
-
-       mutex_lock(&f->sem);
        pg = grab_cache_page_write_begin(mapping, index, flags);
-       if (!pg) {
-               if (alloc_len)
-                       jffs2_complete_reservation(c);
-               mutex_unlock(&f->sem);
+       if (!pg)
                return -ENOMEM;
-       }
        *pagep = pg;
 
-       if (alloc_len) {
+       jffs2_dbg(1, "%s()\n", __func__);
+
+       if (pageofs > inode->i_size) {
                /* Make new hole frag from old EOF to new page */
+               struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+               struct jffs2_raw_inode ri;
                struct jffs2_full_dnode *fn;
+               uint32_t alloc_len;
 
                jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
                          (unsigned int)inode->i_size, pageofs);
 
+               ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
+                                         ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
+               if (ret)
+                       goto out_page;
+
+               mutex_lock(&f->sem);
                memset(&ri, 0, sizeof(ri));
 
                ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -196,6 +190,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
                if (IS_ERR(fn)) {
                        ret = PTR_ERR(fn);
                        jffs2_complete_reservation(c);
+                       mutex_unlock(&f->sem);
                        goto out_page;
                }
                ret = jffs2_add_full_dnode_to_inode(c, f, fn);
@@ -210,10 +205,12 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
                        jffs2_mark_node_obsolete(c, fn->raw);
                        jffs2_free_full_dnode(fn);
                        jffs2_complete_reservation(c);
+                       mutex_unlock(&f->sem);
                        goto out_page;
                }
                jffs2_complete_reservation(c);
                inode->i_size = pageofs;
+               mutex_unlock(&f->sem);
        }
 
        /*
@@ -222,18 +219,18 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
         * case of a short-copy.
         */
        if (!PageUptodate(pg)) {
+               mutex_lock(&f->sem);
                ret = jffs2_do_readpage_nolock(inode, pg);
+               mutex_unlock(&f->sem);
                if (ret)
                        goto out_page;
        }
-       mutex_unlock(&f->sem);
        jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
        return ret;
 
 out_page:
        unlock_page(pg);
        page_cache_release(pg);
-       mutex_unlock(&f->sem);
        return ret;
 }
 
index 5a2dec2..95d5880 100644 (file)
@@ -1296,14 +1296,17 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era
                BUG_ON(start > orig_start);
        }
 
-       /* First, use readpage() to read the appropriate page into the page cache */
-       /* Q: What happens if we actually try to GC the _same_ page for which commit_write()
-        *    triggered garbage collection in the first place?
-        * A: I _think_ it's OK. read_cache_page shouldn't deadlock, we'll write out the
-        *    page OK. We'll actually write it out again in commit_write, which is a little
-        *    suboptimal, but at least we're correct.
-        */
+       /* The rules state that we must obtain the page lock *before* f->sem, so
+        * drop f->sem temporarily. Since we also hold c->alloc_sem, nothing's
+        * actually going to *change* so we're safe; we only allow reading.
+        *
+        * It is important to note that jffs2_write_begin() will ensure that its
+        * page is marked Uptodate before allocating space. That means that if we
+        * end up here trying to GC the *same* page that jffs2_write_begin() is
+        * trying to write out, read_cache_page() will not deadlock. */
+       mutex_unlock(&f->sem);
        pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg);
+       mutex_lock(&f->sem);
 
        if (IS_ERR(pg_ptr)) {
                pr_warn("read_cache_page() returned error: %ld\n",
index fa35ff7..0637271 100644 (file)
@@ -194,6 +194,7 @@ struct jffs2_inode_cache {
 #define INO_STATE_CLEARING     6       /* In clear_inode() */
 
 #define INO_FLAGS_XATTR_CHECKED        0x01    /* has no duplicate xattr_ref */
+#define INO_FLAGS_IS_DIR       0x02    /* is a directory */
 
 #define RAWNODE_CLASS_INODE_CACHE      0
 #define RAWNODE_CLASS_XATTR_DATUM      1
@@ -249,7 +250,10 @@ struct jffs2_readinode_info
 
 struct jffs2_full_dirent
 {
-       struct jffs2_raw_node_ref *raw;
+       union {
+               struct jffs2_raw_node_ref *raw;
+               struct jffs2_inode_cache *ic; /* Just during part of build */
+       };
        struct jffs2_full_dirent *next;
        uint32_t version;
        uint32_t ino; /* == zero for unlink */
index f624d13..9c590e0 100644 (file)
@@ -1712,6 +1712,11 @@ static inline int should_follow_link(struct nameidata *nd, struct path *link,
                return 0;
        if (!follow)
                return 0;
+       /* make sure that d_is_symlink above matches inode */
+       if (nd->flags & LOOKUP_RCU) {
+               if (read_seqcount_retry(&link->dentry->d_seq, seq))
+                       return -ECHILD;
+       }
        return pick_link(nd, link, inode, seq);
 }
 
@@ -1743,11 +1748,11 @@ static int walk_component(struct nameidata *nd, int flags)
                if (err < 0)
                        return err;
 
-               inode = d_backing_inode(path.dentry);
                seq = 0;        /* we are already out of RCU mode */
                err = -ENOENT;
                if (d_is_negative(path.dentry))
                        goto out_path_put;
+               inode = d_backing_inode(path.dentry);
        }
 
        if (flags & WALK_PUT)
@@ -3192,12 +3197,12 @@ retry_lookup:
                return error;
 
        BUG_ON(nd->flags & LOOKUP_RCU);
-       inode = d_backing_inode(path.dentry);
        seq = 0;        /* out of RCU mode, so the value doesn't matter */
        if (unlikely(d_is_negative(path.dentry))) {
                path_to_nameidata(&path, nd);
                return -ENOENT;
        }
+       inode = d_backing_inode(path.dentry);
 finish_lookup:
        if (nd->depth)
                put_link(nd);
@@ -3206,11 +3211,6 @@ finish_lookup:
        if (unlikely(error))
                return error;
 
-       if (unlikely(d_is_symlink(path.dentry)) && !(open_flag & O_PATH)) {
-               path_to_nameidata(&path, nd);
-               return -ELOOP;
-       }
-
        if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path.mnt) {
                path_to_nameidata(&path, nd);
        } else {
@@ -3229,6 +3229,10 @@ finish_open:
                return error;
        }
        audit_inode(nd->name, nd->path.dentry, 0);
+       if (unlikely(d_is_symlink(nd->path.dentry)) && !(open_flag & O_PATH)) {
+               error = -ELOOP;
+               goto out;
+       }
        error = -EISDIR;
        if ((open_flag & O_CREAT) && d_is_dir(nd->path.dentry))
                goto out;
@@ -3273,6 +3277,10 @@ opened:
                        goto exit_fput;
        }
 out:
+       if (unlikely(error > 0)) {
+               WARN_ON(1);
+               error = -EINVAL;
+       }
        if (got_write)
                mnt_drop_write(nd->path.mnt);
        path_put(&save_parent);
index 26c2de2..b7f8eae 100644 (file)
@@ -633,7 +633,7 @@ ncp_fill_cache(struct file *file, struct dir_context *ctx,
                                d_rehash(newdent);
                } else {
                        spin_lock(&dentry->d_lock);
-                       NCP_FINFO(inode)->flags &= ~NCPI_DIR_CACHE;
+                       NCP_FINFO(dir)->flags &= ~NCPI_DIR_CACHE;
                        spin_unlock(&dentry->d_lock);
                }
        } else {
index c59a59c..35ab51c 100644 (file)
@@ -476,6 +476,7 @@ static void ext_tree_free_commitdata(struct nfs4_layoutcommit_args *arg,
 
                for (i = 0; i < nr_pages; i++)
                        put_page(arg->layoutupdate_pages[i]);
+               vfree(arg->start_p);
                kfree(arg->layoutupdate_pages);
        } else {
                put_page(arg->layoutupdate_page);
@@ -559,10 +560,15 @@ retry:
 
        if (unlikely(arg->layoutupdate_pages != &arg->layoutupdate_page)) {
                void *p = start_p, *end = p + arg->layoutupdate_len;
+               struct page *page = NULL;
                int i = 0;
 
-               for ( ; p < end; p += PAGE_SIZE)
-                       arg->layoutupdate_pages[i++] = vmalloc_to_page(p);
+               arg->start_p = start_p;
+               for ( ; p < end; p += PAGE_SIZE) {
+                       page = vmalloc_to_page(p);
+                       arg->layoutupdate_pages[i++] = page;
+                       get_page(page);
+               }
        }
 
        dprintk("%s found %zu ranges\n", __func__, count);
index bd25dc7..dff8346 100644 (file)
 
 #define NFSDBG_FACILITY NFSDBG_PROC
 
-static int nfs42_set_rw_stateid(nfs4_stateid *dst, struct file *file,
-                               fmode_t fmode)
-{
-       struct nfs_open_context *open;
-       struct nfs_lock_context *lock;
-       int ret;
-
-       open = get_nfs_open_context(nfs_file_open_context(file));
-       lock = nfs_get_lock_context(open);
-       if (IS_ERR(lock)) {
-               put_nfs_open_context(open);
-               return PTR_ERR(lock);
-       }
-
-       ret = nfs4_set_rw_stateid(dst, open, lock, fmode);
-
-       nfs_put_lock_context(lock);
-       put_nfs_open_context(open);
-       return ret;
-}
-
 static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
-                                loff_t offset, loff_t len)
+               struct nfs_lock_context *lock, loff_t offset, loff_t len)
 {
        struct inode *inode = file_inode(filep);
        struct nfs_server *server = NFS_SERVER(inode);
@@ -56,7 +35,8 @@ static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
        msg->rpc_argp = &args;
        msg->rpc_resp = &res;
 
-       status = nfs42_set_rw_stateid(&args.falloc_stateid, filep, FMODE_WRITE);
+       status = nfs4_set_rw_stateid(&args.falloc_stateid, lock->open_context,
+                       lock, FMODE_WRITE);
        if (status)
                return status;
 
@@ -78,15 +58,26 @@ static int nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
 {
        struct nfs_server *server = NFS_SERVER(file_inode(filep));
        struct nfs4_exception exception = { };
+       struct nfs_lock_context *lock;
        int err;
 
+       lock = nfs_get_lock_context(nfs_file_open_context(filep));
+       if (IS_ERR(lock))
+               return PTR_ERR(lock);
+
+       exception.inode = file_inode(filep);
+       exception.state = lock->open_context->state;
+
        do {
-               err = _nfs42_proc_fallocate(msg, filep, offset, len);
-               if (err == -ENOTSUPP)
-                       return -EOPNOTSUPP;
+               err = _nfs42_proc_fallocate(msg, filep, lock, offset, len);
+               if (err == -ENOTSUPP) {
+                       err = -EOPNOTSUPP;
+                       break;
+               }
                err = nfs4_handle_exception(server, err, &exception);
        } while (exception.retry);
 
+       nfs_put_lock_context(lock);
        return err;
 }
 
@@ -135,7 +126,8 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len)
        return err;
 }
 
-static loff_t _nfs42_proc_llseek(struct file *filep, loff_t offset, int whence)
+static loff_t _nfs42_proc_llseek(struct file *filep,
+               struct nfs_lock_context *lock, loff_t offset, int whence)
 {
        struct inode *inode = file_inode(filep);
        struct nfs42_seek_args args = {
@@ -156,7 +148,8 @@ static loff_t _nfs42_proc_llseek(struct file *filep, loff_t offset, int whence)
        if (!nfs_server_capable(inode, NFS_CAP_SEEK))
                return -ENOTSUPP;
 
-       status = nfs42_set_rw_stateid(&args.sa_stateid, filep, FMODE_READ);
+       status = nfs4_set_rw_stateid(&args.sa_stateid, lock->open_context,
+                       lock, FMODE_READ);
        if (status)
                return status;
 
@@ -175,17 +168,28 @@ loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence)
 {
        struct nfs_server *server = NFS_SERVER(file_inode(filep));
        struct nfs4_exception exception = { };
+       struct nfs_lock_context *lock;
        loff_t err;
 
+       lock = nfs_get_lock_context(nfs_file_open_context(filep));
+       if (IS_ERR(lock))
+               return PTR_ERR(lock);
+
+       exception.inode = file_inode(filep);
+       exception.state = lock->open_context->state;
+
        do {
-               err = _nfs42_proc_llseek(filep, offset, whence);
+               err = _nfs42_proc_llseek(filep, lock, offset, whence);
                if (err >= 0)
                        break;
-               if (err == -ENOTSUPP)
-                       return -EOPNOTSUPP;
+               if (err == -ENOTSUPP) {
+                       err = -EOPNOTSUPP;
+                       break;
+               }
                err = nfs4_handle_exception(server, err, &exception);
        } while (exception.retry);
 
+       nfs_put_lock_context(lock);
        return err;
 }
 
@@ -298,8 +302,9 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *server,
 }
 
 static int _nfs42_proc_clone(struct rpc_message *msg, struct file *src_f,
-                            struct file *dst_f, loff_t src_offset,
-                            loff_t dst_offset, loff_t count)
+               struct file *dst_f, struct nfs_lock_context *src_lock,
+               struct nfs_lock_context *dst_lock, loff_t src_offset,
+               loff_t dst_offset, loff_t count)
 {
        struct inode *src_inode = file_inode(src_f);
        struct inode *dst_inode = file_inode(dst_f);
@@ -320,11 +325,13 @@ static int _nfs42_proc_clone(struct rpc_message *msg, struct file *src_f,
        msg->rpc_argp = &args;
        msg->rpc_resp = &res;
 
-       status = nfs42_set_rw_stateid(&args.src_stateid, src_f, FMODE_READ);
+       status = nfs4_set_rw_stateid(&args.src_stateid, src_lock->open_context,
+                       src_lock, FMODE_READ);
        if (status)
                return status;
 
-       status = nfs42_set_rw_stateid(&args.dst_stateid, dst_f, FMODE_WRITE);
+       status = nfs4_set_rw_stateid(&args.dst_stateid, dst_lock->open_context,
+                       dst_lock, FMODE_WRITE);
        if (status)
                return status;
 
@@ -349,22 +356,48 @@ int nfs42_proc_clone(struct file *src_f, struct file *dst_f,
        };
        struct inode *inode = file_inode(src_f);
        struct nfs_server *server = NFS_SERVER(file_inode(src_f));
-       struct nfs4_exception exception = { };
-       int err;
+       struct nfs_lock_context *src_lock;
+       struct nfs_lock_context *dst_lock;
+       struct nfs4_exception src_exception = { };
+       struct nfs4_exception dst_exception = { };
+       int err, err2;
 
        if (!nfs_server_capable(inode, NFS_CAP_CLONE))
                return -EOPNOTSUPP;
 
+       src_lock = nfs_get_lock_context(nfs_file_open_context(src_f));
+       if (IS_ERR(src_lock))
+               return PTR_ERR(src_lock);
+
+       src_exception.inode = file_inode(src_f);
+       src_exception.state = src_lock->open_context->state;
+
+       dst_lock = nfs_get_lock_context(nfs_file_open_context(dst_f));
+       if (IS_ERR(dst_lock)) {
+               err = PTR_ERR(dst_lock);
+               goto out_put_src_lock;
+       }
+
+       dst_exception.inode = file_inode(dst_f);
+       dst_exception.state = dst_lock->open_context->state;
+
        do {
-               err = _nfs42_proc_clone(&msg, src_f, dst_f, src_offset,
-                                       dst_offset, count);
+               err = _nfs42_proc_clone(&msg, src_f, dst_f, src_lock, dst_lock,
+                                       src_offset, dst_offset, count);
                if (err == -ENOTSUPP || err == -EOPNOTSUPP) {
                        NFS_SERVER(inode)->caps &= ~NFS_CAP_CLONE;
-                       return -EOPNOTSUPP;
+                       err = -EOPNOTSUPP;
+                       break;
                }
-               err = nfs4_handle_exception(server, err, &exception);
-       } while (exception.retry);
 
-       return err;
+               err2 = nfs4_handle_exception(server, err, &src_exception);
+               err = nfs4_handle_exception(server, err, &dst_exception);
+               if (!err)
+                       err = err2;
+       } while (src_exception.retry || dst_exception.retry);
 
+       nfs_put_lock_context(dst_lock);
+out_put_src_lock:
+       nfs_put_lock_context(src_lock);
+       return err;
 }
index 4bfc33a..1488159 100644 (file)
@@ -2466,9 +2466,9 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
                dentry = d_add_unique(dentry, igrab(state->inode));
                if (dentry == NULL) {
                        dentry = opendata->dentry;
-               } else if (dentry != ctx->dentry) {
+               } else {
                        dput(ctx->dentry);
-                       ctx->dentry = dget(dentry);
+                       ctx->dentry = dentry;
                }
                nfs_set_verifier(dentry,
                                nfs_save_change_attribute(d_inode(opendata->dir)));
index 482b6e9..2fa483e 100644 (file)
@@ -252,6 +252,27 @@ pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo)
        }
 }
 
+/*
+ * Mark a pnfs_layout_hdr and all associated layout segments as invalid
+ *
+ * In order to continue using the pnfs_layout_hdr, a full recovery
+ * is required.
+ * Note that caller must hold inode->i_lock.
+ */
+static int
+pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo,
+               struct list_head *lseg_list)
+{
+       struct pnfs_layout_range range = {
+               .iomode = IOMODE_ANY,
+               .offset = 0,
+               .length = NFS4_MAX_UINT64,
+       };
+
+       set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags);
+       return pnfs_mark_matching_lsegs_invalid(lo, lseg_list, &range);
+}
+
 static int
 pnfs_iomode_to_fail_bit(u32 iomode)
 {
@@ -554,9 +575,8 @@ pnfs_destroy_layout(struct nfs_inode *nfsi)
        spin_lock(&nfsi->vfs_inode.i_lock);
        lo = nfsi->layout;
        if (lo) {
-               lo->plh_block_lgets++; /* permanently block new LAYOUTGETs */
-               pnfs_mark_matching_lsegs_invalid(lo, &tmp_list, NULL);
                pnfs_get_layout_hdr(lo);
+               pnfs_mark_layout_stateid_invalid(lo, &tmp_list);
                pnfs_layout_clear_fail_bit(lo, NFS_LAYOUT_RO_FAILED);
                pnfs_layout_clear_fail_bit(lo, NFS_LAYOUT_RW_FAILED);
                spin_unlock(&nfsi->vfs_inode.i_lock);
@@ -617,11 +637,6 @@ pnfs_layout_free_bulk_destroy_list(struct list_head *layout_list,
 {
        struct pnfs_layout_hdr *lo;
        struct inode *inode;
-       struct pnfs_layout_range range = {
-               .iomode = IOMODE_ANY,
-               .offset = 0,
-               .length = NFS4_MAX_UINT64,
-       };
        LIST_HEAD(lseg_list);
        int ret = 0;
 
@@ -636,11 +651,11 @@ pnfs_layout_free_bulk_destroy_list(struct list_head *layout_list,
 
                spin_lock(&inode->i_lock);
                list_del_init(&lo->plh_bulk_destroy);
-               lo->plh_block_lgets++; /* permanently block new LAYOUTGETs */
-               if (is_bulk_recall)
-                       set_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags);
-               if (pnfs_mark_matching_lsegs_invalid(lo, &lseg_list, &range))
+               if (pnfs_mark_layout_stateid_invalid(lo, &lseg_list)) {
+                       if (is_bulk_recall)
+                               set_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags);
                        ret = -EAGAIN;
+               }
                spin_unlock(&inode->i_lock);
                pnfs_free_lseg_list(&lseg_list);
                /* Free all lsegs that are attached to commit buckets */
@@ -1738,8 +1753,19 @@ pnfs_set_plh_return_iomode(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode)
        if (lo->plh_return_iomode != 0)
                iomode = IOMODE_ANY;
        lo->plh_return_iomode = iomode;
+       set_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags);
 }
 
+/**
+ * pnfs_mark_matching_lsegs_return - Free or return matching layout segments
+ * @lo: pointer to layout header
+ * @tmp_list: list header to be used with pnfs_free_lseg_list()
+ * @return_range: describe layout segment ranges to be returned
+ *
+ * This function is mainly intended for use by layoutrecall. It attempts
+ * to free the layout segment immediately, or else to mark it for return
+ * as soon as its reference count drops to zero.
+ */
 int
 pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
                                struct list_head *tmp_list,
@@ -1762,12 +1788,11 @@ pnfs_mark_matching_lsegs_return(struct pnfs_layout_hdr *lo,
                                lseg, lseg->pls_range.iomode,
                                lseg->pls_range.offset,
                                lseg->pls_range.length);
+                       if (mark_lseg_invalid(lseg, tmp_list))
+                               continue;
+                       remaining++;
                        set_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags);
                        pnfs_set_plh_return_iomode(lo, return_range->iomode);
-                       if (!mark_lseg_invalid(lseg, tmp_list))
-                               remaining++;
-                       set_bit(NFS_LAYOUT_RETURN_REQUESTED,
-                                       &lo->plh_flags);
                }
        return remaining;
 }
index cfcbf11..7115c5d 100644 (file)
 #include <linux/fsnotify_backend.h>
 #include "fsnotify.h"
 
+#define FSNOTIFY_REAPER_DELAY  (1)     /* 1 jiffy */
+
 struct srcu_struct fsnotify_mark_srcu;
+static DEFINE_SPINLOCK(destroy_lock);
+static LIST_HEAD(destroy_list);
+
+static void fsnotify_mark_destroy(struct work_struct *work);
+static DECLARE_DELAYED_WORK(reaper_work, fsnotify_mark_destroy);
 
 void fsnotify_get_mark(struct fsnotify_mark *mark)
 {
@@ -165,19 +172,10 @@ void fsnotify_detach_mark(struct fsnotify_mark *mark)
        atomic_dec(&group->num_marks);
 }
 
-static void
-fsnotify_mark_free_rcu(struct rcu_head *rcu)
-{
-       struct fsnotify_mark    *mark;
-
-       mark = container_of(rcu, struct fsnotify_mark, g_rcu);
-       fsnotify_put_mark(mark);
-}
-
 /*
- * Free fsnotify mark. The freeing is actually happening from a call_srcu
- * callback. Caller must have a reference to the mark or be protected by
- * fsnotify_mark_srcu.
+ * Free fsnotify mark. The freeing is actually happening from a kthread which
+ * first waits for srcu period end. Caller must have a reference to the mark
+ * or be protected by fsnotify_mark_srcu.
  */
 void fsnotify_free_mark(struct fsnotify_mark *mark)
 {
@@ -192,7 +190,11 @@ void fsnotify_free_mark(struct fsnotify_mark *mark)
        mark->flags &= ~FSNOTIFY_MARK_FLAG_ALIVE;
        spin_unlock(&mark->lock);
 
-       call_srcu(&fsnotify_mark_srcu, &mark->g_rcu, fsnotify_mark_free_rcu);
+       spin_lock(&destroy_lock);
+       list_add(&mark->g_list, &destroy_list);
+       spin_unlock(&destroy_lock);
+       queue_delayed_work(system_unbound_wq, &reaper_work,
+                               FSNOTIFY_REAPER_DELAY);
 
        /*
         * Some groups like to know that marks are being freed.  This is a
@@ -388,7 +390,12 @@ err:
 
        spin_unlock(&mark->lock);
 
-       call_srcu(&fsnotify_mark_srcu, &mark->g_rcu, fsnotify_mark_free_rcu);
+       spin_lock(&destroy_lock);
+       list_add(&mark->g_list, &destroy_list);
+       spin_unlock(&destroy_lock);
+       queue_delayed_work(system_unbound_wq, &reaper_work,
+                               FSNOTIFY_REAPER_DELAY);
+
        return ret;
 }
 
@@ -491,3 +498,21 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,
        atomic_set(&mark->refcnt, 1);
        mark->free_mark = free_mark;
 }
+
+static void fsnotify_mark_destroy(struct work_struct *work)
+{
+       struct fsnotify_mark *mark, *next;
+       struct list_head private_destroy_list;
+
+       spin_lock(&destroy_lock);
+       /* exchange the list head */
+       list_replace_init(&destroy_list, &private_destroy_list);
+       spin_unlock(&destroy_lock);
+
+       synchronize_srcu(&fsnotify_mark_srcu);
+
+       list_for_each_entry_safe(mark, next, &private_destroy_list, g_list) {
+               list_del_init(&mark->g_list);
+               fsnotify_put_mark(mark);
+       }
+}
index 794fd15..cda0361 100644 (file)
@@ -956,6 +956,7 @@ clean_orphan:
                tmp_ret = ocfs2_del_inode_from_orphan(osb, inode, di_bh,
                                update_isize, end);
                if (tmp_ret < 0) {
+                       ocfs2_inode_unlock(inode, 1);
                        ret = tmp_ret;
                        mlog_errno(ret);
                        brelse(di_bh);
index 9581d19..77ebc2b 100644 (file)
@@ -147,6 +147,10 @@ static int ocfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
        ret = ocfs2_inode_lock(inode, &di_bh, 1);
        if (ret < 0) {
                mlog_errno(ret);
+               if (ret == -ENOMEM)
+                       ret = VM_FAULT_OOM;
+               else
+                       ret = VM_FAULT_SIGBUS;
                goto out;
        }
 
index ed95272..52f6de5 100644 (file)
@@ -618,7 +618,8 @@ static int ovl_remove_upper(struct dentry *dentry, bool is_dir)
         * sole user of this dentry.  Too tricky...  Just unhash for
         * now.
         */
-       d_drop(dentry);
+       if (!err)
+               d_drop(dentry);
        inode_unlock(dir);
 
        return err;
@@ -903,6 +904,13 @@ static int ovl_rename2(struct inode *olddir, struct dentry *old,
        if (!overwrite && new_is_dir && !old_opaque && new_opaque)
                ovl_remove_opaque(newdentry);
 
+       /*
+        * Old dentry now lives in different location. Dentries in
+        * lowerstack are stale. We cannot drop them here because
+        * access to them is lockless. This could be only pure upper
+        * or opaque directory - numlower is zero. Or upper non-dir
+        * entry - its pureness is tracked by flag opaque.
+        */
        if (old_opaque != new_opaque) {
                ovl_dentry_set_opaque(old, new_opaque);
                if (!overwrite)
index 49e2045..a4ff5d0 100644 (file)
@@ -65,6 +65,8 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr)
 
                inode_lock(upperdentry->d_inode);
                err = notify_change(upperdentry, attr, NULL);
+               if (!err)
+                       ovl_copyattr(upperdentry->d_inode, dentry->d_inode);
                inode_unlock(upperdentry->d_inode);
        }
        ovl_drop_write(dentry);
index 8d826bd..619ad4b 100644 (file)
@@ -76,12 +76,14 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry)
        if (oe->__upperdentry) {
                type = __OVL_PATH_UPPER;
 
-               if (oe->numlower) {
-                       if (S_ISDIR(dentry->d_inode->i_mode))
-                               type |= __OVL_PATH_MERGE;
-               } else if (!oe->opaque) {
+               /*
+                * Non-dir dentry can hold lower dentry from previous
+                * location. Its purity depends only on opaque flag.
+                */
+               if (oe->numlower && S_ISDIR(dentry->d_inode->i_mode))
+                       type |= __OVL_PATH_MERGE;
+               else if (!oe->opaque)
                        type |= __OVL_PATH_PURE;
-               }
        } else {
                if (oe->numlower > 1)
                        type |= __OVL_PATH_MERGE;
@@ -341,6 +343,7 @@ static const struct dentry_operations ovl_dentry_operations = {
 
 static const struct dentry_operations ovl_reval_dentry_operations = {
        .d_release = ovl_dentry_release,
+       .d_select_inode = ovl_d_select_inode,
        .d_revalidate = ovl_dentry_revalidate,
        .d_weak_revalidate = ovl_dentry_weak_revalidate,
 };
index 6367e1e..c524fdd 100644 (file)
@@ -202,6 +202,11 @@ static struct mount *last_dest, *last_source, *dest_master;
 static struct mountpoint *mp;
 static struct hlist_head *list;
 
+static inline bool peers(struct mount *m1, struct mount *m2)
+{
+       return m1->mnt_group_id == m2->mnt_group_id && m1->mnt_group_id;
+}
+
 static int propagate_one(struct mount *m)
 {
        struct mount *child;
@@ -212,7 +217,7 @@ static int propagate_one(struct mount *m)
        /* skip if mountpoint isn't covered by it */
        if (!is_subdir(mp->m_dentry, m->mnt.mnt_root))
                return 0;
-       if (m->mnt_group_id == last_dest->mnt_group_id) {
+       if (peers(m, last_dest)) {
                type = CL_MAKE_SHARED;
        } else {
                struct mount *n, *p;
@@ -223,7 +228,7 @@ static int propagate_one(struct mount *m)
                                        last_source = last_source->mnt_master;
                                        last_dest = last_source->mnt_parent;
                                }
-                               if (n->mnt_group_id != last_dest->mnt_group_id) {
+                               if (!peers(n, last_dest)) {
                                        last_source = last_source->mnt_master;
                                        last_dest = last_source->mnt_parent;
                                }
index 324ec27..dadf24e 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/splice.h>
 #include <linux/compat.h>
 #include <linux/mount.h>
+#include <linux/fs.h>
 #include "internal.h"
 
 #include <asm/uaccess.h>
@@ -183,7 +184,7 @@ loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence)
        switch (whence) {
        case SEEK_SET: case SEEK_CUR:
                return generic_file_llseek_size(file, offset, whence,
-                                               ~0ULL, 0);
+                                               OFFSET_MAX, 0);
        default:
                return -EINVAL;
        }
@@ -1532,10 +1533,12 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in,
 
        if (!(file_in->f_mode & FMODE_READ) ||
            !(file_out->f_mode & FMODE_WRITE) ||
-           (file_out->f_flags & O_APPEND) ||
-           !file_in->f_op->clone_file_range)
+           (file_out->f_flags & O_APPEND))
                return -EBADF;
 
+       if (!file_in->f_op->clone_file_range)
+               return -EOPNOTSUPP;
+
        ret = clone_verify_area(file_in, pos_in, len, false);
        if (ret)
                return ret;
index 1182af8..74914b1 100644 (file)
@@ -415,6 +415,7 @@ void generic_shutdown_super(struct super_block *sb)
                sb->s_flags &= ~MS_ACTIVE;
 
                fsnotify_unmount_inodes(sb);
+               cgroup_writeback_umount();
 
                evict_inodes(sb);
 
index 5031170..66cdb44 100644 (file)
@@ -287,6 +287,12 @@ int handle_userfault(struct vm_area_struct *vma, unsigned long address,
                goto out;
 
        /*
+        * We don't do userfault handling for the final child pid update.
+        */
+       if (current->flags & PF_EXITING)
+               goto out;
+
+       /*
         * Check that we can return VM_FAULT_RETRY.
         *
         * NOTE: it should become possible to return VM_FAULT_RETRY
index 07d0e47..4861322 100644 (file)
@@ -940,7 +940,7 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
        bool trusted = capable(CAP_SYS_ADMIN);
        struct simple_xattr *xattr;
        ssize_t remaining_size = size;
-       int err;
+       int err = 0;
 
 #ifdef CONFIG_FS_POSIX_ACL
        if (inode->i_acl) {
@@ -965,11 +965,11 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
 
                err = xattr_list_one(&buffer, &remaining_size, xattr->name);
                if (err)
-                       return err;
+                       break;
        }
        spin_unlock(&xattrs->lock);
 
-       return size - remaining_size;
+       return err ? err : size - remaining_size;
 }
 
 /*
index 379c089..a9ebabf 100644 (file)
@@ -55,7 +55,7 @@ xfs_count_page_state(
        } while ((bh = bh->b_this_page) != head);
 }
 
-STATIC struct block_device *
+struct block_device *
 xfs_find_bdev_for_inode(
        struct inode            *inode)
 {
@@ -1208,6 +1208,10 @@ xfs_vm_writepages(
        struct writeback_control *wbc)
 {
        xfs_iflags_clear(XFS_I(mapping->host), XFS_ITRUNCATED);
+       if (dax_mapping(mapping))
+               return dax_writeback_mapping_range(mapping,
+                               xfs_find_bdev_for_inode(mapping->host), wbc);
+
        return generic_writepages(mapping, wbc);
 }
 
index f6ffc9a..a4343c6 100644 (file)
@@ -62,5 +62,6 @@ int   xfs_get_blocks_dax_fault(struct inode *inode, sector_t offset,
                                 struct buffer_head *map_bh, int create);
 
 extern void xfs_count_page_state(struct page *, int *, int *);
+extern struct block_device *xfs_find_bdev_for_inode(struct inode *);
 
 #endif /* __XFS_AOPS_H__ */
index 45ec9e4..6c87601 100644 (file)
@@ -75,7 +75,8 @@ xfs_zero_extent(
        ssize_t         size = XFS_FSB_TO_B(mp, count_fsb);
 
        if (IS_DAX(VFS_I(ip)))
-               return dax_clear_blocks(VFS_I(ip), block, size);
+               return dax_clear_sectors(xfs_find_bdev_for_inode(VFS_I(ip)),
+                               sector, size);
 
        /*
         * let the block layer decide on the fastest method of
index da37beb..be55688 100644 (file)
@@ -1109,27 +1109,10 @@ xlog_verify_head(
        bool                    tmp_wrapped;
 
        /*
-        * Search backwards through the log looking for the log record header
-        * block. This wraps all the way back around to the head so something is
-        * seriously wrong if we can't find it.
-        */
-       found = xlog_rseek_logrec_hdr(log, *head_blk, *head_blk, 1, bp, rhead_blk,
-                                     rhead, wrapped);
-       if (found < 0)
-               return found;
-       if (!found) {
-               xfs_warn(log->l_mp, "%s: couldn't find sync record", __func__);
-               return -EIO;
-       }
-
-       *tail_blk = BLOCK_LSN(be64_to_cpu((*rhead)->h_tail_lsn));
-
-       /*
-        * Now that we have a tail block, check the head of the log for torn
-        * writes. Search again until we hit the tail or the maximum number of
-        * log record I/Os that could have been in flight at one time. Use a
-        * temporary buffer so we don't trash the rhead/bp pointer from the
-        * call above.
+        * Check the head of the log for torn writes. Search backwards from the
+        * head until we hit the tail or the maximum number of log record I/Os
+        * that could have been in flight at one time. Use a temporary buffer so
+        * we don't trash the rhead/bp pointers from the caller.
         */
        tmp_bp = xlog_get_bp(log, 1);
        if (!tmp_bp)
@@ -1216,6 +1199,115 @@ xlog_verify_head(
 }
 
 /*
+ * Check whether the head of the log points to an unmount record. In other
+ * words, determine whether the log is clean. If so, update the in-core state
+ * appropriately.
+ */
+static int
+xlog_check_unmount_rec(
+       struct xlog             *log,
+       xfs_daddr_t             *head_blk,
+       xfs_daddr_t             *tail_blk,
+       struct xlog_rec_header  *rhead,
+       xfs_daddr_t             rhead_blk,
+       struct xfs_buf          *bp,
+       bool                    *clean)
+{
+       struct xlog_op_header   *op_head;
+       xfs_daddr_t             umount_data_blk;
+       xfs_daddr_t             after_umount_blk;
+       int                     hblks;
+       int                     error;
+       char                    *offset;
+
+       *clean = false;
+
+       /*
+        * Look for unmount record. If we find it, then we know there was a
+        * clean unmount. Since 'i' could be the last block in the physical
+        * log, we convert to a log block before comparing to the head_blk.
+        *
+        * Save the current tail lsn to use to pass to xlog_clear_stale_blocks()
+        * below. We won't want to clear the unmount record if there is one, so
+        * we pass the lsn of the unmount record rather than the block after it.
+        */
+       if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
+               int     h_size = be32_to_cpu(rhead->h_size);
+               int     h_version = be32_to_cpu(rhead->h_version);
+
+               if ((h_version & XLOG_VERSION_2) &&
+                   (h_size > XLOG_HEADER_CYCLE_SIZE)) {
+                       hblks = h_size / XLOG_HEADER_CYCLE_SIZE;
+                       if (h_size % XLOG_HEADER_CYCLE_SIZE)
+                               hblks++;
+               } else {
+                       hblks = 1;
+               }
+       } else {
+               hblks = 1;
+       }
+       after_umount_blk = rhead_blk + hblks + BTOBB(be32_to_cpu(rhead->h_len));
+       after_umount_blk = do_mod(after_umount_blk, log->l_logBBsize);
+       if (*head_blk == after_umount_blk &&
+           be32_to_cpu(rhead->h_num_logops) == 1) {
+               umount_data_blk = rhead_blk + hblks;
+               umount_data_blk = do_mod(umount_data_blk, log->l_logBBsize);
+               error = xlog_bread(log, umount_data_blk, 1, bp, &offset);
+               if (error)
+                       return error;
+
+               op_head = (struct xlog_op_header *)offset;
+               if (op_head->oh_flags & XLOG_UNMOUNT_TRANS) {
+                       /*
+                        * Set tail and last sync so that newly written log
+                        * records will point recovery to after the current
+                        * unmount record.
+                        */
+                       xlog_assign_atomic_lsn(&log->l_tail_lsn,
+                                       log->l_curr_cycle, after_umount_blk);
+                       xlog_assign_atomic_lsn(&log->l_last_sync_lsn,
+                                       log->l_curr_cycle, after_umount_blk);
+                       *tail_blk = after_umount_blk;
+
+                       *clean = true;
+               }
+       }
+
+       return 0;
+}
+
+static void
+xlog_set_state(
+       struct xlog             *log,
+       xfs_daddr_t             head_blk,
+       struct xlog_rec_header  *rhead,
+       xfs_daddr_t             rhead_blk,
+       bool                    bump_cycle)
+{
+       /*
+        * Reset log values according to the state of the log when we
+        * crashed.  In the case where head_blk == 0, we bump curr_cycle
+        * one because the next write starts a new cycle rather than
+        * continuing the cycle of the last good log record.  At this
+        * point we have guaranteed that all partial log records have been
+        * accounted for.  Therefore, we know that the last good log record
+        * written was complete and ended exactly on the end boundary
+        * of the physical log.
+        */
+       log->l_prev_block = rhead_blk;
+       log->l_curr_block = (int)head_blk;
+       log->l_curr_cycle = be32_to_cpu(rhead->h_cycle);
+       if (bump_cycle)
+               log->l_curr_cycle++;
+       atomic64_set(&log->l_tail_lsn, be64_to_cpu(rhead->h_tail_lsn));
+       atomic64_set(&log->l_last_sync_lsn, be64_to_cpu(rhead->h_lsn));
+       xlog_assign_grant_head(&log->l_reserve_head.grant, log->l_curr_cycle,
+                                       BBTOB(log->l_curr_block));
+       xlog_assign_grant_head(&log->l_write_head.grant, log->l_curr_cycle,
+                                       BBTOB(log->l_curr_block));
+}
+
+/*
  * Find the sync block number or the tail of the log.
  *
  * This will be the block number of the last record to have its
@@ -1238,22 +1330,20 @@ xlog_find_tail(
        xfs_daddr_t             *tail_blk)
 {
        xlog_rec_header_t       *rhead;
-       xlog_op_header_t        *op_head;
        char                    *offset = NULL;
        xfs_buf_t               *bp;
        int                     error;
-       xfs_daddr_t             umount_data_blk;
-       xfs_daddr_t             after_umount_blk;
        xfs_daddr_t             rhead_blk;
        xfs_lsn_t               tail_lsn;
-       int                     hblks;
        bool                    wrapped = false;
+       bool                    clean = false;
 
        /*
         * Find previous log record
         */
        if ((error = xlog_find_head(log, head_blk)))
                return error;
+       ASSERT(*head_blk < INT_MAX);
 
        bp = xlog_get_bp(log, 1);
        if (!bp)
@@ -1271,100 +1361,75 @@ xlog_find_tail(
        }
 
        /*
-        * Trim the head block back to skip over torn records. We can have
-        * multiple log I/Os in flight at any time, so we assume CRC failures
-        * back through the previous several records are torn writes and skip
-        * them.
+        * Search backwards through the log looking for the log record header
+        * block. This wraps all the way back around to the head so something is
+        * seriously wrong if we can't find it.
         */
-       ASSERT(*head_blk < INT_MAX);
-       error = xlog_verify_head(log, head_blk, tail_blk, bp, &rhead_blk,
-                                &rhead, &wrapped);
-       if (error)
-               goto done;
+       error = xlog_rseek_logrec_hdr(log, *head_blk, *head_blk, 1, bp,
+                                     &rhead_blk, &rhead, &wrapped);
+       if (error < 0)
+               return error;
+       if (!error) {
+               xfs_warn(log->l_mp, "%s: couldn't find sync record", __func__);
+               return -EIO;
+       }
+       *tail_blk = BLOCK_LSN(be64_to_cpu(rhead->h_tail_lsn));
 
        /*
-        * Reset log values according to the state of the log when we
-        * crashed.  In the case where head_blk == 0, we bump curr_cycle
-        * one because the next write starts a new cycle rather than
-        * continuing the cycle of the last good log record.  At this
-        * point we have guaranteed that all partial log records have been
-        * accounted for.  Therefore, we know that the last good log record
-        * written was complete and ended exactly on the end boundary
-        * of the physical log.
+        * Set the log state based on the current head record.
         */
-       log->l_prev_block = rhead_blk;
-       log->l_curr_block = (int)*head_blk;
-       log->l_curr_cycle = be32_to_cpu(rhead->h_cycle);
-       if (wrapped)
-               log->l_curr_cycle++;
-       atomic64_set(&log->l_tail_lsn, be64_to_cpu(rhead->h_tail_lsn));
-       atomic64_set(&log->l_last_sync_lsn, be64_to_cpu(rhead->h_lsn));
-       xlog_assign_grant_head(&log->l_reserve_head.grant, log->l_curr_cycle,
-                                       BBTOB(log->l_curr_block));
-       xlog_assign_grant_head(&log->l_write_head.grant, log->l_curr_cycle,
-                                       BBTOB(log->l_curr_block));
+       xlog_set_state(log, *head_blk, rhead, rhead_blk, wrapped);
+       tail_lsn = atomic64_read(&log->l_tail_lsn);
 
        /*
-        * Look for unmount record.  If we find it, then we know there
-        * was a clean unmount.  Since 'i' could be the last block in
-        * the physical log, we convert to a log block before comparing
-        * to the head_blk.
+        * Look for an unmount record at the head of the log. This sets the log
+        * state to determine whether recovery is necessary.
+        */
+       error = xlog_check_unmount_rec(log, head_blk, tail_blk, rhead,
+                                      rhead_blk, bp, &clean);
+       if (error)
+               goto done;
+
+       /*
+        * Verify the log head if the log is not clean (e.g., we have anything
+        * but an unmount record at the head). This uses CRC verification to
+        * detect and trim torn writes. If discovered, CRC failures are
+        * considered torn writes and the log head is trimmed accordingly.
         *
-        * Save the current tail lsn to use to pass to
-        * xlog_clear_stale_blocks() below.  We won't want to clear the
-        * unmount record if there is one, so we pass the lsn of the
-        * unmount record rather than the block after it.
+        * Note that we can only run CRC verification when the log is dirty
+        * because there's no guarantee that the log data behind an unmount
+        * record is compatible with the current architecture.
         */
-       if (xfs_sb_version_haslogv2(&log->l_mp->m_sb)) {
-               int     h_size = be32_to_cpu(rhead->h_size);
-               int     h_version = be32_to_cpu(rhead->h_version);
+       if (!clean) {
+               xfs_daddr_t     orig_head = *head_blk;
 
-               if ((h_version & XLOG_VERSION_2) &&
-                   (h_size > XLOG_HEADER_CYCLE_SIZE)) {
-                       hblks = h_size / XLOG_HEADER_CYCLE_SIZE;
-                       if (h_size % XLOG_HEADER_CYCLE_SIZE)
-                               hblks++;
-               } else {
-                       hblks = 1;
-               }
-       } else {
-               hblks = 1;
-       }
-       after_umount_blk = rhead_blk + hblks + BTOBB(be32_to_cpu(rhead->h_len));
-       after_umount_blk = do_mod(after_umount_blk, log->l_logBBsize);
-       tail_lsn = atomic64_read(&log->l_tail_lsn);
-       if (*head_blk == after_umount_blk &&
-           be32_to_cpu(rhead->h_num_logops) == 1) {
-               umount_data_blk = rhead_blk + hblks;
-               umount_data_blk = do_mod(umount_data_blk, log->l_logBBsize);
-               error = xlog_bread(log, umount_data_blk, 1, bp, &offset);
+               error = xlog_verify_head(log, head_blk, tail_blk, bp,
+                                        &rhead_blk, &rhead, &wrapped);
                if (error)
                        goto done;
 
-               op_head = (xlog_op_header_t *)offset;
-               if (op_head->oh_flags & XLOG_UNMOUNT_TRANS) {
-                       /*
-                        * Set tail and last sync so that newly written
-                        * log records will point recovery to after the
-                        * current unmount record.
-                        */
-                       xlog_assign_atomic_lsn(&log->l_tail_lsn,
-                                       log->l_curr_cycle, after_umount_blk);
-                       xlog_assign_atomic_lsn(&log->l_last_sync_lsn,
-                                       log->l_curr_cycle, after_umount_blk);
-                       *tail_blk = after_umount_blk;
-
-                       /*
-                        * Note that the unmount was clean. If the unmount
-                        * was not clean, we need to know this to rebuild the
-                        * superblock counters from the perag headers if we
-                        * have a filesystem using non-persistent counters.
-                        */
-                       log->l_mp->m_flags |= XFS_MOUNT_WAS_CLEAN;
+               /* update in-core state again if the head changed */
+               if (*head_blk != orig_head) {
+                       xlog_set_state(log, *head_blk, rhead, rhead_blk,
+                                      wrapped);
+                       tail_lsn = atomic64_read(&log->l_tail_lsn);
+                       error = xlog_check_unmount_rec(log, head_blk, tail_blk,
+                                                      rhead, rhead_blk, bp,
+                                                      &clean);
+                       if (error)
+                               goto done;
                }
        }
 
        /*
+        * Note that the unmount was clean. If the unmount was not clean, we
+        * need to know this to rebuild the superblock counters from the perag
+        * headers if we have a filesystem using non-persistent counters.
+        */
+       if (clean)
+               log->l_mp->m_flags |= XFS_MOUNT_WAS_CLEAN;
+
+       /*
         * Make sure that there are no blocks in front of the head
         * with the same cycle number as the head.  This can happen
         * because we allow multiple outstanding log writes concurrently,
@@ -4491,7 +4556,7 @@ xlog_recover_process(
         * know precisely what failed.
         */
        if (pass == XLOG_RECOVER_CRCPASS) {
-               if (rhead->h_crc && crc != le32_to_cpu(rhead->h_crc))
+               if (rhead->h_crc && crc != rhead->h_crc)
                        return -EFSBADCRC;
                return 0;
        }
@@ -4502,7 +4567,7 @@ xlog_recover_process(
         * zero CRC check prevents warnings from being emitted when upgrading
         * the kernel from one that does not add CRCs by default.
         */
-       if (crc != le32_to_cpu(rhead->h_crc)) {
+       if (crc != rhead->h_crc) {
                if (rhead->h_crc || xfs_sb_version_hascrc(&log->l_mp->m_sb)) {
                        xfs_alert(log->l_mp,
                "log record CRC mismatch: found 0x%x, expected 0x%x.",
index 0419485..0f1c6f3 100644 (file)
@@ -75,7 +75,7 @@ typedef u64 __nocast cputime64_t;
  */
 static inline cputime_t timespec_to_cputime(const struct timespec *val)
 {
-       u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_nsec;
+       u64 ret = (u64)val->tv_sec * NSEC_PER_SEC + val->tv_nsec;
        return (__force cputime_t) ret;
 }
 static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val)
@@ -91,7 +91,8 @@ static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val)
  */
 static inline cputime_t timeval_to_cputime(const struct timeval *val)
 {
-       u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_usec * NSEC_PER_USEC;
+       u64 ret = (u64)val->tv_sec * NSEC_PER_SEC +
+                       val->tv_usec * NSEC_PER_USEC;
        return (__force cputime_t) ret;
 }
 static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val)
index 0b3c0d3..c370b26 100644 (file)
@@ -239,6 +239,14 @@ extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
                            pmd_t *pmdp);
 #endif
 
+#ifndef __HAVE_ARCH_PMDP_HUGE_SPLIT_PREPARE
+static inline void pmdp_huge_split_prepare(struct vm_area_struct *vma,
+                                          unsigned long address, pmd_t *pmdp)
+{
+
+}
+#endif
+
 #ifndef __HAVE_ARCH_PTE_SAME
 static inline int pte_same(pte_t pte_a, pte_t pte_b)
 {
index fe5efad..9054598 100644 (file)
@@ -146,6 +146,9 @@ __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
                                            struct drm_connector_state *state);
 void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
                                          struct drm_connector_state *state);
+void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+                                       u16 *red, u16 *green, u16 *blue,
+                                       uint32_t start, uint32_t size);
 
 /**
  * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC
index 8c7fb3d..e0170bf 100644 (file)
@@ -305,6 +305,8 @@ struct drm_plane_helper_funcs;
  * @mode_changed: crtc_state->mode or crtc_state->enable has been changed
  * @active_changed: crtc_state->active has been toggled.
  * @connectors_changed: connectors to this crtc have been updated
+ * @color_mgmt_changed: color management properties have changed (degamma or
+ *     gamma LUT or CSC matrix)
  * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
  * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
  * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders
@@ -312,6 +314,11 @@ struct drm_plane_helper_funcs;
  *     update to ensure framebuffer cleanup isn't done too early
  * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
  * @mode: current mode timings
+ * @degamma_lut: Lookup table for converting framebuffer pixel data
+ *     before apply the conversion matrix
+ * @ctm: Transformation matrix
+ * @gamma_lut: Lookup table for converting pixel data after the
+ *     conversion matrix
  * @event: optional pointer to a DRM event to signal upon completion of the
  *     state update
  * @state: backpointer to global drm_atomic_state
@@ -333,6 +340,7 @@ struct drm_crtc_state {
        bool mode_changed : 1;
        bool active_changed : 1;
        bool connectors_changed : 1;
+       bool color_mgmt_changed : 1;
 
        /* attached planes bitmask:
         * WARNING: transitional helpers do not maintain plane_mask so
@@ -355,6 +363,11 @@ struct drm_crtc_state {
        /* blob property to expose current mode to atomic userspace */
        struct drm_property_blob *mode_blob;
 
+       /* blob property to expose color management to userspace */
+       struct drm_property_blob *degamma_lut;
+       struct drm_property_blob *ctm;
+       struct drm_property_blob *gamma_lut;
+
        struct drm_pending_vblank_event *event;
 
        struct drm_atomic_state *state;
@@ -757,7 +770,7 @@ struct drm_crtc {
        int x, y;
        const struct drm_crtc_funcs *funcs;
 
-       /* CRTC gamma size for reporting to userspace */
+       /* Legacy FB CRTC gamma size for reporting to userspace */
        uint32_t gamma_size;
        uint16_t *gamma_store;
 
@@ -1168,6 +1181,7 @@ struct drm_connector {
        struct drm_mode_object base;
 
        char *name;
+       int connector_id;
        int connector_type;
        int connector_type_id;
        bool interlace_allowed;
@@ -1583,6 +1597,8 @@ struct drm_bridge_funcs {
         *
         * The bridge can assume that the display pipe (i.e. clocks and timing
         * signals) feeding it is still running when this callback is called.
+        *
+        * The disable callback is optional.
         */
        void (*disable)(struct drm_bridge *bridge);
 
@@ -1599,6 +1615,8 @@ struct drm_bridge_funcs {
         * The bridge must assume that the display pipe (i.e. clocks and timing
         * singals) feeding it is no longer running when this callback is
         * called.
+        *
+        * The post_disable callback is optional.
         */
        void (*post_disable)(struct drm_bridge *bridge);
 
@@ -1627,6 +1645,8 @@ struct drm_bridge_funcs {
         * will not yet be running when this callback is called. The bridge must
         * not enable the display link feeding the next bridge in the chain (if
         * there is one) when this callback is called.
+        *
+        * The pre_enable callback is optional.
         */
        void (*pre_enable)(struct drm_bridge *bridge);
 
@@ -1644,6 +1664,8 @@ struct drm_bridge_funcs {
         * signals) feeding it is running when this callback is called. This
         * callback must enable the display link feeding the next bridge in the
         * chain if there is one.
+        *
+        * The enable callback is optional.
         */
        void (*enable)(struct drm_bridge *bridge);
 };
@@ -1676,6 +1698,7 @@ struct drm_bridge {
  * @dev: parent DRM device
  * @allow_modeset: allow full modeset
  * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics
+ * @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL.
  * @planes: pointer to array of plane pointers
  * @plane_states: pointer to array of plane states pointers
  * @crtcs: pointer to array of CRTC pointers
@@ -1689,6 +1712,7 @@ struct drm_atomic_state {
        struct drm_device *dev;
        bool allow_modeset : 1;
        bool legacy_cursor_update : 1;
+       bool legacy_set_config : 1;
        struct drm_plane **planes;
        struct drm_plane_state **plane_states;
        struct drm_crtc **crtcs;
@@ -2025,6 +2049,15 @@ struct drm_mode_config_funcs {
  * @property_blob_list: list of all the blob property objects
  * @blob_lock: mutex for blob property allocation and management
  * @*_property: core property tracking
+ * @degamma_lut_property: LUT used to convert the framebuffer's colors to linear
+ *     gamma
+ * @degamma_lut_size_property: size of the degamma LUT as supported by the
+ *     driver (read-only)
+ * @ctm_property: Matrix used to convert colors after the lookup in the
+ *     degamma LUT
+ * @gamma_lut_property: LUT used to convert the colors, after the CSC matrix, to
+ *     the gamma space of the connected screen (read-only)
+ * @gamma_lut_size_property: size of the gamma LUT as supported by the driver
  * @preferred_depth: preferred RBG pixel depth, used by fb helpers
  * @prefer_shadow: hint to userspace to prefer shadow-fb rendering
  * @async_page_flip: does this device support async flips on the primary plane?
@@ -2049,6 +2082,7 @@ struct drm_mode_config {
        struct list_head fb_list;
 
        int num_connector;
+       struct ida connector_ida;
        struct list_head connector_list;
        int num_encoder;
        struct list_head encoder_list;
@@ -2126,6 +2160,13 @@ struct drm_mode_config {
        struct drm_property *aspect_ratio_property;
        struct drm_property *dirty_info_property;
 
+       /* Optional color correction properties */
+       struct drm_property *degamma_lut_property;
+       struct drm_property *degamma_lut_size_property;
+       struct drm_property *ctm_property;
+       struct drm_property *gamma_lut_property;
+       struct drm_property *gamma_lut_size_property;
+
        /* properties for virtual machine layout */
        struct drm_property *suggested_x_property;
        struct drm_property *suggested_y_property;
@@ -2213,7 +2254,11 @@ int drm_connector_register(struct drm_connector *connector);
 void drm_connector_unregister(struct drm_connector *connector);
 
 extern void drm_connector_cleanup(struct drm_connector *connector);
-extern unsigned int drm_connector_index(struct drm_connector *connector);
+static inline unsigned drm_connector_index(struct drm_connector *connector)
+{
+       return connector->connector_id;
+}
+
 /* helper to unplug all connectors from sysfs for device */
 extern void drm_connector_unplug_all(struct drm_device *dev);
 
@@ -2548,6 +2593,21 @@ static inline struct drm_property *drm_property_find(struct drm_device *dev,
        return mo ? obj_to_property(mo) : NULL;
 }
 
+/*
+ * Extract a degamma/gamma LUT value provided by user and round it to the
+ * precision supported by the hardware.
+ */
+static inline uint32_t drm_color_lut_extract(uint32_t user_input,
+                                            uint32_t bit_precision)
+{
+       uint32_t val = user_input + (1 << (16 - bit_precision - 1));
+       uint32_t max = 0xffff >> (16 - bit_precision);
+
+       val >>= 16 - bit_precision;
+
+       return clamp_val(val, 0, max);
+}
+
 /* Plane list iterator for legacy (overlay only) planes. */
 #define drm_for_each_legacy_plane(plane, dev) \
        list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \
index 4b37afa..97fa894 100644 (file)
@@ -48,6 +48,9 @@ extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
                                     struct drm_display_mode *mode,
                                     int x, int y,
                                     struct drm_framebuffer *old_fb);
+extern void drm_helper_crtc_enable_color_mgmt(struct drm_crtc *crtc,
+                                             int degamma_lut_size,
+                                             int gamma_lut_size);
 extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
 extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
 
index 1b3b1f8..7a9840f 100644 (file)
@@ -96,14 +96,17 @@ struct mipi_dsi_host_ops {
  * struct mipi_dsi_host - DSI host device
  * @dev: driver model device node for this DSI host
  * @ops: DSI host operations
+ * @list: list management
  */
 struct mipi_dsi_host {
        struct device *dev;
        const struct mipi_dsi_host_ops *ops;
+       struct list_head list;
 };
 
 int mipi_dsi_host_register(struct mipi_dsi_host *host);
 void mipi_dsi_host_unregister(struct mipi_dsi_host *host);
+struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node);
 
 /* DSI mode flags */
 
@@ -139,10 +142,28 @@ enum mipi_dsi_pixel_format {
        MIPI_DSI_FMT_RGB565,
 };
 
+#define DSI_DEV_NAME_SIZE              20
+
+/**
+ * struct mipi_dsi_device_info - template for creating a mipi_dsi_device
+ * @type: DSI peripheral chip type
+ * @channel: DSI virtual channel assigned to peripheral
+ * @node: pointer to OF device node or NULL
+ *
+ * This is populated and passed to mipi_dsi_device_new to create a new
+ * DSI device
+ */
+struct mipi_dsi_device_info {
+       char type[DSI_DEV_NAME_SIZE];
+       u32 channel;
+       struct device_node *node;
+};
+
 /**
  * struct mipi_dsi_device - DSI peripheral device
  * @host: DSI host for this peripheral
  * @dev: driver model device node for this peripheral
+ * @name: DSI peripheral chip type
  * @channel: virtual channel assigned to the peripheral
  * @format: pixel format for video mode
  * @lanes: number of active data lanes
@@ -152,6 +173,7 @@ struct mipi_dsi_device {
        struct mipi_dsi_host *host;
        struct device dev;
 
+       char name[DSI_DEV_NAME_SIZE];
        unsigned int channel;
        unsigned int lanes;
        enum mipi_dsi_pixel_format format;
@@ -188,6 +210,10 @@ static inline int mipi_dsi_pixel_format_to_bpp(enum mipi_dsi_pixel_format fmt)
        return -EINVAL;
 }
 
+struct mipi_dsi_device *
+mipi_dsi_device_register_full(struct mipi_dsi_host *host,
+                             const struct mipi_dsi_device_info *info);
+void mipi_dsi_device_unregister(struct mipi_dsi_device *dsi);
 struct mipi_dsi_device *of_find_mipi_dsi_device_by_node(struct device_node *np);
 int mipi_dsi_attach(struct mipi_dsi_device *dsi);
 int mipi_dsi_detach(struct mipi_dsi_device *dsi);
index 8544665..3fd87b3 100644 (file)
@@ -1,9 +1,12 @@
 #ifndef __DRM_OF_H__
 #define __DRM_OF_H__
 
+#include <linux/of_graph.h>
+
 struct component_master_ops;
 struct device;
 struct drm_device;
+struct drm_encoder;
 struct device_node;
 
 #ifdef CONFIG_OF
@@ -12,6 +15,9 @@ extern uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
 extern int drm_of_component_probe(struct device *dev,
                                  int (*compare_of)(struct device *, void *),
                                  const struct component_master_ops *m_ops);
+extern int drm_of_encoder_active_endpoint(struct device_node *node,
+                                         struct drm_encoder *encoder,
+                                         struct of_endpoint *endpoint);
 #else
 static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
                                                  struct device_node *port)
@@ -26,6 +32,33 @@ drm_of_component_probe(struct device *dev,
 {
        return -EINVAL;
 }
+
+static inline int drm_of_encoder_active_endpoint(struct device_node *node,
+                                                struct drm_encoder *encoder,
+                                                struct of_endpoint *endpoint)
+{
+       return -EINVAL;
+}
 #endif
 
+static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,
+                                                   struct drm_encoder *encoder)
+{
+       struct of_endpoint endpoint;
+       int ret = drm_of_encoder_active_endpoint(node, encoder,
+                                                &endpoint);
+
+       return ret ?: endpoint.id;
+}
+
+static inline int drm_of_encoder_active_port_id(struct device_node *node,
+                                               struct drm_encoder *encoder)
+{
+       struct of_endpoint endpoint;
+       int ret = drm_of_encoder_active_endpoint(node, encoder,
+                                                &endpoint);
+
+       return ret ?: endpoint.port;
+}
+
 #endif /* __DRM_OF_H__ */
diff --git a/include/drm/exynos_drm.h b/include/drm/exynos_drm.h
deleted file mode 100644 (file)
index cb65fa1..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/* exynos_drm.h
- *
- * Copyright (c) 2011 Samsung Electronics Co., Ltd.
- * Authors:
- *     Inki Dae <inki.dae@samsung.com>
- *     Joonyoung Shim <jy0922.shim@samsung.com>
- *     Seung-Woo Kim <sw0312.kim@samsung.com>
- *
- * This program is free software; you can redistribute  it and/or modify it
- * under  the terms of  the GNU General  Public License as published by the
- * Free Software Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-#ifndef _EXYNOS_DRM_H_
-#define _EXYNOS_DRM_H_
-
-#include <uapi/drm/exynos_drm.h>
-#include <video/videomode.h>
-
-/**
- * A structure for lcd panel information.
- *
- * @timing: default video mode for initializing
- * @width_mm: physical size of lcd width.
- * @height_mm: physical size of lcd height.
- */
-struct exynos_drm_panel_info {
-       struct videomode vm;
-       u32 width_mm;
-       u32 height_mm;
-};
-
-/**
- * Platform Specific Structure for DRM based FIMD.
- *
- * @panel: default panel info for initializing
- * @default_win: default window layer number to be used for UI.
- * @bpp: default bit per pixel.
- */
-struct exynos_drm_fimd_pdata {
-       struct exynos_drm_panel_info panel;
-       u32                             vidcon0;
-       u32                             vidcon1;
-       unsigned int                    default_win;
-       unsigned int                    bpp;
-};
-
-/**
- * Platform Specific Structure for DRM based HDMI.
- *
- * @hdmi_dev: device point to specific hdmi driver.
- * @mixer_dev: device point to specific mixer driver.
- *
- * this structure is used for common hdmi driver and each device object
- * would be used to access specific device driver(hdmi or mixer driver)
- */
-struct exynos_drm_common_hdmi_pd {
-       struct device *hdmi_dev;
-       struct device *mixer_dev;
-};
-
-/**
- * Platform Specific Structure for DRM based HDMI core.
- *
- * @is_v13: set if hdmi version 13 is.
- * @cfg_hpd: function pointer to configure hdmi hotplug detection pin
- * @get_hpd: function pointer to get value of hdmi hotplug detection pin
- */
-struct exynos_drm_hdmi_pdata {
-       bool is_v13;
-       void (*cfg_hpd)(bool external);
-       int (*get_hpd)(void);
-};
-
-/**
- * Platform Specific Structure for DRM based IPP.
- *
- * @inv_pclk: if set 1. invert pixel clock
- * @inv_vsync: if set 1. invert vsync signal for wb
- * @inv_href: if set 1. invert href signal
- * @inv_hsync: if set 1. invert hsync signal for wb
- */
-struct exynos_drm_ipp_pol {
-       unsigned int inv_pclk;
-       unsigned int inv_vsync;
-       unsigned int inv_href;
-       unsigned int inv_hsync;
-};
-
-/**
- * Platform Specific Structure for DRM based FIMC.
- *
- * @pol: current hardware block polarity settings.
- * @clk_rate: current hardware clock rate.
- */
-struct exynos_drm_fimc_pdata {
-       struct exynos_drm_ipp_pol pol;
-       int clk_rate;
-};
-
-#endif /* _EXYNOS_DRM_H_ */
index f970209..9094599 100644 (file)
        INTEL_VGA_DEVICE(0x191D, info)  /* WKS GT2 */
 
 #define INTEL_SKL_GT3_IDS(info) \
+       INTEL_VGA_DEVICE(0x1923, info), /* ULT GT3 */ \
        INTEL_VGA_DEVICE(0x1926, info), /* ULT GT3 */ \
+       INTEL_VGA_DEVICE(0x1927, info), /* ULT GT3 */ \
        INTEL_VGA_DEVICE(0x192B, info), /* Halo GT3 */ \
        INTEL_VGA_DEVICE(0x192A, info)  /* SRV GT3 */
 
 #define INTEL_BXT_IDS(info) \
        INTEL_VGA_DEVICE(0x0A84, info), \
        INTEL_VGA_DEVICE(0x1A84, info), \
-       INTEL_VGA_DEVICE(0x5A84, info)
+       INTEL_VGA_DEVICE(0x1A85, info), \
+       INTEL_VGA_DEVICE(0x5A84, info), /* APL HD Graphics 505 */ \
+       INTEL_VGA_DEVICE(0x5A85, info)  /* APL HD Graphics 500 */
 
 #define INTEL_KBL_GT1_IDS(info)        \
        INTEL_VGA_DEVICE(0x5913, info), /* ULT GT1.5 */ \
index 6f45aea..0a05b0d 100644 (file)
 /* 104 */
 /* 105 */
 #define TEGRA210_CLK_D_AUDIO 106
-/* 107 ( affects abp -> ape) */
+#define TEGRA210_CLK_APB2APE 107
 /* 108 */
 /* 109 */
 /* 110 */
similarity index 87%
rename from include/media/i2c/tvp5150.h
rename to include/dt-bindings/media/tvp5150.h
index 649908a..c852a35 100644 (file)
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-#ifndef _TVP5150_H_
-#define _TVP5150_H_
+#ifndef _DT_BINDINGS_MEDIA_TVP5150_H
+#define _DT_BINDINGS_MEDIA_TVP5150_H
 
 /* TVP5150 HW inputs */
 #define TVP5150_COMPOSITE0 0
 #define TVP5150_COMPOSITE1 1
 #define TVP5150_SVIDEO     2
 
+#define TVP5150_INPUT_NUM  3
+
 /* TVP5150 HW outputs */
 #define TVP5150_NORMAL       0
 #define TVP5150_BLACK_SCREEN 1
 
-#endif
+#endif /* _DT_BINDINGS_MEDIA_TVP5150_H */
index d2992bf..c1a2f34 100644 (file)
@@ -487,8 +487,8 @@ enum ata_tf_protocols {
 };
 
 enum ata_ioctls {
-       ATA_IOC_GET_IO32        = 0x309,
-       ATA_IOC_SET_IO32        = 0x324,
+       ATA_IOC_GET_IO32        = 0x309, /* HDIO_GET_32BIT */
+       ATA_IOC_SET_IO32        = 0x324, /* HDIO_SET_32BIT */
 };
 
 /* core structures */
index 5349e68..cb68888 100644 (file)
@@ -310,6 +310,43 @@ static inline void bio_clear_flag(struct bio *bio, unsigned int bit)
        bio->bi_flags &= ~(1U << bit);
 }
 
+static inline void bio_get_first_bvec(struct bio *bio, struct bio_vec *bv)
+{
+       *bv = bio_iovec(bio);
+}
+
+static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv)
+{
+       struct bvec_iter iter = bio->bi_iter;
+       int idx;
+
+       if (!bio_flagged(bio, BIO_CLONED)) {
+               *bv = bio->bi_io_vec[bio->bi_vcnt - 1];
+               return;
+       }
+
+       if (unlikely(!bio_multiple_segments(bio))) {
+               *bv = bio_iovec(bio);
+               return;
+       }
+
+       bio_advance_iter(bio, &iter, iter.bi_size);
+
+       if (!iter.bi_bvec_done)
+               idx = iter.bi_idx - 1;
+       else    /* in the middle of bvec */
+               idx = iter.bi_idx;
+
+       *bv = bio->bi_io_vec[idx];
+
+       /*
+        * iter.bi_bvec_done records actual length of the last bvec
+        * if this bio ends in the middle of one io vector
+        */
+       if (iter.bi_bvec_done)
+               bv->bv_len = iter.bi_bvec_done;
+}
+
 enum bip_flags {
        BIP_BLOCK_INTEGRITY     = 1 << 0, /* block layer owns integrity data */
        BIP_MAPPED_INTEGRITY    = 1 << 1, /* ref tag has been remapped */
index 29189ae..413c84f 100644 (file)
@@ -682,9 +682,12 @@ static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b)
 /*
  * q->prep_rq_fn return values
  */
-#define BLKPREP_OK             0       /* serve it */
-#define BLKPREP_KILL           1       /* fatal error, kill */
-#define BLKPREP_DEFER          2       /* leave on queue */
+enum {
+       BLKPREP_OK,             /* serve it */
+       BLKPREP_KILL,           /* fatal error, kill, return -EIO */
+       BLKPREP_DEFER,          /* leave on queue */
+       BLKPREP_INVALID,        /* invalid command, kill, return -EREMOTEIO */
+};
 
 extern unsigned long blk_max_low_pfn, blk_max_pfn;
 
@@ -892,7 +895,7 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq)
 {
        struct request_queue *q = rq->q;
 
-       if (unlikely(rq->cmd_type == REQ_TYPE_BLOCK_PC))
+       if (unlikely(rq->cmd_type != REQ_TYPE_FS))
                return q->limits.max_hw_sectors;
 
        if (!q->limits.chunk_sectors || (rq->cmd_flags & REQ_DISCARD))
@@ -1369,6 +1372,13 @@ static inline void put_dev_sector(Sector p)
        page_cache_release(p.v);
 }
 
+static inline bool __bvec_gap_to_prev(struct request_queue *q,
+                               struct bio_vec *bprv, unsigned int offset)
+{
+       return offset ||
+               ((bprv->bv_offset + bprv->bv_len) & queue_virt_boundary(q));
+}
+
 /*
  * Check if adding a bio_vec after bprv with offset would create a gap in
  * the SG list. Most drivers don't care about this, but some do.
@@ -1378,18 +1388,22 @@ static inline bool bvec_gap_to_prev(struct request_queue *q,
 {
        if (!queue_virt_boundary(q))
                return false;
-       return offset ||
-               ((bprv->bv_offset + bprv->bv_len) & queue_virt_boundary(q));
+       return __bvec_gap_to_prev(q, bprv, offset);
 }
 
 static inline bool bio_will_gap(struct request_queue *q, struct bio *prev,
                         struct bio *next)
 {
-       if (!bio_has_data(prev))
-               return false;
+       if (bio_has_data(prev) && queue_virt_boundary(q)) {
+               struct bio_vec pb, nb;
+
+               bio_get_last_bvec(prev, &pb);
+               bio_get_first_bvec(next, &nb);
 
-       return bvec_gap_to_prev(q, &prev->bi_io_vec[prev->bi_vcnt - 1],
-                               next->bi_io_vec[0].bv_offset);
+               return __bvec_gap_to_prev(q, &pb, nb.bv_offset);
+       }
+
+       return false;
 }
 
 static inline bool req_gap_back_merge(struct request *req, struct bio *bio)
index c1ef6f1..15151f3 100644 (file)
@@ -75,6 +75,7 @@
 #define CEPH_FEATURE_CRUSH_TUNABLES5   (1ULL<<58) /* chooseleaf stable mode */
 // duplicated since it was introduced at the same time as CEPH_FEATURE_CRUSH_TUNABLES5
 #define CEPH_FEATURE_NEW_OSDOPREPLY_ENCODING   (1ULL<<58) /* New, v7 encoding */
+#define CEPH_FEATURE_FS_FILE_LAYOUT_V2       (1ULL<<58) /* file_layout_t */
 
 /*
  * The introduction of CEPH_FEATURE_OSD_SNAPMAPPER caused the feature
index 7f540f7..789471d 100644 (file)
@@ -127,6 +127,12 @@ struct cgroup_subsys_state {
         */
        u64 serial_nr;
 
+       /*
+        * Incremented by online self and children.  Used to guarantee that
+        * parents are not offlined before their children.
+        */
+       atomic_t online_cnt;
+
        /* percpu_ref killing and RCU release */
        struct rcu_head rcu_head;
        struct work_struct destroy_work;
index 00b042c..48f5aab 100644 (file)
@@ -144,7 +144,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
  */
 #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
 #define __trace_if(cond) \
-       if (__builtin_constant_p((cond)) ? !!(cond) :                   \
+       if (__builtin_constant_p(!!(cond)) ? !!(cond) :                 \
        ({                                                              \
                int ______r;                                            \
                static struct ftrace_branch_data                        \
index 85a868c..fea160e 100644 (file)
@@ -137,6 +137,8 @@ static inline void set_mems_allowed(nodemask_t nodemask)
        task_unlock(current);
 }
 
+extern void cpuset_post_attach_flush(void);
+
 #else /* !CONFIG_CPUSETS */
 
 static inline bool cpusets_enabled(void) { return false; }
@@ -243,6 +245,10 @@ static inline bool read_mems_allowed_retry(unsigned int seq)
        return false;
 }
 
+static inline void cpuset_post_attach_flush(void)
+{
+}
+
 #endif /* !CONFIG_CPUSETS */
 
 #endif /* _LINUX_CPUSET_H */
index 818e450..636dd59 100644 (file)
@@ -7,7 +7,7 @@
 
 ssize_t dax_do_io(struct kiocb *, struct inode *, struct iov_iter *, loff_t,
                  get_block_t, dio_iodone_t, int flags);
-int dax_clear_blocks(struct inode *, sector_t block, long size);
+int dax_clear_sectors(struct block_device *bdev, sector_t _sector, long _size);
 int dax_zero_page_range(struct inode *, loff_t from, unsigned len, get_block_t);
 int dax_truncate_page(struct inode *, loff_t from, get_block_t);
 int dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t,
@@ -52,6 +52,8 @@ static inline bool dax_mapping(struct address_space *mapping)
 {
        return mapping->host && IS_DAX(mapping->host);
 }
-int dax_writeback_mapping_range(struct address_space *mapping, loff_t start,
-               loff_t end);
+
+struct writeback_control;
+int dax_writeback_mapping_range(struct address_space *mapping,
+               struct block_device *bdev, struct writeback_control *wbc);
 #endif
index 7781ce1..c4b5f4b 100644 (file)
@@ -409,9 +409,7 @@ static inline bool d_mountpoint(const struct dentry *dentry)
  */
 static inline unsigned __d_entry_type(const struct dentry *dentry)
 {
-       unsigned type = READ_ONCE(dentry->d_flags);
-       smp_rmb();
-       return type & DCACHE_ENTRY_TYPE;
+       return dentry->d_flags & DCACHE_ENTRY_TYPE;
 }
 
 static inline bool d_is_miss(const struct dentry *dentry)
index 251a209..e0ee0b3 100644 (file)
@@ -19,6 +19,8 @@
 
 int devpts_new_index(struct inode *ptmx_inode);
 void devpts_kill_index(struct inode *ptmx_inode, int idx);
+void devpts_add_ref(struct inode *ptmx_inode);
+void devpts_del_ref(struct inode *ptmx_inode);
 /* mknod in devpts */
 struct inode *devpts_pty_new(struct inode *ptmx_inode, dev_t device, int index,
                void *priv);
@@ -32,6 +34,8 @@ void devpts_pty_kill(struct inode *inode);
 /* Dummy stubs in the no-pty case */
 static inline int devpts_new_index(struct inode *ptmx_inode) { return -EINVAL; }
 static inline void devpts_kill_index(struct inode *ptmx_inode, int idx) { }
+static inline void devpts_add_ref(struct inode *ptmx_inode) { }
+static inline void devpts_del_ref(struct inode *ptmx_inode) { }
 static inline struct inode *devpts_pty_new(struct inode *ptmx_inode,
                dev_t device, int index, void *priv)
 {
index 75857cd..728ef07 100644 (file)
@@ -386,7 +386,7 @@ static inline void dma_free_attrs(struct device *dev, size_t size,
        if (dma_release_from_coherent(dev, get_order(size), cpu_addr))
                return;
 
-       if (!ops->free)
+       if (!ops->free || !cpu_addr)
                return;
 
        debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
index 569b5a8..47be3ad 100644 (file)
@@ -1199,7 +1199,10 @@ int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
 struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid,
                                       struct list_head *head, bool remove);
 
-bool efivar_validate(efi_char16_t *var_name, u8 *data, unsigned long len);
+bool efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data,
+                    unsigned long data_size);
+bool efivar_variable_is_removable(efi_guid_t vendor, const char *name,
+                                 size_t len);
 
 extern struct work_struct efivar_work;
 void efivar_run_worker(void);
index 6b7e89f..533c440 100644 (file)
@@ -220,10 +220,7 @@ struct fsnotify_mark {
        /* List of marks by group->i_fsnotify_marks. Also reused for queueing
         * mark into destroy_list when it's waiting for the end of SRCU period
         * before it can be freed. [group->mark_mutex] */
-       union {
-               struct list_head g_list;
-               struct rcu_head g_rcu;
-       };
+       struct list_head g_list;
        /* Protects inode / mnt pointers, flags, masks */
        spinlock_t lock;
        /* List of marks for inode / vfsmount [obj_lock] */
index 81de712..c2b340e 100644 (file)
@@ -603,6 +603,7 @@ extern int ftrace_arch_read_dyn_info(char *buf, int size);
 
 extern int skip_trace(unsigned long ip);
 extern void ftrace_module_init(struct module *mod);
+extern void ftrace_module_enable(struct module *mod);
 extern void ftrace_release_mod(struct module *mod);
 
 extern void ftrace_disable_daemon(void);
@@ -612,8 +613,9 @@ static inline int skip_trace(unsigned long ip) { return 0; }
 static inline int ftrace_force_update(void) { return 0; }
 static inline void ftrace_disable_daemon(void) { }
 static inline void ftrace_enable_daemon(void) { }
-static inline void ftrace_release_mod(struct module *mod) {}
-static inline void ftrace_module_init(struct module *mod) {}
+static inline void ftrace_module_init(struct module *mod) { }
+static inline void ftrace_module_enable(struct module *mod) { }
+static inline void ftrace_release_mod(struct module *mod) { }
 static inline __init int register_ftrace_command(struct ftrace_func_command *cmd)
 {
        return -EINVAL;
index 821273c..2d9b650 100644 (file)
@@ -235,6 +235,9 @@ static inline void dmar_writeq(void __iomem *addr, u64 val)
 /* low 64 bit */
 #define dma_frcd_page_addr(d) (d & (((u64)-1) << PAGE_SHIFT))
 
+/* PRS_REG */
+#define DMA_PRS_PPR    ((u32)1)
+
 #define IOMMU_WAIT_OP(iommu, offset, op, cond, sts)                    \
 do {                                                                   \
        cycles_t start_time = get_cycles();                             \
index 4b9f85c..0fdc798 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _LINUX_KASAN_H
 #define _LINUX_KASAN_H
 
+#include <linux/sched.h>
 #include <linux/types.h>
 
 struct kmem_cache;
@@ -13,7 +14,6 @@ struct vm_struct;
 
 #include <asm/kasan.h>
 #include <asm/pgtable.h>
-#include <linux/sched.h>
 
 extern unsigned char kasan_zero_page[PAGE_SIZE];
 extern pte_t kasan_zero_pte[PTRS_PER_PTE];
@@ -43,6 +43,8 @@ static inline void kasan_disable_current(void)
 
 void kasan_unpoison_shadow(const void *address, size_t size);
 
+void kasan_unpoison_task_stack(struct task_struct *task);
+
 void kasan_alloc_pages(struct page *page, unsigned int order);
 void kasan_free_pages(struct page *page, unsigned int order);
 
@@ -66,6 +68,8 @@ void kasan_free_shadow(const struct vm_struct *vm);
 
 static inline void kasan_unpoison_shadow(const void *address, size_t size) {}
 
+static inline void kasan_unpoison_task_stack(struct task_struct *task) {}
+
 static inline void kasan_enable_current(void) {}
 static inline void kasan_disable_current(void) {}
 
index 851821b..2c4ebef 100644 (file)
@@ -526,6 +526,7 @@ enum ata_lpm_policy {
 enum ata_lpm_hints {
        ATA_LPM_EMPTY           = (1 << 0), /* port empty/probing */
        ATA_LPM_HIPM            = (1 << 1), /* may use HIPM */
+       ATA_LPM_WAKE_ONLY       = (1 << 2), /* only wake up link */
 };
 
 /* forward declarations */
@@ -719,7 +720,7 @@ struct ata_device {
        union {
                u16             id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
                u32             gscr[SATA_PMP_GSCR_DWORDS]; /* PMP GSCR block */
-       };
+       } ____cacheline_aligned;
 
        /* DEVSLP Timing Variables from Identify Device Data Log */
        u8                      devslp_timing[ATA_LOG_DEVSLP_SIZE];
index bed40df..141ffdd 100644 (file)
@@ -26,9 +26,8 @@ enum {
 
        /* need to set a limit somewhere, but yes, this is likely overkill */
        ND_IOCTL_MAX_BUFLEN = SZ_4M,
-       ND_CMD_MAX_ELEM = 4,
+       ND_CMD_MAX_ELEM = 5,
        ND_CMD_MAX_ENVELOPE = 16,
-       ND_CMD_ARS_STATUS_MAX = SZ_4K,
        ND_MAX_MAPPINGS = 32,
 
        /* region flag indicating to direct-map persistent memory by default */
index d675011..2190419 100644 (file)
@@ -135,6 +135,10 @@ enum {
        /* Memory types */
        NVM_ID_FMTYPE_SLC       = 0,
        NVM_ID_FMTYPE_MLC       = 1,
+
+       /* Device capabilities */
+       NVM_ID_DCAP_BBLKMGMT    = 0x1,
+       NVM_UD_DCAP_ECC         = 0x2,
 };
 
 struct nvm_id_lp_mlc {
index 30cf420..5356f4d 100644 (file)
@@ -113,17 +113,6 @@ extern void __list_del_entry(struct list_head *entry);
 extern void list_del(struct list_head *entry);
 #endif
 
-#ifdef CONFIG_DEBUG_LIST
-/*
- * See devm_memremap_pages() which wants DEBUG_LIST=y to assert if one
- * of the pages it allocates is ever passed to list_add()
- */
-extern void list_force_poison(struct list_head *entry);
-#else
-/* fallback to the less strict LIST_POISON* definitions */
-#define list_force_poison list_del
-#endif
-
 /**
  * list_replace - replace old entry by new one
  * @old : the element to be replaced
index c57e424..4dca42f 100644 (file)
@@ -66,7 +66,7 @@ struct lock_class {
        /*
         * class-hash:
         */
-       struct list_head                hash_entry;
+       struct hlist_node               hash_entry;
 
        /*
         * global list of all lock-classes:
@@ -199,7 +199,7 @@ struct lock_chain {
        u8                              irq_context;
        u8                              depth;
        u16                             base;
-       struct list_head                entry;
+       struct hlist_node               entry;
        u64                             chain_key;
 };
 
index 430a929..a0e8cc8 100644 (file)
@@ -44,6 +44,8 @@
 
 #include <linux/timecounter.h>
 
+#define DEFAULT_UAR_PAGE_SHIFT  12
+
 #define MAX_MSIX_P_PORT                17
 #define MAX_MSIX               64
 #define MIN_MSIX_P_PORT                5
@@ -856,6 +858,7 @@ struct mlx4_dev {
        u64                     regid_promisc_array[MLX4_MAX_PORTS + 1];
        u64                     regid_allmulti_array[MLX4_MAX_PORTS + 1];
        struct mlx4_vf_dev     *dev_vfs;
+       u8  uar_page_shift;
 };
 
 struct mlx4_clock_params {
@@ -1528,4 +1531,14 @@ int mlx4_ACCESS_PTYS_REG(struct mlx4_dev *dev,
 int mlx4_get_internal_clock_params(struct mlx4_dev *dev,
                                   struct mlx4_clock_params *params);
 
+static inline int mlx4_to_hw_uar_index(struct mlx4_dev *dev, int index)
+{
+       return (index << (PAGE_SHIFT - dev->uar_page_shift));
+}
+
+static inline int mlx4_get_num_reserved_uar(struct mlx4_dev *dev)
+{
+       /* The first 128 UARs are used for EQ doorbells */
+       return (128 >> (PAGE_SHIFT - dev->uar_page_shift));
+}
 #endif /* MLX4_DEVICE_H */
index 231ab6b..58eef02 100644 (file)
@@ -207,15 +207,15 @@ struct mlx5_ifc_flow_table_fields_supported_bits {
        u8         outer_dmac[0x1];
        u8         outer_smac[0x1];
        u8         outer_ether_type[0x1];
-       u8         reserved_0[0x1];
+       u8         reserved_at_3[0x1];
        u8         outer_first_prio[0x1];
        u8         outer_first_cfi[0x1];
        u8         outer_first_vid[0x1];
-       u8         reserved_1[0x1];
+       u8         reserved_at_7[0x1];
        u8         outer_second_prio[0x1];
        u8         outer_second_cfi[0x1];
        u8         outer_second_vid[0x1];
-       u8         reserved_2[0x1];
+       u8         reserved_at_b[0x1];
        u8         outer_sip[0x1];
        u8         outer_dip[0x1];
        u8         outer_frag[0x1];
@@ -230,21 +230,21 @@ struct mlx5_ifc_flow_table_fields_supported_bits {
        u8         outer_gre_protocol[0x1];
        u8         outer_gre_key[0x1];
        u8         outer_vxlan_vni[0x1];
-       u8         reserved_3[0x5];
+       u8         reserved_at_1a[0x5];
        u8         source_eswitch_port[0x1];
 
        u8         inner_dmac[0x1];
        u8         inner_smac[0x1];
        u8         inner_ether_type[0x1];
-       u8         reserved_4[0x1];
+       u8         reserved_at_23[0x1];
        u8         inner_first_prio[0x1];
        u8         inner_first_cfi[0x1];
        u8         inner_first_vid[0x1];
-       u8         reserved_5[0x1];
+       u8         reserved_at_27[0x1];
        u8         inner_second_prio[0x1];
        u8         inner_second_cfi[0x1];
        u8         inner_second_vid[0x1];
-       u8         reserved_6[0x1];
+       u8         reserved_at_2b[0x1];
        u8         inner_sip[0x1];
        u8         inner_dip[0x1];
        u8         inner_frag[0x1];
@@ -256,37 +256,37 @@ struct mlx5_ifc_flow_table_fields_supported_bits {
        u8         inner_tcp_sport[0x1];
        u8         inner_tcp_dport[0x1];
        u8         inner_tcp_flags[0x1];
-       u8         reserved_7[0x9];
+       u8         reserved_at_37[0x9];
 
-       u8         reserved_8[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_flow_table_prop_layout_bits {
        u8         ft_support[0x1];
-       u8         reserved_0[0x2];
+       u8         reserved_at_1[0x2];
        u8         flow_modify_en[0x1];
        u8         modify_root[0x1];
        u8         identified_miss_table_mode[0x1];
        u8         flow_table_modify[0x1];
-       u8         reserved_1[0x19];
+       u8         reserved_at_7[0x19];
 
-       u8         reserved_2[0x2];
+       u8         reserved_at_20[0x2];
        u8         log_max_ft_size[0x6];
-       u8         reserved_3[0x10];
+       u8         reserved_at_28[0x10];
        u8         max_ft_level[0x8];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_40[0x20];
 
-       u8         reserved_5[0x18];
+       u8         reserved_at_60[0x18];
        u8         log_max_ft_num[0x8];
 
-       u8         reserved_6[0x18];
+       u8         reserved_at_80[0x18];
        u8         log_max_destination[0x8];
 
-       u8         reserved_7[0x18];
+       u8         reserved_at_a0[0x18];
        u8         log_max_flow[0x8];
 
-       u8         reserved_8[0x40];
+       u8         reserved_at_c0[0x40];
 
        struct mlx5_ifc_flow_table_fields_supported_bits ft_field_support;
 
@@ -298,13 +298,13 @@ struct mlx5_ifc_odp_per_transport_service_cap_bits {
        u8         receive[0x1];
        u8         write[0x1];
        u8         read[0x1];
-       u8         reserved_0[0x1];
+       u8         reserved_at_4[0x1];
        u8         srq_receive[0x1];
-       u8         reserved_1[0x1a];
+       u8         reserved_at_6[0x1a];
 };
 
 struct mlx5_ifc_ipv4_layout_bits {
-       u8         reserved_0[0x60];
+       u8         reserved_at_0[0x60];
 
        u8         ipv4[0x20];
 };
@@ -316,7 +316,7 @@ struct mlx5_ifc_ipv6_layout_bits {
 union mlx5_ifc_ipv6_layout_ipv4_layout_auto_bits {
        struct mlx5_ifc_ipv6_layout_bits ipv6_layout;
        struct mlx5_ifc_ipv4_layout_bits ipv4_layout;
-       u8         reserved_0[0x80];
+       u8         reserved_at_0[0x80];
 };
 
 struct mlx5_ifc_fte_match_set_lyr_2_4_bits {
@@ -336,15 +336,15 @@ struct mlx5_ifc_fte_match_set_lyr_2_4_bits {
        u8         ip_dscp[0x6];
        u8         ip_ecn[0x2];
        u8         vlan_tag[0x1];
-       u8         reserved_0[0x1];
+       u8         reserved_at_91[0x1];
        u8         frag[0x1];
-       u8         reserved_1[0x4];
+       u8         reserved_at_93[0x4];
        u8         tcp_flags[0x9];
 
        u8         tcp_sport[0x10];
        u8         tcp_dport[0x10];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_c0[0x20];
 
        u8         udp_sport[0x10];
        u8         udp_dport[0x10];
@@ -355,9 +355,9 @@ struct mlx5_ifc_fte_match_set_lyr_2_4_bits {
 };
 
 struct mlx5_ifc_fte_match_set_misc_bits {
-       u8         reserved_0[0x20];
+       u8         reserved_at_0[0x20];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         source_port[0x10];
 
        u8         outer_second_prio[0x3];
@@ -369,31 +369,31 @@ struct mlx5_ifc_fte_match_set_misc_bits {
 
        u8         outer_second_vlan_tag[0x1];
        u8         inner_second_vlan_tag[0x1];
-       u8         reserved_2[0xe];
+       u8         reserved_at_62[0xe];
        u8         gre_protocol[0x10];
 
        u8         gre_key_h[0x18];
        u8         gre_key_l[0x8];
 
        u8         vxlan_vni[0x18];
-       u8         reserved_3[0x8];
+       u8         reserved_at_b8[0x8];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_c0[0x20];
 
-       u8         reserved_5[0xc];
+       u8         reserved_at_e0[0xc];
        u8         outer_ipv6_flow_label[0x14];
 
-       u8         reserved_6[0xc];
+       u8         reserved_at_100[0xc];
        u8         inner_ipv6_flow_label[0x14];
 
-       u8         reserved_7[0xe0];
+       u8         reserved_at_120[0xe0];
 };
 
 struct mlx5_ifc_cmd_pas_bits {
        u8         pa_h[0x20];
 
        u8         pa_l[0x14];
-       u8         reserved_0[0xc];
+       u8         reserved_at_34[0xc];
 };
 
 struct mlx5_ifc_uint64_bits {
@@ -418,31 +418,31 @@ enum {
 struct mlx5_ifc_ads_bits {
        u8         fl[0x1];
        u8         free_ar[0x1];
-       u8         reserved_0[0xe];
+       u8         reserved_at_2[0xe];
        u8         pkey_index[0x10];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_20[0x8];
        u8         grh[0x1];
        u8         mlid[0x7];
        u8         rlid[0x10];
 
        u8         ack_timeout[0x5];
-       u8         reserved_2[0x3];
+       u8         reserved_at_45[0x3];
        u8         src_addr_index[0x8];
-       u8         reserved_3[0x4];
+       u8         reserved_at_50[0x4];
        u8         stat_rate[0x4];
        u8         hop_limit[0x8];
 
-       u8         reserved_4[0x4];
+       u8         reserved_at_60[0x4];
        u8         tclass[0x8];
        u8         flow_label[0x14];
 
        u8         rgid_rip[16][0x8];
 
-       u8         reserved_5[0x4];
+       u8         reserved_at_100[0x4];
        u8         f_dscp[0x1];
        u8         f_ecn[0x1];
-       u8         reserved_6[0x1];
+       u8         reserved_at_106[0x1];
        u8         f_eth_prio[0x1];
        u8         ecn[0x2];
        u8         dscp[0x6];
@@ -458,25 +458,25 @@ struct mlx5_ifc_ads_bits {
 };
 
 struct mlx5_ifc_flow_table_nic_cap_bits {
-       u8         reserved_0[0x200];
+       u8         reserved_at_0[0x200];
 
        struct mlx5_ifc_flow_table_prop_layout_bits flow_table_properties_nic_receive;
 
-       u8         reserved_1[0x200];
+       u8         reserved_at_400[0x200];
 
        struct mlx5_ifc_flow_table_prop_layout_bits flow_table_properties_nic_receive_sniffer;
 
        struct mlx5_ifc_flow_table_prop_layout_bits flow_table_properties_nic_transmit;
 
-       u8         reserved_2[0x200];
+       u8         reserved_at_a00[0x200];
 
        struct mlx5_ifc_flow_table_prop_layout_bits flow_table_properties_nic_transmit_sniffer;
 
-       u8         reserved_3[0x7200];
+       u8         reserved_at_e00[0x7200];
 };
 
 struct mlx5_ifc_flow_table_eswitch_cap_bits {
-       u8     reserved_0[0x200];
+       u8     reserved_at_0[0x200];
 
        struct mlx5_ifc_flow_table_prop_layout_bits flow_table_properties_nic_esw_fdb;
 
@@ -484,7 +484,7 @@ struct mlx5_ifc_flow_table_eswitch_cap_bits {
 
        struct mlx5_ifc_flow_table_prop_layout_bits flow_table_properties_esw_acl_egress;
 
-       u8      reserved_1[0x7800];
+       u8      reserved_at_800[0x7800];
 };
 
 struct mlx5_ifc_e_switch_cap_bits {
@@ -493,9 +493,9 @@ struct mlx5_ifc_e_switch_cap_bits {
        u8         vport_svlan_insert[0x1];
        u8         vport_cvlan_insert_if_not_exist[0x1];
        u8         vport_cvlan_insert_overwrite[0x1];
-       u8         reserved_0[0x1b];
+       u8         reserved_at_5[0x1b];
 
-       u8         reserved_1[0x7e0];
+       u8         reserved_at_20[0x7e0];
 };
 
 struct mlx5_ifc_per_protocol_networking_offload_caps_bits {
@@ -504,51 +504,51 @@ struct mlx5_ifc_per_protocol_networking_offload_caps_bits {
        u8         lro_cap[0x1];
        u8         lro_psh_flag[0x1];
        u8         lro_time_stamp[0x1];
-       u8         reserved_0[0x3];
+       u8         reserved_at_5[0x3];
        u8         self_lb_en_modifiable[0x1];
-       u8         reserved_1[0x2];
+       u8         reserved_at_9[0x2];
        u8         max_lso_cap[0x5];
-       u8         reserved_2[0x4];
+       u8         reserved_at_10[0x4];
        u8         rss_ind_tbl_cap[0x4];
-       u8         reserved_3[0x3];
+       u8         reserved_at_18[0x3];
        u8         tunnel_lso_const_out_ip_id[0x1];
-       u8         reserved_4[0x2];
+       u8         reserved_at_1c[0x2];
        u8         tunnel_statless_gre[0x1];
        u8         tunnel_stateless_vxlan[0x1];
 
-       u8         reserved_5[0x20];
+       u8         reserved_at_20[0x20];
 
-       u8         reserved_6[0x10];
+       u8         reserved_at_40[0x10];
        u8         lro_min_mss_size[0x10];
 
-       u8         reserved_7[0x120];
+       u8         reserved_at_60[0x120];
 
        u8         lro_timer_supported_periods[4][0x20];
 
-       u8         reserved_8[0x600];
+       u8         reserved_at_200[0x600];
 };
 
 struct mlx5_ifc_roce_cap_bits {
        u8         roce_apm[0x1];
-       u8         reserved_0[0x1f];
+       u8         reserved_at_1[0x1f];
 
-       u8         reserved_1[0x60];
+       u8         reserved_at_20[0x60];
 
-       u8         reserved_2[0xc];
+       u8         reserved_at_80[0xc];
        u8         l3_type[0x4];
-       u8         reserved_3[0x8];
+       u8         reserved_at_90[0x8];
        u8         roce_version[0x8];
 
-       u8         reserved_4[0x10];
+       u8         reserved_at_a0[0x10];
        u8         r_roce_dest_udp_port[0x10];
 
        u8         r_roce_max_src_udp_port[0x10];
        u8         r_roce_min_src_udp_port[0x10];
 
-       u8         reserved_5[0x10];
+       u8         reserved_at_e0[0x10];
        u8         roce_address_table_size[0x10];
 
-       u8         reserved_6[0x700];
+       u8         reserved_at_100[0x700];
 };
 
 enum {
@@ -576,35 +576,35 @@ enum {
 };
 
 struct mlx5_ifc_atomic_caps_bits {
-       u8         reserved_0[0x40];
+       u8         reserved_at_0[0x40];
 
        u8         atomic_req_8B_endianess_mode[0x2];
-       u8         reserved_1[0x4];
+       u8         reserved_at_42[0x4];
        u8         supported_atomic_req_8B_endianess_mode_1[0x1];
 
-       u8         reserved_2[0x19];
+       u8         reserved_at_47[0x19];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
-       u8         reserved_4[0x10];
+       u8         reserved_at_80[0x10];
        u8         atomic_operations[0x10];
 
-       u8         reserved_5[0x10];
+       u8         reserved_at_a0[0x10];
        u8         atomic_size_qp[0x10];
 
-       u8         reserved_6[0x10];
+       u8         reserved_at_c0[0x10];
        u8         atomic_size_dc[0x10];
 
-       u8         reserved_7[0x720];
+       u8         reserved_at_e0[0x720];
 };
 
 struct mlx5_ifc_odp_cap_bits {
-       u8         reserved_0[0x40];
+       u8         reserved_at_0[0x40];
 
        u8         sig[0x1];
-       u8         reserved_1[0x1f];
+       u8         reserved_at_41[0x1f];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 
        struct mlx5_ifc_odp_per_transport_service_cap_bits rc_odp_caps;
 
@@ -612,7 +612,7 @@ struct mlx5_ifc_odp_cap_bits {
 
        struct mlx5_ifc_odp_per_transport_service_cap_bits ud_odp_caps;
 
-       u8         reserved_3[0x720];
+       u8         reserved_at_e0[0x720];
 };
 
 enum {
@@ -660,55 +660,55 @@ enum {
 };
 
 struct mlx5_ifc_cmd_hca_cap_bits {
-       u8         reserved_0[0x80];
+       u8         reserved_at_0[0x80];
 
        u8         log_max_srq_sz[0x8];
        u8         log_max_qp_sz[0x8];
-       u8         reserved_1[0xb];
+       u8         reserved_at_90[0xb];
        u8         log_max_qp[0x5];
 
-       u8         reserved_2[0xb];
+       u8         reserved_at_a0[0xb];
        u8         log_max_srq[0x5];
-       u8         reserved_3[0x10];
+       u8         reserved_at_b0[0x10];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_c0[0x8];
        u8         log_max_cq_sz[0x8];
-       u8         reserved_5[0xb];
+       u8         reserved_at_d0[0xb];
        u8         log_max_cq[0x5];
 
        u8         log_max_eq_sz[0x8];
-       u8         reserved_6[0x2];
+       u8         reserved_at_e8[0x2];
        u8         log_max_mkey[0x6];
-       u8         reserved_7[0xc];
+       u8         reserved_at_f0[0xc];
        u8         log_max_eq[0x4];
 
        u8         max_indirection[0x8];
-       u8         reserved_8[0x1];
+       u8         reserved_at_108[0x1];
        u8         log_max_mrw_sz[0x7];
-       u8         reserved_9[0x2];
+       u8         reserved_at_110[0x2];
        u8         log_max_bsf_list_size[0x6];
-       u8         reserved_10[0x2];
+       u8         reserved_at_118[0x2];
        u8         log_max_klm_list_size[0x6];
 
-       u8         reserved_11[0xa];
+       u8         reserved_at_120[0xa];
        u8         log_max_ra_req_dc[0x6];
-       u8         reserved_12[0xa];
+       u8         reserved_at_130[0xa];
        u8         log_max_ra_res_dc[0x6];
 
-       u8         reserved_13[0xa];
+       u8         reserved_at_140[0xa];
        u8         log_max_ra_req_qp[0x6];
-       u8         reserved_14[0xa];
+       u8         reserved_at_150[0xa];
        u8         log_max_ra_res_qp[0x6];
 
        u8         pad_cap[0x1];
        u8         cc_query_allowed[0x1];
        u8         cc_modify_allowed[0x1];
-       u8         reserved_15[0xd];
+       u8         reserved_at_163[0xd];
        u8         gid_table_size[0x10];
 
        u8         out_of_seq_cnt[0x1];
        u8         vport_counters[0x1];
-       u8         reserved_16[0x4];
+       u8         reserved_at_182[0x4];
        u8         max_qp_cnt[0xa];
        u8         pkey_table_size[0x10];
 
@@ -716,158 +716,158 @@ struct mlx5_ifc_cmd_hca_cap_bits {
        u8         vhca_group_manager[0x1];
        u8         ib_virt[0x1];
        u8         eth_virt[0x1];
-       u8         reserved_17[0x1];
+       u8         reserved_at_1a4[0x1];
        u8         ets[0x1];
        u8         nic_flow_table[0x1];
        u8         eswitch_flow_table[0x1];
        u8         early_vf_enable;
-       u8         reserved_18[0x2];
+       u8         reserved_at_1a8[0x2];
        u8         local_ca_ack_delay[0x5];
-       u8         reserved_19[0x6];
+       u8         reserved_at_1af[0x6];
        u8         port_type[0x2];
        u8         num_ports[0x8];
 
-       u8         reserved_20[0x3];
+       u8         reserved_at_1bf[0x3];
        u8         log_max_msg[0x5];
-       u8         reserved_21[0x18];
+       u8         reserved_at_1c7[0x18];
 
        u8         stat_rate_support[0x10];
-       u8         reserved_22[0xc];
+       u8         reserved_at_1ef[0xc];
        u8         cqe_version[0x4];
 
        u8         compact_address_vector[0x1];
-       u8         reserved_23[0xe];
+       u8         reserved_at_200[0xe];
        u8         drain_sigerr[0x1];
        u8         cmdif_checksum[0x2];
        u8         sigerr_cqe[0x1];
-       u8         reserved_24[0x1];
+       u8         reserved_at_212[0x1];
        u8         wq_signature[0x1];
        u8         sctr_data_cqe[0x1];
-       u8         reserved_25[0x1];
+       u8         reserved_at_215[0x1];
        u8         sho[0x1];
        u8         tph[0x1];
        u8         rf[0x1];
        u8         dct[0x1];
-       u8         reserved_26[0x1];
+       u8         reserved_at_21a[0x1];
        u8         eth_net_offloads[0x1];
        u8         roce[0x1];
        u8         atomic[0x1];
-       u8         reserved_27[0x1];
+       u8         reserved_at_21e[0x1];
 
        u8         cq_oi[0x1];
        u8         cq_resize[0x1];
        u8         cq_moderation[0x1];
-       u8         reserved_28[0x3];
+       u8         reserved_at_222[0x3];
        u8         cq_eq_remap[0x1];
        u8         pg[0x1];
        u8         block_lb_mc[0x1];
-       u8         reserved_29[0x1];
+       u8         reserved_at_228[0x1];
        u8         scqe_break_moderation[0x1];
-       u8         reserved_30[0x1];
+       u8         reserved_at_22a[0x1];
        u8         cd[0x1];
-       u8         reserved_31[0x1];
+       u8         reserved_at_22c[0x1];
        u8         apm[0x1];
-       u8         reserved_32[0x7];
+       u8         reserved_at_22e[0x7];
        u8         qkv[0x1];
        u8         pkv[0x1];
-       u8         reserved_33[0x4];
+       u8         reserved_at_237[0x4];
        u8         xrc[0x1];
        u8         ud[0x1];
        u8         uc[0x1];
        u8         rc[0x1];
 
-       u8         reserved_34[0xa];
+       u8         reserved_at_23f[0xa];
        u8         uar_sz[0x6];
-       u8         reserved_35[0x8];
+       u8         reserved_at_24f[0x8];
        u8         log_pg_sz[0x8];
 
        u8         bf[0x1];
-       u8         reserved_36[0x1];
+       u8         reserved_at_260[0x1];
        u8         pad_tx_eth_packet[0x1];
-       u8         reserved_37[0x8];
+       u8         reserved_at_262[0x8];
        u8         log_bf_reg_size[0x5];
-       u8         reserved_38[0x10];
+       u8         reserved_at_26f[0x10];
 
-       u8         reserved_39[0x10];
+       u8         reserved_at_27f[0x10];
        u8         max_wqe_sz_sq[0x10];
 
-       u8         reserved_40[0x10];
+       u8         reserved_at_29f[0x10];
        u8         max_wqe_sz_rq[0x10];
 
-       u8         reserved_41[0x10];
+       u8         reserved_at_2bf[0x10];
        u8         max_wqe_sz_sq_dc[0x10];
 
-       u8         reserved_42[0x7];
+       u8         reserved_at_2df[0x7];
        u8         max_qp_mcg[0x19];
 
-       u8         reserved_43[0x18];
+       u8         reserved_at_2ff[0x18];
        u8         log_max_mcg[0x8];
 
-       u8         reserved_44[0x3];
+       u8         reserved_at_31f[0x3];
        u8         log_max_transport_domain[0x5];
-       u8         reserved_45[0x3];
+       u8         reserved_at_327[0x3];
        u8         log_max_pd[0x5];
-       u8         reserved_46[0xb];
+       u8         reserved_at_32f[0xb];
        u8         log_max_xrcd[0x5];
 
-       u8         reserved_47[0x20];
+       u8         reserved_at_33f[0x20];
 
-       u8         reserved_48[0x3];
+       u8         reserved_at_35f[0x3];
        u8         log_max_rq[0x5];
-       u8         reserved_49[0x3];
+       u8         reserved_at_367[0x3];
        u8         log_max_sq[0x5];
-       u8         reserved_50[0x3];
+       u8         reserved_at_36f[0x3];
        u8         log_max_tir[0x5];
-       u8         reserved_51[0x3];
+       u8         reserved_at_377[0x3];
        u8         log_max_tis[0x5];
 
        u8         basic_cyclic_rcv_wqe[0x1];
-       u8         reserved_52[0x2];
+       u8         reserved_at_380[0x2];
        u8         log_max_rmp[0x5];
-       u8         reserved_53[0x3];
+       u8         reserved_at_387[0x3];
        u8         log_max_rqt[0x5];
-       u8         reserved_54[0x3];
+       u8         reserved_at_38f[0x3];
        u8         log_max_rqt_size[0x5];
-       u8         reserved_55[0x3];
+       u8         reserved_at_397[0x3];
        u8         log_max_tis_per_sq[0x5];
 
-       u8         reserved_56[0x3];
+       u8         reserved_at_39f[0x3];
        u8         log_max_stride_sz_rq[0x5];
-       u8         reserved_57[0x3];
+       u8         reserved_at_3a7[0x3];
        u8         log_min_stride_sz_rq[0x5];
-       u8         reserved_58[0x3];
+       u8         reserved_at_3af[0x3];
        u8         log_max_stride_sz_sq[0x5];
-       u8         reserved_59[0x3];
+       u8         reserved_at_3b7[0x3];
        u8         log_min_stride_sz_sq[0x5];
 
-       u8         reserved_60[0x1b];
+       u8         reserved_at_3bf[0x1b];
        u8         log_max_wq_sz[0x5];
 
        u8         nic_vport_change_event[0x1];
-       u8         reserved_61[0xa];
+       u8         reserved_at_3e0[0xa];
        u8         log_max_vlan_list[0x5];
-       u8         reserved_62[0x3];
+       u8         reserved_at_3ef[0x3];
        u8         log_max_current_mc_list[0x5];
-       u8         reserved_63[0x3];
+       u8         reserved_at_3f7[0x3];
        u8         log_max_current_uc_list[0x5];
 
-       u8         reserved_64[0x80];
+       u8         reserved_at_3ff[0x80];
 
-       u8         reserved_65[0x3];
+       u8         reserved_at_47f[0x3];
        u8         log_max_l2_table[0x5];
-       u8         reserved_66[0x8];
+       u8         reserved_at_487[0x8];
        u8         log_uar_page_sz[0x10];
 
-       u8         reserved_67[0x20];
+       u8         reserved_at_49f[0x20];
        u8         device_frequency_mhz[0x20];
        u8         device_frequency_khz[0x20];
-       u8         reserved_68[0x5f];
+       u8         reserved_at_4ff[0x5f];
        u8         cqe_zip[0x1];
 
        u8         cqe_zip_timeout[0x10];
        u8         cqe_zip_max_num[0x10];
 
-       u8         reserved_69[0x220];
+       u8         reserved_at_57f[0x220];
 };
 
 enum mlx5_flow_destination_type {
@@ -880,7 +880,7 @@ struct mlx5_ifc_dest_format_struct_bits {
        u8         destination_type[0x8];
        u8         destination_id[0x18];
 
-       u8         reserved_0[0x20];
+       u8         reserved_at_20[0x20];
 };
 
 struct mlx5_ifc_fte_match_param_bits {
@@ -890,7 +890,7 @@ struct mlx5_ifc_fte_match_param_bits {
 
        struct mlx5_ifc_fte_match_set_lyr_2_4_bits inner_headers;
 
-       u8         reserved_0[0xa00];
+       u8         reserved_at_600[0xa00];
 };
 
 enum {
@@ -922,18 +922,18 @@ struct mlx5_ifc_wq_bits {
        u8         wq_signature[0x1];
        u8         end_padding_mode[0x2];
        u8         cd_slave[0x1];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         hds_skip_first_sge[0x1];
        u8         log2_hds_buf_size[0x3];
-       u8         reserved_1[0x7];
+       u8         reserved_at_24[0x7];
        u8         page_offset[0x5];
        u8         lwm[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         pd[0x18];
 
-       u8         reserved_3[0x8];
+       u8         reserved_at_60[0x8];
        u8         uar_page[0x18];
 
        u8         dbr_addr[0x40];
@@ -942,60 +942,60 @@ struct mlx5_ifc_wq_bits {
 
        u8         sw_counter[0x20];
 
-       u8         reserved_4[0xc];
+       u8         reserved_at_100[0xc];
        u8         log_wq_stride[0x4];
-       u8         reserved_5[0x3];
+       u8         reserved_at_110[0x3];
        u8         log_wq_pg_sz[0x5];
-       u8         reserved_6[0x3];
+       u8         reserved_at_118[0x3];
        u8         log_wq_sz[0x5];
 
-       u8         reserved_7[0x4e0];
+       u8         reserved_at_120[0x4e0];
 
        struct mlx5_ifc_cmd_pas_bits pas[0];
 };
 
 struct mlx5_ifc_rq_num_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         rq_num[0x18];
 };
 
 struct mlx5_ifc_mac_address_layout_bits {
-       u8         reserved_0[0x10];
+       u8         reserved_at_0[0x10];
        u8         mac_addr_47_32[0x10];
 
        u8         mac_addr_31_0[0x20];
 };
 
 struct mlx5_ifc_vlan_layout_bits {
-       u8         reserved_0[0x14];
+       u8         reserved_at_0[0x14];
        u8         vlan[0x0c];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_20[0x20];
 };
 
 struct mlx5_ifc_cong_control_r_roce_ecn_np_bits {
-       u8         reserved_0[0xa0];
+       u8         reserved_at_0[0xa0];
 
        u8         min_time_between_cnps[0x20];
 
-       u8         reserved_1[0x12];
+       u8         reserved_at_c0[0x12];
        u8         cnp_dscp[0x6];
-       u8         reserved_2[0x5];
+       u8         reserved_at_d8[0x5];
        u8         cnp_802p_prio[0x3];
 
-       u8         reserved_3[0x720];
+       u8         reserved_at_e0[0x720];
 };
 
 struct mlx5_ifc_cong_control_r_roce_ecn_rp_bits {
-       u8         reserved_0[0x60];
+       u8         reserved_at_0[0x60];
 
-       u8         reserved_1[0x4];
+       u8         reserved_at_60[0x4];
        u8         clamp_tgt_rate[0x1];
-       u8         reserved_2[0x3];
+       u8         reserved_at_65[0x3];
        u8         clamp_tgt_rate_after_time_inc[0x1];
-       u8         reserved_3[0x17];
+       u8         reserved_at_69[0x17];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_80[0x20];
 
        u8         rpg_time_reset[0x20];
 
@@ -1015,7 +1015,7 @@ struct mlx5_ifc_cong_control_r_roce_ecn_rp_bits {
 
        u8         rpg_min_rate[0x20];
 
-       u8         reserved_5[0xe0];
+       u8         reserved_at_1c0[0xe0];
 
        u8         rate_to_set_on_first_cnp[0x20];
 
@@ -1025,15 +1025,15 @@ struct mlx5_ifc_cong_control_r_roce_ecn_rp_bits {
 
        u8         rate_reduce_monitor_period[0x20];
 
-       u8         reserved_6[0x20];
+       u8         reserved_at_320[0x20];
 
        u8         initial_alpha_value[0x20];
 
-       u8         reserved_7[0x4a0];
+       u8         reserved_at_360[0x4a0];
 };
 
 struct mlx5_ifc_cong_control_802_1qau_rp_bits {
-       u8         reserved_0[0x80];
+       u8         reserved_at_0[0x80];
 
        u8         rppp_max_rps[0x20];
 
@@ -1055,7 +1055,7 @@ struct mlx5_ifc_cong_control_802_1qau_rp_bits {
 
        u8         rpg_min_rate[0x20];
 
-       u8         reserved_1[0x640];
+       u8         reserved_at_1c0[0x640];
 };
 
 enum {
@@ -1205,7 +1205,7 @@ struct mlx5_ifc_phys_layer_cntrs_bits {
 
        u8         successful_recovery_events[0x20];
 
-       u8         reserved_0[0x180];
+       u8         reserved_at_640[0x180];
 };
 
 struct mlx5_ifc_eth_per_traffic_grp_data_layout_bits {
@@ -1213,7 +1213,7 @@ struct mlx5_ifc_eth_per_traffic_grp_data_layout_bits {
 
        u8         transmit_queue_low[0x20];
 
-       u8         reserved_0[0x780];
+       u8         reserved_at_40[0x780];
 };
 
 struct mlx5_ifc_eth_per_prio_grp_data_layout_bits {
@@ -1221,7 +1221,7 @@ struct mlx5_ifc_eth_per_prio_grp_data_layout_bits {
 
        u8         rx_octets_low[0x20];
 
-       u8         reserved_0[0xc0];
+       u8         reserved_at_40[0xc0];
 
        u8         rx_frames_high[0x20];
 
@@ -1231,7 +1231,7 @@ struct mlx5_ifc_eth_per_prio_grp_data_layout_bits {
 
        u8         tx_octets_low[0x20];
 
-       u8         reserved_1[0xc0];
+       u8         reserved_at_180[0xc0];
 
        u8         tx_frames_high[0x20];
 
@@ -1257,7 +1257,7 @@ struct mlx5_ifc_eth_per_prio_grp_data_layout_bits {
 
        u8         rx_pause_transition_low[0x20];
 
-       u8         reserved_2[0x400];
+       u8         reserved_at_3c0[0x400];
 };
 
 struct mlx5_ifc_eth_extended_cntrs_grp_data_layout_bits {
@@ -1265,7 +1265,7 @@ struct mlx5_ifc_eth_extended_cntrs_grp_data_layout_bits {
 
        u8         port_transmit_wait_low[0x20];
 
-       u8         reserved_0[0x780];
+       u8         reserved_at_40[0x780];
 };
 
 struct mlx5_ifc_eth_3635_cntrs_grp_data_layout_bits {
@@ -1333,7 +1333,7 @@ struct mlx5_ifc_eth_3635_cntrs_grp_data_layout_bits {
 
        u8         dot3out_pause_frames_low[0x20];
 
-       u8         reserved_0[0x3c0];
+       u8         reserved_at_400[0x3c0];
 };
 
 struct mlx5_ifc_eth_2819_cntrs_grp_data_layout_bits {
@@ -1421,7 +1421,7 @@ struct mlx5_ifc_eth_2819_cntrs_grp_data_layout_bits {
 
        u8         ether_stats_pkts8192to10239octets_low[0x20];
 
-       u8         reserved_0[0x280];
+       u8         reserved_at_540[0x280];
 };
 
 struct mlx5_ifc_eth_2863_cntrs_grp_data_layout_bits {
@@ -1477,7 +1477,7 @@ struct mlx5_ifc_eth_2863_cntrs_grp_data_layout_bits {
 
        u8         if_out_broadcast_pkts_low[0x20];
 
-       u8         reserved_0[0x480];
+       u8         reserved_at_340[0x480];
 };
 
 struct mlx5_ifc_eth_802_3_cntrs_grp_data_layout_bits {
@@ -1557,54 +1557,54 @@ struct mlx5_ifc_eth_802_3_cntrs_grp_data_layout_bits {
 
        u8         a_pause_mac_ctrl_frames_transmitted_low[0x20];
 
-       u8         reserved_0[0x300];
+       u8         reserved_at_4c0[0x300];
 };
 
 struct mlx5_ifc_cmd_inter_comp_event_bits {
        u8         command_completion_vector[0x20];
 
-       u8         reserved_0[0xc0];
+       u8         reserved_at_20[0xc0];
 };
 
 struct mlx5_ifc_stall_vl_event_bits {
-       u8         reserved_0[0x18];
+       u8         reserved_at_0[0x18];
        u8         port_num[0x1];
-       u8         reserved_1[0x3];
+       u8         reserved_at_19[0x3];
        u8         vl[0x4];
 
-       u8         reserved_2[0xa0];
+       u8         reserved_at_20[0xa0];
 };
 
 struct mlx5_ifc_db_bf_congestion_event_bits {
        u8         event_subtype[0x8];
-       u8         reserved_0[0x8];
+       u8         reserved_at_8[0x8];
        u8         congestion_level[0x8];
-       u8         reserved_1[0x8];
+       u8         reserved_at_18[0x8];
 
-       u8         reserved_2[0xa0];
+       u8         reserved_at_20[0xa0];
 };
 
 struct mlx5_ifc_gpio_event_bits {
-       u8         reserved_0[0x60];
+       u8         reserved_at_0[0x60];
 
        u8         gpio_event_hi[0x20];
 
        u8         gpio_event_lo[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_a0[0x40];
 };
 
 struct mlx5_ifc_port_state_change_event_bits {
-       u8         reserved_0[0x40];
+       u8         reserved_at_0[0x40];
 
        u8         port_num[0x4];
-       u8         reserved_1[0x1c];
+       u8         reserved_at_44[0x1c];
 
-       u8         reserved_2[0x80];
+       u8         reserved_at_60[0x80];
 };
 
 struct mlx5_ifc_dropped_packet_logged_bits {
-       u8         reserved_0[0xe0];
+       u8         reserved_at_0[0xe0];
 };
 
 enum {
@@ -1613,15 +1613,15 @@ enum {
 };
 
 struct mlx5_ifc_cq_error_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         cqn[0x18];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_20[0x20];
 
-       u8         reserved_2[0x18];
+       u8         reserved_at_40[0x18];
        u8         syndrome[0x8];
 
-       u8         reserved_3[0x80];
+       u8         reserved_at_60[0x80];
 };
 
 struct mlx5_ifc_rdma_page_fault_event_bits {
@@ -1629,14 +1629,14 @@ struct mlx5_ifc_rdma_page_fault_event_bits {
 
        u8         r_key[0x20];
 
-       u8         reserved_0[0x10];
+       u8         reserved_at_40[0x10];
        u8         packet_len[0x10];
 
        u8         rdma_op_len[0x20];
 
        u8         rdma_va[0x40];
 
-       u8         reserved_1[0x5];
+       u8         reserved_at_c0[0x5];
        u8         rdma[0x1];
        u8         write[0x1];
        u8         requestor[0x1];
@@ -1646,15 +1646,15 @@ struct mlx5_ifc_rdma_page_fault_event_bits {
 struct mlx5_ifc_wqe_associated_page_fault_event_bits {
        u8         bytes_committed[0x20];
 
-       u8         reserved_0[0x10];
+       u8         reserved_at_20[0x10];
        u8         wqe_index[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_40[0x10];
        u8         len[0x10];
 
-       u8         reserved_2[0x60];
+       u8         reserved_at_60[0x60];
 
-       u8         reserved_3[0x5];
+       u8         reserved_at_c0[0x5];
        u8         rdma[0x1];
        u8         write_read[0x1];
        u8         requestor[0x1];
@@ -1662,26 +1662,26 @@ struct mlx5_ifc_wqe_associated_page_fault_event_bits {
 };
 
 struct mlx5_ifc_qp_events_bits {
-       u8         reserved_0[0xa0];
+       u8         reserved_at_0[0xa0];
 
        u8         type[0x8];
-       u8         reserved_1[0x18];
+       u8         reserved_at_a8[0x18];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_c0[0x8];
        u8         qpn_rqn_sqn[0x18];
 };
 
 struct mlx5_ifc_dct_events_bits {
-       u8         reserved_0[0xc0];
+       u8         reserved_at_0[0xc0];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_c0[0x8];
        u8         dct_number[0x18];
 };
 
 struct mlx5_ifc_comp_event_bits {
-       u8         reserved_0[0xc0];
+       u8         reserved_at_0[0xc0];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_c0[0x8];
        u8         cq_number[0x18];
 };
 
@@ -1754,41 +1754,41 @@ enum {
 
 struct mlx5_ifc_qpc_bits {
        u8         state[0x4];
-       u8         reserved_0[0x4];
+       u8         reserved_at_4[0x4];
        u8         st[0x8];
-       u8         reserved_1[0x3];
+       u8         reserved_at_10[0x3];
        u8         pm_state[0x2];
-       u8         reserved_2[0x7];
+       u8         reserved_at_15[0x7];
        u8         end_padding_mode[0x2];
-       u8         reserved_3[0x2];
+       u8         reserved_at_1e[0x2];
 
        u8         wq_signature[0x1];
        u8         block_lb_mc[0x1];
        u8         atomic_like_write_en[0x1];
        u8         latency_sensitive[0x1];
-       u8         reserved_4[0x1];
+       u8         reserved_at_24[0x1];
        u8         drain_sigerr[0x1];
-       u8         reserved_5[0x2];
+       u8         reserved_at_26[0x2];
        u8         pd[0x18];
 
        u8         mtu[0x3];
        u8         log_msg_max[0x5];
-       u8         reserved_6[0x1];
+       u8         reserved_at_48[0x1];
        u8         log_rq_size[0x4];
        u8         log_rq_stride[0x3];
        u8         no_sq[0x1];
        u8         log_sq_size[0x4];
-       u8         reserved_7[0x6];
+       u8         reserved_at_55[0x6];
        u8         rlky[0x1];
-       u8         reserved_8[0x4];
+       u8         reserved_at_5c[0x4];
 
        u8         counter_set_id[0x8];
        u8         uar_page[0x18];
 
-       u8         reserved_9[0x8];
+       u8         reserved_at_80[0x8];
        u8         user_index[0x18];
 
-       u8         reserved_10[0x3];
+       u8         reserved_at_a0[0x3];
        u8         log_page_size[0x5];
        u8         remote_qpn[0x18];
 
@@ -1797,66 +1797,66 @@ struct mlx5_ifc_qpc_bits {
        struct mlx5_ifc_ads_bits secondary_address_path;
 
        u8         log_ack_req_freq[0x4];
-       u8         reserved_11[0x4];
+       u8         reserved_at_384[0x4];
        u8         log_sra_max[0x3];
-       u8         reserved_12[0x2];
+       u8         reserved_at_38b[0x2];
        u8         retry_count[0x3];
        u8         rnr_retry[0x3];
-       u8         reserved_13[0x1];
+       u8         reserved_at_393[0x1];
        u8         fre[0x1];
        u8         cur_rnr_retry[0x3];
        u8         cur_retry_count[0x3];
-       u8         reserved_14[0x5];
+       u8         reserved_at_39b[0x5];
 
-       u8         reserved_15[0x20];
+       u8         reserved_at_3a0[0x20];
 
-       u8         reserved_16[0x8];
+       u8         reserved_at_3c0[0x8];
        u8         next_send_psn[0x18];
 
-       u8         reserved_17[0x8];
+       u8         reserved_at_3e0[0x8];
        u8         cqn_snd[0x18];
 
-       u8         reserved_18[0x40];
+       u8         reserved_at_400[0x40];
 
-       u8         reserved_19[0x8];
+       u8         reserved_at_440[0x8];
        u8         last_acked_psn[0x18];
 
-       u8         reserved_20[0x8];
+       u8         reserved_at_460[0x8];
        u8         ssn[0x18];
 
-       u8         reserved_21[0x8];
+       u8         reserved_at_480[0x8];
        u8         log_rra_max[0x3];
-       u8         reserved_22[0x1];
+       u8         reserved_at_48b[0x1];
        u8         atomic_mode[0x4];
        u8         rre[0x1];
        u8         rwe[0x1];
        u8         rae[0x1];
-       u8         reserved_23[0x1];
+       u8         reserved_at_493[0x1];
        u8         page_offset[0x6];
-       u8         reserved_24[0x3];
+       u8         reserved_at_49a[0x3];
        u8         cd_slave_receive[0x1];
        u8         cd_slave_send[0x1];
        u8         cd_master[0x1];
 
-       u8         reserved_25[0x3];
+       u8         reserved_at_4a0[0x3];
        u8         min_rnr_nak[0x5];
        u8         next_rcv_psn[0x18];
 
-       u8         reserved_26[0x8];
+       u8         reserved_at_4c0[0x8];
        u8         xrcd[0x18];
 
-       u8         reserved_27[0x8];
+       u8         reserved_at_4e0[0x8];
        u8         cqn_rcv[0x18];
 
        u8         dbr_addr[0x40];
 
        u8         q_key[0x20];
 
-       u8         reserved_28[0x5];
+       u8         reserved_at_560[0x5];
        u8         rq_type[0x3];
        u8         srqn_rmpn[0x18];
 
-       u8         reserved_29[0x8];
+       u8         reserved_at_580[0x8];
        u8         rmsn[0x18];
 
        u8         hw_sq_wqebb_counter[0x10];
@@ -1866,33 +1866,33 @@ struct mlx5_ifc_qpc_bits {
 
        u8         sw_rq_counter[0x20];
 
-       u8         reserved_30[0x20];
+       u8         reserved_at_600[0x20];
 
-       u8         reserved_31[0xf];
+       u8         reserved_at_620[0xf];
        u8         cgs[0x1];
        u8         cs_req[0x8];
        u8         cs_res[0x8];
 
        u8         dc_access_key[0x40];
 
-       u8         reserved_32[0xc0];
+       u8         reserved_at_680[0xc0];
 };
 
 struct mlx5_ifc_roce_addr_layout_bits {
        u8         source_l3_address[16][0x8];
 
-       u8         reserved_0[0x3];
+       u8         reserved_at_80[0x3];
        u8         vlan_valid[0x1];
        u8         vlan_id[0xc];
        u8         source_mac_47_32[0x10];
 
        u8         source_mac_31_0[0x20];
 
-       u8         reserved_1[0x14];
+       u8         reserved_at_c0[0x14];
        u8         roce_l3_type[0x4];
        u8         roce_version[0x8];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_e0[0x20];
 };
 
 union mlx5_ifc_hca_cap_union_bits {
@@ -1904,7 +1904,7 @@ union mlx5_ifc_hca_cap_union_bits {
        struct mlx5_ifc_flow_table_nic_cap_bits flow_table_nic_cap;
        struct mlx5_ifc_flow_table_eswitch_cap_bits flow_table_eswitch_cap;
        struct mlx5_ifc_e_switch_cap_bits e_switch_cap;
-       u8         reserved_0[0x8000];
+       u8         reserved_at_0[0x8000];
 };
 
 enum {
@@ -1914,24 +1914,24 @@ enum {
 };
 
 struct mlx5_ifc_flow_context_bits {
-       u8         reserved_0[0x20];
+       u8         reserved_at_0[0x20];
 
        u8         group_id[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         flow_tag[0x18];
 
-       u8         reserved_2[0x10];
+       u8         reserved_at_60[0x10];
        u8         action[0x10];
 
-       u8         reserved_3[0x8];
+       u8         reserved_at_80[0x8];
        u8         destination_list_size[0x18];
 
-       u8         reserved_4[0x160];
+       u8         reserved_at_a0[0x160];
 
        struct mlx5_ifc_fte_match_param_bits match_value;
 
-       u8         reserved_5[0x600];
+       u8         reserved_at_1200[0x600];
 
        struct mlx5_ifc_dest_format_struct_bits destination[0];
 };
@@ -1944,43 +1944,43 @@ enum {
 struct mlx5_ifc_xrc_srqc_bits {
        u8         state[0x4];
        u8         log_xrc_srq_size[0x4];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         wq_signature[0x1];
        u8         cont_srq[0x1];
-       u8         reserved_1[0x1];
+       u8         reserved_at_22[0x1];
        u8         rlky[0x1];
        u8         basic_cyclic_rcv_wqe[0x1];
        u8         log_rq_stride[0x3];
        u8         xrcd[0x18];
 
        u8         page_offset[0x6];
-       u8         reserved_2[0x2];
+       u8         reserved_at_46[0x2];
        u8         cqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         user_index_equal_xrc_srqn[0x1];
-       u8         reserved_4[0x1];
+       u8         reserved_at_81[0x1];
        u8         log_page_size[0x6];
        u8         user_index[0x18];
 
-       u8         reserved_5[0x20];
+       u8         reserved_at_a0[0x20];
 
-       u8         reserved_6[0x8];
+       u8         reserved_at_c0[0x8];
        u8         pd[0x18];
 
        u8         lwm[0x10];
        u8         wqe_cnt[0x10];
 
-       u8         reserved_7[0x40];
+       u8         reserved_at_100[0x40];
 
        u8         db_record_addr_h[0x20];
 
        u8         db_record_addr_l[0x1e];
-       u8         reserved_8[0x2];
+       u8         reserved_at_17e[0x2];
 
-       u8         reserved_9[0x80];
+       u8         reserved_at_180[0x80];
 };
 
 struct mlx5_ifc_traffic_counter_bits {
@@ -1990,16 +1990,16 @@ struct mlx5_ifc_traffic_counter_bits {
 };
 
 struct mlx5_ifc_tisc_bits {
-       u8         reserved_0[0xc];
+       u8         reserved_at_0[0xc];
        u8         prio[0x4];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_2[0x100];
+       u8         reserved_at_20[0x100];
 
-       u8         reserved_3[0x8];
+       u8         reserved_at_120[0x8];
        u8         transport_domain[0x18];
 
-       u8         reserved_4[0x3c0];
+       u8         reserved_at_140[0x3c0];
 };
 
 enum {
@@ -2024,31 +2024,31 @@ enum {
 };
 
 struct mlx5_ifc_tirc_bits {
-       u8         reserved_0[0x20];
+       u8         reserved_at_0[0x20];
 
        u8         disp_type[0x4];
-       u8         reserved_1[0x1c];
+       u8         reserved_at_24[0x1c];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
-       u8         reserved_3[0x4];
+       u8         reserved_at_80[0x4];
        u8         lro_timeout_period_usecs[0x10];
        u8         lro_enable_mask[0x4];
        u8         lro_max_ip_payload_size[0x8];
 
-       u8         reserved_4[0x40];
+       u8         reserved_at_a0[0x40];
 
-       u8         reserved_5[0x8];
+       u8         reserved_at_e0[0x8];
        u8         inline_rqn[0x18];
 
        u8         rx_hash_symmetric[0x1];
-       u8         reserved_6[0x1];
+       u8         reserved_at_101[0x1];
        u8         tunneled_offload_en[0x1];
-       u8         reserved_7[0x5];
+       u8         reserved_at_103[0x5];
        u8         indirect_table[0x18];
 
        u8         rx_hash_fn[0x4];
-       u8         reserved_8[0x2];
+       u8         reserved_at_124[0x2];
        u8         self_lb_block[0x2];
        u8         transport_domain[0x18];
 
@@ -2058,7 +2058,7 @@ struct mlx5_ifc_tirc_bits {
 
        struct mlx5_ifc_rx_hash_field_select_bits rx_hash_field_selector_inner;
 
-       u8         reserved_9[0x4c0];
+       u8         reserved_at_2c0[0x4c0];
 };
 
 enum {
@@ -2069,39 +2069,39 @@ enum {
 struct mlx5_ifc_srqc_bits {
        u8         state[0x4];
        u8         log_srq_size[0x4];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         wq_signature[0x1];
        u8         cont_srq[0x1];
-       u8         reserved_1[0x1];
+       u8         reserved_at_22[0x1];
        u8         rlky[0x1];
-       u8         reserved_2[0x1];
+       u8         reserved_at_24[0x1];
        u8         log_rq_stride[0x3];
        u8         xrcd[0x18];
 
        u8         page_offset[0x6];
-       u8         reserved_3[0x2];
+       u8         reserved_at_46[0x2];
        u8         cqn[0x18];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_60[0x20];
 
-       u8         reserved_5[0x2];
+       u8         reserved_at_80[0x2];
        u8         log_page_size[0x6];
-       u8         reserved_6[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_7[0x20];
+       u8         reserved_at_a0[0x20];
 
-       u8         reserved_8[0x8];
+       u8         reserved_at_c0[0x8];
        u8         pd[0x18];
 
        u8         lwm[0x10];
        u8         wqe_cnt[0x10];
 
-       u8         reserved_9[0x40];
+       u8         reserved_at_100[0x40];
 
        u8         dbr_addr[0x40];
 
-       u8         reserved_10[0x80];
+       u8         reserved_at_180[0x80];
 };
 
 enum {
@@ -2115,39 +2115,39 @@ struct mlx5_ifc_sqc_bits {
        u8         cd_master[0x1];
        u8         fre[0x1];
        u8         flush_in_error_en[0x1];
-       u8         reserved_0[0x4];
+       u8         reserved_at_4[0x4];
        u8         state[0x4];
-       u8         reserved_1[0x14];
+       u8         reserved_at_c[0x14];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_20[0x8];
        u8         user_index[0x18];
 
-       u8         reserved_3[0x8];
+       u8         reserved_at_40[0x8];
        u8         cqn[0x18];
 
-       u8         reserved_4[0xa0];
+       u8         reserved_at_60[0xa0];
 
        u8         tis_lst_sz[0x10];
-       u8         reserved_5[0x10];
+       u8         reserved_at_110[0x10];
 
-       u8         reserved_6[0x40];
+       u8         reserved_at_120[0x40];
 
-       u8         reserved_7[0x8];
+       u8         reserved_at_160[0x8];
        u8         tis_num_0[0x18];
 
        struct mlx5_ifc_wq_bits wq;
 };
 
 struct mlx5_ifc_rqtc_bits {
-       u8         reserved_0[0xa0];
+       u8         reserved_at_0[0xa0];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_a0[0x10];
        u8         rqt_max_size[0x10];
 
-       u8         reserved_2[0x10];
+       u8         reserved_at_c0[0x10];
        u8         rqt_actual_size[0x10];
 
-       u8         reserved_3[0x6a0];
+       u8         reserved_at_e0[0x6a0];
 
        struct mlx5_ifc_rq_num_bits rq_num[0];
 };
@@ -2165,27 +2165,27 @@ enum {
 
 struct mlx5_ifc_rqc_bits {
        u8         rlky[0x1];
-       u8         reserved_0[0x2];
+       u8         reserved_at_1[0x2];
        u8         vsd[0x1];
        u8         mem_rq_type[0x4];
        u8         state[0x4];
-       u8         reserved_1[0x1];
+       u8         reserved_at_c[0x1];
        u8         flush_in_error_en[0x1];
-       u8         reserved_2[0x12];
+       u8         reserved_at_e[0x12];
 
-       u8         reserved_3[0x8];
+       u8         reserved_at_20[0x8];
        u8         user_index[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_40[0x8];
        u8         cqn[0x18];
 
        u8         counter_set_id[0x8];
-       u8         reserved_5[0x18];
+       u8         reserved_at_68[0x18];
 
-       u8         reserved_6[0x8];
+       u8         reserved_at_80[0x8];
        u8         rmpn[0x18];
 
-       u8         reserved_7[0xe0];
+       u8         reserved_at_a0[0xe0];
 
        struct mlx5_ifc_wq_bits wq;
 };
@@ -2196,31 +2196,31 @@ enum {
 };
 
 struct mlx5_ifc_rmpc_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         state[0x4];
-       u8         reserved_1[0x14];
+       u8         reserved_at_c[0x14];
 
        u8         basic_cyclic_rcv_wqe[0x1];
-       u8         reserved_2[0x1f];
+       u8         reserved_at_21[0x1f];
 
-       u8         reserved_3[0x140];
+       u8         reserved_at_40[0x140];
 
        struct mlx5_ifc_wq_bits wq;
 };
 
 struct mlx5_ifc_nic_vport_context_bits {
-       u8         reserved_0[0x1f];
+       u8         reserved_at_0[0x1f];
        u8         roce_en[0x1];
 
        u8         arm_change_event[0x1];
-       u8         reserved_1[0x1a];
+       u8         reserved_at_21[0x1a];
        u8         event_on_mtu[0x1];
        u8         event_on_promisc_change[0x1];
        u8         event_on_vlan_change[0x1];
        u8         event_on_mc_address_change[0x1];
        u8         event_on_uc_address_change[0x1];
 
-       u8         reserved_2[0xf0];
+       u8         reserved_at_40[0xf0];
 
        u8         mtu[0x10];
 
@@ -2228,21 +2228,21 @@ struct mlx5_ifc_nic_vport_context_bits {
        u8         port_guid[0x40];
        u8         node_guid[0x40];
 
-       u8         reserved_3[0x140];
+       u8         reserved_at_200[0x140];
        u8         qkey_violation_counter[0x10];
-       u8         reserved_4[0x430];
+       u8         reserved_at_350[0x430];
 
        u8         promisc_uc[0x1];
        u8         promisc_mc[0x1];
        u8         promisc_all[0x1];
-       u8         reserved_5[0x2];
+       u8         reserved_at_783[0x2];
        u8         allowed_list_type[0x3];
-       u8         reserved_6[0xc];
+       u8         reserved_at_788[0xc];
        u8         allowed_list_size[0xc];
 
        struct mlx5_ifc_mac_address_layout_bits permanent_address;
 
-       u8         reserved_7[0x20];
+       u8         reserved_at_7e0[0x20];
 
        u8         current_uc_mac_address[0][0x40];
 };
@@ -2254,9 +2254,9 @@ enum {
 };
 
 struct mlx5_ifc_mkc_bits {
-       u8         reserved_0[0x1];
+       u8         reserved_at_0[0x1];
        u8         free[0x1];
-       u8         reserved_1[0xd];
+       u8         reserved_at_2[0xd];
        u8         small_fence_on_rdma_read_response[0x1];
        u8         umr_en[0x1];
        u8         a[0x1];
@@ -2265,19 +2265,19 @@ struct mlx5_ifc_mkc_bits {
        u8         lw[0x1];
        u8         lr[0x1];
        u8         access_mode[0x2];
-       u8         reserved_2[0x8];
+       u8         reserved_at_18[0x8];
 
        u8         qpn[0x18];
        u8         mkey_7_0[0x8];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_40[0x20];
 
        u8         length64[0x1];
        u8         bsf_en[0x1];
        u8         sync_umr[0x1];
-       u8         reserved_4[0x2];
+       u8         reserved_at_63[0x2];
        u8         expected_sigerr_count[0x1];
-       u8         reserved_5[0x1];
+       u8         reserved_at_66[0x1];
        u8         en_rinval[0x1];
        u8         pd[0x18];
 
@@ -2287,18 +2287,18 @@ struct mlx5_ifc_mkc_bits {
 
        u8         bsf_octword_size[0x20];
 
-       u8         reserved_6[0x80];
+       u8         reserved_at_120[0x80];
 
        u8         translations_octword_size[0x20];
 
-       u8         reserved_7[0x1b];
+       u8         reserved_at_1c0[0x1b];
        u8         log_page_size[0x5];
 
-       u8         reserved_8[0x20];
+       u8         reserved_at_1e0[0x20];
 };
 
 struct mlx5_ifc_pkey_bits {
-       u8         reserved_0[0x10];
+       u8         reserved_at_0[0x10];
        u8         pkey[0x10];
 };
 
@@ -2309,19 +2309,19 @@ struct mlx5_ifc_array128_auto_bits {
 struct mlx5_ifc_hca_vport_context_bits {
        u8         field_select[0x20];
 
-       u8         reserved_0[0xe0];
+       u8         reserved_at_20[0xe0];
 
        u8         sm_virt_aware[0x1];
        u8         has_smi[0x1];
        u8         has_raw[0x1];
        u8         grh_required[0x1];
-       u8         reserved_1[0xc];
+       u8         reserved_at_104[0xc];
        u8         port_physical_state[0x4];
        u8         vport_state_policy[0x4];
        u8         port_state[0x4];
        u8         vport_state[0x4];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_120[0x20];
 
        u8         system_image_guid[0x40];
 
@@ -2337,33 +2337,33 @@ struct mlx5_ifc_hca_vport_context_bits {
 
        u8         cap_mask2_field_select[0x20];
 
-       u8         reserved_3[0x80];
+       u8         reserved_at_280[0x80];
 
        u8         lid[0x10];
-       u8         reserved_4[0x4];
+       u8         reserved_at_310[0x4];
        u8         init_type_reply[0x4];
        u8         lmc[0x3];
        u8         subnet_timeout[0x5];
 
        u8         sm_lid[0x10];
        u8         sm_sl[0x4];
-       u8         reserved_5[0xc];
+       u8         reserved_at_334[0xc];
 
        u8         qkey_violation_counter[0x10];
        u8         pkey_violation_counter[0x10];
 
-       u8         reserved_6[0xca0];
+       u8         reserved_at_360[0xca0];
 };
 
 struct mlx5_ifc_esw_vport_context_bits {
-       u8         reserved_0[0x3];
+       u8         reserved_at_0[0x3];
        u8         vport_svlan_strip[0x1];
        u8         vport_cvlan_strip[0x1];
        u8         vport_svlan_insert[0x1];
        u8         vport_cvlan_insert[0x2];
-       u8         reserved_1[0x18];
+       u8         reserved_at_8[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_20[0x20];
 
        u8         svlan_cfi[0x1];
        u8         svlan_pcp[0x3];
@@ -2372,7 +2372,7 @@ struct mlx5_ifc_esw_vport_context_bits {
        u8         cvlan_pcp[0x3];
        u8         cvlan_id[0xc];
 
-       u8         reserved_3[0x7a0];
+       u8         reserved_at_60[0x7a0];
 };
 
 enum {
@@ -2387,41 +2387,41 @@ enum {
 
 struct mlx5_ifc_eqc_bits {
        u8         status[0x4];
-       u8         reserved_0[0x9];
+       u8         reserved_at_4[0x9];
        u8         ec[0x1];
        u8         oi[0x1];
-       u8         reserved_1[0x5];
+       u8         reserved_at_f[0x5];
        u8         st[0x4];
-       u8         reserved_2[0x8];
+       u8         reserved_at_18[0x8];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_20[0x20];
 
-       u8         reserved_4[0x14];
+       u8         reserved_at_40[0x14];
        u8         page_offset[0x6];
-       u8         reserved_5[0x6];
+       u8         reserved_at_5a[0x6];
 
-       u8         reserved_6[0x3];
+       u8         reserved_at_60[0x3];
        u8         log_eq_size[0x5];
        u8         uar_page[0x18];
 
-       u8         reserved_7[0x20];
+       u8         reserved_at_80[0x20];
 
-       u8         reserved_8[0x18];
+       u8         reserved_at_a0[0x18];
        u8         intr[0x8];
 
-       u8         reserved_9[0x3];
+       u8         reserved_at_c0[0x3];
        u8         log_page_size[0x5];
-       u8         reserved_10[0x18];
+       u8         reserved_at_c8[0x18];
 
-       u8         reserved_11[0x60];
+       u8         reserved_at_e0[0x60];
 
-       u8         reserved_12[0x8];
+       u8         reserved_at_140[0x8];
        u8         consumer_counter[0x18];
 
-       u8         reserved_13[0x8];
+       u8         reserved_at_160[0x8];
        u8         producer_counter[0x18];
 
-       u8         reserved_14[0x80];
+       u8         reserved_at_180[0x80];
 };
 
 enum {
@@ -2445,14 +2445,14 @@ enum {
 };
 
 struct mlx5_ifc_dctc_bits {
-       u8         reserved_0[0x4];
+       u8         reserved_at_0[0x4];
        u8         state[0x4];
-       u8         reserved_1[0x18];
+       u8         reserved_at_8[0x18];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_20[0x8];
        u8         user_index[0x18];
 
-       u8         reserved_3[0x8];
+       u8         reserved_at_40[0x8];
        u8         cqn[0x18];
 
        u8         counter_set_id[0x8];
@@ -2464,45 +2464,45 @@ struct mlx5_ifc_dctc_bits {
        u8         latency_sensitive[0x1];
        u8         rlky[0x1];
        u8         free_ar[0x1];
-       u8         reserved_4[0xd];
+       u8         reserved_at_73[0xd];
 
-       u8         reserved_5[0x8];
+       u8         reserved_at_80[0x8];
        u8         cs_res[0x8];
-       u8         reserved_6[0x3];
+       u8         reserved_at_90[0x3];
        u8         min_rnr_nak[0x5];
-       u8         reserved_7[0x8];
+       u8         reserved_at_98[0x8];
 
-       u8         reserved_8[0x8];
+       u8         reserved_at_a0[0x8];
        u8         srqn[0x18];
 
-       u8         reserved_9[0x8];
+       u8         reserved_at_c0[0x8];
        u8         pd[0x18];
 
        u8         tclass[0x8];
-       u8         reserved_10[0x4];
+       u8         reserved_at_e8[0x4];
        u8         flow_label[0x14];
 
        u8         dc_access_key[0x40];
 
-       u8         reserved_11[0x5];
+       u8         reserved_at_140[0x5];
        u8         mtu[0x3];
        u8         port[0x8];
        u8         pkey_index[0x10];
 
-       u8         reserved_12[0x8];
+       u8         reserved_at_160[0x8];
        u8         my_addr_index[0x8];
-       u8         reserved_13[0x8];
+       u8         reserved_at_170[0x8];
        u8         hop_limit[0x8];
 
        u8         dc_access_key_violation_count[0x20];
 
-       u8         reserved_14[0x14];
+       u8         reserved_at_1a0[0x14];
        u8         dei_cfi[0x1];
        u8         eth_prio[0x3];
        u8         ecn[0x2];
        u8         dscp[0x6];
 
-       u8         reserved_15[0x40];
+       u8         reserved_at_1c0[0x40];
 };
 
 enum {
@@ -2524,54 +2524,54 @@ enum {
 
 struct mlx5_ifc_cqc_bits {
        u8         status[0x4];
-       u8         reserved_0[0x4];
+       u8         reserved_at_4[0x4];
        u8         cqe_sz[0x3];
        u8         cc[0x1];
-       u8         reserved_1[0x1];
+       u8         reserved_at_c[0x1];
        u8         scqe_break_moderation_en[0x1];
        u8         oi[0x1];
-       u8         reserved_2[0x2];
+       u8         reserved_at_f[0x2];
        u8         cqe_zip_en[0x1];
        u8         mini_cqe_res_format[0x2];
        u8         st[0x4];
-       u8         reserved_3[0x8];
+       u8         reserved_at_18[0x8];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_20[0x20];
 
-       u8         reserved_5[0x14];
+       u8         reserved_at_40[0x14];
        u8         page_offset[0x6];
-       u8         reserved_6[0x6];
+       u8         reserved_at_5a[0x6];
 
-       u8         reserved_7[0x3];
+       u8         reserved_at_60[0x3];
        u8         log_cq_size[0x5];
        u8         uar_page[0x18];
 
-       u8         reserved_8[0x4];
+       u8         reserved_at_80[0x4];
        u8         cq_period[0xc];
        u8         cq_max_count[0x10];
 
-       u8         reserved_9[0x18];
+       u8         reserved_at_a0[0x18];
        u8         c_eqn[0x8];
 
-       u8         reserved_10[0x3];
+       u8         reserved_at_c0[0x3];
        u8         log_page_size[0x5];
-       u8         reserved_11[0x18];
+       u8         reserved_at_c8[0x18];
 
-       u8         reserved_12[0x20];
+       u8         reserved_at_e0[0x20];
 
-       u8         reserved_13[0x8];
+       u8         reserved_at_100[0x8];
        u8         last_notified_index[0x18];
 
-       u8         reserved_14[0x8];
+       u8         reserved_at_120[0x8];
        u8         last_solicit_index[0x18];
 
-       u8         reserved_15[0x8];
+       u8         reserved_at_140[0x8];
        u8         consumer_counter[0x18];
 
-       u8         reserved_16[0x8];
+       u8         reserved_at_160[0x8];
        u8         producer_counter[0x18];
 
-       u8         reserved_17[0x40];
+       u8         reserved_at_180[0x40];
 
        u8         dbr_addr[0x40];
 };
@@ -2580,16 +2580,16 @@ union mlx5_ifc_cong_control_roce_ecn_auto_bits {
        struct mlx5_ifc_cong_control_802_1qau_rp_bits cong_control_802_1qau_rp;
        struct mlx5_ifc_cong_control_r_roce_ecn_rp_bits cong_control_r_roce_ecn_rp;
        struct mlx5_ifc_cong_control_r_roce_ecn_np_bits cong_control_r_roce_ecn_np;
-       u8         reserved_0[0x800];
+       u8         reserved_at_0[0x800];
 };
 
 struct mlx5_ifc_query_adapter_param_block_bits {
-       u8         reserved_0[0xc0];
+       u8         reserved_at_0[0xc0];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_c0[0x8];
        u8         ieee_vendor_id[0x18];
 
-       u8         reserved_2[0x10];
+       u8         reserved_at_e0[0x10];
        u8         vsd_vendor_id[0x10];
 
        u8         vsd[208][0x8];
@@ -2600,14 +2600,14 @@ struct mlx5_ifc_query_adapter_param_block_bits {
 union mlx5_ifc_modify_field_select_resize_field_select_auto_bits {
        struct mlx5_ifc_modify_field_select_bits modify_field_select;
        struct mlx5_ifc_resize_field_select_bits resize_field_select;
-       u8         reserved_0[0x20];
+       u8         reserved_at_0[0x20];
 };
 
 union mlx5_ifc_field_select_802_1_r_roce_auto_bits {
        struct mlx5_ifc_field_select_802_1qau_rp_bits field_select_802_1qau_rp;
        struct mlx5_ifc_field_select_r_roce_rp_bits field_select_r_roce_rp;
        struct mlx5_ifc_field_select_r_roce_np_bits field_select_r_roce_np;
-       u8         reserved_0[0x20];
+       u8         reserved_at_0[0x20];
 };
 
 union mlx5_ifc_eth_cntrs_grp_data_layout_auto_bits {
@@ -2619,7 +2619,7 @@ union mlx5_ifc_eth_cntrs_grp_data_layout_auto_bits {
        struct mlx5_ifc_eth_per_prio_grp_data_layout_bits eth_per_prio_grp_data_layout;
        struct mlx5_ifc_eth_per_traffic_grp_data_layout_bits eth_per_traffic_grp_data_layout;
        struct mlx5_ifc_phys_layer_cntrs_bits phys_layer_cntrs;
-       u8         reserved_0[0x7c0];
+       u8         reserved_at_0[0x7c0];
 };
 
 union mlx5_ifc_event_auto_bits {
@@ -2635,23 +2635,23 @@ union mlx5_ifc_event_auto_bits {
        struct mlx5_ifc_db_bf_congestion_event_bits db_bf_congestion_event;
        struct mlx5_ifc_stall_vl_event_bits stall_vl_event;
        struct mlx5_ifc_cmd_inter_comp_event_bits cmd_inter_comp_event;
-       u8         reserved_0[0xe0];
+       u8         reserved_at_0[0xe0];
 };
 
 struct mlx5_ifc_health_buffer_bits {
-       u8         reserved_0[0x100];
+       u8         reserved_at_0[0x100];
 
        u8         assert_existptr[0x20];
 
        u8         assert_callra[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_140[0x40];
 
        u8         fw_version[0x20];
 
        u8         hw_id[0x20];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_1c0[0x20];
 
        u8         irisc_index[0x8];
        u8         synd[0x8];
@@ -2660,20 +2660,20 @@ struct mlx5_ifc_health_buffer_bits {
 
 struct mlx5_ifc_register_loopback_control_bits {
        u8         no_lb[0x1];
-       u8         reserved_0[0x7];
+       u8         reserved_at_1[0x7];
        u8         port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_2[0x60];
+       u8         reserved_at_20[0x60];
 };
 
 struct mlx5_ifc_teardown_hca_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 enum {
@@ -2683,108 +2683,108 @@ enum {
 
 struct mlx5_ifc_teardown_hca_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x10];
+       u8         reserved_at_40[0x10];
        u8         profile[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_sqerr2rts_qp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_sqerr2rts_qp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         opt_param_mask[0x20];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_a0[0x20];
 
        struct mlx5_ifc_qpc_bits qpc;
 
-       u8         reserved_5[0x80];
+       u8         reserved_at_800[0x80];
 };
 
 struct mlx5_ifc_sqd2rts_qp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_sqd2rts_qp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         opt_param_mask[0x20];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_a0[0x20];
 
        struct mlx5_ifc_qpc_bits qpc;
 
-       u8         reserved_5[0x80];
+       u8         reserved_at_800[0x80];
 };
 
 struct mlx5_ifc_set_roce_address_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_set_roce_address_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         roce_address_index[0x10];
-       u8         reserved_2[0x10];
+       u8         reserved_at_50[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        struct mlx5_ifc_roce_addr_layout_bits roce_address;
 };
 
 struct mlx5_ifc_set_mad_demux_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 enum {
@@ -2794,89 +2794,89 @@ enum {
 
 struct mlx5_ifc_set_mad_demux_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_40[0x20];
 
-       u8         reserved_3[0x6];
+       u8         reserved_at_60[0x6];
        u8         demux_mode[0x2];
-       u8         reserved_4[0x18];
+       u8         reserved_at_68[0x18];
 };
 
 struct mlx5_ifc_set_l2_table_entry_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_set_l2_table_entry_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x60];
+       u8         reserved_at_40[0x60];
 
-       u8         reserved_3[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_index[0x18];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_c0[0x20];
 
-       u8         reserved_5[0x13];
+       u8         reserved_at_e0[0x13];
        u8         vlan_valid[0x1];
        u8         vlan[0xc];
 
        struct mlx5_ifc_mac_address_layout_bits mac_address;
 
-       u8         reserved_6[0xc0];
+       u8         reserved_at_140[0xc0];
 };
 
 struct mlx5_ifc_set_issi_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_set_issi_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x10];
+       u8         reserved_at_40[0x10];
        u8         current_issi[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_set_hca_cap_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_set_hca_cap_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        union mlx5_ifc_hca_cap_union_bits capability;
 };
@@ -2890,156 +2890,156 @@ enum {
 
 struct mlx5_ifc_set_fte_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_set_fte_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         table_type[0x8];
-       u8         reserved_3[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_id[0x18];
 
-       u8         reserved_5[0x18];
+       u8         reserved_at_c0[0x18];
        u8         modify_enable_mask[0x8];
 
-       u8         reserved_6[0x20];
+       u8         reserved_at_e0[0x20];
 
        u8         flow_index[0x20];
 
-       u8         reserved_7[0xe0];
+       u8         reserved_at_120[0xe0];
 
        struct mlx5_ifc_flow_context_bits flow_context;
 };
 
 struct mlx5_ifc_rts2rts_qp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_rts2rts_qp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         opt_param_mask[0x20];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_a0[0x20];
 
        struct mlx5_ifc_qpc_bits qpc;
 
-       u8         reserved_5[0x80];
+       u8         reserved_at_800[0x80];
 };
 
 struct mlx5_ifc_rtr2rts_qp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_rtr2rts_qp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         opt_param_mask[0x20];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_a0[0x20];
 
        struct mlx5_ifc_qpc_bits qpc;
 
-       u8         reserved_5[0x80];
+       u8         reserved_at_800[0x80];
 };
 
 struct mlx5_ifc_rst2init_qp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_rst2init_qp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         opt_param_mask[0x20];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_a0[0x20];
 
        struct mlx5_ifc_qpc_bits qpc;
 
-       u8         reserved_5[0x80];
+       u8         reserved_at_800[0x80];
 };
 
 struct mlx5_ifc_query_xrc_srq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_xrc_srqc_bits xrc_srq_context_entry;
 
-       u8         reserved_2[0x600];
+       u8         reserved_at_280[0x600];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_query_xrc_srq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         xrc_srqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 enum {
@@ -3049,13 +3049,13 @@ enum {
 
 struct mlx5_ifc_query_vport_state_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_40[0x20];
 
-       u8         reserved_2[0x18];
+       u8         reserved_at_60[0x18];
        u8         admin_state[0x4];
        u8         state[0x4];
 };
@@ -3067,25 +3067,25 @@ enum {
 
 struct mlx5_ifc_query_vport_state_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xf];
+       u8         reserved_at_41[0xf];
        u8         vport_number[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_vport_counter_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_traffic_counter_bits received_errors;
 
@@ -3111,7 +3111,7 @@ struct mlx5_ifc_query_vport_counter_out_bits {
 
        struct mlx5_ifc_traffic_counter_bits transmitted_eth_multicast;
 
-       u8         reserved_2[0xa00];
+       u8         reserved_at_680[0xa00];
 };
 
 enum {
@@ -3120,328 +3120,328 @@ enum {
 
 struct mlx5_ifc_query_vport_counter_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xf];
+       u8         reserved_at_41[0xf];
        u8         vport_number[0x10];
 
-       u8         reserved_3[0x60];
+       u8         reserved_at_60[0x60];
 
        u8         clear[0x1];
-       u8         reserved_4[0x1f];
+       u8         reserved_at_c1[0x1f];
 
-       u8         reserved_5[0x20];
+       u8         reserved_at_e0[0x20];
 };
 
 struct mlx5_ifc_query_tis_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_tisc_bits tis_context;
 };
 
 struct mlx5_ifc_query_tis_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         tisn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_tir_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_tirc_bits tir_context;
 };
 
 struct mlx5_ifc_query_tir_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         tirn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_srq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_srqc_bits srq_context_entry;
 
-       u8         reserved_2[0x600];
+       u8         reserved_at_280[0x600];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_query_srq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         srqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_sq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_sqc_bits sq_context;
 };
 
 struct mlx5_ifc_query_sq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         sqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_special_contexts_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_40[0x20];
 
        u8         resd_lkey[0x20];
 };
 
 struct mlx5_ifc_query_special_contexts_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_query_rqt_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_rqtc_bits rqt_context;
 };
 
 struct mlx5_ifc_query_rqt_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         rqtn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_rq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_rqc_bits rq_context;
 };
 
 struct mlx5_ifc_query_rq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         rqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_roce_address_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_roce_addr_layout_bits roce_address;
 };
 
 struct mlx5_ifc_query_roce_address_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         roce_address_index[0x10];
-       u8         reserved_2[0x10];
+       u8         reserved_at_50[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_rmp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_rmpc_bits rmp_context;
 };
 
 struct mlx5_ifc_query_rmp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         rmpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_qp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         opt_param_mask[0x20];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_a0[0x20];
 
        struct mlx5_ifc_qpc_bits qpc;
 
-       u8         reserved_3[0x80];
+       u8         reserved_at_800[0x80];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_query_qp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_q_counter_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         rx_write_requests[0x20];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_a0[0x20];
 
        u8         rx_read_requests[0x20];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_e0[0x20];
 
        u8         rx_atomic_requests[0x20];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_120[0x20];
 
        u8         rx_dct_connect[0x20];
 
-       u8         reserved_5[0x20];
+       u8         reserved_at_160[0x20];
 
        u8         out_of_buffer[0x20];
 
-       u8         reserved_6[0x20];
+       u8         reserved_at_1a0[0x20];
 
        u8         out_of_sequence[0x20];
 
-       u8         reserved_7[0x620];
+       u8         reserved_at_1e0[0x620];
 };
 
 struct mlx5_ifc_query_q_counter_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x80];
+       u8         reserved_at_40[0x80];
 
        u8         clear[0x1];
-       u8         reserved_3[0x1f];
+       u8         reserved_at_c1[0x1f];
 
-       u8         reserved_4[0x18];
+       u8         reserved_at_e0[0x18];
        u8         counter_set_id[0x8];
 };
 
 struct mlx5_ifc_query_pages_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_40[0x10];
        u8         function_id[0x10];
 
        u8         num_pages[0x20];
@@ -3455,55 +3455,55 @@ enum {
 
 struct mlx5_ifc_query_pages_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x10];
+       u8         reserved_at_40[0x10];
        u8         function_id[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_nic_vport_context_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_nic_vport_context_bits nic_vport_context;
 };
 
 struct mlx5_ifc_query_nic_vport_context_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xf];
+       u8         reserved_at_41[0xf];
        u8         vport_number[0x10];
 
-       u8         reserved_3[0x5];
+       u8         reserved_at_60[0x5];
        u8         allowed_list_type[0x3];
-       u8         reserved_4[0x18];
+       u8         reserved_at_68[0x18];
 };
 
 struct mlx5_ifc_query_mkey_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_mkc_bits memory_key_mkey_entry;
 
-       u8         reserved_2[0x600];
+       u8         reserved_at_280[0x600];
 
        u8         bsf0_klm0_pas_mtt0_1[16][0x8];
 
@@ -3512,265 +3512,265 @@ struct mlx5_ifc_query_mkey_out_bits {
 
 struct mlx5_ifc_query_mkey_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         mkey_index[0x18];
 
        u8         pg_access[0x1];
-       u8         reserved_3[0x1f];
+       u8         reserved_at_61[0x1f];
 };
 
 struct mlx5_ifc_query_mad_demux_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         mad_dumux_parameters_block[0x20];
 };
 
 struct mlx5_ifc_query_mad_demux_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_query_l2_table_entry_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0xa0];
+       u8         reserved_at_40[0xa0];
 
-       u8         reserved_2[0x13];
+       u8         reserved_at_e0[0x13];
        u8         vlan_valid[0x1];
        u8         vlan[0xc];
 
        struct mlx5_ifc_mac_address_layout_bits mac_address;
 
-       u8         reserved_3[0xc0];
+       u8         reserved_at_140[0xc0];
 };
 
 struct mlx5_ifc_query_l2_table_entry_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x60];
+       u8         reserved_at_40[0x60];
 
-       u8         reserved_3[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_index[0x18];
 
-       u8         reserved_4[0x140];
+       u8         reserved_at_c0[0x140];
 };
 
 struct mlx5_ifc_query_issi_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_40[0x10];
        u8         current_issi[0x10];
 
-       u8         reserved_2[0xa0];
+       u8         reserved_at_60[0xa0];
 
-       u8         supported_issi_reserved[76][0x8];
+       u8         reserved_at_100[76][0x8];
        u8         supported_issi_dw0[0x20];
 };
 
 struct mlx5_ifc_query_issi_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_query_hca_vport_pkey_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_pkey_bits pkey[0];
 };
 
 struct mlx5_ifc_query_hca_vport_pkey_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xb];
+       u8         reserved_at_41[0xb];
        u8         port_num[0x4];
        u8         vport_number[0x10];
 
-       u8         reserved_3[0x10];
+       u8         reserved_at_60[0x10];
        u8         pkey_index[0x10];
 };
 
 struct mlx5_ifc_query_hca_vport_gid_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_40[0x20];
 
        u8         gids_num[0x10];
-       u8         reserved_2[0x10];
+       u8         reserved_at_70[0x10];
 
        struct mlx5_ifc_array128_auto_bits gid[0];
 };
 
 struct mlx5_ifc_query_hca_vport_gid_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xb];
+       u8         reserved_at_41[0xb];
        u8         port_num[0x4];
        u8         vport_number[0x10];
 
-       u8         reserved_3[0x10];
+       u8         reserved_at_60[0x10];
        u8         gid_index[0x10];
 };
 
 struct mlx5_ifc_query_hca_vport_context_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_hca_vport_context_bits hca_vport_context;
 };
 
 struct mlx5_ifc_query_hca_vport_context_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xb];
+       u8         reserved_at_41[0xb];
        u8         port_num[0x4];
        u8         vport_number[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_hca_cap_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        union mlx5_ifc_hca_cap_union_bits capability;
 };
 
 struct mlx5_ifc_query_hca_cap_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_query_flow_table_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x80];
+       u8         reserved_at_40[0x80];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_c0[0x8];
        u8         level[0x8];
-       u8         reserved_3[0x8];
+       u8         reserved_at_d0[0x8];
        u8         log_size[0x8];
 
-       u8         reserved_4[0x120];
+       u8         reserved_at_e0[0x120];
 };
 
 struct mlx5_ifc_query_flow_table_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         table_type[0x8];
-       u8         reserved_3[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_id[0x18];
 
-       u8         reserved_5[0x140];
+       u8         reserved_at_c0[0x140];
 };
 
 struct mlx5_ifc_query_fte_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x1c0];
+       u8         reserved_at_40[0x1c0];
 
        struct mlx5_ifc_flow_context_bits flow_context;
 };
 
 struct mlx5_ifc_query_fte_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         table_type[0x8];
-       u8         reserved_3[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_id[0x18];
 
-       u8         reserved_5[0x40];
+       u8         reserved_at_c0[0x40];
 
        u8         flow_index[0x20];
 
-       u8         reserved_6[0xe0];
+       u8         reserved_at_120[0xe0];
 };
 
 enum {
@@ -3781,84 +3781,84 @@ enum {
 
 struct mlx5_ifc_query_flow_group_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0xa0];
+       u8         reserved_at_40[0xa0];
 
        u8         start_flow_index[0x20];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_100[0x20];
 
        u8         end_flow_index[0x20];
 
-       u8         reserved_3[0xa0];
+       u8         reserved_at_140[0xa0];
 
-       u8         reserved_4[0x18];
+       u8         reserved_at_1e0[0x18];
        u8         match_criteria_enable[0x8];
 
        struct mlx5_ifc_fte_match_param_bits match_criteria;
 
-       u8         reserved_5[0xe00];
+       u8         reserved_at_1200[0xe00];
 };
 
 struct mlx5_ifc_query_flow_group_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         table_type[0x8];
-       u8         reserved_3[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_id[0x18];
 
        u8         group_id[0x20];
 
-       u8         reserved_5[0x120];
+       u8         reserved_at_e0[0x120];
 };
 
 struct mlx5_ifc_query_esw_vport_context_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_esw_vport_context_bits esw_vport_context;
 };
 
 struct mlx5_ifc_query_esw_vport_context_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xf];
+       u8         reserved_at_41[0xf];
        u8         vport_number[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_modify_esw_vport_context_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_esw_vport_context_fields_select_bits {
-       u8         reserved[0x1c];
+       u8         reserved_at_0[0x1c];
        u8         vport_cvlan_insert[0x1];
        u8         vport_svlan_insert[0x1];
        u8         vport_cvlan_strip[0x1];
@@ -3867,13 +3867,13 @@ struct mlx5_ifc_esw_vport_context_fields_select_bits {
 
 struct mlx5_ifc_modify_esw_vport_context_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xf];
+       u8         reserved_at_41[0xf];
        u8         vport_number[0x10];
 
        struct mlx5_ifc_esw_vport_context_fields_select_bits field_select;
@@ -3883,124 +3883,124 @@ struct mlx5_ifc_modify_esw_vport_context_in_bits {
 
 struct mlx5_ifc_query_eq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_eqc_bits eq_context_entry;
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_280[0x40];
 
        u8         event_bitmask[0x40];
 
-       u8         reserved_3[0x580];
+       u8         reserved_at_300[0x580];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_query_eq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x18];
+       u8         reserved_at_40[0x18];
        u8         eq_number[0x8];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_dct_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_dctc_bits dct_context_entry;
 
-       u8         reserved_2[0x180];
+       u8         reserved_at_280[0x180];
 };
 
 struct mlx5_ifc_query_dct_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         dctn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_cq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_cqc_bits cq_context;
 
-       u8         reserved_2[0x600];
+       u8         reserved_at_280[0x600];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_query_cq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         cqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_cong_status_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_40[0x20];
 
        u8         enable[0x1];
        u8         tag_enable[0x1];
-       u8         reserved_2[0x1e];
+       u8         reserved_at_62[0x1e];
 };
 
 struct mlx5_ifc_query_cong_status_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x18];
+       u8         reserved_at_40[0x18];
        u8         priority[0x4];
        u8         cong_protocol[0x4];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_cong_statistics_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         cur_flows[0x20];
 
@@ -4014,7 +4014,7 @@ struct mlx5_ifc_query_cong_statistics_out_bits {
 
        u8         cnp_handled_low[0x20];
 
-       u8         reserved_2[0x100];
+       u8         reserved_at_140[0x100];
 
        u8         time_stamp_high[0x20];
 
@@ -4030,453 +4030,455 @@ struct mlx5_ifc_query_cong_statistics_out_bits {
 
        u8         cnps_sent_low[0x20];
 
-       u8         reserved_3[0x560];
+       u8         reserved_at_320[0x560];
 };
 
 struct mlx5_ifc_query_cong_statistics_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         clear[0x1];
-       u8         reserved_2[0x1f];
+       u8         reserved_at_41[0x1f];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_cong_params_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        union mlx5_ifc_cong_control_roce_ecn_auto_bits congestion_parameters;
 };
 
 struct mlx5_ifc_query_cong_params_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x1c];
+       u8         reserved_at_40[0x1c];
        u8         cong_protocol[0x4];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_query_adapter_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_query_adapter_param_block_bits query_adapter_struct;
 };
 
 struct mlx5_ifc_query_adapter_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_qp_2rst_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_qp_2rst_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_qp_2err_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_qp_2err_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_page_fault_resume_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_page_fault_resume_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         error[0x1];
-       u8         reserved_2[0x4];
+       u8         reserved_at_41[0x4];
        u8         rdma[0x1];
        u8         read_write[0x1];
        u8         req_res[0x1];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_nop_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_nop_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_vport_state_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_vport_state_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xf];
+       u8         reserved_at_41[0xf];
        u8         vport_number[0x10];
 
-       u8         reserved_3[0x18];
+       u8         reserved_at_60[0x18];
        u8         admin_state[0x4];
-       u8         reserved_4[0x4];
+       u8         reserved_at_7c[0x4];
 };
 
 struct mlx5_ifc_modify_tis_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_tis_bitmask_bits {
-       u8         reserved_0[0x20];
+       u8         reserved_at_0[0x20];
 
-       u8         reserved_1[0x1f];
+       u8         reserved_at_20[0x1f];
        u8         prio[0x1];
 };
 
 struct mlx5_ifc_modify_tis_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         tisn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        struct mlx5_ifc_modify_tis_bitmask_bits bitmask;
 
-       u8         reserved_4[0x40];
+       u8         reserved_at_c0[0x40];
 
        struct mlx5_ifc_tisc_bits ctx;
 };
 
 struct mlx5_ifc_modify_tir_bitmask_bits {
-       u8         reserved_0[0x20];
+       u8         reserved_at_0[0x20];
 
-       u8         reserved_1[0x1b];
+       u8         reserved_at_20[0x1b];
        u8         self_lb_en[0x1];
-       u8         reserved_2[0x3];
+       u8         reserved_at_3c[0x1];
+       u8         hash[0x1];
+       u8         reserved_at_3e[0x1];
        u8         lro[0x1];
 };
 
 struct mlx5_ifc_modify_tir_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_tir_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         tirn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        struct mlx5_ifc_modify_tir_bitmask_bits bitmask;
 
-       u8         reserved_4[0x40];
+       u8         reserved_at_c0[0x40];
 
        struct mlx5_ifc_tirc_bits ctx;
 };
 
 struct mlx5_ifc_modify_sq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_sq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         sq_state[0x4];
-       u8         reserved_2[0x4];
+       u8         reserved_at_44[0x4];
        u8         sqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         modify_bitmask[0x40];
 
-       u8         reserved_4[0x40];
+       u8         reserved_at_c0[0x40];
 
        struct mlx5_ifc_sqc_bits ctx;
 };
 
 struct mlx5_ifc_modify_rqt_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_rqt_bitmask_bits {
-       u8         reserved[0x20];
+       u8         reserved_at_0[0x20];
 
-       u8         reserved1[0x1f];
+       u8         reserved_at_20[0x1f];
        u8         rqn_list[0x1];
 };
 
 struct mlx5_ifc_modify_rqt_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         rqtn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        struct mlx5_ifc_rqt_bitmask_bits bitmask;
 
-       u8         reserved_4[0x40];
+       u8         reserved_at_c0[0x40];
 
        struct mlx5_ifc_rqtc_bits ctx;
 };
 
 struct mlx5_ifc_modify_rq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_rq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         rq_state[0x4];
-       u8         reserved_2[0x4];
+       u8         reserved_at_44[0x4];
        u8         rqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         modify_bitmask[0x40];
 
-       u8         reserved_4[0x40];
+       u8         reserved_at_c0[0x40];
 
        struct mlx5_ifc_rqc_bits ctx;
 };
 
 struct mlx5_ifc_modify_rmp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_rmp_bitmask_bits {
-       u8         reserved[0x20];
+       u8         reserved_at_0[0x20];
 
-       u8         reserved1[0x1f];
+       u8         reserved_at_20[0x1f];
        u8         lwm[0x1];
 };
 
 struct mlx5_ifc_modify_rmp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         rmp_state[0x4];
-       u8         reserved_2[0x4];
+       u8         reserved_at_44[0x4];
        u8         rmpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        struct mlx5_ifc_rmp_bitmask_bits bitmask;
 
-       u8         reserved_4[0x40];
+       u8         reserved_at_c0[0x40];
 
        struct mlx5_ifc_rmpc_bits ctx;
 };
 
 struct mlx5_ifc_modify_nic_vport_context_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_nic_vport_field_select_bits {
-       u8         reserved_0[0x19];
+       u8         reserved_at_0[0x19];
        u8         mtu[0x1];
        u8         change_event[0x1];
        u8         promisc[0x1];
        u8         permanent_address[0x1];
        u8         addresses_list[0x1];
        u8         roce_en[0x1];
-       u8         reserved_1[0x1];
+       u8         reserved_at_1f[0x1];
 };
 
 struct mlx5_ifc_modify_nic_vport_context_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xf];
+       u8         reserved_at_41[0xf];
        u8         vport_number[0x10];
 
        struct mlx5_ifc_modify_nic_vport_field_select_bits field_select;
 
-       u8         reserved_3[0x780];
+       u8         reserved_at_80[0x780];
 
        struct mlx5_ifc_nic_vport_context_bits nic_vport_context;
 };
 
 struct mlx5_ifc_modify_hca_vport_context_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_hca_vport_context_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_2[0xb];
+       u8         reserved_at_41[0xb];
        u8         port_num[0x4];
        u8         vport_number[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        struct mlx5_ifc_hca_vport_context_bits hca_vport_context;
 };
 
 struct mlx5_ifc_modify_cq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 enum {
@@ -4486,83 +4488,83 @@ enum {
 
 struct mlx5_ifc_modify_cq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         cqn[0x18];
 
        union mlx5_ifc_modify_field_select_resize_field_select_auto_bits modify_field_select_resize_field_select;
 
        struct mlx5_ifc_cqc_bits cq_context;
 
-       u8         reserved_3[0x600];
+       u8         reserved_at_280[0x600];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_modify_cong_status_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_cong_status_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x18];
+       u8         reserved_at_40[0x18];
        u8         priority[0x4];
        u8         cong_protocol[0x4];
 
        u8         enable[0x1];
        u8         tag_enable[0x1];
-       u8         reserved_3[0x1e];
+       u8         reserved_at_62[0x1e];
 };
 
 struct mlx5_ifc_modify_cong_params_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_cong_params_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x1c];
+       u8         reserved_at_40[0x1c];
        u8         cong_protocol[0x4];
 
        union mlx5_ifc_field_select_802_1_r_roce_auto_bits field_select;
 
-       u8         reserved_3[0x80];
+       u8         reserved_at_80[0x80];
 
        union mlx5_ifc_cong_control_roce_ecn_auto_bits congestion_parameters;
 };
 
 struct mlx5_ifc_manage_pages_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
        u8         output_num_entries[0x20];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         pas[0][0x40];
 };
@@ -4575,12 +4577,12 @@ enum {
 
 struct mlx5_ifc_manage_pages_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x10];
+       u8         reserved_at_40[0x10];
        u8         function_id[0x10];
 
        u8         input_num_entries[0x20];
@@ -4590,117 +4592,117 @@ struct mlx5_ifc_manage_pages_in_bits {
 
 struct mlx5_ifc_mad_ifc_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         response_mad_packet[256][0x8];
 };
 
 struct mlx5_ifc_mad_ifc_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         remote_lid[0x10];
-       u8         reserved_2[0x8];
+       u8         reserved_at_50[0x8];
        u8         port[0x8];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         mad[256][0x8];
 };
 
 struct mlx5_ifc_init_hca_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_init_hca_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_init2rtr_qp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_init2rtr_qp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         opt_param_mask[0x20];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_a0[0x20];
 
        struct mlx5_ifc_qpc_bits qpc;
 
-       u8         reserved_5[0x80];
+       u8         reserved_at_800[0x80];
 };
 
 struct mlx5_ifc_init2init_qp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_init2init_qp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         opt_param_mask[0x20];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_a0[0x20];
 
        struct mlx5_ifc_qpc_bits qpc;
 
-       u8         reserved_5[0x80];
+       u8         reserved_at_800[0x80];
 };
 
 struct mlx5_ifc_get_dropped_packet_log_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         packet_headers_log[128][0x8];
 
@@ -4709,1029 +4711,1029 @@ struct mlx5_ifc_get_dropped_packet_log_out_bits {
 
 struct mlx5_ifc_get_dropped_packet_log_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_gen_eqe_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x18];
+       u8         reserved_at_40[0x18];
        u8         eq_number[0x8];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         eqe[64][0x8];
 };
 
 struct mlx5_ifc_gen_eq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_enable_hca_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_40[0x20];
 };
 
 struct mlx5_ifc_enable_hca_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x10];
+       u8         reserved_at_40[0x10];
        u8         function_id[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_drain_dct_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_drain_dct_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         dctn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_disable_hca_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_40[0x20];
 };
 
 struct mlx5_ifc_disable_hca_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x10];
+       u8         reserved_at_40[0x10];
        u8         function_id[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_detach_from_mcg_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_detach_from_mcg_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         multicast_gid[16][0x8];
 };
 
 struct mlx5_ifc_destroy_xrc_srq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_xrc_srq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         xrc_srqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_tis_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_tis_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         tisn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_tir_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_tir_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         tirn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_srq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_srq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         srqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_sq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_sq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         sqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_rqt_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_rqt_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         rqtn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_rq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_rq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         rqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_rmp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_rmp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         rmpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_qp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_qp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_psv_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_psv_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         psvn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_mkey_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_mkey_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         mkey_index[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_flow_table_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_flow_table_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         table_type[0x8];
-       u8         reserved_3[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_id[0x18];
 
-       u8         reserved_5[0x140];
+       u8         reserved_at_c0[0x140];
 };
 
 struct mlx5_ifc_destroy_flow_group_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_flow_group_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         table_type[0x8];
-       u8         reserved_3[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_id[0x18];
 
        u8         group_id[0x20];
 
-       u8         reserved_5[0x120];
+       u8         reserved_at_e0[0x120];
 };
 
 struct mlx5_ifc_destroy_eq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_eq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x18];
+       u8         reserved_at_40[0x18];
        u8         eq_number[0x8];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_dct_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_dct_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         dctn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_destroy_cq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_destroy_cq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         cqn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_delete_vxlan_udp_dport_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_delete_vxlan_udp_dport_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_40[0x20];
 
-       u8         reserved_3[0x10];
+       u8         reserved_at_60[0x10];
        u8         vxlan_udp_port[0x10];
 };
 
 struct mlx5_ifc_delete_l2_table_entry_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_delete_l2_table_entry_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x60];
+       u8         reserved_at_40[0x60];
 
-       u8         reserved_3[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_index[0x18];
 
-       u8         reserved_4[0x140];
+       u8         reserved_at_c0[0x140];
 };
 
 struct mlx5_ifc_delete_fte_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_delete_fte_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         table_type[0x8];
-       u8         reserved_3[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_id[0x18];
 
-       u8         reserved_5[0x40];
+       u8         reserved_at_c0[0x40];
 
        u8         flow_index[0x20];
 
-       u8         reserved_6[0xe0];
+       u8         reserved_at_120[0xe0];
 };
 
 struct mlx5_ifc_dealloc_xrcd_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_dealloc_xrcd_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         xrcd[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_dealloc_uar_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_dealloc_uar_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         uar[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_dealloc_transport_domain_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_dealloc_transport_domain_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         transport_domain[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_dealloc_q_counter_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_dealloc_q_counter_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x18];
+       u8         reserved_at_40[0x18];
        u8         counter_set_id[0x8];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_dealloc_pd_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_dealloc_pd_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         pd[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_xrc_srq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         xrc_srqn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_xrc_srq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_xrc_srqc_bits xrc_srq_context_entry;
 
-       u8         reserved_3[0x600];
+       u8         reserved_at_280[0x600];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_create_tis_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         tisn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_tis_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_tisc_bits ctx;
 };
 
 struct mlx5_ifc_create_tir_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         tirn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_tir_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_tirc_bits ctx;
 };
 
 struct mlx5_ifc_create_srq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         srqn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_srq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_srqc_bits srq_context_entry;
 
-       u8         reserved_3[0x600];
+       u8         reserved_at_280[0x600];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_create_sq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         sqn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_sq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_sqc_bits ctx;
 };
 
 struct mlx5_ifc_create_rqt_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         rqtn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_rqt_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_rqtc_bits rqt_context;
 };
 
 struct mlx5_ifc_create_rq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         rqn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_rq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_rqc_bits ctx;
 };
 
 struct mlx5_ifc_create_rmp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         rmpn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_rmp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0xc0];
+       u8         reserved_at_40[0xc0];
 
        struct mlx5_ifc_rmpc_bits ctx;
 };
 
 struct mlx5_ifc_create_qp_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_qp_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         opt_param_mask[0x20];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_a0[0x20];
 
        struct mlx5_ifc_qpc_bits qpc;
 
-       u8         reserved_4[0x80];
+       u8         reserved_at_800[0x80];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_create_psv_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_80[0x8];
        u8         psv0_index[0x18];
 
-       u8         reserved_3[0x8];
+       u8         reserved_at_a0[0x8];
        u8         psv1_index[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_c0[0x8];
        u8         psv2_index[0x18];
 
-       u8         reserved_5[0x8];
+       u8         reserved_at_e0[0x8];
        u8         psv3_index[0x18];
 };
 
 struct mlx5_ifc_create_psv_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         num_psv[0x4];
-       u8         reserved_2[0x4];
+       u8         reserved_at_44[0x4];
        u8         pd[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_mkey_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         mkey_index[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_mkey_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_40[0x20];
 
        u8         pg_access[0x1];
-       u8         reserved_3[0x1f];
+       u8         reserved_at_61[0x1f];
 
        struct mlx5_ifc_mkc_bits memory_key_mkey_entry;
 
-       u8         reserved_4[0x80];
+       u8         reserved_at_280[0x80];
 
        u8         translations_octword_actual_size[0x20];
 
-       u8         reserved_5[0x560];
+       u8         reserved_at_320[0x560];
 
        u8         klm_pas_mtt[0][0x20];
 };
 
 struct mlx5_ifc_create_flow_table_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         table_id[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_flow_table_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         table_type[0x8];
-       u8         reserved_3[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_a0[0x20];
 
-       u8         reserved_5[0x4];
+       u8         reserved_at_c0[0x4];
        u8         table_miss_mode[0x4];
        u8         level[0x8];
-       u8         reserved_6[0x8];
+       u8         reserved_at_d0[0x8];
        u8         log_size[0x8];
 
-       u8         reserved_7[0x8];
+       u8         reserved_at_e0[0x8];
        u8         table_miss_id[0x18];
 
-       u8         reserved_8[0x100];
+       u8         reserved_at_100[0x100];
 };
 
 struct mlx5_ifc_create_flow_group_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         group_id[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 enum {
@@ -5742,134 +5744,134 @@ enum {
 
 struct mlx5_ifc_create_flow_group_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         table_type[0x8];
-       u8         reserved_3[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_id[0x18];
 
-       u8         reserved_5[0x20];
+       u8         reserved_at_c0[0x20];
 
        u8         start_flow_index[0x20];
 
-       u8         reserved_6[0x20];
+       u8         reserved_at_100[0x20];
 
        u8         end_flow_index[0x20];
 
-       u8         reserved_7[0xa0];
+       u8         reserved_at_140[0xa0];
 
-       u8         reserved_8[0x18];
+       u8         reserved_at_1e0[0x18];
        u8         match_criteria_enable[0x8];
 
        struct mlx5_ifc_fte_match_param_bits match_criteria;
 
-       u8         reserved_9[0xe00];
+       u8         reserved_at_1200[0xe00];
 };
 
 struct mlx5_ifc_create_eq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x18];
+       u8         reserved_at_40[0x18];
        u8         eq_number[0x8];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_eq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_eqc_bits eq_context_entry;
 
-       u8         reserved_3[0x40];
+       u8         reserved_at_280[0x40];
 
        u8         event_bitmask[0x40];
 
-       u8         reserved_4[0x580];
+       u8         reserved_at_300[0x580];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_create_dct_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         dctn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_dct_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_dctc_bits dct_context_entry;
 
-       u8         reserved_3[0x180];
+       u8         reserved_at_280[0x180];
 };
 
 struct mlx5_ifc_create_cq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         cqn[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_create_cq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        struct mlx5_ifc_cqc_bits cq_context;
 
-       u8         reserved_3[0x600];
+       u8         reserved_at_280[0x600];
 
        u8         pas[0][0x40];
 };
 
 struct mlx5_ifc_config_int_moderation_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x4];
+       u8         reserved_at_40[0x4];
        u8         min_delay[0xc];
        u8         int_vector[0x10];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 enum {
@@ -5879,49 +5881,49 @@ enum {
 
 struct mlx5_ifc_config_int_moderation_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x4];
+       u8         reserved_at_40[0x4];
        u8         min_delay[0xc];
        u8         int_vector[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_attach_to_mcg_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_attach_to_mcg_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         qpn[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 
        u8         multicast_gid[16][0x8];
 };
 
 struct mlx5_ifc_arm_xrc_srq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 enum {
@@ -5930,25 +5932,25 @@ enum {
 
 struct mlx5_ifc_arm_xrc_srq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         xrc_srqn[0x18];
 
-       u8         reserved_3[0x10];
+       u8         reserved_at_60[0x10];
        u8         lwm[0x10];
 };
 
 struct mlx5_ifc_arm_rq_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 enum {
@@ -5957,179 +5959,179 @@ enum {
 
 struct mlx5_ifc_arm_rq_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         srq_number[0x18];
 
-       u8         reserved_3[0x10];
+       u8         reserved_at_60[0x10];
        u8         lwm[0x10];
 };
 
 struct mlx5_ifc_arm_dct_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_arm_dct_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_40[0x8];
        u8         dct_number[0x18];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_alloc_xrcd_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         xrcd[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_alloc_xrcd_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_alloc_uar_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         uar[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_alloc_uar_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_alloc_transport_domain_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         transport_domain[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_alloc_transport_domain_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_alloc_q_counter_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x18];
+       u8         reserved_at_40[0x18];
        u8         counter_set_id[0x8];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_alloc_q_counter_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_alloc_pd_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x8];
+       u8         reserved_at_40[0x8];
        u8         pd[0x18];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_60[0x20];
 };
 
 struct mlx5_ifc_alloc_pd_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_add_vxlan_udp_dport_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_add_vxlan_udp_dport_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_40[0x20];
 
-       u8         reserved_3[0x10];
+       u8         reserved_at_60[0x10];
        u8         vxlan_udp_port[0x10];
 };
 
 struct mlx5_ifc_access_register_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         register_data[0][0x20];
 };
@@ -6141,12 +6143,12 @@ enum {
 
 struct mlx5_ifc_access_register_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x10];
+       u8         reserved_at_40[0x10];
        u8         register_id[0x10];
 
        u8         argument[0x20];
@@ -6159,24 +6161,24 @@ struct mlx5_ifc_sltp_reg_bits {
        u8         version[0x4];
        u8         local_port[0x8];
        u8         pnat[0x2];
-       u8         reserved_0[0x2];
+       u8         reserved_at_12[0x2];
        u8         lane[0x4];
-       u8         reserved_1[0x8];
+       u8         reserved_at_18[0x8];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_20[0x20];
 
-       u8         reserved_3[0x7];
+       u8         reserved_at_40[0x7];
        u8         polarity[0x1];
        u8         ob_tap0[0x8];
        u8         ob_tap1[0x8];
        u8         ob_tap2[0x8];
 
-       u8         reserved_4[0xc];
+       u8         reserved_at_60[0xc];
        u8         ob_preemp_mode[0x4];
        u8         ob_reg[0x8];
        u8         ob_bias[0x8];
 
-       u8         reserved_5[0x20];
+       u8         reserved_at_80[0x20];
 };
 
 struct mlx5_ifc_slrg_reg_bits {
@@ -6184,36 +6186,36 @@ struct mlx5_ifc_slrg_reg_bits {
        u8         version[0x4];
        u8         local_port[0x8];
        u8         pnat[0x2];
-       u8         reserved_0[0x2];
+       u8         reserved_at_12[0x2];
        u8         lane[0x4];
-       u8         reserved_1[0x8];
+       u8         reserved_at_18[0x8];
 
        u8         time_to_link_up[0x10];
-       u8         reserved_2[0xc];
+       u8         reserved_at_30[0xc];
        u8         grade_lane_speed[0x4];
 
        u8         grade_version[0x8];
        u8         grade[0x18];
 
-       u8         reserved_3[0x4];
+       u8         reserved_at_60[0x4];
        u8         height_grade_type[0x4];
        u8         height_grade[0x18];
 
        u8         height_dz[0x10];
        u8         height_dv[0x10];
 
-       u8         reserved_4[0x10];
+       u8         reserved_at_a0[0x10];
        u8         height_sigma[0x10];
 
-       u8         reserved_5[0x20];
+       u8         reserved_at_c0[0x20];
 
-       u8         reserved_6[0x4];
+       u8         reserved_at_e0[0x4];
        u8         phase_grade_type[0x4];
        u8         phase_grade[0x18];
 
-       u8         reserved_7[0x8];
+       u8         reserved_at_100[0x8];
        u8         phase_eo_pos[0x8];
-       u8         reserved_8[0x8];
+       u8         reserved_at_110[0x8];
        u8         phase_eo_neg[0x8];
 
        u8         ffe_set_tested[0x10];
@@ -6221,70 +6223,70 @@ struct mlx5_ifc_slrg_reg_bits {
 };
 
 struct mlx5_ifc_pvlc_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_2[0x1c];
+       u8         reserved_at_20[0x1c];
        u8         vl_hw_cap[0x4];
 
-       u8         reserved_3[0x1c];
+       u8         reserved_at_40[0x1c];
        u8         vl_admin[0x4];
 
-       u8         reserved_4[0x1c];
+       u8         reserved_at_60[0x1c];
        u8         vl_operational[0x4];
 };
 
 struct mlx5_ifc_pude_reg_bits {
        u8         swid[0x8];
        u8         local_port[0x8];
-       u8         reserved_0[0x4];
+       u8         reserved_at_10[0x4];
        u8         admin_status[0x4];
-       u8         reserved_1[0x4];
+       u8         reserved_at_18[0x4];
        u8         oper_status[0x4];
 
-       u8         reserved_2[0x60];
+       u8         reserved_at_20[0x60];
 };
 
 struct mlx5_ifc_ptys_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0xd];
+       u8         reserved_at_10[0xd];
        u8         proto_mask[0x3];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_20[0x40];
 
        u8         eth_proto_capability[0x20];
 
        u8         ib_link_width_capability[0x10];
        u8         ib_proto_capability[0x10];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_a0[0x20];
 
        u8         eth_proto_admin[0x20];
 
        u8         ib_link_width_admin[0x10];
        u8         ib_proto_admin[0x10];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_100[0x20];
 
        u8         eth_proto_oper[0x20];
 
        u8         ib_link_width_oper[0x10];
        u8         ib_proto_oper[0x10];
 
-       u8         reserved_5[0x20];
+       u8         reserved_at_160[0x20];
 
        u8         eth_proto_lp_advertise[0x20];
 
-       u8         reserved_6[0x60];
+       u8         reserved_at_1a0[0x60];
 };
 
 struct mlx5_ifc_ptas_reg_bits {
-       u8         reserved_0[0x20];
+       u8         reserved_at_0[0x20];
 
        u8         algorithm_options[0x10];
-       u8         reserved_1[0x4];
+       u8         reserved_at_30[0x4];
        u8         repetitions_mode[0x4];
        u8         num_of_repetitions[0x8];
 
@@ -6310,13 +6312,13 @@ struct mlx5_ifc_ptas_reg_bits {
        u8         ndeo_error_threshold[0x10];
 
        u8         mixer_offset_step_size[0x10];
-       u8         reserved_2[0x8];
+       u8         reserved_at_110[0x8];
        u8         mix90_phase_for_voltage_bath[0x8];
 
        u8         mixer_offset_start[0x10];
        u8         mixer_offset_end[0x10];
 
-       u8         reserved_3[0x15];
+       u8         reserved_at_140[0x15];
        u8         ber_test_time[0xb];
 };
 
@@ -6324,154 +6326,154 @@ struct mlx5_ifc_pspa_reg_bits {
        u8         swid[0x8];
        u8         local_port[0x8];
        u8         sub_port[0x8];
-       u8         reserved_0[0x8];
+       u8         reserved_at_18[0x8];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_20[0x20];
 };
 
 struct mlx5_ifc_pqdr_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x5];
+       u8         reserved_at_10[0x5];
        u8         prio[0x3];
-       u8         reserved_2[0x6];
+       u8         reserved_at_18[0x6];
        u8         mode[0x2];
 
-       u8         reserved_3[0x20];
+       u8         reserved_at_20[0x20];
 
-       u8         reserved_4[0x10];
+       u8         reserved_at_40[0x10];
        u8         min_threshold[0x10];
 
-       u8         reserved_5[0x10];
+       u8         reserved_at_60[0x10];
        u8         max_threshold[0x10];
 
-       u8         reserved_6[0x10];
+       u8         reserved_at_80[0x10];
        u8         mark_probability_denominator[0x10];
 
-       u8         reserved_7[0x60];
+       u8         reserved_at_a0[0x60];
 };
 
 struct mlx5_ifc_ppsc_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_2[0x60];
+       u8         reserved_at_20[0x60];
 
-       u8         reserved_3[0x1c];
+       u8         reserved_at_80[0x1c];
        u8         wrps_admin[0x4];
 
-       u8         reserved_4[0x1c];
+       u8         reserved_at_a0[0x1c];
        u8         wrps_status[0x4];
 
-       u8         reserved_5[0x8];
+       u8         reserved_at_c0[0x8];
        u8         up_threshold[0x8];
-       u8         reserved_6[0x8];
+       u8         reserved_at_d0[0x8];
        u8         down_threshold[0x8];
 
-       u8         reserved_7[0x20];
+       u8         reserved_at_e0[0x20];
 
-       u8         reserved_8[0x1c];
+       u8         reserved_at_100[0x1c];
        u8         srps_admin[0x4];
 
-       u8         reserved_9[0x1c];
+       u8         reserved_at_120[0x1c];
        u8         srps_status[0x4];
 
-       u8         reserved_10[0x40];
+       u8         reserved_at_140[0x40];
 };
 
 struct mlx5_ifc_pplr_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_20[0x8];
        u8         lb_cap[0x8];
-       u8         reserved_3[0x8];
+       u8         reserved_at_30[0x8];
        u8         lb_en[0x8];
 };
 
 struct mlx5_ifc_pplm_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_20[0x20];
 
        u8         port_profile_mode[0x8];
        u8         static_port_profile[0x8];
        u8         active_port_profile[0x8];
-       u8         reserved_3[0x8];
+       u8         reserved_at_58[0x8];
 
        u8         retransmission_active[0x8];
        u8         fec_mode_active[0x18];
 
-       u8         reserved_4[0x20];
+       u8         reserved_at_80[0x20];
 };
 
 struct mlx5_ifc_ppcnt_reg_bits {
        u8         swid[0x8];
        u8         local_port[0x8];
        u8         pnat[0x2];
-       u8         reserved_0[0x8];
+       u8         reserved_at_12[0x8];
        u8         grp[0x6];
 
        u8         clr[0x1];
-       u8         reserved_1[0x1c];
+       u8         reserved_at_21[0x1c];
        u8         prio_tc[0x3];
 
        union mlx5_ifc_eth_cntrs_grp_data_layout_auto_bits counter_set;
 };
 
 struct mlx5_ifc_ppad_reg_bits {
-       u8         reserved_0[0x3];
+       u8         reserved_at_0[0x3];
        u8         single_mac[0x1];
-       u8         reserved_1[0x4];
+       u8         reserved_at_4[0x4];
        u8         local_port[0x8];
        u8         mac_47_32[0x10];
 
        u8         mac_31_0[0x20];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_pmtu_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
        u8         max_mtu[0x10];
-       u8         reserved_2[0x10];
+       u8         reserved_at_30[0x10];
 
        u8         admin_mtu[0x10];
-       u8         reserved_3[0x10];
+       u8         reserved_at_50[0x10];
 
        u8         oper_mtu[0x10];
-       u8         reserved_4[0x10];
+       u8         reserved_at_70[0x10];
 };
 
 struct mlx5_ifc_pmpr_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         module[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_2[0x18];
+       u8         reserved_at_20[0x18];
        u8         attenuation_5g[0x8];
 
-       u8         reserved_3[0x18];
+       u8         reserved_at_40[0x18];
        u8         attenuation_7g[0x8];
 
-       u8         reserved_4[0x18];
+       u8         reserved_at_60[0x18];
        u8         attenuation_12g[0x8];
 };
 
 struct mlx5_ifc_pmpe_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         module[0x8];
-       u8         reserved_1[0xc];
+       u8         reserved_at_10[0xc];
        u8         module_status[0x4];
 
-       u8         reserved_2[0x60];
+       u8         reserved_at_20[0x60];
 };
 
 struct mlx5_ifc_pmpc_reg_bits {
@@ -6479,20 +6481,20 @@ struct mlx5_ifc_pmpc_reg_bits {
 };
 
 struct mlx5_ifc_pmlpn_reg_bits {
-       u8         reserved_0[0x4];
+       u8         reserved_at_0[0x4];
        u8         mlpn_status[0x4];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
        u8         e[0x1];
-       u8         reserved_2[0x1f];
+       u8         reserved_at_21[0x1f];
 };
 
 struct mlx5_ifc_pmlp_reg_bits {
        u8         rxtx[0x1];
-       u8         reserved_0[0x7];
+       u8         reserved_at_1[0x7];
        u8         local_port[0x8];
-       u8         reserved_1[0x8];
+       u8         reserved_at_10[0x8];
        u8         width[0x8];
 
        u8         lane0_module_mapping[0x20];
@@ -6503,36 +6505,36 @@ struct mlx5_ifc_pmlp_reg_bits {
 
        u8         lane3_module_mapping[0x20];
 
-       u8         reserved_2[0x160];
+       u8         reserved_at_a0[0x160];
 };
 
 struct mlx5_ifc_pmaos_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         module[0x8];
-       u8         reserved_1[0x4];
+       u8         reserved_at_10[0x4];
        u8         admin_status[0x4];
-       u8         reserved_2[0x4];
+       u8         reserved_at_18[0x4];
        u8         oper_status[0x4];
 
        u8         ase[0x1];
        u8         ee[0x1];
-       u8         reserved_3[0x1c];
+       u8         reserved_at_22[0x1c];
        u8         e[0x2];
 
-       u8         reserved_4[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_plpc_reg_bits {
-       u8         reserved_0[0x4];
+       u8         reserved_at_0[0x4];
        u8         profile_id[0xc];
-       u8         reserved_1[0x4];
+       u8         reserved_at_10[0x4];
        u8         proto_mask[0x4];
-       u8         reserved_2[0x8];
+       u8         reserved_at_18[0x8];
 
-       u8         reserved_3[0x10];
+       u8         reserved_at_20[0x10];
        u8         lane_speed[0x10];
 
-       u8         reserved_4[0x17];
+       u8         reserved_at_40[0x17];
        u8         lpbf[0x1];
        u8         fec_mode_policy[0x8];
 
@@ -6545,44 +6547,44 @@ struct mlx5_ifc_plpc_reg_bits {
        u8         retransmission_request_admin[0x8];
        u8         fec_mode_request_admin[0x18];
 
-       u8         reserved_5[0x80];
+       u8         reserved_at_c0[0x80];
 };
 
 struct mlx5_ifc_plib_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x8];
+       u8         reserved_at_10[0x8];
        u8         ib_port[0x8];
 
-       u8         reserved_2[0x60];
+       u8         reserved_at_20[0x60];
 };
 
 struct mlx5_ifc_plbf_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0xd];
+       u8         reserved_at_10[0xd];
        u8         lbf_mode[0x3];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_20[0x20];
 };
 
 struct mlx5_ifc_pipg_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
        u8         dic[0x1];
-       u8         reserved_2[0x19];
+       u8         reserved_at_21[0x19];
        u8         ipg[0x4];
-       u8         reserved_3[0x2];
+       u8         reserved_at_3e[0x2];
 };
 
 struct mlx5_ifc_pifr_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_2[0xe0];
+       u8         reserved_at_20[0xe0];
 
        u8         port_filter[8][0x20];
 
@@ -6590,36 +6592,36 @@ struct mlx5_ifc_pifr_reg_bits {
 };
 
 struct mlx5_ifc_pfcc_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
        u8         ppan[0x4];
-       u8         reserved_2[0x4];
+       u8         reserved_at_24[0x4];
        u8         prio_mask_tx[0x8];
-       u8         reserved_3[0x8];
+       u8         reserved_at_30[0x8];
        u8         prio_mask_rx[0x8];
 
        u8         pptx[0x1];
        u8         aptx[0x1];
-       u8         reserved_4[0x6];
+       u8         reserved_at_42[0x6];
        u8         pfctx[0x8];
-       u8         reserved_5[0x10];
+       u8         reserved_at_50[0x10];
 
        u8         pprx[0x1];
        u8         aprx[0x1];
-       u8         reserved_6[0x6];
+       u8         reserved_at_62[0x6];
        u8         pfcrx[0x8];
-       u8         reserved_7[0x10];
+       u8         reserved_at_70[0x10];
 
-       u8         reserved_8[0x80];
+       u8         reserved_at_80[0x80];
 };
 
 struct mlx5_ifc_pelc_reg_bits {
        u8         op[0x4];
-       u8         reserved_0[0x4];
+       u8         reserved_at_4[0x4];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
        u8         op_admin[0x8];
        u8         op_capability[0x8];
@@ -6634,28 +6636,28 @@ struct mlx5_ifc_pelc_reg_bits {
 
        u8         active[0x40];
 
-       u8         reserved_2[0x80];
+       u8         reserved_at_140[0x80];
 };
 
 struct mlx5_ifc_peir_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_2[0xc];
+       u8         reserved_at_20[0xc];
        u8         error_count[0x4];
-       u8         reserved_3[0x10];
+       u8         reserved_at_30[0x10];
 
-       u8         reserved_4[0xc];
+       u8         reserved_at_40[0xc];
        u8         lane[0x4];
-       u8         reserved_5[0x8];
+       u8         reserved_at_50[0x8];
        u8         error_type[0x8];
 };
 
 struct mlx5_ifc_pcap_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         local_port[0x8];
-       u8         reserved_1[0x10];
+       u8         reserved_at_10[0x10];
 
        u8         port_capability_mask[4][0x20];
 };
@@ -6663,46 +6665,46 @@ struct mlx5_ifc_pcap_reg_bits {
 struct mlx5_ifc_paos_reg_bits {
        u8         swid[0x8];
        u8         local_port[0x8];
-       u8         reserved_0[0x4];
+       u8         reserved_at_10[0x4];
        u8         admin_status[0x4];
-       u8         reserved_1[0x4];
+       u8         reserved_at_18[0x4];
        u8         oper_status[0x4];
 
        u8         ase[0x1];
        u8         ee[0x1];
-       u8         reserved_2[0x1c];
+       u8         reserved_at_22[0x1c];
        u8         e[0x2];
 
-       u8         reserved_3[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_pamp_reg_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         opamp_group[0x8];
-       u8         reserved_1[0xc];
+       u8         reserved_at_10[0xc];
        u8         opamp_group_type[0x4];
 
        u8         start_index[0x10];
-       u8         reserved_2[0x4];
+       u8         reserved_at_30[0x4];
        u8         num_of_indices[0xc];
 
        u8         index_data[18][0x10];
 };
 
 struct mlx5_ifc_lane_2_module_mapping_bits {
-       u8         reserved_0[0x6];
+       u8         reserved_at_0[0x6];
        u8         rx_lane[0x2];
-       u8         reserved_1[0x6];
+       u8         reserved_at_8[0x6];
        u8         tx_lane[0x2];
-       u8         reserved_2[0x8];
+       u8         reserved_at_10[0x8];
        u8         module[0x8];
 };
 
 struct mlx5_ifc_bufferx_reg_bits {
-       u8         reserved_0[0x6];
+       u8         reserved_at_0[0x6];
        u8         lossy[0x1];
        u8         epsb[0x1];
-       u8         reserved_1[0xc];
+       u8         reserved_at_8[0xc];
        u8         size[0xc];
 
        u8         xoff_threshold[0x10];
@@ -6714,21 +6716,21 @@ struct mlx5_ifc_set_node_in_bits {
 };
 
 struct mlx5_ifc_register_power_settings_bits {
-       u8         reserved_0[0x18];
+       u8         reserved_at_0[0x18];
        u8         power_settings_level[0x8];
 
-       u8         reserved_1[0x60];
+       u8         reserved_at_20[0x60];
 };
 
 struct mlx5_ifc_register_host_endianness_bits {
        u8         he[0x1];
-       u8         reserved_0[0x1f];
+       u8         reserved_at_1[0x1f];
 
-       u8         reserved_1[0x60];
+       u8         reserved_at_20[0x60];
 };
 
 struct mlx5_ifc_umr_pointer_desc_argument_bits {
-       u8         reserved_0[0x20];
+       u8         reserved_at_0[0x20];
 
        u8         mkey[0x20];
 
@@ -6741,7 +6743,7 @@ struct mlx5_ifc_ud_adrs_vector_bits {
        u8         dc_key[0x40];
 
        u8         ext[0x1];
-       u8         reserved_0[0x7];
+       u8         reserved_at_41[0x7];
        u8         destination_qp_dct[0x18];
 
        u8         static_rate[0x4];
@@ -6750,7 +6752,7 @@ struct mlx5_ifc_ud_adrs_vector_bits {
        u8         mlid[0x7];
        u8         rlid_udp_sport[0x10];
 
-       u8         reserved_1[0x20];
+       u8         reserved_at_80[0x20];
 
        u8         rmac_47_16[0x20];
 
@@ -6758,9 +6760,9 @@ struct mlx5_ifc_ud_adrs_vector_bits {
        u8         tclass[0x8];
        u8         hop_limit[0x8];
 
-       u8         reserved_2[0x1];
+       u8         reserved_at_e0[0x1];
        u8         grh[0x1];
-       u8         reserved_3[0x2];
+       u8         reserved_at_e2[0x2];
        u8         src_addr_index[0x8];
        u8         flow_label[0x14];
 
@@ -6768,27 +6770,27 @@ struct mlx5_ifc_ud_adrs_vector_bits {
 };
 
 struct mlx5_ifc_pages_req_event_bits {
-       u8         reserved_0[0x10];
+       u8         reserved_at_0[0x10];
        u8         function_id[0x10];
 
        u8         num_pages[0x20];
 
-       u8         reserved_1[0xa0];
+       u8         reserved_at_40[0xa0];
 };
 
 struct mlx5_ifc_eqe_bits {
-       u8         reserved_0[0x8];
+       u8         reserved_at_0[0x8];
        u8         event_type[0x8];
-       u8         reserved_1[0x8];
+       u8         reserved_at_10[0x8];
        u8         event_sub_type[0x8];
 
-       u8         reserved_2[0xe0];
+       u8         reserved_at_20[0xe0];
 
        union mlx5_ifc_event_auto_bits event_data;
 
-       u8         reserved_3[0x10];
+       u8         reserved_at_1e0[0x10];
        u8         signature[0x8];
-       u8         reserved_4[0x7];
+       u8         reserved_at_1f8[0x7];
        u8         owner[0x1];
 };
 
@@ -6798,14 +6800,14 @@ enum {
 
 struct mlx5_ifc_cmd_queue_entry_bits {
        u8         type[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         input_length[0x20];
 
        u8         input_mailbox_pointer_63_32[0x20];
 
        u8         input_mailbox_pointer_31_9[0x17];
-       u8         reserved_1[0x9];
+       u8         reserved_at_77[0x9];
 
        u8         command_input_inline_data[16][0x8];
 
@@ -6814,20 +6816,20 @@ struct mlx5_ifc_cmd_queue_entry_bits {
        u8         output_mailbox_pointer_63_32[0x20];
 
        u8         output_mailbox_pointer_31_9[0x17];
-       u8         reserved_2[0x9];
+       u8         reserved_at_1b7[0x9];
 
        u8         output_length[0x20];
 
        u8         token[0x8];
        u8         signature[0x8];
-       u8         reserved_3[0x8];
+       u8         reserved_at_1f0[0x8];
        u8         status[0x7];
        u8         ownership[0x1];
 };
 
 struct mlx5_ifc_cmd_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
@@ -6836,9 +6838,9 @@ struct mlx5_ifc_cmd_out_bits {
 
 struct mlx5_ifc_cmd_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
        u8         command[0][0x20];
@@ -6847,16 +6849,16 @@ struct mlx5_ifc_cmd_in_bits {
 struct mlx5_ifc_cmd_if_box_bits {
        u8         mailbox_data[512][0x8];
 
-       u8         reserved_0[0x180];
+       u8         reserved_at_1000[0x180];
 
        u8         next_pointer_63_32[0x20];
 
        u8         next_pointer_31_10[0x16];
-       u8         reserved_1[0xa];
+       u8         reserved_at_11b6[0xa];
 
        u8         block_number[0x20];
 
-       u8         reserved_2[0x8];
+       u8         reserved_at_11e0[0x8];
        u8         token[0x8];
        u8         ctrl_signature[0x8];
        u8         signature[0x8];
@@ -6866,7 +6868,7 @@ struct mlx5_ifc_mtt_bits {
        u8         ptag_63_32[0x20];
 
        u8         ptag_31_8[0x18];
-       u8         reserved_0[0x6];
+       u8         reserved_at_38[0x6];
        u8         wr_en[0x1];
        u8         rd_en[0x1];
 };
@@ -6904,38 +6906,38 @@ struct mlx5_ifc_initial_seg_bits {
        u8         cmd_interface_rev[0x10];
        u8         fw_rev_subminor[0x10];
 
-       u8         reserved_0[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         cmdq_phy_addr_63_32[0x20];
 
        u8         cmdq_phy_addr_31_12[0x14];
-       u8         reserved_1[0x2];
+       u8         reserved_at_b4[0x2];
        u8         nic_interface[0x2];
        u8         log_cmdq_size[0x4];
        u8         log_cmdq_stride[0x4];
 
        u8         command_doorbell_vector[0x20];
 
-       u8         reserved_2[0xf00];
+       u8         reserved_at_e0[0xf00];
 
        u8         initializing[0x1];
-       u8         reserved_3[0x4];
+       u8         reserved_at_fe1[0x4];
        u8         nic_interface_supported[0x3];
-       u8         reserved_4[0x18];
+       u8         reserved_at_fe8[0x18];
 
        struct mlx5_ifc_health_buffer_bits health_buffer;
 
        u8         no_dram_nic_offset[0x20];
 
-       u8         reserved_5[0x6e40];
+       u8         reserved_at_1220[0x6e40];
 
-       u8         reserved_6[0x1f];
+       u8         reserved_at_8060[0x1f];
        u8         clear_int[0x1];
 
        u8         health_syndrome[0x8];
        u8         health_counter[0x18];
 
-       u8         reserved_7[0x17fc0];
+       u8         reserved_at_80a0[0x17fc0];
 };
 
 union mlx5_ifc_ports_control_registers_document_bits {
@@ -6980,44 +6982,44 @@ union mlx5_ifc_ports_control_registers_document_bits {
        struct mlx5_ifc_pvlc_reg_bits pvlc_reg;
        struct mlx5_ifc_slrg_reg_bits slrg_reg;
        struct mlx5_ifc_sltp_reg_bits sltp_reg;
-       u8         reserved_0[0x60e0];
+       u8         reserved_at_0[0x60e0];
 };
 
 union mlx5_ifc_debug_enhancements_document_bits {
        struct mlx5_ifc_health_buffer_bits health_buffer;
-       u8         reserved_0[0x200];
+       u8         reserved_at_0[0x200];
 };
 
 union mlx5_ifc_uplink_pci_interface_document_bits {
        struct mlx5_ifc_initial_seg_bits initial_seg;
-       u8         reserved_0[0x20060];
+       u8         reserved_at_0[0x20060];
 };
 
 struct mlx5_ifc_set_flow_table_root_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_set_flow_table_root_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x40];
+       u8         reserved_at_40[0x40];
 
        u8         table_type[0x8];
-       u8         reserved_3[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_4[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_id[0x18];
 
-       u8         reserved_5[0x140];
+       u8         reserved_at_c0[0x140];
 };
 
 enum {
@@ -7026,39 +7028,39 @@ enum {
 
 struct mlx5_ifc_modify_flow_table_out_bits {
        u8         status[0x8];
-       u8         reserved_0[0x18];
+       u8         reserved_at_8[0x18];
 
        u8         syndrome[0x20];
 
-       u8         reserved_1[0x40];
+       u8         reserved_at_40[0x40];
 };
 
 struct mlx5_ifc_modify_flow_table_in_bits {
        u8         opcode[0x10];
-       u8         reserved_0[0x10];
+       u8         reserved_at_10[0x10];
 
-       u8         reserved_1[0x10];
+       u8         reserved_at_20[0x10];
        u8         op_mod[0x10];
 
-       u8         reserved_2[0x20];
+       u8         reserved_at_40[0x20];
 
-       u8         reserved_3[0x10];
+       u8         reserved_at_60[0x10];
        u8         modify_field_select[0x10];
 
        u8         table_type[0x8];
-       u8         reserved_4[0x18];
+       u8         reserved_at_88[0x18];
 
-       u8         reserved_5[0x8];
+       u8         reserved_at_a0[0x8];
        u8         table_id[0x18];
 
-       u8         reserved_6[0x4];
+       u8         reserved_at_c0[0x4];
        u8         table_miss_mode[0x4];
-       u8         reserved_7[0x18];
+       u8         reserved_at_c8[0x18];
 
-       u8         reserved_8[0x8];
+       u8         reserved_at_e0[0x8];
        u8         table_miss_id[0x18];
 
-       u8         reserved_9[0x100];
+       u8         reserved_at_100[0x100];
 };
 
 #endif /* MLX5_IFC_H */
index 4560d8f..2bb0c30 100644 (file)
@@ -324,6 +324,12 @@ struct module_layout {
 #define __module_layout_align
 #endif
 
+struct mod_kallsyms {
+       Elf_Sym *symtab;
+       unsigned int num_symtab;
+       char *strtab;
+};
+
 struct module {
        enum module_state state;
 
@@ -405,15 +411,10 @@ struct module {
 #endif
 
 #ifdef CONFIG_KALLSYMS
-       /*
-        * We keep the symbol and string tables for kallsyms.
-        * The core_* fields below are temporary, loader-only (they
-        * could really be discarded after module init).
-        */
-       Elf_Sym *symtab, *core_symtab;
-       unsigned int num_symtab, core_num_syms;
-       char *strtab, *core_strtab;
-
+       /* Protected by RCU and/or module_mutex: use rcu_dereference() */
+       struct mod_kallsyms *kallsyms;
+       struct mod_kallsyms core_kallsyms;
+       
        /* Section attributes */
        struct module_sect_attrs *sect_attrs;
 
index 289c231..5440b7b 100644 (file)
@@ -3718,7 +3718,7 @@ void *netdev_lower_get_next_private_rcu(struct net_device *dev,
 void *netdev_lower_get_next(struct net_device *dev,
                                struct list_head **iter);
 #define netdev_for_each_lower_dev(dev, ldev, iter) \
-       for (iter = &(dev)->adj_list.lower, \
+       for (iter = (dev)->adj_list.lower.next, \
             ldev = netdev_lower_get_next(dev, &(iter)); \
             ldev; \
             ldev = netdev_lower_get_next(dev, &(iter)))
index 48e0320..67300f8 100644 (file)
@@ -550,9 +550,7 @@ extern int  nfs_readpage_async(struct nfs_open_context *, struct inode *,
 
 static inline loff_t nfs_size_to_loff_t(__u64 size)
 {
-       if (size > (__u64) OFFSET_MAX - 1)
-               return OFFSET_MAX - 1;
-       return (loff_t) size;
+       return min_t(u64, size, OFFSET_MAX);
 }
 
 static inline ino_t
index 791098a..d320906 100644 (file)
@@ -275,6 +275,7 @@ struct nfs4_layoutcommit_args {
        size_t layoutupdate_len;
        struct page *layoutupdate_page;
        struct page **layoutupdate_pages;
+       __be32 *start_p;
 };
 
 struct nfs4_layoutcommit_res {
index 27df4a6..2771625 100644 (file)
@@ -988,23 +988,6 @@ static inline int pci_is_managed(struct pci_dev *pdev)
        return pdev->is_managed;
 }
 
-static inline void pci_set_managed_irq(struct pci_dev *pdev, unsigned int irq)
-{
-       pdev->irq = irq;
-       pdev->irq_managed = 1;
-}
-
-static inline void pci_reset_managed_irq(struct pci_dev *pdev)
-{
-       pdev->irq = 0;
-       pdev->irq_managed = 0;
-}
-
-static inline bool pci_has_managed_irq(struct pci_dev *pdev)
-{
-       return pdev->irq_managed && pdev->irq > 0;
-}
-
 void pci_disable_device(struct pci_dev *dev);
 
 extern unsigned int pcibios_max_latency;
index b35a61a..f5c5a3f 100644 (file)
@@ -397,6 +397,7 @@ struct pmu {
  * enum perf_event_active_state - the states of a event
  */
 enum perf_event_active_state {
+       PERF_EVENT_STATE_DEAD           = -4,
        PERF_EVENT_STATE_EXIT           = -3,
        PERF_EVENT_STATE_ERROR          = -2,
        PERF_EVENT_STATE_OFF            = -1,
@@ -905,7 +906,7 @@ perf_sw_event_sched(u32 event_id, u64 nr, u64 addr)
        }
 }
 
-extern struct static_key_deferred perf_sched_events;
+extern struct static_key_false perf_sched_events;
 
 static __always_inline bool
 perf_sw_migrate_enabled(void)
@@ -924,7 +925,7 @@ static inline void perf_event_task_migrate(struct task_struct *task)
 static inline void perf_event_task_sched_in(struct task_struct *prev,
                                            struct task_struct *task)
 {
-       if (static_key_false(&perf_sched_events.key))
+       if (static_branch_unlikely(&perf_sched_events))
                __perf_event_task_sched_in(prev, task);
 
        if (perf_sw_migrate_enabled() && task->sched_migrated) {
@@ -941,7 +942,7 @@ static inline void perf_event_task_sched_out(struct task_struct *prev,
 {
        perf_sw_event_sched(PERF_COUNT_SW_CONTEXT_SWITCHES, 1, 0);
 
-       if (static_key_false(&perf_sched_events.key))
+       if (static_branch_unlikely(&perf_sched_events))
                __perf_event_task_sched_out(prev, next);
 }
 
index 2d8e497..1132953 100644 (file)
@@ -10,7 +10,7 @@
  * backing is indicated by flags in the high bits of the value.
  */
 typedef struct {
-       unsigned long val;
+       u64 val;
 } pfn_t;
 #endif
 
index 37448ab..9499481 100644 (file)
@@ -9,14 +9,13 @@
  * PFN_DEV - pfn is not covered by system memmap by default
  * PFN_MAP - pfn has a dynamic page mapping established by a device driver
  */
-#define PFN_FLAGS_MASK (((unsigned long) ~PAGE_MASK) \
-               << (BITS_PER_LONG - PAGE_SHIFT))
-#define PFN_SG_CHAIN (1UL << (BITS_PER_LONG - 1))
-#define PFN_SG_LAST (1UL << (BITS_PER_LONG - 2))
-#define PFN_DEV (1UL << (BITS_PER_LONG - 3))
-#define PFN_MAP (1UL << (BITS_PER_LONG - 4))
-
-static inline pfn_t __pfn_to_pfn_t(unsigned long pfn, unsigned long flags)
+#define PFN_FLAGS_MASK (((u64) ~PAGE_MASK) << (BITS_PER_LONG_LONG - PAGE_SHIFT))
+#define PFN_SG_CHAIN (1ULL << (BITS_PER_LONG_LONG - 1))
+#define PFN_SG_LAST (1ULL << (BITS_PER_LONG_LONG - 2))
+#define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3))
+#define PFN_MAP (1ULL << (BITS_PER_LONG_LONG - 4))
+
+static inline pfn_t __pfn_to_pfn_t(unsigned long pfn, u64 flags)
 {
        pfn_t pfn_t = { .val = pfn | (flags & PFN_FLAGS_MASK), };
 
@@ -29,7 +28,7 @@ static inline pfn_t pfn_to_pfn_t(unsigned long pfn)
        return __pfn_to_pfn_t(pfn, 0);
 }
 
-extern pfn_t phys_to_pfn_t(phys_addr_t addr, unsigned long flags);
+extern pfn_t phys_to_pfn_t(phys_addr_t addr, u64 flags);
 
 static inline bool pfn_t_has_page(pfn_t pfn)
 {
@@ -87,7 +86,7 @@ static inline pmd_t pfn_t_pmd(pfn_t pfn, pgprot_t pgprot)
 #ifdef __HAVE_ARCH_PTE_DEVMAP
 static inline bool pfn_t_devmap(pfn_t pfn)
 {
-       const unsigned long flags = PFN_DEV|PFN_MAP;
+       const u64 flags = PFN_DEV|PFN_MAP;
 
        return (pfn.val & flags) == flags;
 }
index 998d8f1..b50c049 100644 (file)
@@ -49,6 +49,7 @@ struct bq27xxx_reg_cache {
 
 struct bq27xxx_device_info {
        struct device *dev;
+       int id;
        enum bq27xxx_chip chip;
        const char *name;
        struct bq27xxx_access_methods bus;
index a75840c..9c29122 100644 (file)
@@ -34,6 +34,7 @@ extern const struct file_operations random_fops, urandom_fops;
 #endif
 
 unsigned int get_random_int(void);
+unsigned long get_random_long(void);
 unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
 
 u32 prandom_u32(void);
index 11f935c..d3fcd45 100644 (file)
@@ -299,6 +299,7 @@ struct sk_buff;
 #else
 #define MAX_SKB_FRAGS (65536/PAGE_SIZE + 1)
 #endif
+extern int sysctl_max_skb_frags;
 
 typedef struct skb_frag_struct skb_frag_t;
 
@@ -1984,6 +1985,30 @@ static inline void skb_reserve(struct sk_buff *skb, int len)
        skb->tail += len;
 }
 
+/**
+ *     skb_tailroom_reserve - adjust reserved_tailroom
+ *     @skb: buffer to alter
+ *     @mtu: maximum amount of headlen permitted
+ *     @needed_tailroom: minimum amount of reserved_tailroom
+ *
+ *     Set reserved_tailroom so that headlen can be as large as possible but
+ *     not larger than mtu and tailroom cannot be smaller than
+ *     needed_tailroom.
+ *     The required headroom should already have been reserved before using
+ *     this function.
+ */
+static inline void skb_tailroom_reserve(struct sk_buff *skb, unsigned int mtu,
+                                       unsigned int needed_tailroom)
+{
+       SKB_LINEAR_ASSERT(skb);
+       if (mtu < skb_tailroom(skb) - needed_tailroom)
+               /* use at most mtu */
+               skb->reserved_tailroom = skb_tailroom(skb) - mtu;
+       else
+               /* use up to all available space */
+               skb->reserved_tailroom = needed_tailroom;
+}
+
 #define ENCAP_TYPE_ETHER       0
 #define ENCAP_TYPE_IPPROTO     1
 
index 343c13a..35cb926 100644 (file)
@@ -44,6 +44,7 @@
 
 #define KNAV_DMA_NUM_EPIB_WORDS                        4
 #define KNAV_DMA_NUM_PS_WORDS                  16
+#define KNAV_DMA_NUM_SW_DATA_WORDS             4
 #define KNAV_DMA_FDQ_PER_CHAN                  4
 
 /* Tx channel scheduling priority */
@@ -142,6 +143,7 @@ struct knav_dma_cfg {
  * @orig_buff:                 buff pointer since 'buff' can be overwritten
  * @epib:                      Extended packet info block
  * @psdata:                    Protocol specific
+ * @sw_data:                   Software private data not touched by h/w
  */
 struct knav_dma_desc {
        __le32  desc_info;
@@ -154,7 +156,7 @@ struct knav_dma_desc {
        __le32  orig_buff;
        __le32  epib[KNAV_DMA_NUM_EPIB_WORDS];
        __le32  psdata[KNAV_DMA_NUM_PS_WORDS];
-       __le32  pad[4];
+       u32     sw_data[KNAV_DMA_NUM_SW_DATA_WORDS];
 } ____cacheline_aligned;
 
 #if IS_ENABLED(CONFIG_KEYSTONE_NAVIGATOR_DMA)
index eead8ab..881a79d 100644 (file)
@@ -100,6 +100,7 @@ struct plat_stmmacenet_data {
        int interface;
        struct stmmac_mdio_bus_data *mdio_bus_data;
        struct device_node *phy_node;
+       struct device_node *mdio_node;
        struct stmmac_dma_cfg *dma_cfg;
        int clk_csr;
        int has_gmac;
index 429fdfc..925730b 100644 (file)
@@ -568,6 +568,8 @@ enum {
        FILTER_DYN_STRING,
        FILTER_PTR_STRING,
        FILTER_TRACE_FN,
+       FILTER_COMM,
+       FILTER_CPU,
 };
 
 extern int trace_event_raw_init(struct trace_event_call *call);
index acd522a..be586c6 100644 (file)
  * See the file COPYING for more details.
  */
 
+#include <linux/smp.h>
 #include <linux/errno.h>
 #include <linux/types.h>
+#include <linux/cpumask.h>
 #include <linux/rcupdate.h>
 #include <linux/tracepoint-defs.h>
 
@@ -338,15 +340,19 @@ extern void syscall_unregfunc(void);
  * "void *__data, proto" as the callback prototype.
  */
 #define DECLARE_TRACE_NOARGS(name)                                     \
-               __DECLARE_TRACE(name, void, , 1, void *__data, __data)
+       __DECLARE_TRACE(name, void, ,                                   \
+                       cpu_online(raw_smp_processor_id()),             \
+                       void *__data, __data)
 
 #define DECLARE_TRACE(name, proto, args)                               \
-               __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1,   \
-                               PARAMS(void *__data, proto),            \
-                               PARAMS(__data, args))
+       __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),              \
+                       cpu_online(raw_smp_processor_id()),             \
+                       PARAMS(void *__data, proto),                    \
+                       PARAMS(__data, args))
 
 #define DECLARE_TRACE_CONDITION(name, proto, args, cond)               \
-       __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \
+       __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args),              \
+                       cpu_online(raw_smp_processor_id()) && (PARAMS(cond)), \
                        PARAMS(void *__data, proto),                    \
                        PARAMS(__data, args))
 
index cbb20af..bb679b4 100644 (file)
@@ -11,4 +11,8 @@ unsigned long ucs2_strlen(const ucs2_char_t *s);
 unsigned long ucs2_strsize(const ucs2_char_t *data, unsigned long maxlength);
 int ucs2_strncmp(const ucs2_char_t *a, const ucs2_char_t *b, size_t len);
 
+unsigned long ucs2_utf8size(const ucs2_char_t *src);
+unsigned long ucs2_as_utf8(u8 *dest, const ucs2_char_t *src,
+                          unsigned long maxlength);
+
 #endif /* _LINUX_UCS2_STRING_H_ */
index 0e32bc7..ca73c50 100644 (file)
@@ -311,6 +311,7 @@ enum {
 
        __WQ_DRAINING           = 1 << 16, /* internal: workqueue is draining */
        __WQ_ORDERED            = 1 << 17, /* internal: workqueue is ordered */
+       __WQ_LEGACY             = 1 << 18, /* internal: create*_workqueue() */
 
        WQ_MAX_ACTIVE           = 512,    /* I like 512, better ideas? */
        WQ_MAX_UNBOUND_PER_CPU  = 4,      /* 4 * #cpus for unbound wq */
@@ -411,12 +412,12 @@ __alloc_workqueue_key(const char *fmt, unsigned int flags, int max_active,
        alloc_workqueue(fmt, WQ_UNBOUND | __WQ_ORDERED | (flags), 1, ##args)
 
 #define create_workqueue(name)                                         \
-       alloc_workqueue("%s", WQ_MEM_RECLAIM, 1, (name))
+       alloc_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, 1, (name))
 #define create_freezable_workqueue(name)                               \
-       alloc_workqueue("%s", WQ_FREEZABLE | WQ_UNBOUND | WQ_MEM_RECLAIM, \
-                       1, (name))
+       alloc_workqueue("%s", __WQ_LEGACY | WQ_FREEZABLE | WQ_UNBOUND | \
+                       WQ_MEM_RECLAIM, 1, (name))
 #define create_singlethread_workqueue(name)                            \
-       alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name)
+       alloc_ordered_workqueue("%s", __WQ_LEGACY | WQ_MEM_RECLAIM, name)
 
 extern void destroy_workqueue(struct workqueue_struct *wq);
 
index b333c94..d0b5ca5 100644 (file)
@@ -198,6 +198,7 @@ void wbc_attach_and_unlock_inode(struct writeback_control *wbc,
 void wbc_detach_inode(struct writeback_control *wbc);
 void wbc_account_io(struct writeback_control *wbc, struct page *page,
                    size_t bytes);
+void cgroup_writeback_umount(void);
 
 /**
  * inode_attach_wb - associate an inode with its wb
@@ -301,6 +302,10 @@ static inline void wbc_account_io(struct writeback_control *wbc,
 {
 }
 
+static inline void cgroup_writeback_umount(void)
+{
+}
+
 #endif /* CONFIG_CGROUP_WRITEBACK */
 
 /*
index d385589..165451b 100644 (file)
@@ -268,6 +268,10 @@ struct device;
  * struct media_device - Media device
  * @dev:       Parent device
  * @devnode:   Media device node
+ * @driver_name: Optional device driver name. If not set, calls to
+ *             %MEDIA_IOC_DEVICE_INFO will return dev->driver->name.
+ *             This is needed for USB drivers for example, as otherwise
+ *             they'll all appear as if the driver name was "usb".
  * @model:     Device model name
  * @serial:    Device serial number (optional)
  * @bus_info:  Unique and stable device location identifier
@@ -303,6 +307,7 @@ struct media_device {
        struct media_devnode devnode;
 
        char model[32];
+       char driver_name[32];
        char serial[40];
        char bus_info[32];
        u32 hw_revision;
index f649470..c41dd70 100644 (file)
@@ -60,6 +60,7 @@ enum rc_filter_type {
 /**
  * struct rc_dev - represents a remote control device
  * @dev: driver model's view of this device
+ * @initialized: true if the device init has completed
  * @sysfs_groups: sysfs attribute groups
  * @input_name: name of the input child device
  * @input_phys: physical path to the input child device
@@ -121,6 +122,7 @@ enum rc_filter_type {
  */
 struct rc_dev {
        struct device                   dev;
+       bool                            initialized;
        const struct attribute_group    *sysfs_groups[5];
        const char                      *input_name;
        const char                      *input_phys;
index e5321fd..b3edc14 100644 (file)
 #ifdef __KERNEL__
 
 #include <linux/videodev2.h>
-
-/* Tuner PADs */
-/* FIXME: is this the right place for it? */
-enum tuner_pad_index {
-       TUNER_PAD_RF_INPUT,
-       TUNER_PAD_IF_OUTPUT,
-       TUNER_NUM_PADS
-};
+#include <media/v4l2-mc.h>
 
 #define ADDR_UNSET (255)
 
index da6fe98..0bc9b35 100644 (file)
@@ -535,18 +535,6 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
                        u32 id, u8 max, u8 def, const s64 *qmenu_int);
 
 /**
- * v4l2_ctrl_add_ctrl() - Add a control from another handler to this handler.
- * @hdl:       The control handler.
- * @ctrl:      The control to add.
- *
- * It will return NULL if it was unable to add the control reference.
- * If the control already belonged to the handler, then it will do
- * nothing and just return @ctrl.
- */
-struct v4l2_ctrl *v4l2_ctrl_add_ctrl(struct v4l2_ctrl_handler *hdl,
-                                         struct v4l2_ctrl *ctrl);
-
-/**
  * v4l2_ctrl_add_handler() - Add all controls from handler @add to
  * handler @hdl.
  * @hdl:       The control handler.
diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h
new file mode 100644 (file)
index 0000000..79d84bb
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * v4l2-mc.h - Media Controller V4L2 types and prototypes
+ *
+ * Copyright (C) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _V4L2_MC_H
+#define _V4L2_MC_H
+
+#include <media/media-device.h>
+
+/**
+ * enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER
+ *
+ * @TUNER_PAD_RF_INPUT:        Radiofrequency (RF) sink pad, usually linked to a
+ *                     RF connector entity.
+ * @TUNER_PAD_OUTPUT:  Tuner video output source pad. Contains the video
+ *                     chrominance and luminance or the hole bandwidth
+ *                     of the signal converted to an Intermediate Frequency
+ *                     (IF) or to baseband (on zero-IF tuners).
+ * @TUNER_PAD_AUD_OUT: Tuner audio output source pad. Tuners used to decode
+ *                     analog TV signals have an extra pad for audio output.
+ *                     Old tuners use an analog stage with a saw filter for
+ *                     the audio IF frequency. The output of the pad is, in
+ *                     this case, the audio IF, with should be decoded either
+ *                     by the bridge chipset (that's the case of cx2388x
+ *                     chipsets) or may require an external IF sound
+ *                     processor, like msp34xx. On modern silicon tuners,
+ *                     the audio IF decoder is usually incorporated at the
+ *                     tuner. On such case, the output of this pad is an
+ *                     audio sampled data.
+ * @TUNER_NUM_PADS:    Number of pads of the tuner.
+ */
+enum tuner_pad_index {
+       TUNER_PAD_RF_INPUT,
+       TUNER_PAD_OUTPUT,
+       TUNER_PAD_AUD_OUT,
+       TUNER_NUM_PADS
+};
+
+/**
+ * enum if_vid_dec_index - video IF-PLL pad index for
+ *                        MEDIA_ENT_F_IF_VID_DECODER
+ *
+ * @IF_VID_DEC_PAD_IF_INPUT:   video Intermediate Frequency (IF) sink pad
+ * @IF_VID_DEC_PAD_OUT:                IF-PLL video output source pad. Contains the
+ *                             video chrominance and luminance IF signals.
+ * @IF_VID_DEC_PAD_NUM_PADS:   Number of pads of the video IF-PLL.
+ */
+enum if_vid_dec_pad_index {
+       IF_VID_DEC_PAD_IF_INPUT,
+       IF_VID_DEC_PAD_OUT,
+       IF_VID_DEC_PAD_NUM_PADS
+};
+
+/**
+ * enum if_aud_dec_index - audio/sound IF-PLL pad index for
+ *                        MEDIA_ENT_F_IF_AUD_DECODER
+ *
+ * @IF_AUD_DEC_PAD_IF_INPUT:   audio Intermediate Frequency (IF) sink pad
+ * @IF_AUD_DEC_PAD_OUT:                IF-PLL audio output source pad. Contains the
+ *                             audio sampled stream data, usually connected
+ *                             to the bridge bus via an Inter-IC Sound (I2S)
+ *                             bus.
+ * @IF_AUD_DEC_PAD_NUM_PADS:   Number of pads of the audio IF-PLL.
+ */
+enum if_aud_dec_pad_index {
+       IF_AUD_DEC_PAD_IF_INPUT,
+       IF_AUD_DEC_PAD_OUT,
+       IF_AUD_DEC_PAD_NUM_PADS
+};
+
+/**
+ * enum demod_pad_index - analog TV pad index for MEDIA_ENT_F_ATV_DECODER
+ *
+ * @DEMOD_PAD_IF_INPUT:        IF input sink pad.
+ * @DEMOD_PAD_VID_OUT: Video output source pad.
+ * @DEMOD_PAD_VBI_OUT: Vertical Blank Interface (VBI) output source pad.
+ * @DEMOD_NUM_PADS:    Maximum number of output pads.
+ */
+enum demod_pad_index {
+       DEMOD_PAD_IF_INPUT,
+       DEMOD_PAD_VID_OUT,
+       DEMOD_PAD_VBI_OUT,
+       DEMOD_NUM_PADS
+};
+
+/* We don't need to include pci.h or usb.h here */
+struct pci_dev;
+struct usb_device;
+
+#ifdef CONFIG_MEDIA_CONTROLLER
+/**
+ * v4l2_mc_create_media_graph() - create Media Controller links at the graph.
+ *
+ * @mdev:      pointer to the &media_device struct.
+ *
+ * Add links between the entities commonly found on PC customer's hardware at
+ * the V4L2 side: camera sensors, audio and video PLL-IF decoders, tuners,
+ * analog TV decoder and I/O entities (video, VBI and Software Defined Radio).
+ * NOTE: webcams are modelled on a very simple way: the sensor is
+ * connected directly to the I/O entity. All dirty details, like
+ * scaler and crop HW are hidden. While such mapping is enough for v4l2
+ * interface centric PC-consumer's hardware, V4L2 subdev centric camera
+ * hardware should not use this routine, as it will not build the right graph.
+ */
+int v4l2_mc_create_media_graph(struct media_device *mdev);
+
+/**
+ * v4l2_mc_pci_media_device_init() - create and initialize a
+ *     struct &media_device from a PCI device.
+ *
+ * @pci_dev:   pointer to struct pci_dev
+ * @name:      media device name. If %NULL, the routine will use the default
+ *             name for the pci device, given by pci_name() macro.
+ */
+struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev,
+                                                  const char *name);
+/**
+ * __v4l2_mc_usb_media_device_init() - create and initialize a
+ *     struct &media_device from a PCI device.
+ *
+ * @udev:      pointer to struct usb_device
+ * @board_name:        media device name. If %NULL, the routine will use the usb
+ *             product name, if available.
+ * @driver_name: name of the driver. if %NULL, the routine will use the name
+ *             given by udev->dev->driver->name, with is usually the wrong
+ *             thing to do.
+ *
+ * NOTE: It is better to call v4l2_mc_usb_media_device_init() instead, as
+ * such macro fills driver_name with %KBUILD_MODNAME.
+ */
+struct media_device *__v4l2_mc_usb_media_device_init(struct usb_device *udev,
+                                                    const char *board_name,
+                                                    const char *driver_name);
+
+#else
+static inline int v4l2_mc_create_media_graph(struct media_device *mdev)
+{
+       return 0;
+}
+
+static inline
+struct media_device *v4l2_mc_pci_media_device_init(struct pci_dev *pci_dev,
+                                                  char *name)
+{
+       return NULL;
+}
+
+static inline
+struct media_device *__v4l2_mc_usb_media_device_init(struct usb_device *udev,
+                                                    char *board_name,
+                                                    char *driver_name)
+{
+       return NULL;
+}
+#endif
+
+#define v4l2_mc_usb_media_device_init(udev, name) \
+       __v4l2_mc_usb_media_device_init(udev, name, KBUILD_MODNAME)
+
+#endif
index b273cf9..11e2dfe 100644 (file)
@@ -179,6 +179,8 @@ struct v4l2_subdev_io_pin_config {
  *                  for it to be warned when the value of a control changes.
  *
  * @unsubscribe_event: remove event subscription from the control framework.
+ *
+ * @registered_async: the subdevice has been registered async.
  */
 struct v4l2_subdev_core_ops {
        int (*log_status)(struct v4l2_subdev *sd);
@@ -211,6 +213,7 @@ struct v4l2_subdev_core_ops {
                               struct v4l2_event_subscription *sub);
        int (*unsubscribe_event)(struct v4l2_subdev *sd, struct v4l2_fh *fh,
                                 struct v4l2_event_subscription *sub);
+       int (*registered_async)(struct v4l2_subdev *sd);
 };
 
 /**
index 5b64c9e..87b5590 100644 (file)
@@ -8,6 +8,10 @@
 #include <dvb_frontend.h>
 
 #include <media/videobuf2-v4l2.h>
+
+/* We don't actually need to include media-device.h here */
+struct media_device;
+
 /*
  * TODO: This header file should be replaced with videobuf2-core.h
  * Currently, vb2_thread is not a stuff of videobuf2-core,
@@ -50,6 +54,7 @@ int vb2_dvb_register_bus(struct vb2_dvb_frontends *f,
                         struct module *module,
                         void *adapter_priv,
                         struct device *device,
+                        struct media_device *mdev,
                         short *adapter_nr,
                         int mfe_shared);
 
diff --git a/include/media/vsp1.h b/include/media/vsp1.h
new file mode 100644 (file)
index 0000000..cc54175
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * vsp1.h  --  R-Car VSP1 API
+ *
+ * Copyright (C) 2015 Renesas Electronics 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 __MEDIA_VSP1_H__
+#define __MEDIA_VSP1_H__
+
+#include <linux/types.h>
+
+struct device;
+struct v4l2_rect;
+
+int vsp1_du_init(struct device *dev);
+
+int vsp1_du_setup_lif(struct device *dev, unsigned int width,
+                     unsigned int height);
+
+int vsp1_du_atomic_begin(struct device *dev);
+int vsp1_du_atomic_update(struct device *dev, unsigned int rpf, u32 pixelformat,
+                         unsigned int pitch, dma_addr_t mem[2],
+                         const struct v4l2_rect *src,
+                         const struct v4l2_rect *dst);
+int vsp1_du_atomic_flush(struct device *dev);
+
+#endif /* __MEDIA_VSP1_H__ */
index 2a91a05..9b4c418 100644 (file)
@@ -6,8 +6,8 @@
 #include <linux/mutex.h>
 #include <net/sock.h>
 
-void unix_inflight(struct file *fp);
-void unix_notinflight(struct file *fp);
+void unix_inflight(struct user_struct *user, struct file *fp);
+void unix_notinflight(struct user_struct *user, struct file *fp);
 void unix_gc(void);
 void wait_for_unix_gc(void);
 struct sock *unix_get_socket(struct file *filp);
index 481fe1c..49dcad4 100644 (file)
@@ -270,8 +270,9 @@ struct dst_entry *inet_csk_route_child_sock(const struct sock *sk,
                                            struct sock *newsk,
                                            const struct request_sock *req);
 
-void inet_csk_reqsk_queue_add(struct sock *sk, struct request_sock *req,
-                             struct sock *child);
+struct sock *inet_csk_reqsk_queue_add(struct sock *sk,
+                                     struct request_sock *req,
+                                     struct sock *child);
 void inet_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req,
                                   unsigned long timeout);
 struct sock *inet_csk_complete_hashdance(struct sock *sk, struct sock *child,
index 7029527..4079fc1 100644 (file)
@@ -61,6 +61,7 @@ struct fib_nh_exception {
        struct rtable __rcu             *fnhe_rth_input;
        struct rtable __rcu             *fnhe_rth_output;
        unsigned long                   fnhe_stamp;
+       struct rcu_head                 rcu;
 };
 
 struct fnhe_hash_bucket {
index 6db96ea..dda9abf 100644 (file)
@@ -230,6 +230,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 int ip_tunnel_ioctl(struct net_device *dev, struct ip_tunnel_parm *p, int cmd);
 int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,
                    u8 *protocol, struct flowi4 *fl4);
+int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict);
 int ip_tunnel_change_mtu(struct net_device *dev, int new_mtu);
 
 struct rtnl_link_stats64 *ip_tunnel_get_stats64(struct net_device *dev,
index 8f81bbb..e0f4109 100644 (file)
@@ -439,6 +439,12 @@ int dev_get_wireless_info(char *buffer, char **start, off_t offset, int length);
 /* Send a single event to user space */
 void wireless_send_event(struct net_device *dev, unsigned int cmd,
                         union iwreq_data *wrqu, const char *extra);
+#ifdef CONFIG_WEXT_CORE
+/* flush all previous wext events - if work is done from netdev notifiers */
+void wireless_nlevent_flush(void);
+#else
+static inline void wireless_nlevent_flush(void) {}
+#endif
 
 /* We may need a function to send a stream of events to user space.
  * More on that later... */
index 262532d..59fa93c 100644 (file)
@@ -21,6 +21,7 @@ struct scm_creds {
 struct scm_fp_list {
        short                   count;
        short                   max;
+       struct user_struct      *user;
        struct file             *fp[SCM_MAX_FD];
 };
 
index f6f8f03..ae6468f 100644 (file)
@@ -447,7 +447,7 @@ const u8 *tcp_parse_md5sig_option(const struct tcphdr *th);
 
 void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb);
 void tcp_v4_mtu_reduced(struct sock *sk);
-void tcp_req_err(struct sock *sk, u32 seq);
+void tcp_req_err(struct sock *sk, u32 seq, bool abort);
 int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
 struct sock *tcp_create_openreq_child(const struct sock *sk,
                                      struct request_sock *req,
index e2b712c..c21c38c 100644 (file)
@@ -343,7 +343,7 @@ void snd_hdac_bus_enter_link_reset(struct hdac_bus *bus);
 void snd_hdac_bus_exit_link_reset(struct hdac_bus *bus);
 
 void snd_hdac_bus_update_rirb(struct hdac_bus *bus);
-void snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
+int snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
                                    void (*ack)(struct hdac_bus *,
                                                struct hdac_stream *));
 
index 56cf8e4..28ee5c2 100644 (file)
@@ -94,5 +94,8 @@ sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd,
        sense_reason_t (*exec_cmd)(struct se_cmd *cmd));
 
 bool target_sense_desc_format(struct se_device *dev);
+sector_t target_to_linux_sector(struct se_device *dev, sector_t lb);
+bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib,
+                                      struct request_queue *q, int block_size);
 
 #endif /* TARGET_CORE_BACKEND_H */
index 5d82816..e8c8c08 100644 (file)
@@ -140,6 +140,8 @@ enum se_cmd_flags_table {
        SCF_COMPARE_AND_WRITE           = 0x00080000,
        SCF_COMPARE_AND_WRITE_POST      = 0x00100000,
        SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC = 0x00200000,
+       SCF_ACK_KREF                    = 0x00400000,
+       SCF_USE_CPUID                   = 0x00800000,
 };
 
 /* struct se_dev_entry->lun_flags and struct se_lun->lun_access */
@@ -187,6 +189,7 @@ enum target_sc_flags_table {
        TARGET_SCF_BIDI_OP              = 0x01,
        TARGET_SCF_ACK_KREF             = 0x02,
        TARGET_SCF_UNKNOWN_SIZE         = 0x04,
+       TARGET_SCF_USE_CPUID    = 0x08,
 };
 
 /* fabric independent task management function values */
@@ -490,8 +493,9 @@ struct se_cmd {
 #define CMD_T_SENT             (1 << 4)
 #define CMD_T_STOP             (1 << 5)
 #define CMD_T_DEV_ACTIVE       (1 << 7)
-#define CMD_T_REQUEST_STOP     (1 << 8)
 #define CMD_T_BUSY             (1 << 9)
+#define CMD_T_TAS              (1 << 10)
+#define CMD_T_FABRIC_STOP      (1 << 11)
        spinlock_t              t_state_lock;
        struct kref             cmd_kref;
        struct completion       t_transport_stop_comp;
@@ -511,9 +515,6 @@ struct se_cmd {
 
        struct list_head        state_list;
 
-       /* old task stop completion, consider merging with some of the above */
-       struct completion       task_stop_comp;
-
        /* backend private data */
        void                    *priv;
 
index 317a1ed..9130dd5 100644 (file)
@@ -231,13 +231,13 @@ TRACE_EVENT(snd_soc_jack_report,
        TP_ARGS(jack, mask, val),
 
        TP_STRUCT__entry(
-               __string(       name,           jack->jack->name        )
+               __string(       name,           jack->jack->id          )
                __field(        int,            mask                    )
                __field(        int,            val                     )
        ),
 
        TP_fast_assign(
-               __assign_str(name, jack->jack->name);
+               __assign_str(name, jack->jack->id);
                __entry->mask = mask;
                __entry->val = val;
        ),
@@ -253,12 +253,12 @@ TRACE_EVENT(snd_soc_jack_notify,
        TP_ARGS(jack, val),
 
        TP_STRUCT__entry(
-               __string(       name,           jack->jack->name        )
+               __string(       name,           jack->jack->id          )
                __field(        int,            val                     )
        ),
 
        TP_fast_assign(
-               __assign_str(name, jack->jack->name);
+               __assign_str(name, jack->jack->id);
                __entry->val = val;
        ),
 
index 50adb46..c021743 100644 (file)
@@ -487,6 +487,21 @@ struct drm_mode_crtc_lut {
        __u64 blue;
 };
 
+struct drm_color_ctm {
+       /* Conversion matrix in S31.32 format. */
+       __s64 matrix[9];
+};
+
+struct drm_color_lut {
+       /*
+        * Data is U0.16 fixed point format.
+        */
+       __u16 red;
+       __u16 green;
+       __u16 blue;
+       __u16 reserved;
+};
+
 #define DRM_MODE_PAGE_FLIP_EVENT 0x01
 #define DRM_MODE_PAGE_FLIP_ASYNC 0x02
 #define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT|DRM_MODE_PAGE_FLIP_ASYNC)
index 312c67d..3947c2e 100644 (file)
  */
 struct drm_exynos_gem_create {
        __u64 size;
-       unsigned int flags;
-       unsigned int handle;
+       __u32 flags;
+       __u32 handle;
+};
+
+/**
+ * A structure for getting a fake-offset that can be used with mmap.
+ *
+ * @handle: handle of gem object.
+ * @reserved: just padding to be 64-bit aligned.
+ * @offset: a fake-offset of gem object.
+ */
+struct drm_exynos_gem_map {
+       __u32 handle;
+       __u32 reserved;
+       __u64 offset;
 };
 
 /**
@@ -42,8 +55,8 @@ struct drm_exynos_gem_create {
  *     be set by driver.
  */
 struct drm_exynos_gem_info {
-       unsigned int handle;
-       unsigned int flags;
+       __u32 handle;
+       __u32 flags;
        __u64 size;
 };
 
@@ -56,8 +69,8 @@ struct drm_exynos_gem_info {
  * @edid: the edid data pointer from user side.
  */
 struct drm_exynos_vidi_connection {
-       unsigned int connection;
-       unsigned int extensions;
+       __u32 connection;
+       __u32 extensions;
        __u64 edid;
 };
 
@@ -206,9 +219,9 @@ struct drm_exynos_ipp_prop_list {
  * @pos: property of image position(src-cropped,dst-scaler).
  */
 struct drm_exynos_ipp_config {
-       enum drm_exynos_ops_id ops_id;
-       enum drm_exynos_flip    flip;
-       enum drm_exynos_degree  degree;
+       __u32 ops_id;
+       __u32 flip;
+       __u32 degree;
        __u32   fmt;
        struct drm_exynos_sz    sz;
        struct drm_exynos_pos   pos;
@@ -233,7 +246,7 @@ enum drm_exynos_ipp_cmd {
  */
 struct drm_exynos_ipp_property {
        struct drm_exynos_ipp_config config[EXYNOS_DRM_OPS_MAX];
-       enum drm_exynos_ipp_cmd cmd;
+       __u32   cmd;
        __u32   ipp_id;
        __u32   prop_id;
        __u32   refresh_rate;
@@ -255,8 +268,8 @@ enum drm_exynos_ipp_buf_type {
  * @user_data: user data.
  */
 struct drm_exynos_ipp_queue_buf {
-       enum drm_exynos_ops_id  ops_id;
-       enum drm_exynos_ipp_buf_type    buf_type;
+       __u32   ops_id;
+       __u32   buf_type;
        __u32   prop_id;
        __u32   buf_id;
        __u32   handle[EXYNOS_DRM_PLANAR_MAX];
@@ -280,10 +293,11 @@ enum drm_exynos_ipp_ctrl {
  */
 struct drm_exynos_ipp_cmd_ctrl {
        __u32   prop_id;
-       enum drm_exynos_ipp_ctrl        ctrl;
+       __u32   ctrl;
 };
 
 #define DRM_EXYNOS_GEM_CREATE          0x00
+#define DRM_EXYNOS_GEM_MAP             0x01
 /* Reserved 0x03 ~ 0x05 for exynos specific gem ioctl */
 #define DRM_EXYNOS_GEM_GET             0x04
 #define DRM_EXYNOS_VIDI_CONNECTION     0x07
@@ -301,7 +315,8 @@ struct drm_exynos_ipp_cmd_ctrl {
 
 #define DRM_IOCTL_EXYNOS_GEM_CREATE            DRM_IOWR(DRM_COMMAND_BASE + \
                DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
-
+#define DRM_IOCTL_EXYNOS_GEM_MAP               DRM_IOWR(DRM_COMMAND_BASE + \
+               DRM_EXYNOS_GEM_MAP, struct drm_exynos_gem_map)
 #define DRM_IOCTL_EXYNOS_GEM_GET       DRM_IOWR(DRM_COMMAND_BASE + \
                DRM_EXYNOS_GEM_GET,     struct drm_exynos_gem_info)
 
index 6a19371..a5524cc 100644 (file)
@@ -772,10 +772,12 @@ struct drm_i915_gem_execbuffer2 {
 #define I915_EXEC_HANDLE_LUT           (1<<12)
 
 /** Used for switching BSD rings on the platforms with two BSD rings */
-#define I915_EXEC_BSD_MASK             (3<<13)
-#define I915_EXEC_BSD_DEFAULT          (0<<13) /* default ping-pong mode */
-#define I915_EXEC_BSD_RING1            (1<<13)
-#define I915_EXEC_BSD_RING2            (2<<13)
+#define I915_EXEC_BSD_SHIFT     (13)
+#define I915_EXEC_BSD_MASK      (3 << I915_EXEC_BSD_SHIFT)
+/* default ping-pong mode */
+#define I915_EXEC_BSD_DEFAULT   (0 << I915_EXEC_BSD_SHIFT)
+#define I915_EXEC_BSD_RING1     (1 << I915_EXEC_BSD_SHIFT)
+#define I915_EXEC_BSD_RING2     (2 << I915_EXEC_BSD_SHIFT)
 
 /** Tell the kernel that the batchbuffer is processed by
  *  the resource streamer.
index 0e3c4c4..254d3e9 100644 (file)
@@ -51,6 +51,7 @@ struct drm_msm_timespec {
 #define MSM_PARAM_GMEM_SIZE  0x02
 #define MSM_PARAM_CHIP_ID    0x03
 #define MSM_PARAM_MAX_FREQ   0x04
+#define MSM_PARAM_TIMESTAMP  0x05
 
 struct drm_msm_param {
        __u32 pipe;           /* in, MSM_PIPE_x */
index aa6f857..5df4881 100644 (file)
@@ -292,6 +292,9 @@ enum bpf_func_id {
 /* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */
 #define BPF_F_TUNINFO_IPV6             (1ULL << 0)
 
+/* BPF_FUNC_skb_set_tunnel_key flags. */
+#define BPF_F_ZERO_CSUM_TX             (1ULL << 1)
+
 /* user accessible mirror of in-kernel sk_buff.
  * new fields can only be added to the end of this structure
  */
index 1e3c8cb..a2f1af0 100644 (file)
@@ -66,27 +66,42 @@ struct media_device_info {
 /*
  * DVB entities
  */
-#define MEDIA_ENT_F_DTV_DEMOD          (MEDIA_ENT_F_BASE + 1)
-#define MEDIA_ENT_F_TS_DEMUX           (MEDIA_ENT_F_BASE + 2)
-#define MEDIA_ENT_F_DTV_CA             (MEDIA_ENT_F_BASE + 3)
-#define MEDIA_ENT_F_DTV_NET_DECAP      (MEDIA_ENT_F_BASE + 4)
+#define MEDIA_ENT_F_DTV_DEMOD          (MEDIA_ENT_F_BASE + 0x00001)
+#define MEDIA_ENT_F_TS_DEMUX           (MEDIA_ENT_F_BASE + 0x00002)
+#define MEDIA_ENT_F_DTV_CA             (MEDIA_ENT_F_BASE + 0x00003)
+#define MEDIA_ENT_F_DTV_NET_DECAP      (MEDIA_ENT_F_BASE + 0x00004)
 
 /*
- * Connectors
+ * I/O entities
  */
-/* It is a responsibility of the entity drivers to add connectors and links */
-#define MEDIA_ENT_F_CONN_RF            (MEDIA_ENT_F_BASE + 21)
-#define MEDIA_ENT_F_CONN_SVIDEO                (MEDIA_ENT_F_BASE + 22)
-#define MEDIA_ENT_F_CONN_COMPOSITE     (MEDIA_ENT_F_BASE + 23)
-/* For internal test signal generators and other debug connectors */
-#define MEDIA_ENT_F_CONN_TEST          (MEDIA_ENT_F_BASE + 24)
+#define MEDIA_ENT_F_IO_DTV             (MEDIA_ENT_F_BASE + 0x01001)
+#define MEDIA_ENT_F_IO_VBI             (MEDIA_ENT_F_BASE + 0x01002)
+#define MEDIA_ENT_F_IO_SWRADIO         (MEDIA_ENT_F_BASE + 0x01003)
 
 /*
- * I/O entities
+ * Analog TV IF-PLL decoders
+ *
+ * It is a responsibility of the master/bridge drivers to create links
+ * for MEDIA_ENT_F_IF_VID_DECODER and MEDIA_ENT_F_IF_AUD_DECODER.
+ */
+#define MEDIA_ENT_F_IF_VID_DECODER     (MEDIA_ENT_F_BASE + 2001)
+#define MEDIA_ENT_F_IF_AUD_DECODER     (MEDIA_ENT_F_BASE + 2002)
+
+/*
+ * Connectors
  */
-#define MEDIA_ENT_F_IO_DTV             (MEDIA_ENT_F_BASE + 31)
-#define MEDIA_ENT_F_IO_VBI             (MEDIA_ENT_F_BASE + 32)
-#define MEDIA_ENT_F_IO_SWRADIO         (MEDIA_ENT_F_BASE + 33)
+/* It is a responsibility of the entity drivers to add connectors and links */
+#ifdef __KERNEL__
+       /*
+        * For now, it should not be used in userspace, as some
+        * definitions may change
+        */
+
+#define MEDIA_ENT_F_CONN_RF            (MEDIA_ENT_F_BASE + 0x30001)
+#define MEDIA_ENT_F_CONN_SVIDEO                (MEDIA_ENT_F_BASE + 0x30002)
+#define MEDIA_ENT_F_CONN_COMPOSITE     (MEDIA_ENT_F_BASE + 0x30003)
+
+#endif
 
 /*
  * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
@@ -107,14 +122,18 @@ struct media_device_info {
 #define MEDIA_ENT_F_LENS               (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
 #define MEDIA_ENT_F_ATV_DECODER                (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
 /*
- * It is a responsibility of the entity drivers to add connectors and links
- *     for the tuner entities.
+ * It is a responsibility of the master/bridge drivers to add connectors
+ * and links for MEDIA_ENT_F_TUNER. Please notice that some old tuners
+ * may require the usage of separate I2C chips to decode analog TV signals,
+ * when the master/bridge chipset doesn't have its own TV standard decoder.
+ * On such cases, the IF-PLL staging is mapped via one or two entities:
+ * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER.
  */
 #define MEDIA_ENT_F_TUNER              (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
 
 #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN        MEDIA_ENT_F_OLD_SUBDEV_BASE
 
-#ifndef __KERNEL__
+#if !defined(__KERNEL__) || defined(__NEED_MEDIA_LEGACY_API)
 
 /*
  * Legacy symbols used to avoid userspace compilation breakages
@@ -127,6 +146,10 @@ struct media_device_info {
 #define MEDIA_ENT_TYPE_MASK            0x00ff0000
 #define MEDIA_ENT_SUBTYPE_MASK         0x0000ffff
 
+/* End of the old subdev reserved numberspace */
+#define MEDIA_ENT_T_DEVNODE_UNKNOWN    (MEDIA_ENT_T_DEVNODE | \
+                                        MEDIA_ENT_SUBTYPE_MASK)
+
 #define MEDIA_ENT_T_DEVNODE            MEDIA_ENT_F_OLD_BASE
 #define MEDIA_ENT_T_DEVNODE_V4L                MEDIA_ENT_F_IO_V4L
 #define MEDIA_ENT_T_DEVNODE_FB         (MEDIA_ENT_T_DEVNODE + 2)
@@ -286,19 +309,19 @@ struct media_links_enum {
  *       later, before the adding this API upstream.
  */
 
-#if 0 /* Let's postpone it to Kernel 4.6 */
+
 struct media_v2_entity {
        __u32 id;
        char name[64];          /* FIXME: move to a property? (RFC says so) */
        __u32 function;         /* Main function of the entity */
-       __u16 reserved[12];
-};
+       __u32 reserved[6];
+} __attribute__ ((packed));
 
 /* Should match the specific fields at media_intf_devnode */
 struct media_v2_intf_devnode {
        __u32 major;
        __u32 minor;
-};
+} __attribute__ ((packed));
 
 struct media_v2_interface {
        __u32 id;
@@ -310,22 +333,22 @@ struct media_v2_interface {
                struct media_v2_intf_devnode devnode;
                __u32 raw[16];
        };
-};
+} __attribute__ ((packed));
 
 struct media_v2_pad {
        __u32 id;
        __u32 entity_id;
        __u32 flags;
-       __u16 reserved[9];
-};
+       __u32 reserved[5];
+} __attribute__ ((packed));
 
 struct media_v2_link {
        __u32 id;
        __u32 source_id;
        __u32 sink_id;
        __u32 flags;
-       __u32 reserved[5];
-};
+       __u32 reserved[6];
+} __attribute__ ((packed));
 
 struct media_v2_topology {
        __u64 topology_version;
@@ -345,13 +368,12 @@ struct media_v2_topology {
        __u32 num_links;
        __u32 reserved4;
        __u64 ptr_links;
-};
+} __attribute__ ((packed));
 
 static inline void __user *media_get_uptr(__u64 arg)
 {
        return (void __user *)(uintptr_t)arg;
 }
-#endif
 
 /* ioctls */
 
@@ -359,9 +381,6 @@ static inline void __user *media_get_uptr(__u64 arg)
 #define MEDIA_IOC_ENUM_ENTITIES                _IOWR('|', 0x01, struct media_entity_desc)
 #define MEDIA_IOC_ENUM_LINKS           _IOWR('|', 0x02, struct media_links_enum)
 #define MEDIA_IOC_SETUP_LINK           _IOWR('|', 0x03, struct media_link_desc)
-
-#if 0 /* Let's postpone it to Kernel 4.6 */
 #define MEDIA_IOC_G_TOPOLOGY           _IOWR('|', 0x04, struct media_v2_topology)
-#endif
 
 #endif /* __LINUX_MEDIA_H */
index 5b4a4be..cc68b92 100644 (file)
@@ -66,14 +66,18 @@ struct nd_cmd_ars_cap {
        __u64 length;
        __u32 status;
        __u32 max_ars_out;
+       __u32 clear_err_unit;
+       __u32 reserved;
 } __packed;
 
 struct nd_cmd_ars_start {
        __u64 address;
        __u64 length;
        __u16 type;
-       __u8 reserved[6];
+       __u8 flags;
+       __u8 reserved[5];
        __u32 status;
+       __u32 scrub_time;
 } __packed;
 
 struct nd_cmd_ars_status {
@@ -81,11 +85,14 @@ struct nd_cmd_ars_status {
        __u32 out_length;
        __u64 address;
        __u64 length;
+       __u64 restart_address;
+       __u64 restart_length;
        __u16 type;
+       __u16 flags;
        __u32 num_records;
        struct nd_ars_record {
                __u32 handle;
-               __u32 flags;
+               __u32 reserved;
                __u64 err_address;
                __u64 length;
        } __packed records[0];
index 1527398..5b3f685 100644 (file)
  * Copyright (C) 2012 Nokia Corporation
  * Contact: Sakari Ailus <sakari.ailus@iki.fi>
  *
- * 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 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.
+ *  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
+ *  Alternatively you can redistribute this file under the terms of the
+ *  BSD license as stated below:
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions
+ *  are met:
+ *  1. Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *  2. Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in
+ *     the documentation and/or other materials provided with the
+ *     distribution.
+ *  3. The names of its contributors may not be used to endorse or promote
+ *     products derived from this software without specific prior written
+ *     permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ *  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
 
index 2d225bc..b6a357a 100644 (file)
@@ -390,6 +390,7 @@ enum v4l2_mpeg_video_multi_slice_mode {
 #define V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER          (V4L2_CID_MPEG_BASE+226)
 #define V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE          (V4L2_CID_MPEG_BASE+227)
 #define V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE          (V4L2_CID_MPEG_BASE+228)
+#define V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME            (V4L2_CID_MPEG_BASE+229)
 
 #define V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP            (V4L2_CID_MPEG_BASE+300)
 #define V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP            (V4L2_CID_MPEG_BASE+301)
@@ -912,8 +913,18 @@ enum v4l2_dv_rgb_range {
        V4L2_DV_RGB_RANGE_FULL    = 2,
 };
 
+#define V4L2_CID_DV_TX_IT_CONTENT_TYPE         (V4L2_CID_DV_CLASS_BASE + 6)
+enum v4l2_dv_it_content_type {
+       V4L2_DV_IT_CONTENT_TYPE_GRAPHICS  = 0,
+       V4L2_DV_IT_CONTENT_TYPE_PHOTO     = 1,
+       V4L2_DV_IT_CONTENT_TYPE_CINEMA    = 2,
+       V4L2_DV_IT_CONTENT_TYPE_GAME      = 3,
+       V4L2_DV_IT_CONTENT_TYPE_NO_ITC    = 4,
+};
+
 #define        V4L2_CID_DV_RX_POWER_PRESENT            (V4L2_CID_DV_CLASS_BASE + 100)
 #define V4L2_CID_DV_RX_RGB_RANGE               (V4L2_CID_DV_CLASS_BASE + 101)
+#define V4L2_CID_DV_RX_IT_CONTENT_TYPE         (V4L2_CID_DV_CLASS_BASE + 102)
 
 #define V4L2_CID_FM_RX_CLASS_BASE              (V4L2_CTRL_CLASS_FM_RX | 0x900)
 #define V4L2_CID_FM_RX_CLASS                   (V4L2_CTRL_CLASS_FM_RX | 1)
index 14cd5eb..4664584 100644 (file)
@@ -546,6 +546,10 @@ struct v4l2_pix_format {
 /* three non contiguous planes - Y, Cb, Cr */
 #define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2') /* 12  YUV420 planar */
 #define V4L2_PIX_FMT_YVU420M v4l2_fourcc('Y', 'M', '2', '1') /* 12  YVU420 planar */
+#define V4L2_PIX_FMT_YUV422M v4l2_fourcc('Y', 'M', '1', '6') /* 16  YUV422 planar */
+#define V4L2_PIX_FMT_YVU422M v4l2_fourcc('Y', 'M', '6', '1') /* 16  YVU422 planar */
+#define V4L2_PIX_FMT_YUV444M v4l2_fourcc('Y', 'M', '2', '4') /* 24  YUV444 planar */
+#define V4L2_PIX_FMT_YVU444M v4l2_fourcc('Y', 'M', '4', '2') /* 24  YVU444 planar */
 
 /* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
 #define V4L2_PIX_FMT_SBGGR8  v4l2_fourcc('B', 'A', '8', '1') /*  8  BGBG.. GRGR.. */
index 69279c0..56830d1 100644 (file)
@@ -45,21 +45,6 @@ struct encoder_tfp410_platform_data {
        int data_lines;
 };
 
-/**
- * encoder_tpd12s015 platform data
- * @name: name for this display entity
- * @ct_cp_hpd_gpio: CT_CP_HPD gpio number
- * @ls_oe_gpio: LS_OE gpio number
- * @hpd_gpio: HPD gpio number
- */
-struct encoder_tpd12s015_platform_data {
-       const char *name;
-       const char *source;
-
-       int ct_cp_hpd_gpio;
-       int ls_oe_gpio;
-       int hpd_gpio;
-};
 
 /**
  * connector_dvi platform data
index 295b41e..8e14ad7 100644 (file)
@@ -51,6 +51,7 @@
 #define DISPC_IRQ_FRAMEDONEWB          (1 << 23)
 #define DISPC_IRQ_FRAMEDONETV          (1 << 24)
 #define DISPC_IRQ_WBBUFFEROVERFLOW     (1 << 25)
+#define DISPC_IRQ_WBUNCOMPLETEERROR    (1 << 26)
 #define DISPC_IRQ_SYNC_LOST3           (1 << 27)
 #define DISPC_IRQ_VSYNC3               (1 << 28)
 #define DISPC_IRQ_ACBIAS_COUNT_STAT3   (1 << 29)
@@ -331,8 +332,6 @@ struct omap_dss_board_info {
 
 /* Init with the board info */
 extern int omap_display_init(struct omap_dss_board_info *board_data);
-/* HDMI mux init*/
-extern int omap_hdmi_init(enum omap_hdmi_flags flags);
 
 struct omap_video_timings {
        /* Unit: pixels */
@@ -366,6 +365,8 @@ struct omap_video_timings {
        enum omap_dss_signal_level de_level;
        /* Pixel clock edges to drive HSYNC and VSYNC signals */
        enum omap_dss_signal_edge sync_pclk_edge;
+
+       bool double_pixel;
 };
 
 /* Hardcoded timings for tv modes. Venc only uses these to
@@ -769,6 +770,7 @@ struct omap_dss_device {
 
        /* DISPC channel for this output */
        enum omap_channel dispc_channel;
+       bool dispc_channel_connected;
 
        /* output instance */
        enum omap_dss_output_id id;
@@ -782,13 +784,6 @@ struct omap_dss_device {
        struct omap_dss_device *dst;
 };
 
-struct omap_dss_hdmi_data
-{
-       int ct_cp_hpd_gpio;
-       int ls_oe_gpio;
-       int hpd_gpio;
-};
-
 struct omap_dss_driver {
        int (*probe)(struct omap_dss_device *);
        void (*remove)(struct omap_dss_device *);
@@ -897,85 +892,9 @@ typedef void (*omap_dispc_isr_t) (void *arg, u32 mask);
 int omap_dispc_register_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
 int omap_dispc_unregister_isr(omap_dispc_isr_t isr, void *arg, u32 mask);
 
-u32 dispc_read_irqstatus(void);
-void dispc_clear_irqstatus(u32 mask);
-u32 dispc_read_irqenable(void);
-void dispc_write_irqenable(u32 mask);
-
-int dispc_request_irq(irq_handler_t handler, void *dev_id);
-void dispc_free_irq(void *dev_id);
-
-int dispc_runtime_get(void);
-void dispc_runtime_put(void);
-
-void dispc_mgr_enable(enum omap_channel channel, bool enable);
-bool dispc_mgr_is_enabled(enum omap_channel channel);
-u32 dispc_mgr_get_vsync_irq(enum omap_channel channel);
-u32 dispc_mgr_get_framedone_irq(enum omap_channel channel);
-u32 dispc_mgr_get_sync_lost_irq(enum omap_channel channel);
-bool dispc_mgr_go_busy(enum omap_channel channel);
-void dispc_mgr_go(enum omap_channel channel);
-void dispc_mgr_set_lcd_config(enum omap_channel channel,
-               const struct dss_lcd_mgr_config *config);
-void dispc_mgr_set_timings(enum omap_channel channel,
-               const struct omap_video_timings *timings);
-void dispc_mgr_setup(enum omap_channel channel,
-               const struct omap_overlay_manager_info *info);
-
-int dispc_ovl_check(enum omap_plane plane, enum omap_channel channel,
-               const struct omap_overlay_info *oi,
-               const struct omap_video_timings *timings,
-               int *x_predecim, int *y_predecim);
-
-int dispc_ovl_enable(enum omap_plane plane, bool enable);
-bool dispc_ovl_enabled(enum omap_plane plane);
-void dispc_ovl_set_channel_out(enum omap_plane plane,
-               enum omap_channel channel);
-int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi,
-               bool replication, const struct omap_video_timings *mgr_timings,
-               bool mem_to_mem);
-
 int omapdss_compat_init(void);
 void omapdss_compat_uninit(void);
 
-struct dss_mgr_ops {
-       int (*connect)(struct omap_overlay_manager *mgr,
-               struct omap_dss_device *dst);
-       void (*disconnect)(struct omap_overlay_manager *mgr,
-               struct omap_dss_device *dst);
-
-       void (*start_update)(struct omap_overlay_manager *mgr);
-       int (*enable)(struct omap_overlay_manager *mgr);
-       void (*disable)(struct omap_overlay_manager *mgr);
-       void (*set_timings)(struct omap_overlay_manager *mgr,
-                       const struct omap_video_timings *timings);
-       void (*set_lcd_config)(struct omap_overlay_manager *mgr,
-                       const struct dss_lcd_mgr_config *config);
-       int (*register_framedone_handler)(struct omap_overlay_manager *mgr,
-                       void (*handler)(void *), void *data);
-       void (*unregister_framedone_handler)(struct omap_overlay_manager *mgr,
-                       void (*handler)(void *), void *data);
-};
-
-int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops);
-void dss_uninstall_mgr_ops(void);
-
-int dss_mgr_connect(struct omap_overlay_manager *mgr,
-               struct omap_dss_device *dst);
-void dss_mgr_disconnect(struct omap_overlay_manager *mgr,
-               struct omap_dss_device *dst);
-void dss_mgr_set_timings(struct omap_overlay_manager *mgr,
-               const struct omap_video_timings *timings);
-void dss_mgr_set_lcd_config(struct omap_overlay_manager *mgr,
-               const struct dss_lcd_mgr_config *config);
-int dss_mgr_enable(struct omap_overlay_manager *mgr);
-void dss_mgr_disable(struct omap_overlay_manager *mgr);
-void dss_mgr_start_update(struct omap_overlay_manager *mgr);
-int dss_mgr_register_framedone_handler(struct omap_overlay_manager *mgr,
-               void (*handler)(void *), void *data);
-void dss_mgr_unregister_framedone_handler(struct omap_overlay_manager *mgr,
-               void (*handler)(void *), void *data);
-
 static inline bool omapdss_device_is_connected(struct omap_dss_device *dssdev)
 {
        return dssdev->src;
index ed3027d..331fc1b 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -156,11 +156,12 @@ static inline struct shmid_kernel *shm_lock(struct ipc_namespace *ns, int id)
        struct kern_ipc_perm *ipcp = ipc_lock(&shm_ids(ns), id);
 
        /*
-        * We raced in the idr lookup or with shm_destroy().  Either way, the
-        * ID is busted.
+        * Callers of shm_lock() must validate the status of the returned ipc
+        * object pointer (as returned by ipc_lock()), and error out as
+        * appropriate.
         */
-       WARN_ON(IS_ERR(ipcp));
-
+       if (IS_ERR(ipcp))
+               return (void *)ipcp;
        return container_of(ipcp, struct shmid_kernel, shm_perm);
 }
 
@@ -186,18 +187,33 @@ static inline void shm_rmid(struct ipc_namespace *ns, struct shmid_kernel *s)
 }
 
 
-/* This is called by fork, once for every shm attach. */
-static void shm_open(struct vm_area_struct *vma)
+static int __shm_open(struct vm_area_struct *vma)
 {
        struct file *file = vma->vm_file;
        struct shm_file_data *sfd = shm_file_data(file);
        struct shmid_kernel *shp;
 
        shp = shm_lock(sfd->ns, sfd->id);
+
+       if (IS_ERR(shp))
+               return PTR_ERR(shp);
+
        shp->shm_atim = get_seconds();
        shp->shm_lprid = task_tgid_vnr(current);
        shp->shm_nattch++;
        shm_unlock(shp);
+       return 0;
+}
+
+/* This is called by fork, once for every shm attach. */
+static void shm_open(struct vm_area_struct *vma)
+{
+       int err = __shm_open(vma);
+       /*
+        * We raced in the idr lookup or with shm_destroy().
+        * Either way, the ID is busted.
+        */
+       WARN_ON_ONCE(err);
 }
 
 /*
@@ -260,6 +276,14 @@ static void shm_close(struct vm_area_struct *vma)
        down_write(&shm_ids(ns).rwsem);
        /* remove from the list of attaches of the shm segment */
        shp = shm_lock(ns, sfd->id);
+
+       /*
+        * We raced in the idr lookup or with shm_destroy().
+        * Either way, the ID is busted.
+        */
+       if (WARN_ON_ONCE(IS_ERR(shp)))
+               goto done; /* no-op */
+
        shp->shm_lprid = task_tgid_vnr(current);
        shp->shm_dtim = get_seconds();
        shp->shm_nattch--;
@@ -267,6 +291,7 @@ static void shm_close(struct vm_area_struct *vma)
                shm_destroy(ns, shp);
        else
                shm_unlock(shp);
+done:
        up_write(&shm_ids(ns).rwsem);
 }
 
@@ -388,17 +413,25 @@ static int shm_mmap(struct file *file, struct vm_area_struct *vma)
        struct shm_file_data *sfd = shm_file_data(file);
        int ret;
 
+       /*
+        * In case of remap_file_pages() emulation, the file can represent
+        * removed IPC ID: propogate shm_lock() error to caller.
+        */
+       ret =__shm_open(vma);
+       if (ret)
+               return ret;
+
        ret = sfd->file->f_op->mmap(sfd->file, vma);
-       if (ret != 0)
+       if (ret) {
+               shm_close(vma);
                return ret;
+       }
        sfd->vm_ops = vma->vm_ops;
 #ifdef CONFIG_MMU
        WARN_ON(!sfd->vm_ops->fault);
 #endif
        vma->vm_ops = &shm_vm_ops;
-       shm_open(vma);
-
-       return ret;
+       return 0;
 }
 
 static int shm_release(struct inode *ino, struct file *file)
index d1d3e8f..2e7f7ab 100644 (file)
@@ -2082,7 +2082,7 @@ static void adjust_branches(struct bpf_prog *prog, int pos, int delta)
                /* adjust offset of jmps if necessary */
                if (i < pos && i + insn->off + 1 > pos)
                        insn->off += delta;
-               else if (i > pos && i + insn->off + 1 < pos)
+               else if (i > pos + delta && i + insn->off + 1 <= pos + delta)
                        insn->off -= delta;
        }
 }
index c03a640..d27904c 100644 (file)
@@ -58,6 +58,7 @@
 #include <linux/kthread.h>
 #include <linux/delay.h>
 #include <linux/atomic.h>
+#include <linux/cpuset.h>
 #include <net/sock.h>
 
 /*
@@ -2739,6 +2740,7 @@ out_unlock_rcu:
 out_unlock_threadgroup:
        percpu_up_write(&cgroup_threadgroup_rwsem);
        cgroup_kn_unlock(of->kn);
+       cpuset_post_attach_flush();
        return ret ?: nbytes;
 }
 
@@ -4655,14 +4657,15 @@ static void css_free_work_fn(struct work_struct *work)
 
        if (ss) {
                /* css free path */
+               struct cgroup_subsys_state *parent = css->parent;
                int id = css->id;
 
-               if (css->parent)
-                       css_put(css->parent);
-
                ss->css_free(css);
                cgroup_idr_remove(&ss->css_idr, id);
                cgroup_put(cgrp);
+
+               if (parent)
+                       css_put(parent);
        } else {
                /* cgroup free path */
                atomic_dec(&cgrp->root->nr_cgrps);
@@ -4758,6 +4761,7 @@ static void init_and_link_css(struct cgroup_subsys_state *css,
        INIT_LIST_HEAD(&css->sibling);
        INIT_LIST_HEAD(&css->children);
        css->serial_nr = css_serial_nr_next++;
+       atomic_set(&css->online_cnt, 0);
 
        if (cgroup_parent(cgrp)) {
                css->parent = cgroup_css(cgroup_parent(cgrp), ss);
@@ -4780,6 +4784,10 @@ static int online_css(struct cgroup_subsys_state *css)
        if (!ret) {
                css->flags |= CSS_ONLINE;
                rcu_assign_pointer(css->cgroup->subsys[ss->id], css);
+
+               atomic_inc(&css->online_cnt);
+               if (css->parent)
+                       atomic_inc(&css->parent->online_cnt);
        }
        return ret;
 }
@@ -5017,10 +5025,15 @@ static void css_killed_work_fn(struct work_struct *work)
                container_of(work, struct cgroup_subsys_state, destroy_work);
 
        mutex_lock(&cgroup_mutex);
-       offline_css(css);
-       mutex_unlock(&cgroup_mutex);
 
-       css_put(css);
+       do {
+               offline_css(css);
+               css_put(css);
+               /* @css can't go away while we're holding cgroup_mutex */
+               css = css->parent;
+       } while (css && atomic_dec_and_test(&css->online_cnt));
+
+       mutex_unlock(&cgroup_mutex);
 }
 
 /* css kill confirmation processing requires process context, bounce */
@@ -5029,8 +5042,10 @@ static void css_killed_ref_fn(struct percpu_ref *ref)
        struct cgroup_subsys_state *css =
                container_of(ref, struct cgroup_subsys_state, refcnt);
 
-       INIT_WORK(&css->destroy_work, css_killed_work_fn);
-       queue_work(cgroup_destroy_wq, &css->destroy_work);
+       if (atomic_dec_and_test(&css->online_cnt)) {
+               INIT_WORK(&css->destroy_work, css_killed_work_fn);
+               queue_work(cgroup_destroy_wq, &css->destroy_work);
+       }
 }
 
 /**
index 3e945fc..41989ab 100644 (file)
@@ -287,6 +287,8 @@ static struct cpuset top_cpuset = {
 static DEFINE_MUTEX(cpuset_mutex);
 static DEFINE_SPINLOCK(callback_lock);
 
+static struct workqueue_struct *cpuset_migrate_mm_wq;
+
 /*
  * CPU / memory hotplug is handled asynchronously.
  */
@@ -972,31 +974,51 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
 }
 
 /*
- * cpuset_migrate_mm
- *
- *    Migrate memory region from one set of nodes to another.
- *
- *    Temporarilly set tasks mems_allowed to target nodes of migration,
- *    so that the migration code can allocate pages on these nodes.
- *
- *    While the mm_struct we are migrating is typically from some
- *    other task, the task_struct mems_allowed that we are hacking
- *    is for our current task, which must allocate new pages for that
- *    migrating memory region.
+ * Migrate memory region from one set of nodes to another.  This is
+ * performed asynchronously as it can be called from process migration path
+ * holding locks involved in process management.  All mm migrations are
+ * performed in the queued order and can be waited for by flushing
+ * cpuset_migrate_mm_wq.
  */
 
+struct cpuset_migrate_mm_work {
+       struct work_struct      work;
+       struct mm_struct        *mm;
+       nodemask_t              from;
+       nodemask_t              to;
+};
+
+static void cpuset_migrate_mm_workfn(struct work_struct *work)
+{
+       struct cpuset_migrate_mm_work *mwork =
+               container_of(work, struct cpuset_migrate_mm_work, work);
+
+       /* on a wq worker, no need to worry about %current's mems_allowed */
+       do_migrate_pages(mwork->mm, &mwork->from, &mwork->to, MPOL_MF_MOVE_ALL);
+       mmput(mwork->mm);
+       kfree(mwork);
+}
+
 static void cpuset_migrate_mm(struct mm_struct *mm, const nodemask_t *from,
                                                        const nodemask_t *to)
 {
-       struct task_struct *tsk = current;
-
-       tsk->mems_allowed = *to;
+       struct cpuset_migrate_mm_work *mwork;
 
-       do_migrate_pages(mm, from, to, MPOL_MF_MOVE_ALL);
+       mwork = kzalloc(sizeof(*mwork), GFP_KERNEL);
+       if (mwork) {
+               mwork->mm = mm;
+               mwork->from = *from;
+               mwork->to = *to;
+               INIT_WORK(&mwork->work, cpuset_migrate_mm_workfn);
+               queue_work(cpuset_migrate_mm_wq, &mwork->work);
+       } else {
+               mmput(mm);
+       }
+}
 
-       rcu_read_lock();
-       guarantee_online_mems(task_cs(tsk), &tsk->mems_allowed);
-       rcu_read_unlock();
+void cpuset_post_attach_flush(void)
+{
+       flush_workqueue(cpuset_migrate_mm_wq);
 }
 
 /*
@@ -1097,7 +1119,8 @@ static void update_tasks_nodemask(struct cpuset *cs)
                mpol_rebind_mm(mm, &cs->mems_allowed);
                if (migrate)
                        cpuset_migrate_mm(mm, &cs->old_mems_allowed, &newmems);
-               mmput(mm);
+               else
+                       mmput(mm);
        }
        css_task_iter_end(&it);
 
@@ -1545,11 +1568,11 @@ static void cpuset_attach(struct cgroup_taskset *tset)
                         * @old_mems_allowed is the right nodesets that we
                         * migrate mm from.
                         */
-                       if (is_memory_migrate(cs)) {
+                       if (is_memory_migrate(cs))
                                cpuset_migrate_mm(mm, &oldcs->old_mems_allowed,
                                                  &cpuset_attach_nodemask_to);
-                       }
-                       mmput(mm);
+                       else
+                               mmput(mm);
                }
        }
 
@@ -1714,6 +1737,7 @@ out_unlock:
        mutex_unlock(&cpuset_mutex);
        kernfs_unbreak_active_protection(of->kn);
        css_put(&cs->css);
+       flush_workqueue(cpuset_migrate_mm_wq);
        return retval ?: nbytes;
 }
 
@@ -2359,6 +2383,9 @@ void __init cpuset_init_smp(void)
        top_cpuset.effective_mems = node_states[N_MEMORY];
 
        register_hotmemory_notifier(&cpuset_track_online_nodes_nb);
+
+       cpuset_migrate_mm_wq = alloc_ordered_workqueue("cpuset_migrate_mm", 0);
+       BUG_ON(!cpuset_migrate_mm_wq);
 }
 
 /**
index 5946460..6146148 100644 (file)
@@ -64,8 +64,17 @@ static void remote_function(void *data)
        struct task_struct *p = tfc->p;
 
        if (p) {
-               tfc->ret = -EAGAIN;
-               if (task_cpu(p) != smp_processor_id() || !task_curr(p))
+               /* -EAGAIN */
+               if (task_cpu(p) != smp_processor_id())
+                       return;
+
+               /*
+                * Now that we're on right CPU with IRQs disabled, we can test
+                * if we hit the right task without races.
+                */
+
+               tfc->ret = -ESRCH; /* No such (running) process */
+               if (p != current)
                        return;
        }
 
@@ -92,13 +101,17 @@ task_function_call(struct task_struct *p, remote_function_f func, void *info)
                .p      = p,
                .func   = func,
                .info   = info,
-               .ret    = -ESRCH, /* No such (running) process */
+               .ret    = -EAGAIN,
        };
+       int ret;
 
-       if (task_curr(p))
-               smp_call_function_single(task_cpu(p), remote_function, &data, 1);
+       do {
+               ret = smp_call_function_single(task_cpu(p), remote_function, &data, 1);
+               if (!ret)
+                       ret = data.ret;
+       } while (ret == -EAGAIN);
 
-       return data.ret;
+       return ret;
 }
 
 /**
@@ -169,19 +182,6 @@ static bool is_kernel_event(struct perf_event *event)
  *    rely on ctx->is_active and therefore cannot use event_function_call().
  *    See perf_install_in_context().
  *
- * This is because we need a ctx->lock serialized variable (ctx->is_active)
- * to reliably determine if a particular task/context is scheduled in. The
- * task_curr() use in task_function_call() is racy in that a remote context
- * switch is not a single atomic operation.
- *
- * As is, the situation is 'safe' because we set rq->curr before we do the
- * actual context switch. This means that task_curr() will fail early, but
- * we'll continue spinning on ctx->is_active until we've passed
- * perf_event_task_sched_out().
- *
- * Without this ctx->lock serialized variable we could have race where we find
- * the task (and hence the context) would not be active while in fact they are.
- *
  * If ctx->nr_events, then ctx->is_active and cpuctx->task_ctx are set.
  */
 
@@ -212,7 +212,7 @@ static int event_function(void *info)
         */
        if (ctx->task) {
                if (ctx->task != current) {
-                       ret = -EAGAIN;
+                       ret = -ESRCH;
                        goto unlock;
                }
 
@@ -276,10 +276,10 @@ static void event_function_call(struct perf_event *event, event_f func, void *da
                return;
        }
 
-again:
        if (task == TASK_TOMBSTONE)
                return;
 
+again:
        if (!task_function_call(task, event_function, &efs))
                return;
 
@@ -289,13 +289,15 @@ again:
         * a concurrent perf_event_context_sched_out().
         */
        task = ctx->task;
-       if (task != TASK_TOMBSTONE) {
-               if (ctx->is_active) {
-                       raw_spin_unlock_irq(&ctx->lock);
-                       goto again;
-               }
-               func(event, NULL, ctx, data);
+       if (task == TASK_TOMBSTONE) {
+               raw_spin_unlock_irq(&ctx->lock);
+               return;
        }
+       if (ctx->is_active) {
+               raw_spin_unlock_irq(&ctx->lock);
+               goto again;
+       }
+       func(event, NULL, ctx, data);
        raw_spin_unlock_irq(&ctx->lock);
 }
 
@@ -314,6 +316,7 @@ again:
 enum event_type_t {
        EVENT_FLEXIBLE = 0x1,
        EVENT_PINNED = 0x2,
+       EVENT_TIME = 0x4,
        EVENT_ALL = EVENT_FLEXIBLE | EVENT_PINNED,
 };
 
@@ -321,7 +324,13 @@ enum event_type_t {
  * perf_sched_events : >0 events exist
  * perf_cgroup_events: >0 per-cpu cgroup events exist on this cpu
  */
-struct static_key_deferred perf_sched_events __read_mostly;
+
+static void perf_sched_delayed(struct work_struct *work);
+DEFINE_STATIC_KEY_FALSE(perf_sched_events);
+static DECLARE_DELAYED_WORK(perf_sched_work, perf_sched_delayed);
+static DEFINE_MUTEX(perf_sched_mutex);
+static atomic_t perf_sched_count;
+
 static DEFINE_PER_CPU(atomic_t, perf_cgroup_events);
 static DEFINE_PER_CPU(int, perf_sched_cb_usages);
 
@@ -1288,16 +1297,18 @@ static u64 perf_event_time(struct perf_event *event)
 
 /*
  * Update the total_time_enabled and total_time_running fields for a event.
- * The caller of this function needs to hold the ctx->lock.
  */
 static void update_event_times(struct perf_event *event)
 {
        struct perf_event_context *ctx = event->ctx;
        u64 run_end;
 
+       lockdep_assert_held(&ctx->lock);
+
        if (event->state < PERF_EVENT_STATE_INACTIVE ||
            event->group_leader->state < PERF_EVENT_STATE_INACTIVE)
                return;
+
        /*
         * in cgroup mode, time_enabled represents
         * the time the event was enabled AND active
@@ -1645,7 +1656,7 @@ out:
 
 static bool is_orphaned_event(struct perf_event *event)
 {
-       return event->state == PERF_EVENT_STATE_EXIT;
+       return event->state == PERF_EVENT_STATE_DEAD;
 }
 
 static inline int pmu_filter_match(struct perf_event *event)
@@ -1690,14 +1701,14 @@ event_sched_out(struct perf_event *event,
 
        perf_pmu_disable(event->pmu);
 
+       event->tstamp_stopped = tstamp;
+       event->pmu->del(event, 0);
+       event->oncpu = -1;
        event->state = PERF_EVENT_STATE_INACTIVE;
        if (event->pending_disable) {
                event->pending_disable = 0;
                event->state = PERF_EVENT_STATE_OFF;
        }
-       event->tstamp_stopped = tstamp;
-       event->pmu->del(event, 0);
-       event->oncpu = -1;
 
        if (!is_software_event(event))
                cpuctx->active_oncpu--;
@@ -1732,7 +1743,6 @@ group_sched_out(struct perf_event *group_event,
 }
 
 #define DETACH_GROUP   0x01UL
-#define DETACH_STATE   0x02UL
 
 /*
  * Cross CPU call to remove a performance event
@@ -1752,8 +1762,6 @@ __perf_remove_from_context(struct perf_event *event,
        if (flags & DETACH_GROUP)
                perf_group_detach(event);
        list_del_event(event, ctx);
-       if (flags & DETACH_STATE)
-               event->state = PERF_EVENT_STATE_EXIT;
 
        if (!ctx->nr_events && ctx->is_active) {
                ctx->is_active = 0;
@@ -2063,14 +2071,27 @@ static void add_event_to_ctx(struct perf_event *event,
        event->tstamp_stopped = tstamp;
 }
 
-static void task_ctx_sched_out(struct perf_cpu_context *cpuctx,
-                              struct perf_event_context *ctx);
+static void ctx_sched_out(struct perf_event_context *ctx,
+                         struct perf_cpu_context *cpuctx,
+                         enum event_type_t event_type);
 static void
 ctx_sched_in(struct perf_event_context *ctx,
             struct perf_cpu_context *cpuctx,
             enum event_type_t event_type,
             struct task_struct *task);
 
+static void task_ctx_sched_out(struct perf_cpu_context *cpuctx,
+                              struct perf_event_context *ctx)
+{
+       if (!cpuctx->task_ctx)
+               return;
+
+       if (WARN_ON_ONCE(ctx != cpuctx->task_ctx))
+               return;
+
+       ctx_sched_out(ctx, cpuctx, EVENT_ALL);
+}
+
 static void perf_event_sched_in(struct perf_cpu_context *cpuctx,
                                struct perf_event_context *ctx,
                                struct task_struct *task)
@@ -2097,49 +2118,68 @@ static void ctx_resched(struct perf_cpu_context *cpuctx,
 /*
  * Cross CPU call to install and enable a performance event
  *
- * Must be called with ctx->mutex held
+ * Very similar to remote_function() + event_function() but cannot assume that
+ * things like ctx->is_active and cpuctx->task_ctx are set.
  */
 static int  __perf_install_in_context(void *info)
 {
-       struct perf_event_context *ctx = info;
+       struct perf_event *event = info;
+       struct perf_event_context *ctx = event->ctx;
        struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
        struct perf_event_context *task_ctx = cpuctx->task_ctx;
+       bool activate = true;
+       int ret = 0;
 
        raw_spin_lock(&cpuctx->ctx.lock);
        if (ctx->task) {
                raw_spin_lock(&ctx->lock);
-               /*
-                * If we hit the 'wrong' task, we've since scheduled and
-                * everything should be sorted, nothing to do!
-                */
                task_ctx = ctx;
-               if (ctx->task != current)
+
+               /* If we're on the wrong CPU, try again */
+               if (task_cpu(ctx->task) != smp_processor_id()) {
+                       ret = -ESRCH;
                        goto unlock;
+               }
 
                /*
-                * If task_ctx is set, it had better be to us.
+                * If we're on the right CPU, see if the task we target is
+                * current, if not we don't have to activate the ctx, a future
+                * context switch will do that for us.
                 */
-               WARN_ON_ONCE(cpuctx->task_ctx != ctx && cpuctx->task_ctx);
+               if (ctx->task != current)
+                       activate = false;
+               else
+                       WARN_ON_ONCE(cpuctx->task_ctx && cpuctx->task_ctx != ctx);
+
        } else if (task_ctx) {
                raw_spin_lock(&task_ctx->lock);
        }
 
-       ctx_resched(cpuctx, task_ctx);
+       if (activate) {
+               ctx_sched_out(ctx, cpuctx, EVENT_TIME);
+               add_event_to_ctx(event, ctx);
+               ctx_resched(cpuctx, task_ctx);
+       } else {
+               add_event_to_ctx(event, ctx);
+       }
+
 unlock:
        perf_ctx_unlock(cpuctx, task_ctx);
 
-       return 0;
+       return ret;
 }
 
 /*
- * Attach a performance event to a context
+ * Attach a performance event to a context.
+ *
+ * Very similar to event_function_call, see comment there.
  */
 static void
 perf_install_in_context(struct perf_event_context *ctx,
                        struct perf_event *event,
                        int cpu)
 {
-       struct task_struct *task = NULL;
+       struct task_struct *task = READ_ONCE(ctx->task);
 
        lockdep_assert_held(&ctx->mutex);
 
@@ -2147,40 +2187,46 @@ perf_install_in_context(struct perf_event_context *ctx,
        if (event->cpu != -1)
                event->cpu = cpu;
 
+       if (!task) {
+               cpu_function_call(cpu, __perf_install_in_context, event);
+               return;
+       }
+
+       /*
+        * Should not happen, we validate the ctx is still alive before calling.
+        */
+       if (WARN_ON_ONCE(task == TASK_TOMBSTONE))
+               return;
+
        /*
         * Installing events is tricky because we cannot rely on ctx->is_active
         * to be set in case this is the nr_events 0 -> 1 transition.
-        *
-        * So what we do is we add the event to the list here, which will allow
-        * a future context switch to DTRT and then send a racy IPI. If the IPI
-        * fails to hit the right task, this means a context switch must have
-        * happened and that will have taken care of business.
         */
-       raw_spin_lock_irq(&ctx->lock);
-       task = ctx->task;
+again:
        /*
-        * Worse, we cannot even rely on the ctx actually existing anymore. If
-        * between find_get_context() and perf_install_in_context() the task
-        * went through perf_event_exit_task() its dead and we should not be
-        * adding new events.
+        * Cannot use task_function_call() because we need to run on the task's
+        * CPU regardless of whether its current or not.
         */
-       if (task == TASK_TOMBSTONE) {
+       if (!cpu_function_call(task_cpu(task), __perf_install_in_context, event))
+               return;
+
+       raw_spin_lock_irq(&ctx->lock);
+       task = ctx->task;
+       if (WARN_ON_ONCE(task == TASK_TOMBSTONE)) {
+               /*
+                * Cannot happen because we already checked above (which also
+                * cannot happen), and we hold ctx->mutex, which serializes us
+                * against perf_event_exit_task_context().
+                */
                raw_spin_unlock_irq(&ctx->lock);
                return;
        }
-       update_context_time(ctx);
+       raw_spin_unlock_irq(&ctx->lock);
        /*
-        * Update cgrp time only if current cgrp matches event->cgrp.
-        * Must be done before calling add_event_to_ctx().
+        * Since !ctx->is_active doesn't mean anything, we must IPI
+        * unconditionally.
         */
-       update_cgrp_time_from_event(event);
-       add_event_to_ctx(event, ctx);
-       raw_spin_unlock_irq(&ctx->lock);
-
-       if (task)
-               task_function_call(task, __perf_install_in_context, ctx);
-       else
-               cpu_function_call(cpu, __perf_install_in_context, ctx);
+       goto again;
 }
 
 /*
@@ -2219,17 +2265,18 @@ static void __perf_event_enable(struct perf_event *event,
            event->state <= PERF_EVENT_STATE_ERROR)
                return;
 
-       update_context_time(ctx);
+       if (ctx->is_active)
+               ctx_sched_out(ctx, cpuctx, EVENT_TIME);
+
        __perf_event_mark_enabled(event);
 
        if (!ctx->is_active)
                return;
 
        if (!event_filter_match(event)) {
-               if (is_cgroup_event(event)) {
-                       perf_cgroup_set_timestamp(current, ctx); // XXX ?
+               if (is_cgroup_event(event))
                        perf_cgroup_defer_enabled(event);
-               }
+               ctx_sched_in(ctx, cpuctx, EVENT_TIME, current);
                return;
        }
 
@@ -2237,8 +2284,10 @@ static void __perf_event_enable(struct perf_event *event,
         * If the event is in a group and isn't the group leader,
         * then don't put it on unless the group is on.
         */
-       if (leader != event && leader->state != PERF_EVENT_STATE_ACTIVE)
+       if (leader != event && leader->state != PERF_EVENT_STATE_ACTIVE) {
+               ctx_sched_in(ctx, cpuctx, EVENT_TIME, current);
                return;
+       }
 
        task_ctx = cpuctx->task_ctx;
        if (ctx->task)
@@ -2344,24 +2393,33 @@ static void ctx_sched_out(struct perf_event_context *ctx,
        }
 
        ctx->is_active &= ~event_type;
+       if (!(ctx->is_active & EVENT_ALL))
+               ctx->is_active = 0;
+
        if (ctx->task) {
                WARN_ON_ONCE(cpuctx->task_ctx != ctx);
                if (!ctx->is_active)
                        cpuctx->task_ctx = NULL;
        }
 
-       update_context_time(ctx);
-       update_cgrp_time_from_cpuctx(cpuctx);
-       if (!ctx->nr_active)
+       is_active ^= ctx->is_active; /* changed bits */
+
+       if (is_active & EVENT_TIME) {
+               /* update (and stop) ctx time */
+               update_context_time(ctx);
+               update_cgrp_time_from_cpuctx(cpuctx);
+       }
+
+       if (!ctx->nr_active || !(is_active & EVENT_ALL))
                return;
 
        perf_pmu_disable(ctx->pmu);
-       if ((is_active & EVENT_PINNED) && (event_type & EVENT_PINNED)) {
+       if (is_active & EVENT_PINNED) {
                list_for_each_entry(event, &ctx->pinned_groups, group_entry)
                        group_sched_out(event, cpuctx, ctx);
        }
 
-       if ((is_active & EVENT_FLEXIBLE) && (event_type & EVENT_FLEXIBLE)) {
+       if (is_active & EVENT_FLEXIBLE) {
                list_for_each_entry(event, &ctx->flexible_groups, group_entry)
                        group_sched_out(event, cpuctx, ctx);
        }
@@ -2641,18 +2699,6 @@ void __perf_event_task_sched_out(struct task_struct *task,
                perf_cgroup_sched_out(task, next);
 }
 
-static void task_ctx_sched_out(struct perf_cpu_context *cpuctx,
-                              struct perf_event_context *ctx)
-{
-       if (!cpuctx->task_ctx)
-               return;
-
-       if (WARN_ON_ONCE(ctx != cpuctx->task_ctx))
-               return;
-
-       ctx_sched_out(ctx, cpuctx, EVENT_ALL);
-}
-
 /*
  * Called with IRQs disabled
  */
@@ -2735,7 +2781,7 @@ ctx_sched_in(struct perf_event_context *ctx,
        if (likely(!ctx->nr_events))
                return;
 
-       ctx->is_active |= event_type;
+       ctx->is_active |= (event_type | EVENT_TIME);
        if (ctx->task) {
                if (!is_active)
                        cpuctx->task_ctx = ctx;
@@ -2743,18 +2789,24 @@ ctx_sched_in(struct perf_event_context *ctx,
                        WARN_ON_ONCE(cpuctx->task_ctx != ctx);
        }
 
-       now = perf_clock();
-       ctx->timestamp = now;
-       perf_cgroup_set_timestamp(task, ctx);
+       is_active ^= ctx->is_active; /* changed bits */
+
+       if (is_active & EVENT_TIME) {
+               /* start ctx time */
+               now = perf_clock();
+               ctx->timestamp = now;
+               perf_cgroup_set_timestamp(task, ctx);
+       }
+
        /*
         * First go through the list and put on any pinned groups
         * in order to give them the best chance of going on.
         */
-       if (!(is_active & EVENT_PINNED) && (event_type & EVENT_PINNED))
+       if (is_active & EVENT_PINNED)
                ctx_pinned_sched_in(ctx, cpuctx);
 
        /* Then walk through the lower prio flexible groups */
-       if (!(is_active & EVENT_FLEXIBLE) && (event_type & EVENT_FLEXIBLE))
+       if (is_active & EVENT_FLEXIBLE)
                ctx_flexible_sched_in(ctx, cpuctx);
 }
 
@@ -3120,6 +3172,7 @@ static void perf_event_enable_on_exec(int ctxn)
 
        cpuctx = __get_cpu_context(ctx);
        perf_ctx_lock(cpuctx, ctx);
+       ctx_sched_out(ctx, cpuctx, EVENT_TIME);
        list_for_each_entry(event, &ctx->event_list, event_entry)
                enabled |= event_enable_on_exec(event, ctx);
 
@@ -3537,12 +3590,22 @@ static void unaccount_event(struct perf_event *event)
        if (has_branch_stack(event))
                dec = true;
 
-       if (dec)
-               static_key_slow_dec_deferred(&perf_sched_events);
+       if (dec) {
+               if (!atomic_add_unless(&perf_sched_count, -1, 1))
+                       schedule_delayed_work(&perf_sched_work, HZ);
+       }
 
        unaccount_event_cpu(event, event->cpu);
 }
 
+static void perf_sched_delayed(struct work_struct *work)
+{
+       mutex_lock(&perf_sched_mutex);
+       if (atomic_dec_and_test(&perf_sched_count))
+               static_branch_disable(&perf_sched_events);
+       mutex_unlock(&perf_sched_mutex);
+}
+
 /*
  * The following implement mutual exclusion of events on "exclusive" pmus
  * (PERF_PMU_CAP_EXCLUSIVE). Such pmus can only have one event scheduled
@@ -3752,30 +3815,42 @@ static void put_event(struct perf_event *event)
  */
 int perf_event_release_kernel(struct perf_event *event)
 {
-       struct perf_event_context *ctx;
+       struct perf_event_context *ctx = event->ctx;
        struct perf_event *child, *tmp;
 
+       /*
+        * If we got here through err_file: fput(event_file); we will not have
+        * attached to a context yet.
+        */
+       if (!ctx) {
+               WARN_ON_ONCE(event->attach_state &
+                               (PERF_ATTACH_CONTEXT|PERF_ATTACH_GROUP));
+               goto no_ctx;
+       }
+
        if (!is_kernel_event(event))
                perf_remove_from_owner(event);
 
        ctx = perf_event_ctx_lock(event);
        WARN_ON_ONCE(ctx->parent_ctx);
-       perf_remove_from_context(event, DETACH_GROUP | DETACH_STATE);
-       perf_event_ctx_unlock(event, ctx);
+       perf_remove_from_context(event, DETACH_GROUP);
 
+       raw_spin_lock_irq(&ctx->lock);
        /*
-        * At this point we must have event->state == PERF_EVENT_STATE_EXIT,
-        * either from the above perf_remove_from_context() or through
-        * perf_event_exit_event().
+        * Mark this even as STATE_DEAD, there is no external reference to it
+        * anymore.
         *
-        * Therefore, anybody acquiring event->child_mutex after the below
-        * loop _must_ also see this, most importantly inherit_event() which
-        * will avoid placing more children on the list.
+        * Anybody acquiring event->child_mutex after the below loop _must_
+        * also see this, most importantly inherit_event() which will avoid
+        * placing more children on the list.
         *
         * Thus this guarantees that we will in fact observe and kill _ALL_
         * child events.
         */
-       WARN_ON_ONCE(event->state != PERF_EVENT_STATE_EXIT);
+       event->state = PERF_EVENT_STATE_DEAD;
+       raw_spin_unlock_irq(&ctx->lock);
+
+       perf_event_ctx_unlock(event, ctx);
 
 again:
        mutex_lock(&event->child_mutex);
@@ -3830,8 +3905,8 @@ again:
        }
        mutex_unlock(&event->child_mutex);
 
-       /* Must be the last reference */
-       put_event(event);
+no_ctx:
+       put_event(event); /* Must be the 'last' reference */
        return 0;
 }
 EXPORT_SYMBOL_GPL(perf_event_release_kernel);
@@ -3988,7 +4063,7 @@ static bool is_event_hup(struct perf_event *event)
 {
        bool no_children;
 
-       if (event->state != PERF_EVENT_STATE_EXIT)
+       if (event->state > PERF_EVENT_STATE_EXIT)
                return false;
 
        mutex_lock(&event->child_mutex);
@@ -7769,8 +7844,28 @@ static void account_event(struct perf_event *event)
        if (is_cgroup_event(event))
                inc = true;
 
-       if (inc)
-               static_key_slow_inc(&perf_sched_events.key);
+       if (inc) {
+               if (atomic_inc_not_zero(&perf_sched_count))
+                       goto enabled;
+
+               mutex_lock(&perf_sched_mutex);
+               if (!atomic_read(&perf_sched_count)) {
+                       static_branch_enable(&perf_sched_events);
+                       /*
+                        * Guarantee that all CPUs observe they key change and
+                        * call the perf scheduling hooks before proceeding to
+                        * install events that need them.
+                        */
+                       synchronize_sched();
+               }
+               /*
+                * Now that we have waited for the sync_sched(), allow further
+                * increments to by-pass the mutex.
+                */
+               atomic_inc(&perf_sched_count);
+               mutex_unlock(&perf_sched_mutex);
+       }
+enabled:
 
        account_event_cpu(event, event->cpu);
 }
@@ -8389,10 +8484,19 @@ SYSCALL_DEFINE5(perf_event_open,
        if (move_group) {
                gctx = group_leader->ctx;
                mutex_lock_double(&gctx->mutex, &ctx->mutex);
+               if (gctx->task == TASK_TOMBSTONE) {
+                       err = -ESRCH;
+                       goto err_locked;
+               }
        } else {
                mutex_lock(&ctx->mutex);
        }
 
+       if (ctx->task == TASK_TOMBSTONE) {
+               err = -ESRCH;
+               goto err_locked;
+       }
+
        if (!perf_event_validate_size(event)) {
                err = -E2BIG;
                goto err_locked;
@@ -8509,7 +8613,12 @@ err_context:
        perf_unpin_context(ctx);
        put_ctx(ctx);
 err_alloc:
-       free_event(event);
+       /*
+        * If event_file is set, the fput() above will have called ->release()
+        * and that will take care of freeing the event.
+        */
+       if (!event_file)
+               free_event(event);
 err_cpus:
        put_online_cpus();
 err_task:
@@ -8563,12 +8672,14 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
 
        WARN_ON_ONCE(ctx->parent_ctx);
        mutex_lock(&ctx->mutex);
+       if (ctx->task == TASK_TOMBSTONE) {
+               err = -ESRCH;
+               goto err_unlock;
+       }
+
        if (!exclusive_event_installable(event, ctx)) {
-               mutex_unlock(&ctx->mutex);
-               perf_unpin_context(ctx);
-               put_ctx(ctx);
                err = -EBUSY;
-               goto err_free;
+               goto err_unlock;
        }
 
        perf_install_in_context(ctx, event, cpu);
@@ -8577,6 +8688,10 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
 
        return event;
 
+err_unlock:
+       mutex_unlock(&ctx->mutex);
+       perf_unpin_context(ctx);
+       put_ctx(ctx);
 err_free:
        free_event(event);
 err:
@@ -8695,7 +8810,7 @@ perf_event_exit_event(struct perf_event *child_event,
        if (parent_event)
                perf_group_detach(child_event);
        list_del_event(child_event, child_ctx);
-       child_event->state = PERF_EVENT_STATE_EXIT; /* see perf_event_release_kernel() */
+       child_event->state = PERF_EVENT_STATE_EXIT; /* is_event_hup() */
        raw_spin_unlock_irq(&child_ctx->lock);
 
        /*
@@ -9206,7 +9321,7 @@ static void perf_event_init_cpu(int cpu)
        struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
 
        mutex_lock(&swhash->hlist_mutex);
-       if (swhash->hlist_refcount > 0) {
+       if (swhash->hlist_refcount > 0 && !swevent_hlist_deref(swhash)) {
                struct swevent_hlist *hlist;
 
                hlist = kzalloc_node(sizeof(*hlist), GFP_KERNEL, cpu_to_node(cpu));
@@ -9282,11 +9397,9 @@ perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
        switch (action & ~CPU_TASKS_FROZEN) {
 
        case CPU_UP_PREPARE:
-       case CPU_DOWN_FAILED:
                perf_event_init_cpu(cpu);
                break;
 
-       case CPU_UP_CANCELED:
        case CPU_DOWN_PREPARE:
                perf_event_exit_cpu(cpu);
                break;
@@ -9315,9 +9428,6 @@ void __init perf_event_init(void)
        ret = init_hw_breakpoint();
        WARN(ret, "hw_breakpoint initialization failed with: %d", ret);
 
-       /* do not patch jump label more than once per second */
-       jump_label_rate_limit(&perf_sched_events, HZ);
-
        /*
         * Build time assertion that we keep the data_head at the intended
         * location.  IOW, validation we got the __reserved[] size right.
index 60ace56..716547f 100644 (file)
@@ -292,7 +292,7 @@ LIST_HEAD(all_lock_classes);
 #define __classhashfn(key)     hash_long((unsigned long)key, CLASSHASH_BITS)
 #define classhashentry(key)    (classhash_table + __classhashfn((key)))
 
-static struct list_head classhash_table[CLASSHASH_SIZE];
+static struct hlist_head classhash_table[CLASSHASH_SIZE];
 
 /*
  * We put the lock dependency chains into a hash-table as well, to cache
@@ -303,7 +303,7 @@ static struct list_head classhash_table[CLASSHASH_SIZE];
 #define __chainhashfn(chain)   hash_long(chain, CHAINHASH_BITS)
 #define chainhashentry(chain)  (chainhash_table + __chainhashfn((chain)))
 
-static struct list_head chainhash_table[CHAINHASH_SIZE];
+static struct hlist_head chainhash_table[CHAINHASH_SIZE];
 
 /*
  * The hash key of the lock dependency chains is a hash itself too:
@@ -666,7 +666,7 @@ static inline struct lock_class *
 look_up_lock_class(struct lockdep_map *lock, unsigned int subclass)
 {
        struct lockdep_subclass_key *key;
-       struct list_head *hash_head;
+       struct hlist_head *hash_head;
        struct lock_class *class;
 
 #ifdef CONFIG_DEBUG_LOCKDEP
@@ -719,7 +719,7 @@ look_up_lock_class(struct lockdep_map *lock, unsigned int subclass)
        if (DEBUG_LOCKS_WARN_ON(!irqs_disabled()))
                return NULL;
 
-       list_for_each_entry_rcu(class, hash_head, hash_entry) {
+       hlist_for_each_entry_rcu(class, hash_head, hash_entry) {
                if (class->key == key) {
                        /*
                         * Huh! same key, different name? Did someone trample
@@ -742,7 +742,7 @@ static inline struct lock_class *
 register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
 {
        struct lockdep_subclass_key *key;
-       struct list_head *hash_head;
+       struct hlist_head *hash_head;
        struct lock_class *class;
 
        DEBUG_LOCKS_WARN_ON(!irqs_disabled());
@@ -774,7 +774,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
         * We have to do the hash-walk again, to avoid races
         * with another CPU:
         */
-       list_for_each_entry_rcu(class, hash_head, hash_entry) {
+       hlist_for_each_entry_rcu(class, hash_head, hash_entry) {
                if (class->key == key)
                        goto out_unlock_set;
        }
@@ -805,7 +805,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
         * We use RCU's safe list-add method to make
         * parallel walking of the hash-list safe:
         */
-       list_add_tail_rcu(&class->hash_entry, hash_head);
+       hlist_add_head_rcu(&class->hash_entry, hash_head);
        /*
         * Add it to the global list of classes:
         */
@@ -1822,7 +1822,7 @@ check_deadlock(struct task_struct *curr, struct held_lock *next,
  */
 static int
 check_prev_add(struct task_struct *curr, struct held_lock *prev,
-              struct held_lock *next, int distance, int trylock_loop)
+              struct held_lock *next, int distance, int *stack_saved)
 {
        struct lock_list *entry;
        int ret;
@@ -1883,8 +1883,11 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
                }
        }
 
-       if (!trylock_loop && !save_trace(&trace))
-               return 0;
+       if (!*stack_saved) {
+               if (!save_trace(&trace))
+                       return 0;
+               *stack_saved = 1;
+       }
 
        /*
         * Ok, all validations passed, add the new lock
@@ -1907,6 +1910,8 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
         * Debugging printouts:
         */
        if (verbose(hlock_class(prev)) || verbose(hlock_class(next))) {
+               /* We drop graph lock, so another thread can overwrite trace. */
+               *stack_saved = 0;
                graph_unlock();
                printk("\n new dependency: ");
                print_lock_name(hlock_class(prev));
@@ -1929,7 +1934,7 @@ static int
 check_prevs_add(struct task_struct *curr, struct held_lock *next)
 {
        int depth = curr->lockdep_depth;
-       int trylock_loop = 0;
+       int stack_saved = 0;
        struct held_lock *hlock;
 
        /*
@@ -1956,7 +1961,7 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
                 */
                if (hlock->read != 2 && hlock->check) {
                        if (!check_prev_add(curr, hlock, next,
-                                               distance, trylock_loop))
+                                               distance, &stack_saved))
                                return 0;
                        /*
                         * Stop after the first non-trylock entry,
@@ -1979,7 +1984,6 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
                if (curr->held_locks[depth].irq_context !=
                                curr->held_locks[depth-1].irq_context)
                        break;
-               trylock_loop = 1;
        }
        return 1;
 out_bug:
@@ -2017,7 +2021,7 @@ static inline int lookup_chain_cache(struct task_struct *curr,
                                     u64 chain_key)
 {
        struct lock_class *class = hlock_class(hlock);
-       struct list_head *hash_head = chainhashentry(chain_key);
+       struct hlist_head *hash_head = chainhashentry(chain_key);
        struct lock_chain *chain;
        struct held_lock *hlock_curr;
        int i, j;
@@ -2033,7 +2037,7 @@ static inline int lookup_chain_cache(struct task_struct *curr,
         * We can walk it lock-free, because entries only get added
         * to the hash:
         */
-       list_for_each_entry_rcu(chain, hash_head, entry) {
+       hlist_for_each_entry_rcu(chain, hash_head, entry) {
                if (chain->chain_key == chain_key) {
 cache_hit:
                        debug_atomic_inc(chain_lookup_hits);
@@ -2057,7 +2061,7 @@ cache_hit:
        /*
         * We have to walk the chain again locked - to avoid duplicates:
         */
-       list_for_each_entry(chain, hash_head, entry) {
+       hlist_for_each_entry(chain, hash_head, entry) {
                if (chain->chain_key == chain_key) {
                        graph_unlock();
                        goto cache_hit;
@@ -2091,7 +2095,7 @@ cache_hit:
                }
                chain_hlocks[chain->base + j] = class - lock_classes;
        }
-       list_add_tail_rcu(&chain->entry, hash_head);
+       hlist_add_head_rcu(&chain->entry, hash_head);
        debug_atomic_inc(chain_lookup_misses);
        inc_chains();
 
@@ -3875,7 +3879,7 @@ void lockdep_reset(void)
        nr_process_chains = 0;
        debug_locks = 1;
        for (i = 0; i < CHAINHASH_SIZE; i++)
-               INIT_LIST_HEAD(chainhash_table + i);
+               INIT_HLIST_HEAD(chainhash_table + i);
        raw_local_irq_restore(flags);
 }
 
@@ -3894,7 +3898,7 @@ static void zap_class(struct lock_class *class)
        /*
         * Unhash the class and remove it from the all_lock_classes list:
         */
-       list_del_rcu(&class->hash_entry);
+       hlist_del_rcu(&class->hash_entry);
        list_del_rcu(&class->lock_entry);
 
        RCU_INIT_POINTER(class->key, NULL);
@@ -3917,7 +3921,7 @@ static inline int within(const void *addr, void *start, unsigned long size)
 void lockdep_free_key_range(void *start, unsigned long size)
 {
        struct lock_class *class;
-       struct list_head *head;
+       struct hlist_head *head;
        unsigned long flags;
        int i;
        int locked;
@@ -3930,9 +3934,7 @@ void lockdep_free_key_range(void *start, unsigned long size)
         */
        for (i = 0; i < CLASSHASH_SIZE; i++) {
                head = classhash_table + i;
-               if (list_empty(head))
-                       continue;
-               list_for_each_entry_rcu(class, head, hash_entry) {
+               hlist_for_each_entry_rcu(class, head, hash_entry) {
                        if (within(class->key, start, size))
                                zap_class(class);
                        else if (within(class->name, start, size))
@@ -3962,7 +3964,7 @@ void lockdep_free_key_range(void *start, unsigned long size)
 void lockdep_reset_lock(struct lockdep_map *lock)
 {
        struct lock_class *class;
-       struct list_head *head;
+       struct hlist_head *head;
        unsigned long flags;
        int i, j;
        int locked;
@@ -3987,9 +3989,7 @@ void lockdep_reset_lock(struct lockdep_map *lock)
        locked = graph_lock();
        for (i = 0; i < CLASSHASH_SIZE; i++) {
                head = classhash_table + i;
-               if (list_empty(head))
-                       continue;
-               list_for_each_entry_rcu(class, head, hash_entry) {
+               hlist_for_each_entry_rcu(class, head, hash_entry) {
                        int match = 0;
 
                        for (j = 0; j < NR_LOCKDEP_CACHING_CLASSES; j++)
@@ -4027,10 +4027,10 @@ void lockdep_init(void)
                return;
 
        for (i = 0; i < CLASSHASH_SIZE; i++)
-               INIT_LIST_HEAD(classhash_table + i);
+               INIT_HLIST_HEAD(classhash_table + i);
 
        for (i = 0; i < CHAINHASH_SIZE; i++)
-               INIT_LIST_HEAD(chainhash_table + i);
+               INIT_HLIST_HEAD(chainhash_table + i);
 
        lockdep_initialized = 1;
 }
index 70ee377..6cf5461 100644 (file)
@@ -29,10 +29,10 @@ __weak void __iomem *ioremap_cache(resource_size_t offset, unsigned long size)
 
 static void *try_ram_remap(resource_size_t offset, size_t size)
 {
-       struct page *page = pfn_to_page(offset >> PAGE_SHIFT);
+       unsigned long pfn = PHYS_PFN(offset);
 
        /* In the simple case just return the existing linear address */
-       if (!PageHighMem(page))
+       if (pfn_valid(pfn) && !PageHighMem(pfn_to_page(pfn)))
                return __va(offset);
        return NULL; /* fallback to ioremap_cache */
 }
@@ -114,7 +114,7 @@ EXPORT_SYMBOL(memunmap);
 
 static void devm_memremap_release(struct device *dev, void *res)
 {
-       memunmap(res);
+       memunmap(*(void **)res);
 }
 
 static int devm_memremap_match(struct device *dev, void *res, void *match_data)
@@ -136,8 +136,10 @@ void *devm_memremap(struct device *dev, resource_size_t offset,
        if (addr) {
                *ptr = addr;
                devres_add(dev, ptr);
-       } else
+       } else {
                devres_free(ptr);
+               return ERR_PTR(-ENXIO);
+       }
 
        return addr;
 }
@@ -150,7 +152,7 @@ void devm_memunmap(struct device *dev, void *addr)
 }
 EXPORT_SYMBOL(devm_memunmap);
 
-pfn_t phys_to_pfn_t(phys_addr_t addr, unsigned long flags)
+pfn_t phys_to_pfn_t(phys_addr_t addr, u64 flags)
 {
        return __pfn_to_pfn_t(addr >> PAGE_SHIFT, flags);
 }
@@ -268,13 +270,16 @@ struct dev_pagemap *find_dev_pagemap(resource_size_t phys)
 void *devm_memremap_pages(struct device *dev, struct resource *res,
                struct percpu_ref *ref, struct vmem_altmap *altmap)
 {
-       int is_ram = region_intersects(res->start, resource_size(res),
-                       "System RAM");
        resource_size_t key, align_start, align_size, align_end;
        struct dev_pagemap *pgmap;
        struct page_map *page_map;
+       int error, nid, is_ram;
        unsigned long pfn;
-       int error, nid;
+
+       align_start = res->start & ~(SECTION_SIZE - 1);
+       align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE)
+               - align_start;
+       is_ram = region_intersects(align_start, align_size, "System RAM");
 
        if (is_ram == REGION_MIXED) {
                WARN_ONCE(1, "%s attempted on mixed region %pr\n",
@@ -312,8 +317,6 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
 
        mutex_lock(&pgmap_lock);
        error = 0;
-       align_start = res->start & ~(SECTION_SIZE - 1);
-       align_size = ALIGN(resource_size(res), SECTION_SIZE);
        align_end = align_start + align_size - 1;
        for (key = align_start; key <= align_end; key += SECTION_SIZE) {
                struct dev_pagemap *dup;
@@ -349,8 +352,13 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
        for_each_device_pfn(pfn, page_map) {
                struct page *page = pfn_to_page(pfn);
 
-               /* ZONE_DEVICE pages must never appear on a slab lru */
-               list_force_poison(&page->lru);
+               /*
+                * ZONE_DEVICE pages union ->lru with a ->pgmap back
+                * pointer.  It is a bug if a ZONE_DEVICE page is ever
+                * freed or placed on a driver-private list.  Seed the
+                * storage with LIST_POISON* values.
+                */
+               list_del(&page->lru);
                page->pgmap = pgmap;
        }
        devres_add(dev, page_map);
index 8358f46..794ebe8 100644 (file)
@@ -303,6 +303,9 @@ struct load_info {
        struct _ddebug *debug;
        unsigned int num_debug;
        bool sig_ok;
+#ifdef CONFIG_KALLSYMS
+       unsigned long mod_kallsyms_init_off;
+#endif
        struct {
                unsigned int sym, str, mod, vers, info, pcpu;
        } index;
@@ -981,6 +984,8 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
                mod->exit();
        blocking_notifier_call_chain(&module_notify_list,
                                     MODULE_STATE_GOING, mod);
+       ftrace_release_mod(mod);
+
        async_synchronize_full();
 
        /* Store the name of the last unloaded module for diagnostic purposes */
@@ -2480,10 +2485,21 @@ static void layout_symtab(struct module *mod, struct load_info *info)
        strsect->sh_flags |= SHF_ALLOC;
        strsect->sh_entsize = get_offset(mod, &mod->init_layout.size, strsect,
                                         info->index.str) | INIT_OFFSET_MASK;
-       mod->init_layout.size = debug_align(mod->init_layout.size);
        pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
+
+       /* We'll tack temporary mod_kallsyms on the end. */
+       mod->init_layout.size = ALIGN(mod->init_layout.size,
+                                     __alignof__(struct mod_kallsyms));
+       info->mod_kallsyms_init_off = mod->init_layout.size;
+       mod->init_layout.size += sizeof(struct mod_kallsyms);
+       mod->init_layout.size = debug_align(mod->init_layout.size);
 }
 
+/*
+ * We use the full symtab and strtab which layout_symtab arranged to
+ * be appended to the init section.  Later we switch to the cut-down
+ * core-only ones.
+ */
 static void add_kallsyms(struct module *mod, const struct load_info *info)
 {
        unsigned int i, ndst;
@@ -2492,29 +2508,34 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
        char *s;
        Elf_Shdr *symsec = &info->sechdrs[info->index.sym];
 
-       mod->symtab = (void *)symsec->sh_addr;
-       mod->num_symtab = symsec->sh_size / sizeof(Elf_Sym);
+       /* Set up to point into init section. */
+       mod->kallsyms = mod->init_layout.base + info->mod_kallsyms_init_off;
+
+       mod->kallsyms->symtab = (void *)symsec->sh_addr;
+       mod->kallsyms->num_symtab = symsec->sh_size / sizeof(Elf_Sym);
        /* Make sure we get permanent strtab: don't use info->strtab. */
-       mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
+       mod->kallsyms->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
 
        /* Set types up while we still have access to sections. */
-       for (i = 0; i < mod->num_symtab; i++)
-               mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
-
-       mod->core_symtab = dst = mod->core_layout.base + info->symoffs;
-       mod->core_strtab = s = mod->core_layout.base + info->stroffs;
-       src = mod->symtab;
-       for (ndst = i = 0; i < mod->num_symtab; i++) {
+       for (i = 0; i < mod->kallsyms->num_symtab; i++)
+               mod->kallsyms->symtab[i].st_info
+                       = elf_type(&mod->kallsyms->symtab[i], info);
+
+       /* Now populate the cut down core kallsyms for after init. */
+       mod->core_kallsyms.symtab = dst = mod->core_layout.base + info->symoffs;
+       mod->core_kallsyms.strtab = s = mod->core_layout.base + info->stroffs;
+       src = mod->kallsyms->symtab;
+       for (ndst = i = 0; i < mod->kallsyms->num_symtab; i++) {
                if (i == 0 ||
                    is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum,
                                   info->index.pcpu)) {
                        dst[ndst] = src[i];
-                       dst[ndst++].st_name = s - mod->core_strtab;
-                       s += strlcpy(s, &mod->strtab[src[i].st_name],
+                       dst[ndst++].st_name = s - mod->core_kallsyms.strtab;
+                       s += strlcpy(s, &mod->kallsyms->strtab[src[i].st_name],
                                     KSYM_NAME_LEN) + 1;
                }
        }
-       mod->core_num_syms = ndst;
+       mod->core_kallsyms.num_symtab = ndst;
 }
 #else
 static inline void layout_symtab(struct module *mod, struct load_info *info)
@@ -3263,9 +3284,8 @@ static noinline int do_init_module(struct module *mod)
        module_put(mod);
        trim_init_extable(mod);
 #ifdef CONFIG_KALLSYMS
-       mod->num_symtab = mod->core_num_syms;
-       mod->symtab = mod->core_symtab;
-       mod->strtab = mod->core_strtab;
+       /* Switch to core kallsyms now init is done: kallsyms may be walking! */
+       rcu_assign_pointer(mod->kallsyms, &mod->core_kallsyms);
 #endif
        mod_tree_remove_init(mod);
        disable_ro_nx(&mod->init_layout);
@@ -3295,6 +3315,7 @@ fail:
        module_put(mod);
        blocking_notifier_call_chain(&module_notify_list,
                                     MODULE_STATE_GOING, mod);
+       ftrace_release_mod(mod);
        free_module(mod);
        wake_up_all(&module_wq);
        return ret;
@@ -3371,6 +3392,7 @@ static int complete_formation(struct module *mod, struct load_info *info)
        mod->state = MODULE_STATE_COMING;
        mutex_unlock(&module_mutex);
 
+       ftrace_module_enable(mod);
        blocking_notifier_call_chain(&module_notify_list,
                                     MODULE_STATE_COMING, mod);
        return 0;
@@ -3496,7 +3518,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
 
        /* Module is ready to execute: parsing args may do that. */
        after_dashes = parse_args(mod->name, mod->args, mod->kp, mod->num_kp,
-                                 -32768, 32767, NULL,
+                                 -32768, 32767, mod,
                                  unknown_module_param_cb);
        if (IS_ERR(after_dashes)) {
                err = PTR_ERR(after_dashes);
@@ -3627,6 +3649,11 @@ static inline int is_arm_mapping_symbol(const char *str)
               && (str[2] == '\0' || str[2] == '.');
 }
 
+static const char *symname(struct mod_kallsyms *kallsyms, unsigned int symnum)
+{
+       return kallsyms->strtab + kallsyms->symtab[symnum].st_name;
+}
+
 static const char *get_ksymbol(struct module *mod,
                               unsigned long addr,
                               unsigned long *size,
@@ -3634,6 +3661,7 @@ static const char *get_ksymbol(struct module *mod,
 {
        unsigned int i, best = 0;
        unsigned long nextval;
+       struct mod_kallsyms *kallsyms = rcu_dereference_sched(mod->kallsyms);
 
        /* At worse, next value is at end of module */
        if (within_module_init(addr, mod))
@@ -3643,32 +3671,32 @@ static const char *get_ksymbol(struct module *mod,
 
        /* Scan for closest preceding symbol, and next symbol. (ELF
           starts real symbols at 1). */
-       for (i = 1; i < mod->num_symtab; i++) {
-               if (mod->symtab[i].st_shndx == SHN_UNDEF)
+       for (i = 1; i < kallsyms->num_symtab; i++) {
+               if (kallsyms->symtab[i].st_shndx == SHN_UNDEF)
                        continue;
 
                /* We ignore unnamed symbols: they're uninformative
                 * and inserted at a whim. */
-               if (mod->symtab[i].st_value <= addr
-                   && mod->symtab[i].st_value > mod->symtab[best].st_value
-                   && *(mod->strtab + mod->symtab[i].st_name) != '\0'
-                   && !is_arm_mapping_symbol(mod->strtab + mod->symtab[i].st_name))
+               if (*symname(kallsyms, i) == '\0'
+                   || is_arm_mapping_symbol(symname(kallsyms, i)))
+                       continue;
+
+               if (kallsyms->symtab[i].st_value <= addr
+                   && kallsyms->symtab[i].st_value > kallsyms->symtab[best].st_value)
                        best = i;
-               if (mod->symtab[i].st_value > addr
-                   && mod->symtab[i].st_value < nextval
-                   && *(mod->strtab + mod->symtab[i].st_name) != '\0'
-                   && !is_arm_mapping_symbol(mod->strtab + mod->symtab[i].st_name))
-                       nextval = mod->symtab[i].st_value;
+               if (kallsyms->symtab[i].st_value > addr
+                   && kallsyms->symtab[i].st_value < nextval)
+                       nextval = kallsyms->symtab[i].st_value;
        }
 
        if (!best)
                return NULL;
 
        if (size)
-               *size = nextval - mod->symtab[best].st_value;
+               *size = nextval - kallsyms->symtab[best].st_value;
        if (offset)
-               *offset = addr - mod->symtab[best].st_value;
-       return mod->strtab + mod->symtab[best].st_name;
+               *offset = addr - kallsyms->symtab[best].st_value;
+       return symname(kallsyms, best);
 }
 
 /* For kallsyms to ask for address resolution.  NULL means not found.  Careful
@@ -3758,19 +3786,21 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
 
        preempt_disable();
        list_for_each_entry_rcu(mod, &modules, list) {
+               struct mod_kallsyms *kallsyms;
+
                if (mod->state == MODULE_STATE_UNFORMED)
                        continue;
-               if (symnum < mod->num_symtab) {
-                       *value = mod->symtab[symnum].st_value;
-                       *type = mod->symtab[symnum].st_info;
-                       strlcpy(name, mod->strtab + mod->symtab[symnum].st_name,
-                               KSYM_NAME_LEN);
+               kallsyms = rcu_dereference_sched(mod->kallsyms);
+               if (symnum < kallsyms->num_symtab) {
+                       *value = kallsyms->symtab[symnum].st_value;
+                       *type = kallsyms->symtab[symnum].st_info;
+                       strlcpy(name, symname(kallsyms, symnum), KSYM_NAME_LEN);
                        strlcpy(module_name, mod->name, MODULE_NAME_LEN);
                        *exported = is_exported(name, *value, mod);
                        preempt_enable();
                        return 0;
                }
-               symnum -= mod->num_symtab;
+               symnum -= kallsyms->num_symtab;
        }
        preempt_enable();
        return -ERANGE;
@@ -3779,11 +3809,12 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
 static unsigned long mod_find_symname(struct module *mod, const char *name)
 {
        unsigned int i;
+       struct mod_kallsyms *kallsyms = rcu_dereference_sched(mod->kallsyms);
 
-       for (i = 0; i < mod->num_symtab; i++)
-               if (strcmp(name, mod->strtab+mod->symtab[i].st_name) == 0 &&
-                   mod->symtab[i].st_info != 'U')
-                       return mod->symtab[i].st_value;
+       for (i = 0; i < kallsyms->num_symtab; i++)
+               if (strcmp(name, symname(kallsyms, i)) == 0 &&
+                   kallsyms->symtab[i].st_info != 'U')
+                       return kallsyms->symtab[i].st_value;
        return 0;
 }
 
@@ -3822,11 +3853,14 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
        module_assert_mutex();
 
        list_for_each_entry(mod, &modules, list) {
+               /* We hold module_mutex: no need for rcu_dereference_sched */
+               struct mod_kallsyms *kallsyms = mod->kallsyms;
+
                if (mod->state == MODULE_STATE_UNFORMED)
                        continue;
-               for (i = 0; i < mod->num_symtab; i++) {
-                       ret = fn(data, mod->strtab + mod->symtab[i].st_name,
-                                mod, mod->symtab[i].st_value);
+               for (i = 0; i < kallsyms->num_symtab; i++) {
+                       ret = fn(data, symname(kallsyms, i),
+                                mod, kallsyms->symtab[i].st_value);
                        if (ret != 0)
                                return ret;
                }
index 09c0597..3669d1b 100644 (file)
@@ -1083,9 +1083,10 @@ struct resource * __request_region(struct resource *parent,
                if (!conflict)
                        break;
                if (conflict != parent) {
-                       parent = conflict;
-                       if (!(conflict->flags & IORESOURCE_BUSY))
+                       if (!(conflict->flags & IORESOURCE_BUSY)) {
+                               parent = conflict;
                                continue;
+                       }
                }
                if (conflict->flags & flags & IORESOURCE_MUXED) {
                        add_wait_queue(&muxed_resource_wait, &wait);
index 9503d59..41f6b22 100644 (file)
@@ -26,6 +26,7 @@
  *              Thomas Gleixner, Mike Kravetz
  */
 
+#include <linux/kasan.h>
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/nmi.h>
@@ -5096,6 +5097,8 @@ void init_idle(struct task_struct *idle, int cpu)
        idle->state = TASK_RUNNING;
        idle->se.exec_start = sched_clock();
 
+       kasan_unpoison_task_stack(idle);
+
 #ifdef CONFIG_SMP
        /*
         * Its possible that init_idle() gets called multiple times on a task,
index cd64c97..57b939c 100644 (file)
@@ -420,7 +420,7 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se,
         * entity.
         */
        if (dl_time_before(dl_se->deadline, rq_clock(rq))) {
-               printk_deferred_once("sched: DL replenish lagged to much\n");
+               printk_deferred_once("sched: DL replenish lagged too much\n");
                dl_se->deadline = rq_clock(rq) + pi_se->dl_deadline;
                dl_se->runtime = pi_se->dl_runtime;
        }
index eca592f..57a6eea 100644 (file)
@@ -4961,7 +4961,7 @@ void ftrace_release_mod(struct module *mod)
        mutex_unlock(&ftrace_lock);
 }
 
-static void ftrace_module_enable(struct module *mod)
+void ftrace_module_enable(struct module *mod)
 {
        struct dyn_ftrace *rec;
        struct ftrace_page *pg;
@@ -5038,38 +5038,8 @@ void ftrace_module_init(struct module *mod)
        ftrace_process_locs(mod, mod->ftrace_callsites,
                            mod->ftrace_callsites + mod->num_ftrace_callsites);
 }
-
-static int ftrace_module_notify(struct notifier_block *self,
-                               unsigned long val, void *data)
-{
-       struct module *mod = data;
-
-       switch (val) {
-       case MODULE_STATE_COMING:
-               ftrace_module_enable(mod);
-               break;
-       case MODULE_STATE_GOING:
-               ftrace_release_mod(mod);
-               break;
-       default:
-               break;
-       }
-
-       return 0;
-}
-#else
-static int ftrace_module_notify(struct notifier_block *self,
-                               unsigned long val, void *data)
-{
-       return 0;
-}
 #endif /* CONFIG_MODULES */
 
-struct notifier_block ftrace_module_nb = {
-       .notifier_call = ftrace_module_notify,
-       .priority = INT_MIN,    /* Run after anything that can remove kprobes */
-};
-
 void __init ftrace_init(void)
 {
        extern unsigned long __start_mcount_loc[];
@@ -5098,10 +5068,6 @@ void __init ftrace_init(void)
                                  __start_mcount_loc,
                                  __stop_mcount_loc);
 
-       ret = register_module_notifier(&ftrace_module_nb);
-       if (ret)
-               pr_warning("Failed to register trace ftrace module exit notifier\n");
-
        set_ftrace_early_filters();
 
        return;
index f333e57..05ddc08 100644 (file)
@@ -97,16 +97,16 @@ trace_find_event_field(struct trace_event_call *call, char *name)
        struct ftrace_event_field *field;
        struct list_head *head;
 
-       field = __find_event_field(&ftrace_generic_fields, name);
+       head = trace_get_fields(call);
+       field = __find_event_field(head, name);
        if (field)
                return field;
 
-       field = __find_event_field(&ftrace_common_fields, name);
+       field = __find_event_field(&ftrace_generic_fields, name);
        if (field)
                return field;
 
-       head = trace_get_fields(call);
-       return __find_event_field(head, name);
+       return __find_event_field(&ftrace_common_fields, name);
 }
 
 static int __trace_define_field(struct list_head *head, const char *type,
@@ -171,8 +171,10 @@ static int trace_define_generic_fields(void)
 {
        int ret;
 
-       __generic_field(int, cpu, FILTER_OTHER);
-       __generic_field(char *, comm, FILTER_PTR_STRING);
+       __generic_field(int, CPU, FILTER_CPU);
+       __generic_field(int, cpu, FILTER_CPU);
+       __generic_field(char *, COMM, FILTER_COMM);
+       __generic_field(char *, comm, FILTER_COMM);
 
        return ret;
 }
@@ -869,7 +871,8 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
                 * The ftrace subsystem is for showing formats only.
                 * They can not be enabled or disabled via the event files.
                 */
-               if (call->class && call->class->reg)
+               if (call->class && call->class->reg &&
+                   !(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE))
                        return file;
        }
 
index f93a219..6816302 100644 (file)
@@ -1043,13 +1043,14 @@ static int init_pred(struct filter_parse_state *ps,
                return -EINVAL;
        }
 
-       if (is_string_field(field)) {
+       if (field->filter_type == FILTER_COMM) {
+               filter_build_regex(pred);
+               fn = filter_pred_comm;
+               pred->regex.field_len = TASK_COMM_LEN;
+       } else if (is_string_field(field)) {
                filter_build_regex(pred);
 
-               if (!strcmp(field->name, "comm")) {
-                       fn = filter_pred_comm;
-                       pred->regex.field_len = TASK_COMM_LEN;
-               } else if (field->filter_type == FILTER_STATIC_STRING) {
+               if (field->filter_type == FILTER_STATIC_STRING) {
                        fn = filter_pred_string;
                        pred->regex.field_len = field->size;
                } else if (field->filter_type == FILTER_DYN_STRING)
@@ -1072,7 +1073,7 @@ static int init_pred(struct filter_parse_state *ps,
                }
                pred->val = val;
 
-               if (!strcmp(field->name, "cpu"))
+               if (field->filter_type == FILTER_CPU)
                        fn = filter_pred_cpu;
                else
                        fn = select_comparison_fn(pred->op, field->size,
index 202df6c..2a1abba 100644 (file)
@@ -156,7 +156,11 @@ check_stack(unsigned long ip, unsigned long *stack)
                for (; p < top && i < stack_trace_max.nr_entries; p++) {
                        if (stack_dump_trace[i] == ULONG_MAX)
                                break;
-                       if (*p == stack_dump_trace[i]) {
+                       /*
+                        * The READ_ONCE_NOCHECK is used to let KASAN know that
+                        * this is not a stack-out-of-bounds error.
+                        */
+                       if ((READ_ONCE_NOCHECK(*p)) == stack_dump_trace[i]) {
                                stack_dump_trace[x] = stack_dump_trace[i++];
                                this_size = stack_trace_index[x++] =
                                        (top - p) * sizeof(unsigned long);
index 61a0264..7ff5dc7 100644 (file)
@@ -301,7 +301,23 @@ static DEFINE_SPINLOCK(wq_mayday_lock);    /* protects wq->maydays list */
 static LIST_HEAD(workqueues);          /* PR: list of all workqueues */
 static bool workqueue_freezing;                /* PL: have wqs started freezing? */
 
-static cpumask_var_t wq_unbound_cpumask; /* PL: low level cpumask for all unbound wqs */
+/* PL: allowable cpus for unbound wqs and work items */
+static cpumask_var_t wq_unbound_cpumask;
+
+/* CPU where unbound work was last round robin scheduled from this CPU */
+static DEFINE_PER_CPU(int, wq_rr_cpu_last);
+
+/*
+ * Local execution of unbound work items is no longer guaranteed.  The
+ * following always forces round-robin CPU selection on unbound work items
+ * to uncover usages which depend on it.
+ */
+#ifdef CONFIG_DEBUG_WQ_FORCE_RR_CPU
+static bool wq_debug_force_rr_cpu = true;
+#else
+static bool wq_debug_force_rr_cpu = false;
+#endif
+module_param_named(debug_force_rr_cpu, wq_debug_force_rr_cpu, bool, 0644);
 
 /* the per-cpu worker pools */
 static DEFINE_PER_CPU_SHARED_ALIGNED(struct worker_pool [NR_STD_WORKER_POOLS],
@@ -570,6 +586,16 @@ static struct pool_workqueue *unbound_pwq_by_node(struct workqueue_struct *wq,
                                                  int node)
 {
        assert_rcu_or_wq_mutex_or_pool_mutex(wq);
+
+       /*
+        * XXX: @node can be NUMA_NO_NODE if CPU goes offline while a
+        * delayed item is pending.  The plan is to keep CPU -> NODE
+        * mapping valid and stable across CPU on/offlines.  Once that
+        * happens, this workaround can be removed.
+        */
+       if (unlikely(node == NUMA_NO_NODE))
+               return wq->dfl_pwq;
+
        return rcu_dereference_raw(wq->numa_pwq_tbl[node]);
 }
 
@@ -1298,6 +1324,39 @@ static bool is_chained_work(struct workqueue_struct *wq)
        return worker && worker->current_pwq->wq == wq;
 }
 
+/*
+ * When queueing an unbound work item to a wq, prefer local CPU if allowed
+ * by wq_unbound_cpumask.  Otherwise, round robin among the allowed ones to
+ * avoid perturbing sensitive tasks.
+ */
+static int wq_select_unbound_cpu(int cpu)
+{
+       static bool printed_dbg_warning;
+       int new_cpu;
+
+       if (likely(!wq_debug_force_rr_cpu)) {
+               if (cpumask_test_cpu(cpu, wq_unbound_cpumask))
+                       return cpu;
+       } else if (!printed_dbg_warning) {
+               pr_warn("workqueue: round-robin CPU selection forced, expect performance impact\n");
+               printed_dbg_warning = true;
+       }
+
+       if (cpumask_empty(wq_unbound_cpumask))
+               return cpu;
+
+       new_cpu = __this_cpu_read(wq_rr_cpu_last);
+       new_cpu = cpumask_next_and(new_cpu, wq_unbound_cpumask, cpu_online_mask);
+       if (unlikely(new_cpu >= nr_cpu_ids)) {
+               new_cpu = cpumask_first_and(wq_unbound_cpumask, cpu_online_mask);
+               if (unlikely(new_cpu >= nr_cpu_ids))
+                       return cpu;
+       }
+       __this_cpu_write(wq_rr_cpu_last, new_cpu);
+
+       return new_cpu;
+}
+
 static void __queue_work(int cpu, struct workqueue_struct *wq,
                         struct work_struct *work)
 {
@@ -1323,7 +1382,7 @@ static void __queue_work(int cpu, struct workqueue_struct *wq,
                return;
 retry:
        if (req_cpu == WORK_CPU_UNBOUND)
-               cpu = raw_smp_processor_id();
+               cpu = wq_select_unbound_cpu(raw_smp_processor_id());
 
        /* pwq which will be used unless @work is executing elsewhere */
        if (!(wq->flags & WQ_UNBOUND))
@@ -1464,13 +1523,13 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
        timer_stats_timer_set_start_info(&dwork->timer);
 
        dwork->wq = wq;
-       /* timer isn't guaranteed to run in this cpu, record earlier */
-       if (cpu == WORK_CPU_UNBOUND)
-               cpu = raw_smp_processor_id();
        dwork->cpu = cpu;
        timer->expires = jiffies + delay;
 
-       add_timer_on(timer, cpu);
+       if (unlikely(cpu != WORK_CPU_UNBOUND))
+               add_timer_on(timer, cpu);
+       else
+               add_timer(timer);
 }
 
 /**
@@ -2355,7 +2414,8 @@ static void check_flush_dependency(struct workqueue_struct *target_wq,
        WARN_ONCE(current->flags & PF_MEMALLOC,
                  "workqueue: PF_MEMALLOC task %d(%s) is flushing !WQ_MEM_RECLAIM %s:%pf",
                  current->pid, current->comm, target_wq->name, target_func);
-       WARN_ONCE(worker && (worker->current_pwq->wq->flags & WQ_MEM_RECLAIM),
+       WARN_ONCE(worker && ((worker->current_pwq->wq->flags &
+                             (WQ_MEM_RECLAIM | __WQ_LEGACY)) == WQ_MEM_RECLAIM),
                  "workqueue: WQ_MEM_RECLAIM %s:%pf is flushing !WQ_MEM_RECLAIM %s:%pf",
                  worker->current_pwq->wq->name, worker->current_func,
                  target_wq->name, target_func);
index ecb9e75..8bfd1ac 100644 (file)
@@ -1400,6 +1400,21 @@ config RCU_EQS_DEBUG
 
 endmenu # "RCU Debugging"
 
+config DEBUG_WQ_FORCE_RR_CPU
+       bool "Force round-robin CPU selection for unbound work items"
+       depends on DEBUG_KERNEL
+       default n
+       help
+         Workqueue used to implicitly guarantee that work items queued
+         without explicit CPU specified are put on the local CPU.  This
+         guarantee is no longer true and while local CPU is still
+         preferred work items may be put on foreign CPUs.  Kernel
+         parameter "workqueue.debug_force_rr_cpu" is added to force
+         round-robin CPU selection to flush out usages which depend on the
+         now broken guarantee.  This config option enables the debug
+         feature by default.  When enabled, memory and cache locality will
+         be impacted.
+
 config DEBUG_BLOCK_EXT_DEVT
         bool "Force extended block device numbers and spread them"
        depends on DEBUG_KERNEL
index 49518fb..e07c1ba 100644 (file)
@@ -18,6 +18,8 @@ config UBSAN_SANITIZE_ALL
          This option activates instrumentation for the entire kernel.
          If you don't enable this option, you have to explicitly specify
          UBSAN_SANITIZE := y for the files/directories you want to check for UB.
+         Enabling this option will get kernel image size increased
+         significantly.
 
 config UBSAN_ALIGNMENT
        bool "Enable checking of pointers alignment"
@@ -25,5 +27,5 @@ config UBSAN_ALIGNMENT
        default y if !HAVE_EFFICIENT_UNALIGNED_ACCESS
        help
          This option enables detection of unaligned memory accesses.
-         Enabling this option on architectures that support unalligned
+         Enabling this option on architectures that support unaligned
          accesses may produce a lot of false positives.
index d74cf7a..0507fa5 100644 (file)
@@ -282,9 +282,9 @@ void klist_iter_init_node(struct klist *k, struct klist_iter *i,
                          struct klist_node *n)
 {
        i->i_klist = k;
-       i->i_cur = n;
-       if (n)
-               kref_get(&n->n_ref);
+       i->i_cur = NULL;
+       if (n && kref_get_unless_zero(&n->n_ref))
+               i->i_cur = n;
 }
 EXPORT_SYMBOL_GPL(klist_iter_init_node);
 
index 3345a08..3859bf6 100644 (file)
 #include <linux/kernel.h>
 #include <linux/rculist.h>
 
-static struct list_head force_poison;
-void list_force_poison(struct list_head *entry)
-{
-       entry->next = &force_poison;
-       entry->prev = &force_poison;
-}
-
 /*
  * Insert a new entry between two known consecutive entries.
  *
@@ -30,8 +23,6 @@ void __list_add(struct list_head *new,
                              struct list_head *prev,
                              struct list_head *next)
 {
-       WARN(new->next == &force_poison || new->prev == &force_poison,
-               "list_add attempted on force-poisoned entry\n");
        WARN(next->prev != prev,
                "list_add corruption. next->prev should be "
                "prev (%p), but was %p. (next=%p).\n",
index bafa993..004fc70 100644 (file)
@@ -598,9 +598,9 @@ EXPORT_SYMBOL(sg_miter_next);
  *
  * Description:
  *   Stops mapping iterator @miter.  @miter should have been started
- *   started using sg_miter_start().  A stopped iteration can be
- *   resumed by calling sg_miter_next() on it.  This is useful when
- *   resources (kmap) need to be released during iteration.
+ *   using sg_miter_start().  A stopped iteration can be resumed by
+ *   calling sg_miter_next() on it.  This is useful when resources (kmap)
+ *   need to be released during iteration.
  *
  * Context:
  *   Preemption disabled if the SG_MITER_ATOMIC is set.  Don't care
index 6f500ef..f0b323a 100644 (file)
@@ -49,3 +49,65 @@ ucs2_strncmp(const ucs2_char_t *a, const ucs2_char_t *b, size_t len)
         }
 }
 EXPORT_SYMBOL(ucs2_strncmp);
+
+unsigned long
+ucs2_utf8size(const ucs2_char_t *src)
+{
+       unsigned long i;
+       unsigned long j = 0;
+
+       for (i = 0; i < ucs2_strlen(src); i++) {
+               u16 c = src[i];
+
+               if (c >= 0x800)
+                       j += 3;
+               else if (c >= 0x80)
+                       j += 2;
+               else
+                       j += 1;
+       }
+
+       return j;
+}
+EXPORT_SYMBOL(ucs2_utf8size);
+
+/*
+ * copy at most maxlength bytes of whole utf8 characters to dest from the
+ * ucs2 string src.
+ *
+ * The return value is the number of characters copied, not including the
+ * final NUL character.
+ */
+unsigned long
+ucs2_as_utf8(u8 *dest, const ucs2_char_t *src, unsigned long maxlength)
+{
+       unsigned int i;
+       unsigned long j = 0;
+       unsigned long limit = ucs2_strnlen(src, maxlength);
+
+       for (i = 0; maxlength && i < limit; i++) {
+               u16 c = src[i];
+
+               if (c >= 0x800) {
+                       if (maxlength < 3)
+                               break;
+                       maxlength -= 3;
+                       dest[j++] = 0xe0 | (c & 0xf000) >> 12;
+                       dest[j++] = 0x80 | (c & 0x0fc0) >> 6;
+                       dest[j++] = 0x80 | (c & 0x003f);
+               } else if (c >= 0x80) {
+                       if (maxlength < 2)
+                               break;
+                       maxlength -= 2;
+                       dest[j++] = 0xc0 | (c & 0x7c0) >> 6;
+                       dest[j++] = 0x80 | (c & 0x03f);
+               } else {
+                       maxlength -= 1;
+                       dest[j++] = c & 0x7f;
+               }
+       }
+       if (maxlength)
+               dest[j] = '\0';
+       return j;
+}
+EXPORT_SYMBOL(ucs2_as_utf8);
index 48ff9c3..f44e178 100644 (file)
@@ -1590,22 +1590,23 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
                        return buf;
                }
        case 'K':
-               /*
-                * %pK cannot be used in IRQ context because its test
-                * for CAP_SYSLOG would be meaningless.
-                */
-               if (kptr_restrict && (in_irq() || in_serving_softirq() ||
-                                     in_nmi())) {
-                       if (spec.field_width == -1)
-                               spec.field_width = default_width;
-                       return string(buf, end, "pK-error", spec);
-               }
-
                switch (kptr_restrict) {
                case 0:
                        /* Always print %pK values */
                        break;
                case 1: {
+                       const struct cred *cred;
+
+                       /*
+                        * kptr_restrict==1 cannot be used in IRQ context
+                        * because its test for CAP_SYSLOG would be meaningless.
+                        */
+                       if (in_irq() || in_serving_softirq() || in_nmi()) {
+                               if (spec.field_width == -1)
+                                       spec.field_width = default_width;
+                               return string(buf, end, "pK-error", spec);
+                       }
+
                        /*
                         * Only print the real pointer value if the current
                         * process has CAP_SYSLOG and is running with the
@@ -1615,8 +1616,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
                         * leak pointer values if a binary opens a file using
                         * %pK and then elevates privileges before reading it.
                         */
-                       const struct cred *cred = current_cred();
-
+                       cred = current_cred();
                        if (!has_capability_noaudit(current, CAP_SYSLOG) ||
                            !uid_eq(cred->euid, cred->uid) ||
                            !gid_eq(cred->egid, cred->gid))
index 926c76d..c554d17 100644 (file)
@@ -328,7 +328,7 @@ static int wb_init(struct bdi_writeback *wb, struct backing_dev_info *bdi,
        return 0;
 
 out_destroy_stat:
-       while (--i)
+       while (i--)
                percpu_counter_destroy(&wb->stat[i]);
        fprop_local_destroy_percpu(&wb->completions);
 out_put_cong:
index bc94386..da7a35d 100644 (file)
@@ -195,6 +195,30 @@ void __delete_from_page_cache(struct page *page, void *shadow,
        else
                cleancache_invalidate_page(mapping, page);
 
+       VM_BUG_ON_PAGE(page_mapped(page), page);
+       if (!IS_ENABLED(CONFIG_DEBUG_VM) && unlikely(page_mapped(page))) {
+               int mapcount;
+
+               pr_alert("BUG: Bad page cache in process %s  pfn:%05lx\n",
+                        current->comm, page_to_pfn(page));
+               dump_page(page, "still mapped when deleted");
+               dump_stack();
+               add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
+
+               mapcount = page_mapcount(page);
+               if (mapping_exiting(mapping) &&
+                   page_count(page) >= mapcount + 2) {
+                       /*
+                        * All vmas have already been torn down, so it's
+                        * a good bet that actually the page is unmapped,
+                        * and we'd prefer not to leak it: if we're wrong,
+                        * some other bad page check should catch it later.
+                        */
+                       page_mapcount_reset(page);
+                       atomic_sub(mapcount, &page->_count);
+               }
+       }
+
        page_cache_tree_delete(mapping, page, shadow);
 
        page->mapping = NULL;
@@ -205,7 +229,6 @@ void __delete_from_page_cache(struct page *page, void *shadow,
                __dec_zone_page_state(page, NR_FILE_PAGES);
        if (PageSwapBacked(page))
                __dec_zone_page_state(page, NR_SHMEM);
-       VM_BUG_ON_PAGE(page_mapped(page), page);
 
        /*
         * At this point page must be either written or cleaned by truncate.
@@ -446,7 +469,8 @@ int filemap_write_and_wait(struct address_space *mapping)
 {
        int err = 0;
 
-       if (mapping->nrpages) {
+       if ((!dax_mapping(mapping) && mapping->nrpages) ||
+           (dax_mapping(mapping) && mapping->nrexceptional)) {
                err = filemap_fdatawrite(mapping);
                /*
                 * Even if the above returned error, the pages may be
@@ -482,13 +506,8 @@ int filemap_write_and_wait_range(struct address_space *mapping,
 {
        int err = 0;
 
-       if (dax_mapping(mapping) && mapping->nrexceptional) {
-               err = dax_writeback_mapping_range(mapping, lstart, lend);
-               if (err)
-                       return err;
-       }
-
-       if (mapping->nrpages) {
+       if ((!dax_mapping(mapping) && mapping->nrpages) ||
+           (dax_mapping(mapping) && mapping->nrexceptional)) {
                err = __filemap_fdatawrite_range(mapping, lstart, lend,
                                                 WB_SYNC_ALL);
                /* See comment of filemap_write_and_wait() */
@@ -1890,6 +1909,7 @@ EXPORT_SYMBOL(generic_file_read_iter);
  * page_cache_read - adds requested page to the page cache if not already there
  * @file:      file to read
  * @offset:    page index
+ * @gfp_mask:  memory allocation flags
  *
  * This adds the requested page to the page cache if it isn't already there,
  * and schedules an I/O to read in its contents from disk.
index 08fc0ba..e10a4fe 100644 (file)
@@ -1700,7 +1700,8 @@ bool move_huge_pmd(struct vm_area_struct *vma, struct vm_area_struct *new_vma,
                pmd = pmdp_huge_get_and_clear(mm, old_addr, old_pmd);
                VM_BUG_ON(!pmd_none(*new_pmd));
 
-               if (pmd_move_must_withdraw(new_ptl, old_ptl)) {
+               if (pmd_move_must_withdraw(new_ptl, old_ptl) &&
+                               vma_is_anonymous(vma)) {
                        pgtable_t pgtable;
                        pgtable = pgtable_trans_huge_withdraw(mm, old_pmd);
                        pgtable_trans_huge_deposit(mm, new_pmd, pgtable);
@@ -2835,6 +2836,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
        pgtable_t pgtable;
        pmd_t _pmd;
        bool young, write, dirty;
+       unsigned long addr;
        int i;
 
        VM_BUG_ON(haddr & ~HPAGE_PMD_MASK);
@@ -2860,10 +2862,11 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
        young = pmd_young(*pmd);
        dirty = pmd_dirty(*pmd);
 
+       pmdp_huge_split_prepare(vma, haddr, pmd);
        pgtable = pgtable_trans_huge_withdraw(mm, pmd);
        pmd_populate(mm, &_pmd, pgtable);
 
-       for (i = 0; i < HPAGE_PMD_NR; i++, haddr += PAGE_SIZE) {
+       for (i = 0, addr = haddr; i < HPAGE_PMD_NR; i++, addr += PAGE_SIZE) {
                pte_t entry, *pte;
                /*
                 * Note that NUMA hinting access restrictions are not
@@ -2884,9 +2887,9 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
                }
                if (dirty)
                        SetPageDirty(page + i);
-               pte = pte_offset_map(&_pmd, haddr);
+               pte = pte_offset_map(&_pmd, addr);
                BUG_ON(!pte_none(*pte));
-               set_pte_at(mm, haddr, pte, entry);
+               set_pte_at(mm, addr, pte, entry);
                atomic_inc(&page[i]._mapcount);
                pte_unmap(pte);
        }
@@ -2936,7 +2939,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd,
        pmd_populate(mm, pmd, pgtable);
 
        if (freeze) {
-               for (i = 0; i < HPAGE_PMD_NR; i++, haddr += PAGE_SIZE) {
+               for (i = 0; i < HPAGE_PMD_NR; i++) {
                        page_remove_rmap(page + i, false);
                        put_page(page + i);
                }
index 06ae13e..aefba5a 100644 (file)
@@ -2630,8 +2630,10 @@ static int __init hugetlb_init(void)
                        hugetlb_add_hstate(HUGETLB_PAGE_ORDER);
        }
        default_hstate_idx = hstate_index(size_to_hstate(default_hstate_size));
-       if (default_hstate_max_huge_pages)
-               default_hstate.max_huge_pages = default_hstate_max_huge_pages;
+       if (default_hstate_max_huge_pages) {
+               if (!default_hstate.max_huge_pages)
+                       default_hstate.max_huge_pages = default_hstate_max_huge_pages;
+       }
 
        hugetlb_init_hstates();
        gather_bootmem_prealloc();
@@ -2749,7 +2751,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
        int ret;
 
        if (!hugepages_supported())
-               return -ENOTSUPP;
+               return -EOPNOTSUPP;
 
        table->data = &tmp;
        table->maxlen = sizeof(unsigned long);
@@ -2790,7 +2792,7 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
        int ret;
 
        if (!hugepages_supported())
-               return -ENOTSUPP;
+               return -EOPNOTSUPP;
 
        tmp = h->nr_overcommit_huge_pages;
 
@@ -3500,7 +3502,7 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma,
         * COW. Warn that such a situation has occurred as it may not be obvious
         */
        if (is_vma_resv_set(vma, HPAGE_RESV_UNMAPPED)) {
-               pr_warning("PID %d killed due to inadequate hugepage pool\n",
+               pr_warn_ratelimited("PID %d killed due to inadequate hugepage pool\n",
                           current->pid);
                return ret;
        }
index bc0a8d8..1ad20ad 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/kmemleak.h>
+#include <linux/linkage.h>
 #include <linux/memblock.h>
 #include <linux/memory.h>
 #include <linux/mm.h>
@@ -60,6 +61,25 @@ void kasan_unpoison_shadow(const void *address, size_t size)
        }
 }
 
+static void __kasan_unpoison_stack(struct task_struct *task, void *sp)
+{
+       void *base = task_stack_page(task);
+       size_t size = sp - base;
+
+       kasan_unpoison_shadow(base, size);
+}
+
+/* Unpoison the entire stack for a task. */
+void kasan_unpoison_task_stack(struct task_struct *task)
+{
+       __kasan_unpoison_stack(task, task_stack_page(task) + THREAD_SIZE);
+}
+
+/* Unpoison the stack for the current task beyond a watermark sp value. */
+asmlinkage void kasan_unpoison_remaining_stack(void *sp)
+{
+       __kasan_unpoison_stack(current, sp);
+}
 
 /*
  * All functions below always inlined so compiler could
index 635451a..8132787 100644 (file)
@@ -3404,8 +3404,18 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
        if (unlikely(pmd_none(*pmd)) &&
            unlikely(__pte_alloc(mm, vma, pmd, address)))
                return VM_FAULT_OOM;
-       /* if an huge pmd materialized from under us just retry later */
-       if (unlikely(pmd_trans_huge(*pmd) || pmd_devmap(*pmd)))
+       /*
+        * If a huge pmd materialized under us just retry later.  Use
+        * pmd_trans_unstable() instead of pmd_trans_huge() to ensure the pmd
+        * didn't become pmd_trans_huge under us and then back to pmd_none, as
+        * a result of MADV_DONTNEED running immediately after a huge pmd fault
+        * in a different thread of this mm, in turn leading to a misleading
+        * pmd_trans_huge() retval.  All we have to ensure is that it is a
+        * regular pmd that we can walk with pte_offset_map() and we can do that
+        * through an atomic read in C, which is what pmd_trans_unstable()
+        * provides.
+        */
+       if (unlikely(pmd_trans_unstable(pmd) || pmd_devmap(*pmd)))
                return 0;
        /*
         * A regular pmd is established and it can't morph into a huge pmd
index 4c4187c..9a3f6b9 100644 (file)
@@ -532,7 +532,7 @@ retry:
                nid = page_to_nid(page);
                if (node_isset(nid, *qp->nmask) == !!(flags & MPOL_MF_INVERT))
                        continue;
-               if (PageTail(page) && PageAnon(page)) {
+               if (PageTransCompound(page) && PageAnon(page)) {
                        get_page(page);
                        pte_unmap_unlock(pte, ptl);
                        lock_page(page);
index b1034f9..3ad0fea 100644 (file)
@@ -1582,7 +1582,7 @@ static struct page *alloc_misplaced_dst_page(struct page *page,
                                         (GFP_HIGHUSER_MOVABLE |
                                          __GFP_THISNODE | __GFP_NOMEMALLOC |
                                          __GFP_NORETRY | __GFP_NOWARN) &
-                                        ~(__GFP_IO | __GFP_FS), 0);
+                                        ~__GFP_RECLAIM, 0);
 
        return newpage;
 }
index 2f2415a..76d1ec2 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2664,12 +2664,29 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
        if (!vma || !(vma->vm_flags & VM_SHARED))
                goto out;
 
-       if (start < vma->vm_start || start + size > vma->vm_end)
+       if (start < vma->vm_start)
                goto out;
 
-       if (pgoff == linear_page_index(vma, start)) {
-               ret = 0;
-               goto out;
+       if (start + size > vma->vm_end) {
+               struct vm_area_struct *next;
+
+               for (next = vma->vm_next; next; next = next->vm_next) {
+                       /* hole between vmas ? */
+                       if (next->vm_start != next->vm_prev->vm_end)
+                               goto out;
+
+                       if (next->vm_file != vma->vm_file)
+                               goto out;
+
+                       if (next->vm_flags != vma->vm_flags)
+                               goto out;
+
+                       if (start + size <= next->vm_end)
+                               break;
+               }
+
+               if (!next)
+                       goto out;
        }
 
        prot |= vma->vm_flags & VM_READ ? PROT_READ : 0;
@@ -2679,9 +2696,16 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
        flags &= MAP_NONBLOCK;
        flags |= MAP_SHARED | MAP_FIXED | MAP_POPULATE;
        if (vma->vm_flags & VM_LOCKED) {
+               struct vm_area_struct *tmp;
                flags |= MAP_LOCKED;
+
                /* drop PG_Mlocked flag for over-mapped range */
-               munlock_vma_pages_range(vma, start, start + size);
+               for (tmp = vma; tmp->vm_start >= start + size;
+                               tmp = tmp->vm_next) {
+                       munlock_vma_pages_range(tmp,
+                                       max(tmp->vm_start, start),
+                                       min(tmp->vm_end, start + size));
+               }
        }
 
        file = get_file(vma->vm_file);
index 8eb7bb4..f7cb3d4 100644 (file)
@@ -160,9 +160,11 @@ static inline unsigned long change_pmd_range(struct vm_area_struct *vma,
                }
 
                if (pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) {
-                       if (next - addr != HPAGE_PMD_SIZE)
+                       if (next - addr != HPAGE_PMD_SIZE) {
                                split_huge_pmd(vma, pmd, addr);
-                       else {
+                               if (pmd_none(*pmd))
+                                       continue;
+                       } else {
                                int nr_ptes = change_huge_pmd(vma, pmd, addr,
                                                newprot, prot_numa);
 
index d77946a..8eeba02 100644 (file)
@@ -210,6 +210,8 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
                                }
                        }
                        split_huge_pmd(vma, old_pmd, old_addr);
+                       if (pmd_none(*old_pmd))
+                               continue;
                        VM_BUG_ON(pmd_trans_huge(*old_pmd));
                }
                if (pmd_none(*new_pmd) && __pte_alloc(new_vma->vm_mm, new_vma,
index 9d47676..06a005b 100644 (file)
@@ -90,9 +90,9 @@ pte_t ptep_clear_flush(struct vm_area_struct *vma, unsigned long address,
  * ARCHes with special requirements for evicting THP backing TLB entries can
  * implement this. Otherwise also, it can help optimize normal TLB flush in
  * THP regime. stock flush_tlb_range() typically has optimization to nuke the
- * entire TLB TLB if flush span is greater than a threshhold, which will
+ * entire TLB if flush span is greater than a threshold, which will
  * likely be true for a single huge page. Thus a single thp flush will
- * invalidate the entire TLB which is not desitable.
+ * invalidate the entire TLB which is not desirable.
  * e.g. see arch/arc: flush_pmd_tlb_range
  */
 #define flush_pmd_tlb_range(vma, addr, end)    flush_tlb_range(vma, addr, end)
@@ -195,7 +195,9 @@ pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address,
        VM_BUG_ON(address & ~HPAGE_PMD_MASK);
        VM_BUG_ON(pmd_trans_huge(*pmdp));
        pmd = pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp);
-       flush_pmd_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
+
+       /* collapse entails shooting down ptes not pmd */
+       flush_tlb_range(vma, address, address + HPAGE_PMD_SIZE);
        return pmd;
 }
 #endif
index 6ecc697..621fbcb 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2275,7 +2275,7 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags)
 
        err = setup_cpu_cache(cachep, gfp);
        if (err) {
-               __kmem_cache_shutdown(cachep);
+               __kmem_cache_release(cachep);
                return err;
        }
 
@@ -2414,12 +2414,13 @@ int __kmem_cache_shrink(struct kmem_cache *cachep, bool deactivate)
 
 int __kmem_cache_shutdown(struct kmem_cache *cachep)
 {
+       return __kmem_cache_shrink(cachep, false);
+}
+
+void __kmem_cache_release(struct kmem_cache *cachep)
+{
        int i;
        struct kmem_cache_node *n;
-       int rc = __kmem_cache_shrink(cachep, false);
-
-       if (rc)
-               return rc;
 
        free_percpu(cachep->cpu_cache);
 
@@ -2430,7 +2431,6 @@ int __kmem_cache_shutdown(struct kmem_cache *cachep)
                kfree(n);
                cachep->node[i] = NULL;
        }
-       return 0;
 }
 
 /*
index 834ad24..2eedace 100644 (file)
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -140,6 +140,7 @@ static inline unsigned long kmem_cache_flags(unsigned long object_size,
 #define CACHE_CREATE_MASK (SLAB_CORE_FLAGS | SLAB_DEBUG_FLAGS | SLAB_CACHE_FLAGS)
 
 int __kmem_cache_shutdown(struct kmem_cache *);
+void __kmem_cache_release(struct kmem_cache *);
 int __kmem_cache_shrink(struct kmem_cache *, bool);
 void slab_kmem_cache_release(struct kmem_cache *);
 
index b50aef0..065b7bd 100644 (file)
@@ -693,6 +693,7 @@ static inline int shutdown_memcg_caches(struct kmem_cache *s,
 
 void slab_kmem_cache_release(struct kmem_cache *s)
 {
+       __kmem_cache_release(s);
        destroy_memcg_params(s);
        kfree_const(s->name);
        kmem_cache_free(kmem_cache, s);
index 17e8f8c..5ec1580 100644 (file)
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -630,6 +630,10 @@ int __kmem_cache_shutdown(struct kmem_cache *c)
        return 0;
 }
 
+void __kmem_cache_release(struct kmem_cache *c)
+{
+}
+
 int __kmem_cache_shrink(struct kmem_cache *d, bool deactivate)
 {
        return 0;
index 2e1355a..d8fbd4a 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -1592,18 +1592,12 @@ static inline void add_partial(struct kmem_cache_node *n,
        __add_partial(n, page, tail);
 }
 
-static inline void
-__remove_partial(struct kmem_cache_node *n, struct page *page)
-{
-       list_del(&page->lru);
-       n->nr_partial--;
-}
-
 static inline void remove_partial(struct kmem_cache_node *n,
                                        struct page *page)
 {
        lockdep_assert_held(&n->list_lock);
-       __remove_partial(n, page);
+       list_del(&page->lru);
+       n->nr_partial--;
 }
 
 /*
@@ -3184,6 +3178,12 @@ static void free_kmem_cache_nodes(struct kmem_cache *s)
        }
 }
 
+void __kmem_cache_release(struct kmem_cache *s)
+{
+       free_percpu(s->cpu_slab);
+       free_kmem_cache_nodes(s);
+}
+
 static int init_kmem_cache_nodes(struct kmem_cache *s)
 {
        int node;
@@ -3443,28 +3443,31 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page,
 
 /*
  * Attempt to free all partial slabs on a node.
- * This is called from kmem_cache_close(). We must be the last thread
- * using the cache and therefore we do not need to lock anymore.
+ * This is called from __kmem_cache_shutdown(). We must take list_lock
+ * because sysfs file might still access partial list after the shutdowning.
  */
 static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n)
 {
        struct page *page, *h;
 
+       BUG_ON(irqs_disabled());
+       spin_lock_irq(&n->list_lock);
        list_for_each_entry_safe(page, h, &n->partial, lru) {
                if (!page->inuse) {
-                       __remove_partial(n, page);
+                       remove_partial(n, page);
                        discard_slab(s, page);
                } else {
                        list_slab_objects(s, page,
-                       "Objects remaining in %s on kmem_cache_close()");
+                       "Objects remaining in %s on __kmem_cache_shutdown()");
                }
        }
+       spin_unlock_irq(&n->list_lock);
 }
 
 /*
  * Release all resources used by a slab cache.
  */
-static inline int kmem_cache_close(struct kmem_cache *s)
+int __kmem_cache_shutdown(struct kmem_cache *s)
 {
        int node;
        struct kmem_cache_node *n;
@@ -3476,16 +3479,9 @@ static inline int kmem_cache_close(struct kmem_cache *s)
                if (n->nr_partial || slabs_node(s, node))
                        return 1;
        }
-       free_percpu(s->cpu_slab);
-       free_kmem_cache_nodes(s);
        return 0;
 }
 
-int __kmem_cache_shutdown(struct kmem_cache *s)
-{
-       return kmem_cache_close(s);
-}
-
 /********************************************************************
  *             Kmalloc subsystem
  *******************************************************************/
@@ -3980,7 +3976,7 @@ int __kmem_cache_create(struct kmem_cache *s, unsigned long flags)
        memcg_propagate_slab_attrs(s);
        err = sysfs_slab_add(s);
        if (err)
-               kmem_cache_close(s);
+               __kmem_cache_release(s);
 
        return err;
 }
index d5871ac..f066781 100644 (file)
@@ -1625,7 +1625,7 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 
                rt = atrtr_find(&at_hint);
        }
-       err = ENETUNREACH;
+       err = -ENETUNREACH;
        if (!rt)
                goto out;
 
index e6c8382..ccf70be 100644 (file)
@@ -527,11 +527,12 @@ void batadv_gw_node_update(struct batadv_priv *bat_priv,
                 * gets dereferenced.
                 */
                spin_lock_bh(&bat_priv->gw.list_lock);
-               hlist_del_init_rcu(&gw_node->list);
+               if (!hlist_unhashed(&gw_node->list)) {
+                       hlist_del_init_rcu(&gw_node->list);
+                       batadv_gw_node_free_ref(gw_node);
+               }
                spin_unlock_bh(&bat_priv->gw.list_lock);
 
-               batadv_gw_node_free_ref(gw_node);
-
                curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
                if (gw_node == curr_gw)
                        batadv_gw_reselect(bat_priv);
index 01acccc..57f7107 100644 (file)
@@ -76,6 +76,28 @@ out:
 }
 
 /**
+ * batadv_mutual_parents - check if two devices are each others parent
+ * @dev1: 1st net_device
+ * @dev2: 2nd net_device
+ *
+ * veth devices come in pairs and each is the parent of the other!
+ *
+ * Return: true if the devices are each others parent, otherwise false
+ */
+static bool batadv_mutual_parents(const struct net_device *dev1,
+                                 const struct net_device *dev2)
+{
+       int dev1_parent_iflink = dev_get_iflink(dev1);
+       int dev2_parent_iflink = dev_get_iflink(dev2);
+
+       if (!dev1_parent_iflink || !dev2_parent_iflink)
+               return false;
+
+       return (dev1_parent_iflink == dev2->ifindex) &&
+              (dev2_parent_iflink == dev1->ifindex);
+}
+
+/**
  * batadv_is_on_batman_iface - check if a device is a batman iface descendant
  * @net_dev: the device to check
  *
@@ -108,6 +130,9 @@ static bool batadv_is_on_batman_iface(const struct net_device *net_dev)
        if (WARN(!parent_dev, "Cannot find parent device"))
                return false;
 
+       if (batadv_mutual_parents(net_dev, parent_dev))
+               return false;
+
        ret = batadv_is_on_batman_iface(parent_dev);
 
        return ret;
index cdfc85f..0e80fd1 100644 (file)
@@ -303,9 +303,11 @@ static void batadv_tt_global_size_mod(struct batadv_orig_node *orig_node,
 
        if (atomic_add_return(v, &vlan->tt.num_entries) == 0) {
                spin_lock_bh(&orig_node->vlan_list_lock);
-               hlist_del_init_rcu(&vlan->list);
+               if (!hlist_unhashed(&vlan->list)) {
+                       hlist_del_init_rcu(&vlan->list);
+                       batadv_orig_node_vlan_free_ref(vlan);
+               }
                spin_unlock_bh(&orig_node->vlan_list_lock);
-               batadv_orig_node_vlan_free_ref(vlan);
        }
 
        batadv_orig_node_vlan_free_ref(vlan);
index 47bcef7..883c821 100644 (file)
@@ -4112,8 +4112,10 @@ void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status,
                        break;
                }
 
-               *req_complete = bt_cb(skb)->hci.req_complete;
-               *req_complete_skb = bt_cb(skb)->hci.req_complete_skb;
+               if (bt_cb(skb)->hci.req_flags & HCI_REQ_SKB)
+                       *req_complete_skb = bt_cb(skb)->hci.req_complete_skb;
+               else
+                       *req_complete = bt_cb(skb)->hci.req_complete;
                kfree_skb(skb);
        }
        spin_unlock_irqrestore(&hdev->cmd_q.lock, flags);
index 82e3e97..dcea4f4 100644 (file)
@@ -723,6 +723,8 @@ int br_fdb_dump(struct sk_buff *skb,
                struct net_bridge_fdb_entry *f;
 
                hlist_for_each_entry_rcu(f, &br->hash[i], hlist) {
+                       int err;
+
                        if (idx < cb->args[0])
                                goto skip;
 
@@ -741,12 +743,15 @@ int br_fdb_dump(struct sk_buff *skb,
                        if (!filter_dev && f->dst)
                                goto skip;
 
-                       if (fdb_fill_info(skb, br, f,
-                                         NETLINK_CB(cb->skb).portid,
-                                         cb->nlh->nlmsg_seq,
-                                         RTM_NEWNEIGH,
-                                         NLM_F_MULTI) < 0)
+                       err = fdb_fill_info(skb, br, f,
+                                           NETLINK_CB(cb->skb).portid,
+                                           cb->nlh->nlmsg_seq,
+                                           RTM_NEWNEIGH,
+                                           NLM_F_MULTI);
+                       if (err < 0) {
+                               cb->args[1] = err;
                                break;
+                       }
 skip:
                        ++idx;
                }
index 30e105f..74c278e 100644 (file)
@@ -425,8 +425,8 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
        mp = br_mdb_ip_get(mdb, group);
        if (!mp) {
                mp = br_multicast_new_group(br, port, group);
-               err = PTR_ERR(mp);
-               if (IS_ERR(mp))
+               err = PTR_ERR_OR_ZERO(mp);
+               if (err)
                        return err;
        }
 
index 61d7617..b82440e 100644 (file)
@@ -159,7 +159,7 @@ static int cfrfml_receive(struct cflayer *layr, struct cfpkt *pkt)
                tmppkt = NULL;
 
                /* Verify that length is correct */
-               err = EPROTO;
+               err = -EPROTO;
                if (rfml->pdu_size != cfpkt_getlen(pkt) - RFM_HEAD_SIZE + 1)
                        goto out;
        }
index 9cfedf5..9382619 100644 (file)
@@ -1197,6 +1197,13 @@ static bool ceph_msg_data_advance(struct ceph_msg_data_cursor *cursor,
        return new_piece;
 }
 
+static size_t sizeof_footer(struct ceph_connection *con)
+{
+       return (con->peer_features & CEPH_FEATURE_MSG_AUTH) ?
+           sizeof(struct ceph_msg_footer) :
+           sizeof(struct ceph_msg_footer_old);
+}
+
 static void prepare_message_data(struct ceph_msg *msg, u32 data_len)
 {
        BUG_ON(!msg);
@@ -2335,9 +2342,9 @@ static int read_partial_message(struct ceph_connection *con)
                        ceph_pr_addr(&con->peer_addr.in_addr),
                        seq, con->in_seq + 1);
                con->in_base_pos = -front_len - middle_len - data_len -
-                       sizeof(m->footer);
+                       sizeof_footer(con);
                con->in_tag = CEPH_MSGR_TAG_READY;
-               return 0;
+               return 1;
        } else if ((s64)seq - (s64)con->in_seq > 1) {
                pr_err("read_partial_message bad seq %lld expected %lld\n",
                       seq, con->in_seq + 1);
@@ -2360,10 +2367,10 @@ static int read_partial_message(struct ceph_connection *con)
                        /* skip this message */
                        dout("alloc_msg said skip message\n");
                        con->in_base_pos = -front_len - middle_len - data_len -
-                               sizeof(m->footer);
+                               sizeof_footer(con);
                        con->in_tag = CEPH_MSGR_TAG_READY;
                        con->in_seq++;
-                       return 0;
+                       return 1;
                }
 
                BUG_ON(!con->in_msg);
index 3534e12..5bc0537 100644 (file)
@@ -2853,8 +2853,8 @@ static struct ceph_msg *get_reply(struct ceph_connection *con,
        mutex_lock(&osdc->request_mutex);
        req = __lookup_request(osdc, tid);
        if (!req) {
-               pr_warn("%s osd%d tid %llu unknown, skipping\n",
-                       __func__, osd->o_osd, tid);
+               dout("%s osd%d tid %llu unknown, skipping\n", __func__,
+                    osd->o_osd, tid);
                m = NULL;
                *skip = 1;
                goto out;
index 8cba3d8..0ef061b 100644 (file)
@@ -5379,12 +5379,12 @@ void *netdev_lower_get_next(struct net_device *dev, struct list_head **iter)
 {
        struct netdev_adjacent *lower;
 
-       lower = list_entry((*iter)->next, struct netdev_adjacent, list);
+       lower = list_entry(*iter, struct netdev_adjacent, list);
 
        if (&lower->list == &dev->adj_list.lower)
                return NULL;
 
-       *iter = &lower->list;
+       *iter = lower->list.next;
 
        return lower->dev;
 }
@@ -7422,8 +7422,10 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
        dev->priv_flags = IFF_XMIT_DST_RELEASE | IFF_XMIT_DST_RELEASE_PERM;
        setup(dev);
 
-       if (!dev->tx_queue_len)
+       if (!dev->tx_queue_len) {
                dev->priv_flags |= IFF_NO_QUEUE;
+               dev->tx_queue_len = 1;
+       }
 
        dev->num_tx_queues = txqs;
        dev->real_num_tx_queues = txqs;
index 94d2620..bba502f 100644 (file)
@@ -1752,7 +1752,7 @@ static u64 bpf_skb_set_tunnel_key(u64 r1, u64 r2, u64 size, u64 flags, u64 r5)
        u8 compat[sizeof(struct bpf_tunnel_key)];
        struct ip_tunnel_info *info;
 
-       if (unlikely(flags & ~(BPF_F_TUNINFO_IPV6)))
+       if (unlikely(flags & ~(BPF_F_TUNINFO_IPV6 | BPF_F_ZERO_CSUM_TX)))
                return -EINVAL;
        if (unlikely(size != sizeof(struct bpf_tunnel_key))) {
                switch (size) {
@@ -1776,7 +1776,7 @@ static u64 bpf_skb_set_tunnel_key(u64 r1, u64 r2, u64 size, u64 flags, u64 r5)
        info = &md->u.tun_info;
        info->mode = IP_TUNNEL_INFO_TX;
 
-       info->key.tun_flags = TUNNEL_KEY;
+       info->key.tun_flags = TUNNEL_KEY | TUNNEL_CSUM;
        info->key.tun_id = cpu_to_be64(from->tunnel_id);
        info->key.tos = from->tunnel_tos;
        info->key.ttl = from->tunnel_ttl;
@@ -1787,6 +1787,8 @@ static u64 bpf_skb_set_tunnel_key(u64 r1, u64 r2, u64 size, u64 flags, u64 r5)
                       sizeof(from->remote_ipv6));
        } else {
                info->key.u.ipv4.dst = cpu_to_be32(from->remote_ipv4);
+               if (flags & BPF_F_ZERO_CSUM_TX)
+                       info->key.tun_flags &= ~TUNNEL_CSUM;
        }
 
        return 0;
index d79699c..12e7003 100644 (file)
@@ -208,7 +208,6 @@ ip:
        case htons(ETH_P_IPV6): {
                const struct ipv6hdr *iph;
                struct ipv6hdr _iph;
-               __be32 flow_label;
 
 ipv6:
                iph = __skb_header_pointer(skb, nhoff, sizeof(_iph), data, hlen, &_iph);
@@ -230,8 +229,12 @@ ipv6:
                        key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
                }
 
-               flow_label = ip6_flowlabel(iph);
-               if (flow_label) {
+               if ((dissector_uses_key(flow_dissector,
+                                       FLOW_DISSECTOR_KEY_FLOW_LABEL) ||
+                    (flags & FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL)) &&
+                   ip6_flowlabel(iph)) {
+                       __be32 flow_label = ip6_flowlabel(iph);
+
                        if (dissector_uses_key(flow_dissector,
                                               FLOW_DISSECTOR_KEY_FLOW_LABEL)) {
                                key_tags = skb_flow_dissector_target(flow_dissector,
@@ -396,6 +399,13 @@ ip_proto_again:
                                goto out_bad;
                        proto = eth->h_proto;
                        nhoff += sizeof(*eth);
+
+                       /* Cap headers that we access via pointers at the
+                        * end of the Ethernet header as our maximum alignment
+                        * at that point is only 2 bytes.
+                        */
+                       if (NET_IP_ALIGN)
+                               hlen = nhoff;
                }
 
                key_control->flags |= FLOW_DIS_ENCAPSULATION;
index d735e85..8261d95 100644 (file)
@@ -2911,6 +2911,7 @@ int ndo_dflt_fdb_dump(struct sk_buff *skb,
        nlmsg_populate_fdb(skb, cb, dev, &idx, &dev->mc);
 out:
        netif_addr_unlock_bh(dev);
+       cb->args[1] = err;
        return idx;
 }
 EXPORT_SYMBOL(ndo_dflt_fdb_dump);
@@ -2944,6 +2945,7 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
                ops = br_dev->netdev_ops;
        }
 
+       cb->args[1] = 0;
        for_each_netdev(net, dev) {
                if (brport_idx && (dev->ifindex != brport_idx))
                        continue;
@@ -2971,12 +2973,16 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
                                idx = cops->ndo_fdb_dump(skb, cb, br_dev, dev,
                                                         idx);
                }
+               if (cb->args[1] == -EMSGSIZE)
+                       break;
 
                if (dev->netdev_ops->ndo_fdb_dump)
                        idx = dev->netdev_ops->ndo_fdb_dump(skb, cb, dev, NULL,
                                                            idx);
                else
                        idx = ndo_dflt_fdb_dump(skb, cb, dev, NULL, idx);
+               if (cb->args[1] == -EMSGSIZE)
+                       break;
 
                cops = NULL;
        }
index 14596fb..2696aef 100644 (file)
@@ -87,6 +87,7 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
                *fplp = fpl;
                fpl->count = 0;
                fpl->max = SCM_MAX_FD;
+               fpl->user = NULL;
        }
        fpp = &fpl->fp[fpl->count];
 
@@ -107,6 +108,10 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
                *fpp++ = file;
                fpl->count++;
        }
+
+       if (!fpl->user)
+               fpl->user = get_uid(current_user());
+
        return num;
 }
 
@@ -119,6 +124,7 @@ void __scm_destroy(struct scm_cookie *scm)
                scm->fp = NULL;
                for (i=fpl->count-1; i>=0; i--)
                        fput(fpl->fp[i]);
+               free_uid(fpl->user);
                kfree(fpl);
        }
 }
@@ -336,6 +342,7 @@ struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl)
                for (i = 0; i < fpl->count; i++)
                        get_file(fpl->fp[i]);
                new_fpl->max = new_fpl->count;
+               new_fpl->user = get_uid(fpl->user);
        }
        return new_fpl;
 }
index b2df375..8616d11 100644 (file)
@@ -79,6 +79,8 @@
 
 struct kmem_cache *skbuff_head_cache __read_mostly;
 static struct kmem_cache *skbuff_fclone_cache __read_mostly;
+int sysctl_max_skb_frags __read_mostly = MAX_SKB_FRAGS;
+EXPORT_SYMBOL(sysctl_max_skb_frags);
 
 /**
  *     skb_panic - private function for out-of-line support
@@ -2946,6 +2948,24 @@ int skb_append_pagefrags(struct sk_buff *skb, struct page *page,
 EXPORT_SYMBOL_GPL(skb_append_pagefrags);
 
 /**
+ *     skb_push_rcsum - push skb and update receive checksum
+ *     @skb: buffer to update
+ *     @len: length of data pulled
+ *
+ *     This function performs an skb_push on the packet and updates
+ *     the CHECKSUM_COMPLETE checksum.  It should be used on
+ *     receive path processing instead of skb_push unless you know
+ *     that the checksum difference is zero (e.g., a valid IP header)
+ *     or you are setting ip_summed to CHECKSUM_NONE.
+ */
+static unsigned char *skb_push_rcsum(struct sk_buff *skb, unsigned len)
+{
+       skb_push(skb, len);
+       skb_postpush_rcsum(skb, skb->data, len);
+       return skb->data;
+}
+
+/**
  *     skb_pull_rcsum - pull skb and update receive checksum
  *     @skb: buffer to update
  *     @len: length of data pulled
@@ -4082,9 +4102,9 @@ struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb,
        if (!pskb_may_pull(skb_chk, offset))
                goto err;
 
-       __skb_pull(skb_chk, offset);
+       skb_pull_rcsum(skb_chk, offset);
        ret = skb_chkf(skb_chk);
-       __skb_push(skb_chk, offset);
+       skb_push_rcsum(skb_chk, offset);
 
        if (ret)
                goto err;
index 95b6139..a6beb7b 100644 (file)
@@ -26,6 +26,7 @@ static int zero = 0;
 static int one = 1;
 static int min_sndbuf = SOCK_MIN_SNDBUF;
 static int min_rcvbuf = SOCK_MIN_RCVBUF;
+static int max_skb_frags = MAX_SKB_FRAGS;
 
 static int net_msg_warn;       /* Unused, but still a sysctl */
 
@@ -392,6 +393,15 @@ static struct ctl_table net_core_table[] = {
                .mode           = 0644,
                .proc_handler   = proc_dointvec
        },
+       {
+               .procname       = "max_skb_frags",
+               .data           = &sysctl_max_skb_frags,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec_minmax,
+               .extra1         = &one,
+               .extra2         = &max_skb_frags,
+       },
        { }
 };
 
index 5684e14..902d606 100644 (file)
@@ -824,26 +824,26 @@ lookup:
 
        if (sk->sk_state == DCCP_NEW_SYN_RECV) {
                struct request_sock *req = inet_reqsk(sk);
-               struct sock *nsk = NULL;
+               struct sock *nsk;
 
                sk = req->rsk_listener;
-               if (likely(sk->sk_state == DCCP_LISTEN)) {
-                       nsk = dccp_check_req(sk, skb, req);
-               } else {
+               if (unlikely(sk->sk_state != DCCP_LISTEN)) {
                        inet_csk_reqsk_queue_drop_and_put(sk, req);
                        goto lookup;
                }
+               sock_hold(sk);
+               nsk = dccp_check_req(sk, skb, req);
                if (!nsk) {
                        reqsk_put(req);
-                       goto discard_it;
+                       goto discard_and_relse;
                }
                if (nsk == sk) {
-                       sock_hold(sk);
                        reqsk_put(req);
                } else if (dccp_child_process(sk, nsk, skb)) {
                        dccp_v4_ctl_send_reset(sk, skb);
-                       goto discard_it;
+                       goto discard_and_relse;
                } else {
+                       sock_put(sk);
                        return 0;
                }
        }
index 9c6d050..b8608b7 100644 (file)
@@ -691,26 +691,26 @@ lookup:
 
        if (sk->sk_state == DCCP_NEW_SYN_RECV) {
                struct request_sock *req = inet_reqsk(sk);
-               struct sock *nsk = NULL;
+               struct sock *nsk;
 
                sk = req->rsk_listener;
-               if (likely(sk->sk_state == DCCP_LISTEN)) {
-                       nsk = dccp_check_req(sk, skb, req);
-               } else {
+               if (unlikely(sk->sk_state != DCCP_LISTEN)) {
                        inet_csk_reqsk_queue_drop_and_put(sk, req);
                        goto lookup;
                }
+               sock_hold(sk);
+               nsk = dccp_check_req(sk, skb, req);
                if (!nsk) {
                        reqsk_put(req);
-                       goto discard_it;
+                       goto discard_and_relse;
                }
                if (nsk == sk) {
-                       sock_hold(sk);
                        reqsk_put(req);
                } else if (dccp_child_process(sk, nsk, skb)) {
                        dccp_v6_ctl_send_reset(sk, skb);
-                       goto discard_it;
+                       goto discard_and_relse;
                } else {
+                       sock_put(sk);
                        return 0;
                }
        }
index 40b9ca7..ab24521 100644 (file)
@@ -1194,7 +1194,6 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
        if (ret) {
                netdev_err(master, "error %d registering interface %s\n",
                           ret, slave_dev->name);
-               phy_disconnect(p->phy);
                ds->ports[port] = NULL;
                free_netdev(slave_dev);
                return ret;
@@ -1205,6 +1204,7 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
        ret = dsa_slave_phy_setup(p, slave_dev);
        if (ret) {
                netdev_err(master, "error %d setting up slave phy\n", ret);
+               unregister_netdev(slave_dev);
                free_netdev(slave_dev);
                return ret;
        }
index cebd9d3..f6303b1 100644 (file)
@@ -1847,7 +1847,7 @@ static int inet_netconf_get_devconf(struct sk_buff *in_skb,
        if (err < 0)
                goto errout;
 
-       err = EINVAL;
+       err = -EINVAL;
        if (!tb[NETCONFA_IFINDEX])
                goto errout;
 
index 05e4cba..b3086cf 100644 (file)
@@ -356,9 +356,8 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, unsigned int mtu)
        skb_dst_set(skb, &rt->dst);
        skb->dev = dev;
 
-       skb->reserved_tailroom = skb_end_offset(skb) -
-                                min(mtu, skb_end_offset(skb));
        skb_reserve(skb, hlen);
+       skb_tailroom_reserve(skb, mtu, tlen);
 
        skb_reset_network_header(skb);
        pip = ip_hdr(skb);
index 46b9c88..6414891 100644 (file)
@@ -789,14 +789,16 @@ static void inet_child_forget(struct sock *sk, struct request_sock *req,
        reqsk_put(req);
 }
 
-void inet_csk_reqsk_queue_add(struct sock *sk, struct request_sock *req,
-                             struct sock *child)
+struct sock *inet_csk_reqsk_queue_add(struct sock *sk,
+                                     struct request_sock *req,
+                                     struct sock *child)
 {
        struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue;
 
        spin_lock(&queue->rskq_lock);
        if (unlikely(sk->sk_state != TCP_LISTEN)) {
                inet_child_forget(sk, req, child);
+               child = NULL;
        } else {
                req->sk = child;
                req->dl_next = NULL;
@@ -808,6 +810,7 @@ void inet_csk_reqsk_queue_add(struct sock *sk, struct request_sock *req,
                sk_acceptq_added(sk);
        }
        spin_unlock(&queue->rskq_lock);
+       return child;
 }
 EXPORT_SYMBOL(inet_csk_reqsk_queue_add);
 
@@ -817,11 +820,8 @@ struct sock *inet_csk_complete_hashdance(struct sock *sk, struct sock *child,
        if (own_req) {
                inet_csk_reqsk_queue_drop(sk, req);
                reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req);
-               inet_csk_reqsk_queue_add(sk, req, child);
-               /* Warning: caller must not call reqsk_put(req);
-                * child stole last reference on it.
-                */
-               return child;
+               if (inet_csk_reqsk_queue_add(sk, req, child))
+                       return child;
        }
        /* Too bad, another child took ownership of the request, undo. */
        bh_unlock_sock(child);
index 7c51c4e..41ba68d 100644 (file)
@@ -1054,8 +1054,9 @@ static const struct net_device_ops gre_tap_netdev_ops = {
 static void ipgre_tap_setup(struct net_device *dev)
 {
        ether_setup(dev);
-       dev->netdev_ops         = &gre_tap_netdev_ops;
-       dev->priv_flags         |= IFF_LIVE_ADDR_CHANGE;
+       dev->netdev_ops = &gre_tap_netdev_ops;
+       dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+       dev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
        ip_tunnel_setup(dev, gre_tap_net_id);
 }
 
@@ -1240,6 +1241,14 @@ struct net_device *gretap_fb_dev_create(struct net *net, const char *name,
        err = ipgre_newlink(net, dev, tb, NULL);
        if (err < 0)
                goto out;
+
+       /* openvswitch users expect packet sizes to be unrestricted,
+        * so set the largest MTU we can.
+        */
+       err = __ip_tunnel_change_mtu(dev, IP_MAX_MTU, false);
+       if (err)
+               goto out;
+
        return dev;
 out:
        free_netdev(dev);
index 64878ef..565bf64 100644 (file)
@@ -1236,13 +1236,16 @@ ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page,
        if (!skb)
                return -EINVAL;
 
-       cork->length += size;
        if ((size + skb->len > mtu) &&
            (sk->sk_protocol == IPPROTO_UDP) &&
            (rt->dst.dev->features & NETIF_F_UFO)) {
+               if (skb->ip_summed != CHECKSUM_PARTIAL)
+                       return -EOPNOTSUPP;
+
                skb_shinfo(skb)->gso_size = mtu - fragheaderlen;
                skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
        }
+       cork->length += size;
 
        while (size > 0) {
                if (skb_is_gso(skb)) {
index 5f73a7c..a501242 100644 (file)
@@ -249,6 +249,8 @@ int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc,
                switch (cmsg->cmsg_type) {
                case IP_RETOPTS:
                        err = cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr));
+
+                       /* Our caller is responsible for freeing ipc->opt */
                        err = ip_options_get(net, &ipc->opt, CMSG_DATA(cmsg),
                                             err < 40 ? err : 40);
                        if (err)
index c7bd72e..336e689 100644 (file)
@@ -661,6 +661,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
        inner_iph = (const struct iphdr *)skb_inner_network_header(skb);
        connected = (tunnel->parms.iph.daddr != 0);
 
+       memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
+
        dst = tnl_params->daddr;
        if (dst == 0) {
                /* NBMA tunnel */
@@ -758,7 +760,6 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
                                tunnel->err_time + IPTUNNEL_ERR_TIMEO)) {
                        tunnel->err_count--;
 
-                       memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
                        dst_link_failure(skb);
                } else
                        tunnel->err_count = 0;
@@ -943,17 +944,31 @@ done:
 }
 EXPORT_SYMBOL_GPL(ip_tunnel_ioctl);
 
-int ip_tunnel_change_mtu(struct net_device *dev, int new_mtu)
+int __ip_tunnel_change_mtu(struct net_device *dev, int new_mtu, bool strict)
 {
        struct ip_tunnel *tunnel = netdev_priv(dev);
        int t_hlen = tunnel->hlen + sizeof(struct iphdr);
+       int max_mtu = 0xFFF8 - dev->hard_header_len - t_hlen;
 
-       if (new_mtu < 68 ||
-           new_mtu > 0xFFF8 - dev->hard_header_len - t_hlen)
+       if (new_mtu < 68)
                return -EINVAL;
+
+       if (new_mtu > max_mtu) {
+               if (strict)
+                       return -EINVAL;
+
+               new_mtu = max_mtu;
+       }
+
        dev->mtu = new_mtu;
        return 0;
 }
+EXPORT_SYMBOL_GPL(__ip_tunnel_change_mtu);
+
+int ip_tunnel_change_mtu(struct net_device *dev, int new_mtu)
+{
+       return __ip_tunnel_change_mtu(dev, new_mtu, true);
+}
 EXPORT_SYMBOL_GPL(ip_tunnel_change_mtu);
 
 static void ip_tunnel_dev_free(struct net_device *dev)
index c117b21..d3a2716 100644 (file)
@@ -746,8 +746,10 @@ static int ping_v4_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 
        if (msg->msg_controllen) {
                err = ip_cmsg_send(sock_net(sk), msg, &ipc, false);
-               if (err)
+               if (unlikely(err)) {
+                       kfree(ipc.opt);
                        return err;
+               }
                if (ipc.opt)
                        free = 1;
        }
index bc35f18..7113bae 100644 (file)
@@ -547,8 +547,10 @@ static int raw_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
 
        if (msg->msg_controllen) {
                err = ip_cmsg_send(net, msg, &ipc, false);
-               if (err)
+               if (unlikely(err)) {
+                       kfree(ipc.opt);
                        goto out;
+               }
                if (ipc.opt)
                        free = 1;
        }
index 85f184e..02c6229 100644 (file)
@@ -129,6 +129,7 @@ static int ip_rt_mtu_expires __read_mostly  = 10 * 60 * HZ;
 static int ip_rt_min_pmtu __read_mostly                = 512 + 20 + 20;
 static int ip_rt_min_advmss __read_mostly      = 256;
 
+static int ip_rt_gc_timeout __read_mostly      = RT_GC_TIMEOUT;
 /*
  *     Interface to generic destination cache.
  */
@@ -755,7 +756,7 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow
                                struct fib_nh *nh = &FIB_RES_NH(res);
 
                                update_or_create_fnhe(nh, fl4->daddr, new_gw,
-                                                     0, 0);
+                                               0, jiffies + ip_rt_gc_timeout);
                        }
                        if (kill_route)
                                rt->dst.obsolete = DST_OBSOLETE_KILL;
@@ -1556,6 +1557,36 @@ static void ip_handle_martian_source(struct net_device *dev,
 #endif
 }
 
+static void ip_del_fnhe(struct fib_nh *nh, __be32 daddr)
+{
+       struct fnhe_hash_bucket *hash;
+       struct fib_nh_exception *fnhe, __rcu **fnhe_p;
+       u32 hval = fnhe_hashfun(daddr);
+
+       spin_lock_bh(&fnhe_lock);
+
+       hash = rcu_dereference_protected(nh->nh_exceptions,
+                                        lockdep_is_held(&fnhe_lock));
+       hash += hval;
+
+       fnhe_p = &hash->chain;
+       fnhe = rcu_dereference_protected(*fnhe_p, lockdep_is_held(&fnhe_lock));
+       while (fnhe) {
+               if (fnhe->fnhe_daddr == daddr) {
+                       rcu_assign_pointer(*fnhe_p, rcu_dereference_protected(
+                               fnhe->fnhe_next, lockdep_is_held(&fnhe_lock)));
+                       fnhe_flush_routes(fnhe);
+                       kfree_rcu(fnhe, rcu);
+                       break;
+               }
+               fnhe_p = &fnhe->fnhe_next;
+               fnhe = rcu_dereference_protected(fnhe->fnhe_next,
+                                                lockdep_is_held(&fnhe_lock));
+       }
+
+       spin_unlock_bh(&fnhe_lock);
+}
+
 /* called in rcu_read_lock() section */
 static int __mkroute_input(struct sk_buff *skb,
                           const struct fib_result *res,
@@ -1609,11 +1640,20 @@ static int __mkroute_input(struct sk_buff *skb,
 
        fnhe = find_exception(&FIB_RES_NH(*res), daddr);
        if (do_cache) {
-               if (fnhe)
+               if (fnhe) {
                        rth = rcu_dereference(fnhe->fnhe_rth_input);
-               else
-                       rth = rcu_dereference(FIB_RES_NH(*res).nh_rth_input);
+                       if (rth && rth->dst.expires &&
+                           time_after(jiffies, rth->dst.expires)) {
+                               ip_del_fnhe(&FIB_RES_NH(*res), daddr);
+                               fnhe = NULL;
+                       } else {
+                               goto rt_cache;
+                       }
+               }
+
+               rth = rcu_dereference(FIB_RES_NH(*res).nh_rth_input);
 
+rt_cache:
                if (rt_cache_valid(rth)) {
                        skb_dst_set_noref(skb, &rth->dst);
                        goto out;
@@ -2014,19 +2054,29 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
                struct fib_nh *nh = &FIB_RES_NH(*res);
 
                fnhe = find_exception(nh, fl4->daddr);
-               if (fnhe)
+               if (fnhe) {
                        prth = &fnhe->fnhe_rth_output;
-               else {
-                       if (unlikely(fl4->flowi4_flags &
-                                    FLOWI_FLAG_KNOWN_NH &&
-                                    !(nh->nh_gw &&
-                                      nh->nh_scope == RT_SCOPE_LINK))) {
-                               do_cache = false;
-                               goto add;
+                       rth = rcu_dereference(*prth);
+                       if (rth && rth->dst.expires &&
+                           time_after(jiffies, rth->dst.expires)) {
+                               ip_del_fnhe(nh, fl4->daddr);
+                               fnhe = NULL;
+                       } else {
+                               goto rt_cache;
                        }
-                       prth = raw_cpu_ptr(nh->nh_pcpu_rth_output);
                }
+
+               if (unlikely(fl4->flowi4_flags &
+                            FLOWI_FLAG_KNOWN_NH &&
+                            !(nh->nh_gw &&
+                              nh->nh_scope == RT_SCOPE_LINK))) {
+                       do_cache = false;
+                       goto add;
+               }
+               prth = raw_cpu_ptr(nh->nh_pcpu_rth_output);
                rth = rcu_dereference(*prth);
+
+rt_cache:
                if (rt_cache_valid(rth)) {
                        dst_hold(&rth->dst);
                        return rth;
@@ -2569,7 +2619,6 @@ void ip_rt_multicast_event(struct in_device *in_dev)
 }
 
 #ifdef CONFIG_SYSCTL
-static int ip_rt_gc_timeout __read_mostly      = RT_GC_TIMEOUT;
 static int ip_rt_gc_interval __read_mostly  = 60 * HZ;
 static int ip_rt_gc_min_interval __read_mostly = HZ / 2;
 static int ip_rt_gc_elasticity __read_mostly   = 8;
index 19746b3..483ffdf 100644 (file)
@@ -940,7 +940,7 @@ new_segment:
 
                i = skb_shinfo(skb)->nr_frags;
                can_coalesce = skb_can_coalesce(skb, i, page, offset);
-               if (!can_coalesce && i >= MAX_SKB_FRAGS) {
+               if (!can_coalesce && i >= sysctl_max_skb_frags) {
                        tcp_mark_push(tp, skb);
                        goto new_segment;
                }
@@ -1213,7 +1213,7 @@ new_segment:
 
                        if (!skb_can_coalesce(skb, i, pfrag->page,
                                              pfrag->offset)) {
-                               if (i == MAX_SKB_FRAGS || !sg) {
+                               if (i == sysctl_max_skb_frags || !sg) {
                                        tcp_mark_push(tp, skb);
                                        goto new_segment;
                                }
@@ -2950,7 +2950,7 @@ static void __tcp_alloc_md5sig_pool(void)
                        struct crypto_hash *hash;
 
                        hash = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
-                       if (IS_ERR_OR_NULL(hash))
+                       if (IS_ERR(hash))
                                return;
                        per_cpu(tcp_md5sig_pool, cpu).md5_desc.tfm = hash;
                }
index 1c2a734..3b2c8e9 100644 (file)
@@ -2896,7 +2896,10 @@ static void tcp_update_rtt_min(struct sock *sk, u32 rtt_us)
 {
        const u32 now = tcp_time_stamp, wlen = sysctl_tcp_min_rtt_wlen * HZ;
        struct rtt_meas *m = tcp_sk(sk)->rtt_min;
-       struct rtt_meas rttm = { .rtt = (rtt_us ? : 1), .ts = now };
+       struct rtt_meas rttm = {
+               .rtt = likely(rtt_us) ? rtt_us : jiffies_to_usecs(1),
+               .ts = now,
+       };
        u32 elapsed;
 
        /* Check if the new measurement updates the 1st, 2nd, or 3rd choices */
index a4d5237..487ac67 100644 (file)
@@ -311,7 +311,7 @@ static void do_redirect(struct sk_buff *skb, struct sock *sk)
 
 
 /* handle ICMP messages on TCP_NEW_SYN_RECV request sockets */
-void tcp_req_err(struct sock *sk, u32 seq)
+void tcp_req_err(struct sock *sk, u32 seq, bool abort)
 {
        struct request_sock *req = inet_reqsk(sk);
        struct net *net = sock_net(sk);
@@ -323,7 +323,7 @@ void tcp_req_err(struct sock *sk, u32 seq)
 
        if (seq != tcp_rsk(req)->snt_isn) {
                NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
-       } else {
+       } else if (abort) {
                /*
                 * Still in SYN_RECV, just remove it silently.
                 * There is no good way to pass the error to the newly
@@ -383,7 +383,12 @@ void tcp_v4_err(struct sk_buff *icmp_skb, u32 info)
        }
        seq = ntohl(th->seq);
        if (sk->sk_state == TCP_NEW_SYN_RECV)
-               return tcp_req_err(sk, seq);
+               return tcp_req_err(sk, seq,
+                                 type == ICMP_PARAMETERPROB ||
+                                 type == ICMP_TIME_EXCEEDED ||
+                                 (type == ICMP_DEST_UNREACH &&
+                                  (code == ICMP_NET_UNREACH ||
+                                   code == ICMP_HOST_UNREACH)));
 
        bh_lock_sock(sk);
        /* If too many ICMPs get dropped on busy
@@ -1592,28 +1597,30 @@ process:
 
        if (sk->sk_state == TCP_NEW_SYN_RECV) {
                struct request_sock *req = inet_reqsk(sk);
-               struct sock *nsk = NULL;
+               struct sock *nsk;
 
                sk = req->rsk_listener;
-               if (tcp_v4_inbound_md5_hash(sk, skb))
-                       goto discard_and_relse;
-               if (likely(sk->sk_state == TCP_LISTEN)) {
-                       nsk = tcp_check_req(sk, skb, req, false);
-               } else {
+               if (unlikely(tcp_v4_inbound_md5_hash(sk, skb))) {
+                       reqsk_put(req);
+                       goto discard_it;
+               }
+               if (unlikely(sk->sk_state != TCP_LISTEN)) {
                        inet_csk_reqsk_queue_drop_and_put(sk, req);
                        goto lookup;
                }
+               sock_hold(sk);
+               nsk = tcp_check_req(sk, skb, req, false);
                if (!nsk) {
                        reqsk_put(req);
-                       goto discard_it;
+                       goto discard_and_relse;
                }
                if (nsk == sk) {
-                       sock_hold(sk);
                        reqsk_put(req);
                } else if (tcp_child_process(sk, nsk, skb)) {
                        tcp_v4_send_reset(nsk, skb);
-                       goto discard_it;
+                       goto discard_and_relse;
                } else {
+                       sock_put(sk);
                        return 0;
                }
        }
index c8cbc2b..a726d78 100644 (file)
@@ -550,7 +550,7 @@ reset:
         */
        if (crtt > tp->srtt_us) {
                /* Set RTO like tcp_rtt_estimator(), but from cached RTT. */
-               crtt /= 8 * USEC_PER_MSEC;
+               crtt /= 8 * USEC_PER_SEC / HZ;
                inet_csk(sk)->icsk_rto = crtt + max(2 * crtt, tcp_rto_min(sk));
        } else if (tp->srtt_us == 0) {
                /* RFC6298: 5.7 We've failed to get a valid RTT sample from
index 75632a9..9b02af2 100644 (file)
@@ -455,7 +455,7 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 
                newtp->rcv_wup = newtp->copied_seq =
                newtp->rcv_nxt = treq->rcv_isn + 1;
-               newtp->segs_in = 0;
+               newtp->segs_in = 1;
 
                newtp->snd_sml = newtp->snd_una =
                newtp->snd_nxt = newtp->snd_up = treq->snt_isn + 1;
@@ -815,6 +815,7 @@ int tcp_child_process(struct sock *parent, struct sock *child,
        int ret = 0;
        int state = child->sk_state;
 
+       tcp_sk(child)->segs_in += max_t(u16, 1, skb_shinfo(skb)->gso_segs);
        if (!sock_owned_by_user(child)) {
                ret = tcp_rcv_state_process(child, skb);
                /* Wakeup parent, send SIGIO */
index be0b218..95d2f19 100644 (file)
@@ -1048,8 +1048,10 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
        if (msg->msg_controllen) {
                err = ip_cmsg_send(sock_net(sk), msg, &ipc,
                                   sk->sk_family == AF_INET6);
-               if (err)
+               if (unlikely(err)) {
+                       kfree(ipc.opt);
                        return err;
+               }
                if (ipc.opt)
                        free = 1;
                connected = 0;
index 0ec0881..96599d1 100644 (file)
@@ -89,6 +89,8 @@ void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb
        uh->source = src_port;
        uh->len = htons(skb->len);
 
+       memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
+
        udp_set_csum(nocheck, skb, src, dst, skb->len);
 
        iptunnel_xmit(sk, rt, skb, src, dst, IPPROTO_UDP, tos, ttl, df, xnet);
index 38eedde..bdd7eac 100644 (file)
@@ -583,7 +583,7 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
        if (err < 0)
                goto errout;
 
-       err = EINVAL;
+       err = -EINVAL;
        if (!tb[NETCONFA_IFINDEX])
                goto errout;
 
@@ -3538,6 +3538,7 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
 {
        struct inet6_dev *idev = ifp->idev;
        struct net_device *dev = idev->dev;
+       bool notify = false;
 
        addrconf_join_solict(dev, &ifp->addr);
 
@@ -3583,7 +3584,7 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
                        /* Because optimistic nodes can use this address,
                         * notify listeners. If DAD fails, RTM_DELADDR is sent.
                         */
-                       ipv6_ifa_notify(RTM_NEWADDR, ifp);
+                       notify = true;
                }
        }
 
@@ -3591,6 +3592,8 @@ static void addrconf_dad_begin(struct inet6_ifaddr *ifp)
 out:
        spin_unlock(&ifp->lock);
        read_unlock_bh(&idev->lock);
+       if (notify)
+               ipv6_ifa_notify(RTM_NEWADDR, ifp);
 }
 
 static void addrconf_dad_start(struct inet6_ifaddr *ifp)
index 5c5d23e..9508a20 100644 (file)
@@ -257,7 +257,11 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
                                                *fragoff = _frag_off;
                                        return hp->nexthdr;
                                }
-                               return -ENOENT;
+                               if (!found)
+                                       return -ENOENT;
+                               if (fragoff)
+                                       *fragoff = _frag_off;
+                               break;
                        }
                        hdrlen = 8;
                } else if (nexthdr == NEXTHDR_AUTH) {
index 1f9ebe3..dc2db4f 100644 (file)
@@ -540,12 +540,13 @@ int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen)
                }
                spin_lock_bh(&ip6_sk_fl_lock);
                for (sflp = &np->ipv6_fl_list;
-                    (sfl = rcu_dereference(*sflp)) != NULL;
+                    (sfl = rcu_dereference_protected(*sflp,
+                                                     lockdep_is_held(&ip6_sk_fl_lock))) != NULL;
                     sflp = &sfl->next) {
                        if (sfl->fl->label == freq.flr_label) {
                                if (freq.flr_label == (np->flow_label&IPV6_FLOWLABEL_MASK))
                                        np->flow_label &= ~IPV6_FLOWLABEL_MASK;
-                               *sflp = rcu_dereference(sfl->next);
+                               *sflp = sfl->next;
                                spin_unlock_bh(&ip6_sk_fl_lock);
                                fl_release(sfl->fl);
                                kfree_rcu(sfl, rcu);
index f37f18b..c0d4dc1 100644 (file)
@@ -777,6 +777,8 @@ static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
        __u32 mtu;
        int err;
 
+       memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
+
        if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
                encap_limit = t->parms.encap_limit;
 
@@ -1512,6 +1514,7 @@ static void ip6gre_tap_setup(struct net_device *dev)
        dev->destructor = ip6gre_dev_free;
 
        dev->features |= NETIF_F_NETNS_LOCAL;
+       dev->priv_flags &= ~IFF_TX_SKB_SHARING;
 }
 
 static int ip6gre_newlink(struct net *src_net, struct net_device *dev,
index 137fca4..6c5dfec 100644 (file)
@@ -1180,6 +1180,8 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
        u8 tproto;
        int err;
 
+       memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
+
        tproto = ACCESS_ONCE(t->parms.proto);
        if (tproto != IPPROTO_IPIP && tproto != 0)
                return -1;
index 5ee56d0..d64ee7e 100644 (file)
@@ -1574,9 +1574,8 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, unsigned int mtu)
                return NULL;
 
        skb->priority = TC_PRIO_CONTROL;
-       skb->reserved_tailroom = skb_end_offset(skb) -
-                                min(mtu, skb_end_offset(skb));
        skb_reserve(skb, hlen);
+       skb_tailroom_reserve(skb, mtu, tlen);
 
        if (__ipv6_get_lladdr(idev, &addr_buf, IFA_F_TENTATIVE)) {
                /* <draft-ietf-magma-mld-source-05.txt>:
index 31ba7ca..051b6a6 100644 (file)
 #include <net/ipv6.h>
 #include <net/netfilter/ipv6/nf_nat_masquerade.h>
 
+#define MAX_WORK_COUNT 16
+
+static atomic_t v6_worker_count;
+
 unsigned int
 nf_nat_masquerade_ipv6(struct sk_buff *skb, const struct nf_nat_range *range,
                       const struct net_device *out)
@@ -78,14 +82,78 @@ static struct notifier_block masq_dev_notifier = {
        .notifier_call  = masq_device_event,
 };
 
+struct masq_dev_work {
+       struct work_struct work;
+       struct net *net;
+       int ifindex;
+};
+
+static void iterate_cleanup_work(struct work_struct *work)
+{
+       struct masq_dev_work *w;
+       long index;
+
+       w = container_of(work, struct masq_dev_work, work);
+
+       index = w->ifindex;
+       nf_ct_iterate_cleanup(w->net, device_cmp, (void *)index, 0, 0);
+
+       put_net(w->net);
+       kfree(w);
+       atomic_dec(&v6_worker_count);
+       module_put(THIS_MODULE);
+}
+
+/* ipv6 inet notifier is an atomic notifier, i.e. we cannot
+ * schedule.
+ *
+ * Unfortunately, nf_ct_iterate_cleanup can run for a long
+ * time if there are lots of conntracks and the system
+ * handles high softirq load, so it frequently calls cond_resched
+ * while iterating the conntrack table.
+ *
+ * So we defer nf_ct_iterate_cleanup walk to the system workqueue.
+ *
+ * As we can have 'a lot' of inet_events (depending on amount
+ * of ipv6 addresses being deleted), we also need to add an upper
+ * limit to the number of queued work items.
+ */
 static int masq_inet_event(struct notifier_block *this,
                           unsigned long event, void *ptr)
 {
        struct inet6_ifaddr *ifa = ptr;
-       struct netdev_notifier_info info;
+       const struct net_device *dev;
+       struct masq_dev_work *w;
+       struct net *net;
+
+       if (event != NETDEV_DOWN ||
+           atomic_read(&v6_worker_count) >= MAX_WORK_COUNT)
+               return NOTIFY_DONE;
+
+       dev = ifa->idev->dev;
+       net = maybe_get_net(dev_net(dev));
+       if (!net)
+               return NOTIFY_DONE;
 
-       netdev_notifier_info_init(&info, ifa->idev->dev);
-       return masq_device_event(this, event, &info);
+       if (!try_module_get(THIS_MODULE))
+               goto err_module;
+
+       w = kmalloc(sizeof(*w), GFP_ATOMIC);
+       if (w) {
+               atomic_inc(&v6_worker_count);
+
+               INIT_WORK(&w->work, iterate_cleanup_work);
+               w->ifindex = dev->ifindex;
+               w->net = net;
+               schedule_work(&w->work);
+
+               return NOTIFY_DONE;
+       }
+
+       module_put(THIS_MODULE);
+ err_module:
+       put_net(net);
+       return NOTIFY_DONE;
 }
 
 static struct notifier_block masq_inet_notifier = {
index 006396e..5c8c842 100644 (file)
@@ -327,6 +327,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        struct tcp_sock *tp;
        __u32 seq, snd_una;
        struct sock *sk;
+       bool fatal;
        int err;
 
        sk = __inet6_lookup_established(net, &tcp_hashinfo,
@@ -345,8 +346,9 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
                return;
        }
        seq = ntohl(th->seq);
+       fatal = icmpv6_err_convert(type, code, &err);
        if (sk->sk_state == TCP_NEW_SYN_RECV)
-               return tcp_req_err(sk, seq);
+               return tcp_req_err(sk, seq, fatal);
 
        bh_lock_sock(sk);
        if (sock_owned_by_user(sk) && type != ICMPV6_PKT_TOOBIG)
@@ -400,7 +402,6 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
                goto out;
        }
 
-       icmpv6_err_convert(type, code, &err);
 
        /* Might be for an request_sock */
        switch (sk->sk_state) {
@@ -1386,7 +1387,7 @@ process:
 
        if (sk->sk_state == TCP_NEW_SYN_RECV) {
                struct request_sock *req = inet_reqsk(sk);
-               struct sock *nsk = NULL;
+               struct sock *nsk;
 
                sk = req->rsk_listener;
                tcp_v6_fill_cb(skb, hdr, th);
@@ -1394,24 +1395,24 @@ process:
                        reqsk_put(req);
                        goto discard_it;
                }
-               if (likely(sk->sk_state == TCP_LISTEN)) {
-                       nsk = tcp_check_req(sk, skb, req, false);
-               } else {
+               if (unlikely(sk->sk_state != TCP_LISTEN)) {
                        inet_csk_reqsk_queue_drop_and_put(sk, req);
                        goto lookup;
                }
+               sock_hold(sk);
+               nsk = tcp_check_req(sk, skb, req, false);
                if (!nsk) {
                        reqsk_put(req);
-                       goto discard_it;
+                       goto discard_and_relse;
                }
                if (nsk == sk) {
-                       sock_hold(sk);
                        reqsk_put(req);
                        tcp_v6_restore_cb(skb);
                } else if (tcp_child_process(sk, nsk, skb)) {
                        tcp_v6_send_reset(nsk, skb);
-                       goto discard_it;
+                       goto discard_and_relse;
                } else {
+                       sock_put(sk);
                        return 0;
                }
        }
index 22e28a4..422dd01 100644 (file)
@@ -962,11 +962,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
                ret = udpv6_queue_rcv_skb(sk, skb);
                sock_put(sk);
 
-               /* a return value > 0 means to resubmit the input, but
-                * it wants the return to be -protocol, or 0
-                */
+               /* a return value > 0 means to resubmit the input */
                if (ret > 0)
-                       return -ret;
+                       return ret;
 
                return 0;
        }
index f93c5be..2caaa84 100644 (file)
@@ -124,8 +124,13 @@ static int l2tp_tunnel_notify(struct genl_family *family,
        ret = l2tp_nl_tunnel_send(msg, info->snd_portid, info->snd_seq,
                                  NLM_F_ACK, tunnel, cmd);
 
-       if (ret >= 0)
-               return genlmsg_multicast_allns(family, msg, 0,  0, GFP_ATOMIC);
+       if (ret >= 0) {
+               ret = genlmsg_multicast_allns(family, msg, 0, 0, GFP_ATOMIC);
+               /* We don't care if no one is listening */
+               if (ret == -ESRCH)
+                       ret = 0;
+               return ret;
+       }
 
        nlmsg_free(msg);
 
@@ -147,8 +152,13 @@ static int l2tp_session_notify(struct genl_family *family,
        ret = l2tp_nl_session_send(msg, info->snd_portid, info->snd_seq,
                                   NLM_F_ACK, session, cmd);
 
-       if (ret >= 0)
-               return genlmsg_multicast_allns(family, msg, 0,  0, GFP_ATOMIC);
+       if (ret >= 0) {
+               ret = genlmsg_multicast_allns(family, msg, 0, 0, GFP_ATOMIC);
+               /* We don't care if no one is listening */
+               if (ret == -ESRCH)
+                       ret = 0;
+               return ret;
+       }
 
        nlmsg_free(msg);
 
index 10ad4ac..367784b 100644 (file)
@@ -291,7 +291,7 @@ void __ieee80211_start_rx_ba_session(struct sta_info *sta,
        }
 
        /* prepare A-MPDU MLME for Rx aggregation */
-       tid_agg_rx = kmalloc(sizeof(struct tid_ampdu_rx), GFP_KERNEL);
+       tid_agg_rx = kzalloc(sizeof(*tid_agg_rx), GFP_KERNEL);
        if (!tid_agg_rx)
                goto end;
 
index b84f6aa..f006f4a 100644 (file)
@@ -92,7 +92,7 @@ struct ieee80211_fragment_entry {
        u16 extra_len;
        u16 last_frag;
        u8 rx_queue;
-       bool ccmp; /* Whether fragments were encrypted with CCMP */
+       bool check_sequential_pn; /* needed for CCMP/GCMP */
        u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
 };
 
index 3ece7d1..b54f398 100644 (file)
@@ -711,7 +711,7 @@ static u32 minstrel_get_expected_throughput(void *priv_sta)
         * computing cur_tp
         */
        tmp_mrs = &mi->r[idx].stats;
-       tmp_cur_tp = minstrel_get_tp_avg(&mi->r[idx], tmp_mrs->prob_ewma);
+       tmp_cur_tp = minstrel_get_tp_avg(&mi->r[idx], tmp_mrs->prob_ewma) * 10;
        tmp_cur_tp = tmp_cur_tp * 1200 * 8 / 1024;
 
        return tmp_cur_tp;
index 3928dbd..370d677 100644 (file)
@@ -414,15 +414,16 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
            (max_tp_group != MINSTREL_CCK_GROUP))
                return;
 
+       max_gpr_group = mg->max_group_prob_rate / MCS_GROUP_RATES;
+       max_gpr_idx = mg->max_group_prob_rate % MCS_GROUP_RATES;
+       max_gpr_prob = mi->groups[max_gpr_group].rates[max_gpr_idx].prob_ewma;
+
        if (mrs->prob_ewma > MINSTREL_FRAC(75, 100)) {
                cur_tp_avg = minstrel_ht_get_tp_avg(mi, cur_group, cur_idx,
                                                    mrs->prob_ewma);
                if (cur_tp_avg > tmp_tp_avg)
                        mi->max_prob_rate = index;
 
-               max_gpr_group = mg->max_group_prob_rate / MCS_GROUP_RATES;
-               max_gpr_idx = mg->max_group_prob_rate % MCS_GROUP_RATES;
-               max_gpr_prob = mi->groups[max_gpr_group].rates[max_gpr_idx].prob_ewma;
                max_gpr_tp_avg = minstrel_ht_get_tp_avg(mi, max_gpr_group,
                                                        max_gpr_idx,
                                                        max_gpr_prob);
@@ -431,7 +432,7 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
        } else {
                if (mrs->prob_ewma > tmp_prob)
                        mi->max_prob_rate = index;
-               if (mrs->prob_ewma > mg->rates[mg->max_group_prob_rate].prob_ewma)
+               if (mrs->prob_ewma > max_gpr_prob)
                        mg->max_group_prob_rate = index;
        }
 }
@@ -691,7 +692,7 @@ minstrel_aggr_check(struct ieee80211_sta *pubsta, struct sk_buff *skb)
        if (likely(sta->ampdu_mlme.tid_tx[tid]))
                return;
 
-       ieee80211_start_tx_ba_session(pubsta, tid, 5000);
+       ieee80211_start_tx_ba_session(pubsta, tid, 0);
 }
 
 static void
@@ -871,7 +872,7 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
         *  - if station is in dynamic SMPS (and streams > 1)
         *  - for fallback rates, to increase chances of getting through
         */
-       if (offset > 0 &&
+       if (offset > 0 ||
            (mi->sta->smps_mode == IEEE80211_SMPS_DYNAMIC &&
             group->streams > 1)) {
                ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts;
@@ -1334,7 +1335,8 @@ static u32 minstrel_ht_get_expected_throughput(void *priv_sta)
        prob = mi->groups[i].rates[j].prob_ewma;
 
        /* convert tp_avg from pkt per second in kbps */
-       tp_avg = minstrel_ht_get_tp_avg(mi, i, j, prob) * AVG_PKT_SIZE * 8 / 1024;
+       tp_avg = minstrel_ht_get_tp_avg(mi, i, j, prob) * 10;
+       tp_avg = tp_avg * AVG_PKT_SIZE * 8 / 1024;
 
        return tp_avg;
 }
index bc08185..60d093f 100644 (file)
@@ -1753,7 +1753,7 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
        entry->seq = seq;
        entry->rx_queue = rx_queue;
        entry->last_frag = frag;
-       entry->ccmp = 0;
+       entry->check_sequential_pn = false;
        entry->extra_len = 0;
 
        return entry;
@@ -1849,15 +1849,27 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
                                                 rx->seqno_idx, &(rx->skb));
                if (rx->key &&
                    (rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP ||
-                    rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP_256) &&
+                    rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP_256 ||
+                    rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP ||
+                    rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP_256) &&
                    ieee80211_has_protected(fc)) {
                        int queue = rx->security_idx;
-                       /* Store CCMP PN so that we can verify that the next
-                        * fragment has a sequential PN value. */
-                       entry->ccmp = 1;
+
+                       /* Store CCMP/GCMP PN so that we can verify that the
+                        * next fragment has a sequential PN value.
+                        */
+                       entry->check_sequential_pn = true;
                        memcpy(entry->last_pn,
                               rx->key->u.ccmp.rx_pn[queue],
                               IEEE80211_CCMP_PN_LEN);
+                       BUILD_BUG_ON(offsetof(struct ieee80211_key,
+                                             u.ccmp.rx_pn) !=
+                                    offsetof(struct ieee80211_key,
+                                             u.gcmp.rx_pn));
+                       BUILD_BUG_ON(sizeof(rx->key->u.ccmp.rx_pn[queue]) !=
+                                    sizeof(rx->key->u.gcmp.rx_pn[queue]));
+                       BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN !=
+                                    IEEE80211_GCMP_PN_LEN);
                }
                return RX_QUEUED;
        }
@@ -1872,15 +1884,21 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
                return RX_DROP_MONITOR;
        }
 
-       /* Verify that MPDUs within one MSDU have sequential PN values.
-        * (IEEE 802.11i, 8.3.3.4.5) */
-       if (entry->ccmp) {
+       /* "The receiver shall discard MSDUs and MMPDUs whose constituent
+        *  MPDU PN values are not incrementing in steps of 1."
+        * see IEEE P802.11-REVmc/D5.0, 12.5.3.4.4, item d (for CCMP)
+        * and IEEE P802.11-REVmc/D5.0, 12.5.5.4.4, item d (for GCMP)
+        */
+       if (entry->check_sequential_pn) {
                int i;
                u8 pn[IEEE80211_CCMP_PN_LEN], *rpn;
                int queue;
+
                if (!rx->key ||
                    (rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP &&
-                    rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP_256))
+                    rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP_256 &&
+                    rx->key->conf.cipher != WLAN_CIPHER_SUITE_GCMP &&
+                    rx->key->conf.cipher != WLAN_CIPHER_SUITE_GCMP_256))
                        return RX_DROP_UNUSABLE;
                memcpy(pn, entry->last_pn, IEEE80211_CCMP_PN_LEN);
                for (i = IEEE80211_CCMP_PN_LEN - 1; i >= 0; i--) {
@@ -3366,6 +3384,7 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)
                                return false;
                        /* ignore action frames to TDLS-peers */
                        if (ieee80211_is_action(hdr->frame_control) &&
+                           !is_broadcast_ether_addr(bssid) &&
                            !ether_addr_equal(bssid, hdr->addr1))
                                return false;
                }
index 8c067e6..95e757c 100644 (file)
@@ -891,7 +891,7 @@ config NETFILTER_XT_TARGET_TEE
        depends on IPV6 || IPV6=n
        depends on !NF_CONNTRACK || NF_CONNTRACK
        select NF_DUP_IPV4
-       select NF_DUP_IPV6 if IP6_NF_IPTABLES != n
+       select NF_DUP_IPV6 if IPV6
        ---help---
        This option adds a "TEE" target with which a packet can be cloned and
        this clone be rerouted to another nexthop.
index 58882de..f60b4fd 100644 (file)
@@ -1412,6 +1412,7 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data),
                }
                spin_unlock(lockp);
                local_bh_enable();
+               cond_resched();
        }
 
        for_each_possible_cpu(cpu) {
@@ -1424,6 +1425,7 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data),
                                set_bit(IPS_DYING_BIT, &ct->status);
                }
                spin_unlock_bh(&pcpu->lock);
+               cond_resched();
        }
        return NULL;
 found:
@@ -1440,6 +1442,8 @@ void nf_ct_iterate_cleanup(struct net *net,
        struct nf_conn *ct;
        unsigned int bucket = 0;
 
+       might_sleep();
+
        while ((ct = get_next_corpse(net, iter, data, &bucket)) != NULL) {
                /* Time to push up daises... */
                if (del_timer(&ct->timeout))
@@ -1448,6 +1452,7 @@ void nf_ct_iterate_cleanup(struct net *net,
                /* ... else the timer will get him soon. */
 
                nf_ct_put(ct);
+               cond_resched();
        }
 }
 EXPORT_SYMBOL_GPL(nf_ct_iterate_cleanup);
index a7ba233..857ae89 100644 (file)
@@ -311,14 +311,14 @@ replay:
 #endif
                {
                        nfnl_unlock(subsys_id);
-                       netlink_ack(skb, nlh, -EOPNOTSUPP);
+                       netlink_ack(oskb, nlh, -EOPNOTSUPP);
                        return kfree_skb(skb);
                }
        }
 
        if (!ss->commit || !ss->abort) {
                nfnl_unlock(subsys_id);
-               netlink_ack(skb, nlh, -EOPNOTSUPP);
+               netlink_ack(oskb, nlh, -EOPNOTSUPP);
                return kfree_skb(skb);
        }
 
@@ -328,10 +328,12 @@ replay:
                nlh = nlmsg_hdr(skb);
                err = 0;
 
-               if (nlmsg_len(nlh) < sizeof(struct nfgenmsg) ||
-                   skb->len < nlh->nlmsg_len) {
-                       err = -EINVAL;
-                       goto ack;
+               if (nlh->nlmsg_len < NLMSG_HDRLEN ||
+                   skb->len < nlh->nlmsg_len ||
+                   nlmsg_len(nlh) < sizeof(struct nfgenmsg)) {
+                       nfnl_err_reset(&err_list);
+                       status |= NFNL_BATCH_FAILURE;
+                       goto done;
                }
 
                /* Only requests are handled by the kernel */
@@ -406,7 +408,7 @@ ack:
                                 * pointing to the batch header.
                                 */
                                nfnl_err_reset(&err_list);
-                               netlink_ack(skb, nlmsg_hdr(oskb), -ENOMEM);
+                               netlink_ack(oskb, nlmsg_hdr(oskb), -ENOMEM);
                                status |= NFNL_BATCH_FAILURE;
                                goto done;
                        }
index 94837d2..2671b9d 100644 (file)
@@ -312,7 +312,7 @@ static void ctnl_untimeout(struct net *net, struct ctnl_timeout *timeout)
                        hlist_nulls_for_each_entry(h, nn, &net->ct.hash[i], hnnode)
                                untimeout(h, timeout);
                }
-               nf_conntrack_lock(&nf_conntrack_locks[i % CONNTRACK_LOCKS]);
+               spin_unlock(&nf_conntrack_locks[i % CONNTRACK_LOCKS]);
        }
        local_bh_enable();
 }
index c7808fc..c9743f7 100644 (file)
@@ -100,7 +100,7 @@ static int nft_counter_init(const struct nft_ctx *ctx,
 
        cpu_stats = netdev_alloc_pcpu_stats(struct nft_counter_percpu);
        if (cpu_stats == NULL)
-               return ENOMEM;
+               return -ENOMEM;
 
        preempt_disable();
        this_cpu = this_cpu_ptr(cpu_stats);
@@ -138,7 +138,7 @@ static int nft_counter_clone(struct nft_expr *dst, const struct nft_expr *src)
        cpu_stats = __netdev_alloc_pcpu_stats(struct nft_counter_percpu,
                                              GFP_ATOMIC);
        if (cpu_stats == NULL)
-               return ENOMEM;
+               return -ENOMEM;
 
        preempt_disable();
        this_cpu = this_cpu_ptr(cpu_stats);
index 3eff7b6..6e57a39 100644 (file)
@@ -38,7 +38,7 @@ tee_tg4(struct sk_buff *skb, const struct xt_action_param *par)
        return XT_CONTINUE;
 }
 
-#if IS_ENABLED(CONFIG_NF_DUP_IPV6)
+#if IS_ENABLED(CONFIG_IPV6)
 static unsigned int
 tee_tg6(struct sk_buff *skb, const struct xt_action_param *par)
 {
@@ -131,7 +131,7 @@ static struct xt_target tee_tg_reg[] __read_mostly = {
                .destroy    = tee_tg_destroy,
                .me         = THIS_MODULE,
        },
-#if IS_ENABLED(CONFIG_NF_DUP_IPV6)
+#if IS_ENABLED(CONFIG_IPV6)
        {
                .name       = "TEE",
                .revision   = 1,
index 1605691..5eb7694 100644 (file)
@@ -90,7 +90,9 @@ static struct vport *vxlan_tnl_create(const struct vport_parms *parms)
        int err;
        struct vxlan_config conf = {
                .no_share = true,
-               .flags = VXLAN_F_COLLECT_METADATA,
+               .flags = VXLAN_F_COLLECT_METADATA | VXLAN_F_UDP_ZERO_CSUM6_RX,
+               /* Don't restrict the packets that can be sent by MTU */
+               .mtu = IP_MAX_MTU,
        };
 
        if (!options) {
index d058696..6b70399 100644 (file)
@@ -62,6 +62,7 @@ static void ipt_destroy_target(struct xt_entry_target *t)
        struct xt_tgdtor_param par = {
                .target   = t->u.kernel.target,
                .targinfo = t->data,
+               .family   = NFPROTO_IPV4,
        };
        if (par.target->destroy != NULL)
                par.target->destroy(&par);
@@ -195,6 +196,7 @@ static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a,
        par.hooknum  = ipt->tcfi_hook;
        par.target   = ipt->tcfi_t->u.kernel.target;
        par.targinfo = ipt->tcfi_t->data;
+       par.family   = NFPROTO_IPV4;
        ret = par.target->target(skb, &par);
 
        switch (ret) {
index b5c2cf2..af1acf0 100644 (file)
@@ -1852,6 +1852,7 @@ reset:
        }
 
        tp = old_tp;
+       protocol = tc_skb_protocol(skb);
        goto reclassify;
 #endif
 }
index ec52912..ce46f1c 100644 (file)
@@ -526,6 +526,8 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
                }
                return 0;
        }
+       if (addr1->v6.sin6_port != addr2->v6.sin6_port)
+               return 0;
        if (!ipv6_addr_equal(&addr1->v6.sin6_addr, &addr2->v6.sin6_addr))
                return 0;
        /* If this is a linklocal address, compare the scope_id. */
index ded7d93..963dffc 100644 (file)
@@ -482,7 +482,7 @@ static void sctp_remaddr_seq_stop(struct seq_file *seq, void *v)
 static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
 {
        struct sctp_association *assoc;
-       struct sctp_transport *tsp;
+       struct sctp_transport *transport, *tsp;
 
        if (v == SEQ_START_TOKEN) {
                seq_printf(seq, "ADDR ASSOC_ID HB_ACT RTO MAX_PATH_RTX "
@@ -490,10 +490,10 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
                return 0;
        }
 
-       tsp = (struct sctp_transport *)v;
-       if (!sctp_transport_hold(tsp))
+       transport = (struct sctp_transport *)v;
+       if (!sctp_transport_hold(transport))
                return 0;
-       assoc = tsp->asoc;
+       assoc = transport->asoc;
 
        list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list,
                                transports) {
@@ -546,7 +546,7 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
                seq_printf(seq, "\n");
        }
 
-       sctp_transport_put(tsp);
+       sctp_transport_put(transport);
 
        return 0;
 }
index ab0d538..1099e99 100644 (file)
@@ -60,6 +60,8 @@
 #include <net/inet_common.h>
 #include <net/inet_ecn.h>
 
+#define MAX_SCTP_PORT_HASH_ENTRIES (64 * 1024)
+
 /* Global data structures. */
 struct sctp_globals sctp_globals __read_mostly;
 
@@ -1355,6 +1357,8 @@ static __init int sctp_init(void)
        unsigned long limit;
        int max_share;
        int order;
+       int num_entries;
+       int max_entry_order;
 
        sock_skb_cb_check_size(sizeof(struct sctp_ulpevent));
 
@@ -1407,14 +1411,24 @@ static __init int sctp_init(void)
 
        /* Size and allocate the association hash table.
         * The methodology is similar to that of the tcp hash tables.
+        * Though not identical.  Start by getting a goal size
         */
        if (totalram_pages >= (128 * 1024))
                goal = totalram_pages >> (22 - PAGE_SHIFT);
        else
                goal = totalram_pages >> (24 - PAGE_SHIFT);
 
-       for (order = 0; (1UL << order) < goal; order++)
-               ;
+       /* Then compute the page order for said goal */
+       order = get_order(goal);
+
+       /* Now compute the required page order for the maximum sized table we
+        * want to create
+        */
+       max_entry_order = get_order(MAX_SCTP_PORT_HASH_ENTRIES *
+                                   sizeof(struct sctp_bind_hashbucket));
+
+       /* Limit the page order by that maximum hash table size */
+       order = min(order, max_entry_order);
 
        /* Allocate and initialize the endpoint hash table.  */
        sctp_ep_hashsize = 64;
@@ -1430,20 +1444,35 @@ static __init int sctp_init(void)
                INIT_HLIST_HEAD(&sctp_ep_hashtable[i].chain);
        }
 
-       /* Allocate and initialize the SCTP port hash table.  */
+       /* Allocate and initialize the SCTP port hash table.
+        * Note that order is initalized to start at the max sized
+        * table we want to support.  If we can't get that many pages
+        * reduce the order and try again
+        */
        do {
-               sctp_port_hashsize = (1UL << order) * PAGE_SIZE /
-                                       sizeof(struct sctp_bind_hashbucket);
-               if ((sctp_port_hashsize > (64 * 1024)) && order > 0)
-                       continue;
                sctp_port_hashtable = (struct sctp_bind_hashbucket *)
                        __get_free_pages(GFP_KERNEL | __GFP_NOWARN, order);
        } while (!sctp_port_hashtable && --order > 0);
+
        if (!sctp_port_hashtable) {
                pr_err("Failed bind hash alloc\n");
                status = -ENOMEM;
                goto err_bhash_alloc;
        }
+
+       /* Now compute the number of entries that will fit in the
+        * port hash space we allocated
+        */
+       num_entries = (1UL << order) * PAGE_SIZE /
+                     sizeof(struct sctp_bind_hashbucket);
+
+       /* And finish by rounding it down to the nearest power of two
+        * this wastes some memory of course, but its needed because
+        * the hash function operates based on the assumption that
+        * that the number of entries is a power of two
+        */
+       sctp_port_hashsize = rounddown_pow_of_two(num_entries);
+
        for (i = 0; i < sctp_port_hashsize; i++) {
                spin_lock_init(&sctp_port_hashtable[i].lock);
                INIT_HLIST_HEAD(&sctp_port_hashtable[i].chain);
@@ -1452,7 +1481,8 @@ static __init int sctp_init(void)
        if (sctp_transport_hashtable_init())
                goto err_thash_alloc;
 
-       pr_info("Hash tables configured (bind %d)\n", sctp_port_hashsize);
+       pr_info("Hash tables configured (bind %d/%d)\n", sctp_port_hashsize,
+               num_entries);
 
        sctp_sysctl_register();
 
index 5ca2ebf..e878da0 100644 (file)
@@ -5538,6 +5538,7 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,
        struct sctp_hmac_algo_param *hmacs;
        __u16 data_len = 0;
        u32 num_idents;
+       int i;
 
        if (!ep->auth_enable)
                return -EACCES;
@@ -5555,8 +5556,12 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,
                return -EFAULT;
        if (put_user(num_idents, &p->shmac_num_idents))
                return -EFAULT;
-       if (copy_to_user(p->shmac_idents, hmacs->hmac_ids, data_len))
-               return -EFAULT;
+       for (i = 0; i < num_idents; i++) {
+               __u16 hmacid = ntohs(hmacs->hmac_ids[i]);
+
+               if (copy_to_user(&p->shmac_idents[i], &hmacid, sizeof(__u16)))
+                       return -EFAULT;
+       }
        return 0;
 }
 
index 799e65b..cabf586 100644 (file)
@@ -740,7 +740,7 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
                default:
                        printk(KERN_CRIT "%s: bad return from "
                                "gss_fill_context: %zd\n", __func__, err);
-                       BUG();
+                       gss_msg->msg.errno = -EIO;
                }
                goto err_release_msg;
        }
index 2b32fd6..273bc3a 100644 (file)
@@ -1225,7 +1225,7 @@ int qword_get(char **bpp, char *dest, int bufsize)
        if (bp[0] == '\\' && bp[1] == 'x') {
                /* HEX STRING */
                bp += 2;
-               while (len < bufsize) {
+               while (len < bufsize - 1) {
                        int h, l;
 
                        h = hex_to_bin(bp[0]);
index cc1251d..2dcd764 100644 (file)
@@ -341,6 +341,8 @@ void rpcrdma_bc_receive_call(struct rpcrdma_xprt *r_xprt,
        rqst->rq_reply_bytes_recvd = 0;
        rqst->rq_bytes_sent = 0;
        rqst->rq_xid = headerp->rm_xid;
+
+       rqst->rq_private_buf.len = size;
        set_bit(RPC_BC_PA_IN_USE, &rqst->rq_bc_pa_state);
 
        buf = &rqst->rq_rcv_buf;
index 47f7da5..8b5833c 100644 (file)
@@ -1093,8 +1093,11 @@ int switchdev_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb,
                .cb = cb,
                .idx = idx,
        };
+       int err;
 
-       switchdev_port_obj_dump(dev, &dump.fdb.obj, switchdev_port_fdb_dump_cb);
+       err = switchdev_port_obj_dump(dev, &dump.fdb.obj,
+                                     switchdev_port_fdb_dump_cb);
+       cb->args[1] = err;
        return dump.idx;
 }
 EXPORT_SYMBOL_GPL(switchdev_port_fdb_dump);
index 0c2944f..347cdc9 100644 (file)
@@ -1973,8 +1973,10 @@ int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg)
 
        hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
                          NLM_F_MULTI, TIPC_NL_LINK_GET);
-       if (!hdr)
+       if (!hdr) {
+               tipc_bcast_unlock(net);
                return -EMSGSIZE;
+       }
 
        attrs = nla_nest_start(msg->skb, TIPC_NLA_LINK);
        if (!attrs)
index fa97d96..9d7a16f 100644 (file)
@@ -346,12 +346,6 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr, u16 capabilities)
        skb_queue_head_init(&n->bc_entry.inputq2);
        for (i = 0; i < MAX_BEARERS; i++)
                spin_lock_init(&n->links[i].lock);
-       hlist_add_head_rcu(&n->hash, &tn->node_htable[tipc_hashfn(addr)]);
-       list_for_each_entry_rcu(temp_node, &tn->node_list, list) {
-               if (n->addr < temp_node->addr)
-                       break;
-       }
-       list_add_tail_rcu(&n->list, &temp_node->list);
        n->state = SELF_DOWN_PEER_LEAVING;
        n->signature = INVALID_NODE_SIG;
        n->active_links[0] = INVALID_BEARER_ID;
@@ -372,6 +366,12 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr, u16 capabilities)
        tipc_node_get(n);
        setup_timer(&n->timer, tipc_node_timeout, (unsigned long)n);
        n->keepalive_intv = U32_MAX;
+       hlist_add_head_rcu(&n->hash, &tn->node_htable[tipc_hashfn(addr)]);
+       list_for_each_entry_rcu(temp_node, &tn->node_list, list) {
+               if (n->addr < temp_node->addr)
+                       break;
+       }
+       list_add_tail_rcu(&n->list, &temp_node->list);
 exit:
        spin_unlock_bh(&tn->node_list_lock);
        return n;
index 69c2905..4d420bb 100644 (file)
@@ -673,7 +673,7 @@ static int tipc_sendmcast(struct  socket *sock, struct tipc_name_seq *seq,
        struct tipc_sock *tsk = tipc_sk(sk);
        struct net *net = sock_net(sk);
        struct tipc_msg *mhdr = &tsk->phdr;
-       struct sk_buff_head *pktchain = &sk->sk_write_queue;
+       struct sk_buff_head pktchain;
        struct iov_iter save = msg->msg_iter;
        uint mtu;
        int rc;
@@ -687,14 +687,16 @@ static int tipc_sendmcast(struct  socket *sock, struct tipc_name_seq *seq,
        msg_set_nameupper(mhdr, seq->upper);
        msg_set_hdr_sz(mhdr, MCAST_H_SIZE);
 
+       skb_queue_head_init(&pktchain);
+
 new_mtu:
        mtu = tipc_bcast_get_mtu(net);
-       rc = tipc_msg_build(mhdr, msg, 0, dsz, mtu, pktchain);
+       rc = tipc_msg_build(mhdr, msg, 0, dsz, mtu, &pktchain);
        if (unlikely(rc < 0))
                return rc;
 
        do {
-               rc = tipc_bcast_xmit(net, pktchain);
+               rc = tipc_bcast_xmit(net, &pktchain);
                if (likely(!rc))
                        return dsz;
 
@@ -704,7 +706,7 @@ new_mtu:
                        if (!rc)
                                continue;
                }
-               __skb_queue_purge(pktchain);
+               __skb_queue_purge(&pktchain);
                if (rc == -EMSGSIZE) {
                        msg->msg_iter = save;
                        goto new_mtu;
@@ -863,7 +865,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz)
        struct net *net = sock_net(sk);
        struct tipc_msg *mhdr = &tsk->phdr;
        u32 dnode, dport;
-       struct sk_buff_head *pktchain = &sk->sk_write_queue;
+       struct sk_buff_head pktchain;
        struct sk_buff *skb;
        struct tipc_name_seq *seq;
        struct iov_iter save;
@@ -924,17 +926,18 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz)
                msg_set_hdr_sz(mhdr, BASIC_H_SIZE);
        }
 
+       skb_queue_head_init(&pktchain);
        save = m->msg_iter;
 new_mtu:
        mtu = tipc_node_get_mtu(net, dnode, tsk->portid);
-       rc = tipc_msg_build(mhdr, m, 0, dsz, mtu, pktchain);
+       rc = tipc_msg_build(mhdr, m, 0, dsz, mtu, &pktchain);
        if (rc < 0)
                return rc;
 
        do {
-               skb = skb_peek(pktchain);
+               skb = skb_peek(&pktchain);
                TIPC_SKB_CB(skb)->wakeup_pending = tsk->link_cong;
-               rc = tipc_node_xmit(net, pktchain, dnode, tsk->portid);
+               rc = tipc_node_xmit(net, &pktchain, dnode, tsk->portid);
                if (likely(!rc)) {
                        if (sock->state != SS_READY)
                                sock->state = SS_CONNECTING;
@@ -946,7 +949,7 @@ new_mtu:
                        if (!rc)
                                continue;
                }
-               __skb_queue_purge(pktchain);
+               __skb_queue_purge(&pktchain);
                if (rc == -EMSGSIZE) {
                        m->msg_iter = save;
                        goto new_mtu;
@@ -1016,7 +1019,7 @@ static int __tipc_send_stream(struct socket *sock, struct msghdr *m, size_t dsz)
        struct net *net = sock_net(sk);
        struct tipc_sock *tsk = tipc_sk(sk);
        struct tipc_msg *mhdr = &tsk->phdr;
-       struct sk_buff_head *pktchain = &sk->sk_write_queue;
+       struct sk_buff_head pktchain;
        DECLARE_SOCKADDR(struct sockaddr_tipc *, dest, m->msg_name);
        u32 portid = tsk->portid;
        int rc = -EINVAL;
@@ -1044,17 +1047,19 @@ static int __tipc_send_stream(struct socket *sock, struct msghdr *m, size_t dsz)
 
        timeo = sock_sndtimeo(sk, m->msg_flags & MSG_DONTWAIT);
        dnode = tsk_peer_node(tsk);
+       skb_queue_head_init(&pktchain);
 
 next:
        save = m->msg_iter;
        mtu = tsk->max_pkt;
        send = min_t(uint, dsz - sent, TIPC_MAX_USER_MSG_SIZE);
-       rc = tipc_msg_build(mhdr, m, sent, send, mtu, pktchain);
+       rc = tipc_msg_build(mhdr, m, sent, send, mtu, &pktchain);
        if (unlikely(rc < 0))
                return rc;
+
        do {
                if (likely(!tsk_conn_cong(tsk))) {
-                       rc = tipc_node_xmit(net, pktchain, dnode, portid);
+                       rc = tipc_node_xmit(net, &pktchain, dnode, portid);
                        if (likely(!rc)) {
                                tsk->sent_unacked++;
                                sent += send;
@@ -1063,7 +1068,7 @@ next:
                                goto next;
                        }
                        if (rc == -EMSGSIZE) {
-                               __skb_queue_purge(pktchain);
+                               __skb_queue_purge(&pktchain);
                                tsk->max_pkt = tipc_node_get_mtu(net, dnode,
                                                                 portid);
                                m->msg_iter = save;
@@ -1077,7 +1082,7 @@ next:
                rc = tipc_wait_for_sndpkt(sock, &timeo);
        } while (!rc);
 
-       __skb_queue_purge(pktchain);
+       __skb_queue_purge(&pktchain);
        return sent ? sent : rc;
 }
 
index 69ee2ee..f9ff73a 100644 (file)
@@ -296,7 +296,8 @@ static void tipc_subscrb_rcv_cb(struct net *net, int conid,
        if (tipc_subscrp_create(net, (struct tipc_subscr *)buf, subscrb, &sub))
                return tipc_conn_terminate(tn->topsrv, subscrb->conid);
 
-       tipc_nametbl_subscribe(sub);
+       if (sub)
+               tipc_nametbl_subscribe(sub);
 }
 
 /* Handle one request to establish a new subscriber */
index 49d5093..f75f847 100644 (file)
@@ -1496,7 +1496,7 @@ static void unix_detach_fds(struct scm_cookie *scm, struct sk_buff *skb)
        UNIXCB(skb).fp = NULL;
 
        for (i = scm->fp->count-1; i >= 0; i--)
-               unix_notinflight(scm->fp->fp[i]);
+               unix_notinflight(scm->fp->user, scm->fp->fp[i]);
 }
 
 static void unix_destruct_scm(struct sk_buff *skb)
@@ -1561,7 +1561,7 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
                return -ENOMEM;
 
        for (i = scm->fp->count - 1; i >= 0; i--)
-               unix_inflight(scm->fp->fp[i]);
+               unix_inflight(scm->fp->user, scm->fp->fp[i]);
        return max_level;
 }
 
@@ -1781,7 +1781,12 @@ restart_locked:
                        goto out_unlock;
        }
 
-       if (unlikely(unix_peer(other) != sk && unix_recvq_full(other))) {
+       /* other == sk && unix_peer(other) != sk if
+        * - unix_peer(sk) == NULL, destination address bound to sk
+        * - unix_peer(sk) == sk by time of get but disconnected before lock
+        */
+       if (other != sk &&
+           unlikely(unix_peer(other) != sk && unix_recvq_full(other))) {
                if (timeo) {
                        timeo = unix_wait_for_peer(other, timeo);
 
@@ -2277,13 +2282,15 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state)
        size_t size = state->size;
        unsigned int last_len;
 
-       err = -EINVAL;
-       if (sk->sk_state != TCP_ESTABLISHED)
+       if (unlikely(sk->sk_state != TCP_ESTABLISHED)) {
+               err = -EINVAL;
                goto out;
+       }
 
-       err = -EOPNOTSUPP;
-       if (flags & MSG_OOB)
+       if (unlikely(flags & MSG_OOB)) {
+               err = -EOPNOTSUPP;
                goto out;
+       }
 
        target = sock_rcvlowat(sk, flags & MSG_WAITALL, size);
        timeo = sock_rcvtimeo(sk, noblock);
@@ -2305,6 +2312,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state)
                bool drop_skb;
                struct sk_buff *skb, *last;
 
+redo:
                unix_state_lock(sk);
                if (sock_flag(sk, SOCK_DEAD)) {
                        err = -ECONNRESET;
@@ -2329,9 +2337,11 @@ again:
                                goto unlock;
 
                        unix_state_unlock(sk);
-                       err = -EAGAIN;
-                       if (!timeo)
+                       if (!timeo) {
+                               err = -EAGAIN;
                                break;
+                       }
+
                        mutex_unlock(&u->readlock);
 
                        timeo = unix_stream_data_wait(sk, timeo, last,
@@ -2344,7 +2354,7 @@ again:
                        }
 
                        mutex_lock(&u->readlock);
-                       continue;
+                       goto redo;
 unlock:
                        unix_state_unlock(sk);
                        break;
index c512f64..4d96797 100644 (file)
@@ -220,7 +220,7 @@ done:
        return skb->len;
 }
 
-static struct sock *unix_lookup_by_ino(int ino)
+static struct sock *unix_lookup_by_ino(unsigned int ino)
 {
        int i;
        struct sock *sk;
index 8fcdc22..6a0d485 100644 (file)
@@ -116,7 +116,7 @@ struct sock *unix_get_socket(struct file *filp)
  * descriptor if it is for an AF_UNIX socket.
  */
 
-void unix_inflight(struct file *fp)
+void unix_inflight(struct user_struct *user, struct file *fp)
 {
        struct sock *s = unix_get_socket(fp);
 
@@ -133,11 +133,11 @@ void unix_inflight(struct file *fp)
                }
                unix_tot_inflight++;
        }
-       fp->f_cred->user->unix_inflight++;
+       user->unix_inflight++;
        spin_unlock(&unix_gc_lock);
 }
 
-void unix_notinflight(struct file *fp)
+void unix_notinflight(struct user_struct *user, struct file *fp)
 {
        struct sock *s = unix_get_socket(fp);
 
@@ -152,7 +152,7 @@ void unix_notinflight(struct file *fp)
                        list_del_init(&u->link);
                unix_tot_inflight--;
        }
-       fp->f_cred->user->unix_inflight--;
+       user->unix_inflight--;
        spin_unlock(&unix_gc_lock);
 }
 
index 7fd1220..bbe65dc 100644 (file)
@@ -1557,8 +1557,6 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
        if (err < 0)
                goto out;
 
-       prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
-
        while (total_written < len) {
                ssize_t written;
 
@@ -1578,7 +1576,9 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
                                goto out_wait;
 
                        release_sock(sk);
+                       prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
                        timeout = schedule_timeout(timeout);
+                       finish_wait(sk_sleep(sk), &wait);
                        lock_sock(sk);
                        if (signal_pending(current)) {
                                err = sock_intr_errno(timeout);
@@ -1588,8 +1588,6 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
                                goto out_wait;
                        }
 
-                       prepare_to_wait(sk_sleep(sk), &wait,
-                                       TASK_INTERRUPTIBLE);
                }
 
                /* These checks occur both as part of and after the loop
@@ -1635,7 +1633,6 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
 out_wait:
        if (total_written > 0)
                err = total_written;
-       finish_wait(sk_sleep(sk), &wait);
 out:
        release_sock(sk);
        return err;
@@ -1716,7 +1713,6 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
        if (err < 0)
                goto out;
 
-       prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
 
        while (1) {
                s64 ready = vsock_stream_has_data(vsk);
@@ -1727,7 +1723,7 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
                         */
 
                        err = -ENOMEM;
-                       goto out_wait;
+                       goto out;
                } else if (ready > 0) {
                        ssize_t read;
 
@@ -1750,7 +1746,7 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
                                        vsk, target, read,
                                        !(flags & MSG_PEEK), &recv_data);
                        if (err < 0)
-                               goto out_wait;
+                               goto out;
 
                        if (read >= target || flags & MSG_PEEK)
                                break;
@@ -1773,7 +1769,9 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
                                break;
 
                        release_sock(sk);
+                       prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
                        timeout = schedule_timeout(timeout);
+                       finish_wait(sk_sleep(sk), &wait);
                        lock_sock(sk);
 
                        if (signal_pending(current)) {
@@ -1783,9 +1781,6 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
                                err = -EAGAIN;
                                break;
                        }
-
-                       prepare_to_wait(sk_sleep(sk), &wait,
-                                       TASK_INTERRUPTIBLE);
                }
        }
 
@@ -1816,8 +1811,6 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
                err = copied;
        }
 
-out_wait:
-       finish_wait(sk_sleep(sk), &wait);
 out:
        release_sock(sk);
        return err;
index b091551..8f0bac7 100644 (file)
@@ -1147,6 +1147,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
                return NOTIFY_DONE;
        }
 
+       wireless_nlevent_flush();
+
        return NOTIFY_OK;
 }
 
index d4786f2..711cb7a 100644 (file)
@@ -7547,7 +7547,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
 
                if ((ibss.chandef.width != NL80211_CHAN_WIDTH_20_NOHT) &&
                    no_ht) {
-                       kfree(connkeys);
+                       kzfree(connkeys);
                        return -EINVAL;
                }
        }
index 8020b5b..d49ed76 100644 (file)
@@ -917,6 +917,12 @@ void __cfg80211_disconnected(struct net_device *dev, const u8 *ie,
 
        nl80211_send_disconnected(rdev, dev, reason, ie, ie_len, from_ap);
 
+       /* stop critical protocol if supported */
+       if (rdev->ops->crit_proto_stop && rdev->crit_proto_nlportid) {
+               rdev->crit_proto_nlportid = 0;
+               rdev_crit_proto_stop(rdev, wdev);
+       }
+
        /*
         * Delete all the keys ... pairwise keys can't really
         * exist any more anyway, but default keys might.
index c8717c1..b50ee5d 100644 (file)
@@ -342,6 +342,40 @@ static const int compat_event_type_size[] = {
 
 /* IW event code */
 
+void wireless_nlevent_flush(void)
+{
+       struct sk_buff *skb;
+       struct net *net;
+
+       ASSERT_RTNL();
+
+       for_each_net(net) {
+               while ((skb = skb_dequeue(&net->wext_nlevents)))
+                       rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL,
+                                   GFP_KERNEL);
+       }
+}
+EXPORT_SYMBOL_GPL(wireless_nlevent_flush);
+
+static int wext_netdev_notifier_call(struct notifier_block *nb,
+                                    unsigned long state, void *ptr)
+{
+       /*
+        * When a netdev changes state in any way, flush all pending messages
+        * to avoid them going out in a strange order, e.g. RTM_NEWLINK after
+        * RTM_DELLINK, or with IFF_UP after without IFF_UP during dev_close()
+        * or similar - all of which could otherwise happen due to delays from
+        * schedule_work().
+        */
+       wireless_nlevent_flush();
+
+       return NOTIFY_OK;
+}
+
+static struct notifier_block wext_netdev_notifier = {
+       .notifier_call = wext_netdev_notifier_call,
+};
+
 static int __net_init wext_pernet_init(struct net *net)
 {
        skb_queue_head_init(&net->wext_nlevents);
@@ -360,7 +394,12 @@ static struct pernet_operations wext_pernet_ops = {
 
 static int __init wireless_nlevent_init(void)
 {
-       return register_pernet_subsys(&wext_pernet_ops);
+       int err = register_pernet_subsys(&wext_pernet_ops);
+
+       if (err)
+               return err;
+
+       return register_netdevice_notifier(&wext_netdev_notifier);
 }
 
 subsys_initcall(wireless_nlevent_init);
@@ -368,17 +407,8 @@ subsys_initcall(wireless_nlevent_init);
 /* Process events generated by the wireless layer or the driver. */
 static void wireless_nlevent_process(struct work_struct *work)
 {
-       struct sk_buff *skb;
-       struct net *net;
-
        rtnl_lock();
-
-       for_each_net(net) {
-               while ((skb = skb_dequeue(&net->wext_nlevents)))
-                       rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL,
-                                   GFP_KERNEL);
-       }
-
+       wireless_nlevent_flush();
        rtnl_unlock();
 }
 
diff --git a/scripts/prune-kernel b/scripts/prune-kernel
new file mode 100755 (executable)
index 0000000..ab5034e
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# because I use CONFIG_LOCALVERSION_AUTO, not the same version again and
+# again, /boot and /lib/modules/ eventually fill up.
+# Dumb script to purge that stuff:
+
+for f in "$@"
+do
+        if rpm -qf "/lib/modules/$f" >/dev/null; then
+                echo "keeping $f (installed from rpm)"
+        elif [ $(uname -r) = "$f" ]; then
+                echo "keeping $f (running kernel) "
+        else
+                echo "removing $f"
+                rm -f "/boot/initramfs-$f.img" "/boot/System.map-$f"
+                rm -f "/boot/vmlinuz-$f"   "/boot/config-$f"
+                rm -rf "/lib/modules/$f"
+                new-kernel-pkg --remove $f
+        fi
+done
index f716025..e6ea9d4 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/integrity.h>
 #include <linux/evm.h>
 #include <crypto/hash.h>
+#include <crypto/algapi.h>
 #include "evm.h"
 
 int evm_initialized;
@@ -148,7 +149,7 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
                                   xattr_value_len, calc.digest);
                if (rc)
                        break;
-               rc = memcmp(xattr_data->digest, calc.digest,
+               rc = crypto_memneq(xattr_data->digest, calc.digest,
                            sizeof(calc.digest));
                if (rc)
                        rc = -EINVAL;
index f8110cf..f1ab715 100644 (file)
@@ -3249,7 +3249,7 @@ static int selinux_inode_listsecurity(struct inode *inode, char *buffer, size_t
 
 static void selinux_inode_getsecid(struct inode *inode, u32 *secid)
 {
-       struct inode_security_struct *isec = inode_security(inode);
+       struct inode_security_struct *isec = inode_security_novalidate(inode);
        *secid = isec->sid;
 }
 
index 2bbb418..8495b93 100644 (file)
@@ -83,6 +83,7 @@ static struct nlmsg_perm nlmsg_tcpdiag_perms[] =
        { TCPDIAG_GETSOCK,      NETLINK_TCPDIAG_SOCKET__NLMSG_READ },
        { DCCPDIAG_GETSOCK,     NETLINK_TCPDIAG_SOCKET__NLMSG_READ },
        { SOCK_DIAG_BY_FAMILY,  NETLINK_TCPDIAG_SOCKET__NLMSG_READ },
+       { SOCK_DESTROY,         NETLINK_TCPDIAG_SOCKET__NLMSG_WRITE },
 };
 
 static struct nlmsg_perm nlmsg_xfrm_perms[] =
index b9c0910..0608f21 100644 (file)
@@ -170,6 +170,19 @@ struct snd_ctl_elem_value32 {
         unsigned char reserved[128];
 };
 
+#ifdef CONFIG_X86_X32
+/* x32 has a different alignment for 64bit values from ia32 */
+struct snd_ctl_elem_value_x32 {
+       struct snd_ctl_elem_id id;
+       unsigned int indirect;  /* bit-field causes misalignment */
+       union {
+               s32 integer[128];
+               unsigned char data[512];
+               s64 integer64[64];
+       } value;
+       unsigned char reserved[128];
+};
+#endif /* CONFIG_X86_X32 */
 
 /* get the value type and count of the control */
 static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id,
@@ -219,9 +232,11 @@ static int get_elem_size(int type, int count)
 
 static int copy_ctl_value_from_user(struct snd_card *card,
                                    struct snd_ctl_elem_value *data,
-                                   struct snd_ctl_elem_value32 __user *data32,
+                                   void __user *userdata,
+                                   void __user *valuep,
                                    int *typep, int *countp)
 {
+       struct snd_ctl_elem_value32 __user *data32 = userdata;
        int i, type, size;
        int uninitialized_var(count);
        unsigned int indirect;
@@ -239,8 +254,9 @@ static int copy_ctl_value_from_user(struct snd_card *card,
        if (type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
            type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
                for (i = 0; i < count; i++) {
+                       s32 __user *intp = valuep;
                        int val;
-                       if (get_user(val, &data32->value.integer[i]))
+                       if (get_user(val, &intp[i]))
                                return -EFAULT;
                        data->value.integer.value[i] = val;
                }
@@ -250,8 +266,7 @@ static int copy_ctl_value_from_user(struct snd_card *card,
                        dev_err(card->dev, "snd_ioctl32_ctl_elem_value: unknown type %d\n", type);
                        return -EINVAL;
                }
-               if (copy_from_user(data->value.bytes.data,
-                                  data32->value.data, size))
+               if (copy_from_user(data->value.bytes.data, valuep, size))
                        return -EFAULT;
        }
 
@@ -261,7 +276,8 @@ static int copy_ctl_value_from_user(struct snd_card *card,
 }
 
 /* restore the value to 32bit */
-static int copy_ctl_value_to_user(struct snd_ctl_elem_value32 __user *data32,
+static int copy_ctl_value_to_user(void __user *userdata,
+                                 void __user *valuep,
                                  struct snd_ctl_elem_value *data,
                                  int type, int count)
 {
@@ -270,22 +286,22 @@ static int copy_ctl_value_to_user(struct snd_ctl_elem_value32 __user *data32,
        if (type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
            type == SNDRV_CTL_ELEM_TYPE_INTEGER) {
                for (i = 0; i < count; i++) {
+                       s32 __user *intp = valuep;
                        int val;
                        val = data->value.integer.value[i];
-                       if (put_user(val, &data32->value.integer[i]))
+                       if (put_user(val, &intp[i]))
                                return -EFAULT;
                }
        } else {
                size = get_elem_size(type, count);
-               if (copy_to_user(data32->value.data,
-                                data->value.bytes.data, size))
+               if (copy_to_user(valuep, data->value.bytes.data, size))
                        return -EFAULT;
        }
        return 0;
 }
 
-static int snd_ctl_elem_read_user_compat(struct snd_card *card, 
-                                        struct snd_ctl_elem_value32 __user *data32)
+static int ctl_elem_read_user(struct snd_card *card,
+                             void __user *userdata, void __user *valuep)
 {
        struct snd_ctl_elem_value *data;
        int err, type, count;
@@ -294,7 +310,9 @@ static int snd_ctl_elem_read_user_compat(struct snd_card *card,
        if (data == NULL)
                return -ENOMEM;
 
-       if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0)
+       err = copy_ctl_value_from_user(card, data, userdata, valuep,
+                                      &type, &count);
+       if (err < 0)
                goto error;
 
        snd_power_lock(card);
@@ -303,14 +321,15 @@ static int snd_ctl_elem_read_user_compat(struct snd_card *card,
                err = snd_ctl_elem_read(card, data);
        snd_power_unlock(card);
        if (err >= 0)
-               err = copy_ctl_value_to_user(data32, data, type, count);
+               err = copy_ctl_value_to_user(userdata, valuep, data,
+                                            type, count);
  error:
        kfree(data);
        return err;
 }
 
-static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
-                                         struct snd_ctl_elem_value32 __user *data32)
+static int ctl_elem_write_user(struct snd_ctl_file *file,
+                              void __user *userdata, void __user *valuep)
 {
        struct snd_ctl_elem_value *data;
        struct snd_card *card = file->card;
@@ -320,7 +339,9 @@ static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
        if (data == NULL)
                return -ENOMEM;
 
-       if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0)
+       err = copy_ctl_value_from_user(card, data, userdata, valuep,
+                                      &type, &count);
+       if (err < 0)
                goto error;
 
        snd_power_lock(card);
@@ -329,12 +350,39 @@ static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
                err = snd_ctl_elem_write(card, file, data);
        snd_power_unlock(card);
        if (err >= 0)
-               err = copy_ctl_value_to_user(data32, data, type, count);
+               err = copy_ctl_value_to_user(userdata, valuep, data,
+                                            type, count);
  error:
        kfree(data);
        return err;
 }
 
+static int snd_ctl_elem_read_user_compat(struct snd_card *card,
+                                        struct snd_ctl_elem_value32 __user *data32)
+{
+       return ctl_elem_read_user(card, data32, &data32->value);
+}
+
+static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
+                                         struct snd_ctl_elem_value32 __user *data32)
+{
+       return ctl_elem_write_user(file, data32, &data32->value);
+}
+
+#ifdef CONFIG_X86_X32
+static int snd_ctl_elem_read_user_x32(struct snd_card *card,
+                                     struct snd_ctl_elem_value_x32 __user *data32)
+{
+       return ctl_elem_read_user(card, data32, &data32->value);
+}
+
+static int snd_ctl_elem_write_user_x32(struct snd_ctl_file *file,
+                                      struct snd_ctl_elem_value_x32 __user *data32)
+{
+       return ctl_elem_write_user(file, data32, &data32->value);
+}
+#endif /* CONFIG_X86_X32 */
+
 /* add or replace a user control */
 static int snd_ctl_elem_add_compat(struct snd_ctl_file *file,
                                   struct snd_ctl_elem_info32 __user *data32,
@@ -393,6 +441,10 @@ enum {
        SNDRV_CTL_IOCTL_ELEM_WRITE32 = _IOWR('U', 0x13, struct snd_ctl_elem_value32),
        SNDRV_CTL_IOCTL_ELEM_ADD32 = _IOWR('U', 0x17, struct snd_ctl_elem_info32),
        SNDRV_CTL_IOCTL_ELEM_REPLACE32 = _IOWR('U', 0x18, struct snd_ctl_elem_info32),
+#ifdef CONFIG_X86_X32
+       SNDRV_CTL_IOCTL_ELEM_READ_X32 = _IOWR('U', 0x12, struct snd_ctl_elem_value_x32),
+       SNDRV_CTL_IOCTL_ELEM_WRITE_X32 = _IOWR('U', 0x13, struct snd_ctl_elem_value_x32),
+#endif /* CONFIG_X86_X32 */
 };
 
 static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
@@ -431,6 +483,12 @@ static inline long snd_ctl_ioctl_compat(struct file *file, unsigned int cmd, uns
                return snd_ctl_elem_add_compat(ctl, argp, 0);
        case SNDRV_CTL_IOCTL_ELEM_REPLACE32:
                return snd_ctl_elem_add_compat(ctl, argp, 1);
+#ifdef CONFIG_X86_X32
+       case SNDRV_CTL_IOCTL_ELEM_READ_X32:
+               return snd_ctl_elem_read_user_x32(ctl->card, argp);
+       case SNDRV_CTL_IOCTL_ELEM_WRITE_X32:
+               return snd_ctl_elem_write_user_x32(ctl, argp);
+#endif /* CONFIG_X86_X32 */
        }
 
        down_read(&snd_ioctl_rwsem);
index 9630e9f..1f64ab0 100644 (file)
@@ -183,6 +183,14 @@ static int snd_pcm_ioctl_channel_info_compat(struct snd_pcm_substream *substream
        return err;
 }
 
+#ifdef CONFIG_X86_X32
+/* X32 ABI has the same struct as x86-64 for snd_pcm_channel_info */
+static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream,
+                                    struct snd_pcm_channel_info __user *src);
+#define snd_pcm_ioctl_channel_info_x32(s, p)   \
+       snd_pcm_channel_info_user(s, p)
+#endif /* CONFIG_X86_X32 */
+
 struct snd_pcm_status32 {
        s32 state;
        struct compat_timespec trigger_tstamp;
@@ -243,6 +251,71 @@ static int snd_pcm_status_user_compat(struct snd_pcm_substream *substream,
        return err;
 }
 
+#ifdef CONFIG_X86_X32
+/* X32 ABI has 64bit timespec and 64bit alignment */
+struct snd_pcm_status_x32 {
+       s32 state;
+       u32 rsvd; /* alignment */
+       struct timespec trigger_tstamp;
+       struct timespec tstamp;
+       u32 appl_ptr;
+       u32 hw_ptr;
+       s32 delay;
+       u32 avail;
+       u32 avail_max;
+       u32 overrange;
+       s32 suspended_state;
+       u32 audio_tstamp_data;
+       struct timespec audio_tstamp;
+       struct timespec driver_tstamp;
+       u32 audio_tstamp_accuracy;
+       unsigned char reserved[52-2*sizeof(struct timespec)];
+} __packed;
+
+#define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst))
+
+static int snd_pcm_status_user_x32(struct snd_pcm_substream *substream,
+                                  struct snd_pcm_status_x32 __user *src,
+                                  bool ext)
+{
+       struct snd_pcm_status status;
+       int err;
+
+       memset(&status, 0, sizeof(status));
+       /*
+        * with extension, parameters are read/write,
+        * get audio_tstamp_data from user,
+        * ignore rest of status structure
+        */
+       if (ext && get_user(status.audio_tstamp_data,
+                               (u32 __user *)(&src->audio_tstamp_data)))
+               return -EFAULT;
+       err = snd_pcm_status(substream, &status);
+       if (err < 0)
+               return err;
+
+       if (clear_user(src, sizeof(*src)))
+               return -EFAULT;
+       if (put_user(status.state, &src->state) ||
+           put_timespec(&status.trigger_tstamp, &src->trigger_tstamp) ||
+           put_timespec(&status.tstamp, &src->tstamp) ||
+           put_user(status.appl_ptr, &src->appl_ptr) ||
+           put_user(status.hw_ptr, &src->hw_ptr) ||
+           put_user(status.delay, &src->delay) ||
+           put_user(status.avail, &src->avail) ||
+           put_user(status.avail_max, &src->avail_max) ||
+           put_user(status.overrange, &src->overrange) ||
+           put_user(status.suspended_state, &src->suspended_state) ||
+           put_user(status.audio_tstamp_data, &src->audio_tstamp_data) ||
+           put_timespec(&status.audio_tstamp, &src->audio_tstamp) ||
+           put_timespec(&status.driver_tstamp, &src->driver_tstamp) ||
+           put_user(status.audio_tstamp_accuracy, &src->audio_tstamp_accuracy))
+               return -EFAULT;
+
+       return err;
+}
+#endif /* CONFIG_X86_X32 */
+
 /* both for HW_PARAMS and HW_REFINE */
 static int snd_pcm_ioctl_hw_params_compat(struct snd_pcm_substream *substream,
                                          int refine, 
@@ -469,6 +542,93 @@ static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream,
        return 0;
 }
 
+#ifdef CONFIG_X86_X32
+/* X32 ABI has 64bit timespec and 64bit alignment */
+struct snd_pcm_mmap_status_x32 {
+       s32 state;
+       s32 pad1;
+       u32 hw_ptr;
+       u32 pad2; /* alignment */
+       struct timespec tstamp;
+       s32 suspended_state;
+       struct timespec audio_tstamp;
+} __packed;
+
+struct snd_pcm_mmap_control_x32 {
+       u32 appl_ptr;
+       u32 avail_min;
+};
+
+struct snd_pcm_sync_ptr_x32 {
+       u32 flags;
+       u32 rsvd; /* alignment */
+       union {
+               struct snd_pcm_mmap_status_x32 status;
+               unsigned char reserved[64];
+       } s;
+       union {
+               struct snd_pcm_mmap_control_x32 control;
+               unsigned char reserved[64];
+       } c;
+} __packed;
+
+static int snd_pcm_ioctl_sync_ptr_x32(struct snd_pcm_substream *substream,
+                                     struct snd_pcm_sync_ptr_x32 __user *src)
+{
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       volatile struct snd_pcm_mmap_status *status;
+       volatile struct snd_pcm_mmap_control *control;
+       u32 sflags;
+       struct snd_pcm_mmap_control scontrol;
+       struct snd_pcm_mmap_status sstatus;
+       snd_pcm_uframes_t boundary;
+       int err;
+
+       if (snd_BUG_ON(!runtime))
+               return -EINVAL;
+
+       if (get_user(sflags, &src->flags) ||
+           get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) ||
+           get_user(scontrol.avail_min, &src->c.control.avail_min))
+               return -EFAULT;
+       if (sflags & SNDRV_PCM_SYNC_PTR_HWSYNC) {
+               err = snd_pcm_hwsync(substream);
+               if (err < 0)
+                       return err;
+       }
+       status = runtime->status;
+       control = runtime->control;
+       boundary = recalculate_boundary(runtime);
+       if (!boundary)
+               boundary = 0x7fffffff;
+       snd_pcm_stream_lock_irq(substream);
+       /* FIXME: we should consider the boundary for the sync from app */
+       if (!(sflags & SNDRV_PCM_SYNC_PTR_APPL))
+               control->appl_ptr = scontrol.appl_ptr;
+       else
+               scontrol.appl_ptr = control->appl_ptr % boundary;
+       if (!(sflags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN))
+               control->avail_min = scontrol.avail_min;
+       else
+               scontrol.avail_min = control->avail_min;
+       sstatus.state = status->state;
+       sstatus.hw_ptr = status->hw_ptr % boundary;
+       sstatus.tstamp = status->tstamp;
+       sstatus.suspended_state = status->suspended_state;
+       sstatus.audio_tstamp = status->audio_tstamp;
+       snd_pcm_stream_unlock_irq(substream);
+       if (put_user(sstatus.state, &src->s.status.state) ||
+           put_user(sstatus.hw_ptr, &src->s.status.hw_ptr) ||
+           put_timespec(&sstatus.tstamp, &src->s.status.tstamp) ||
+           put_user(sstatus.suspended_state, &src->s.status.suspended_state) ||
+           put_timespec(&sstatus.audio_tstamp, &src->s.status.audio_tstamp) ||
+           put_user(scontrol.appl_ptr, &src->c.control.appl_ptr) ||
+           put_user(scontrol.avail_min, &src->c.control.avail_min))
+               return -EFAULT;
+
+       return 0;
+}
+#endif /* CONFIG_X86_X32 */
 
 /*
  */
@@ -487,7 +647,12 @@ enum {
        SNDRV_PCM_IOCTL_WRITEN_FRAMES32 = _IOW('A', 0x52, struct snd_xfern32),
        SNDRV_PCM_IOCTL_READN_FRAMES32 = _IOR('A', 0x53, struct snd_xfern32),
        SNDRV_PCM_IOCTL_SYNC_PTR32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr32),
-
+#ifdef CONFIG_X86_X32
+       SNDRV_PCM_IOCTL_CHANNEL_INFO_X32 = _IOR('A', 0x32, struct snd_pcm_channel_info),
+       SNDRV_PCM_IOCTL_STATUS_X32 = _IOR('A', 0x20, struct snd_pcm_status_x32),
+       SNDRV_PCM_IOCTL_STATUS_EXT_X32 = _IOWR('A', 0x24, struct snd_pcm_status_x32),
+       SNDRV_PCM_IOCTL_SYNC_PTR_X32 = _IOWR('A', 0x23, struct snd_pcm_sync_ptr_x32),
+#endif /* CONFIG_X86_X32 */
 };
 
 static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
@@ -559,6 +724,16 @@ static long snd_pcm_ioctl_compat(struct file *file, unsigned int cmd, unsigned l
                return snd_pcm_ioctl_rewind_compat(substream, argp);
        case SNDRV_PCM_IOCTL_FORWARD32:
                return snd_pcm_ioctl_forward_compat(substream, argp);
+#ifdef CONFIG_X86_X32
+       case SNDRV_PCM_IOCTL_STATUS_X32:
+               return snd_pcm_status_user_x32(substream, argp, false);
+       case SNDRV_PCM_IOCTL_STATUS_EXT_X32:
+               return snd_pcm_status_user_x32(substream, argp, true);
+       case SNDRV_PCM_IOCTL_SYNC_PTR_X32:
+               return snd_pcm_ioctl_sync_ptr_x32(substream, argp);
+       case SNDRV_PCM_IOCTL_CHANNEL_INFO_X32:
+               return snd_pcm_ioctl_channel_info_x32(substream, argp);
+#endif /* CONFIG_X86_X32 */
        }
 
        return -ENOIOCTLCMD;
index fadd3eb..9106d8e 100644 (file)
@@ -74,6 +74,18 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream);
 static DEFINE_RWLOCK(snd_pcm_link_rwlock);
 static DECLARE_RWSEM(snd_pcm_link_rwsem);
 
+/* Writer in rwsem may block readers even during its waiting in queue,
+ * and this may lead to a deadlock when the code path takes read sem
+ * twice (e.g. one in snd_pcm_action_nonatomic() and another in
+ * snd_pcm_stream_lock()).  As a (suboptimal) workaround, let writer to
+ * spin until it gets the lock.
+ */
+static inline void down_write_nonblock(struct rw_semaphore *lock)
+{
+       while (!down_write_trylock(lock))
+               cond_resched();
+}
+
 /**
  * snd_pcm_stream_lock - Lock the PCM stream
  * @substream: PCM substream
@@ -1813,7 +1825,7 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
                res = -ENOMEM;
                goto _nolock;
        }
-       down_write(&snd_pcm_link_rwsem);
+       down_write_nonblock(&snd_pcm_link_rwsem);
        write_lock_irq(&snd_pcm_link_rwlock);
        if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN ||
            substream->runtime->status->state != substream1->runtime->status->state ||
@@ -1860,7 +1872,7 @@ static int snd_pcm_unlink(struct snd_pcm_substream *substream)
        struct snd_pcm_substream *s;
        int res = 0;
 
-       down_write(&snd_pcm_link_rwsem);
+       down_write_nonblock(&snd_pcm_link_rwsem);
        write_lock_irq(&snd_pcm_link_rwlock);
        if (!snd_pcm_stream_linked(substream)) {
                res = -EALREADY;
index 5268c1f..f69764d 100644 (file)
@@ -85,8 +85,7 @@ static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile,
        if (err < 0)
                return err;
 
-       if (put_user(status.tstamp.tv_sec, &src->tstamp.tv_sec) ||
-           put_user(status.tstamp.tv_nsec, &src->tstamp.tv_nsec) ||
+       if (compat_put_timespec(&status.tstamp, &src->tstamp) ||
            put_user(status.avail, &src->avail) ||
            put_user(status.xruns, &src->xruns))
                return -EFAULT;
@@ -94,9 +93,58 @@ static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile,
        return 0;
 }
 
+#ifdef CONFIG_X86_X32
+/* X32 ABI has 64bit timespec and 64bit alignment */
+struct snd_rawmidi_status_x32 {
+       s32 stream;
+       u32 rsvd; /* alignment */
+       struct timespec tstamp;
+       u32 avail;
+       u32 xruns;
+       unsigned char reserved[16];
+} __attribute__((packed));
+
+#define put_timespec(src, dst) copy_to_user(dst, src, sizeof(*dst))
+
+static int snd_rawmidi_ioctl_status_x32(struct snd_rawmidi_file *rfile,
+                                       struct snd_rawmidi_status_x32 __user *src)
+{
+       int err;
+       struct snd_rawmidi_status status;
+
+       if (rfile->output == NULL)
+               return -EINVAL;
+       if (get_user(status.stream, &src->stream))
+               return -EFAULT;
+
+       switch (status.stream) {
+       case SNDRV_RAWMIDI_STREAM_OUTPUT:
+               err = snd_rawmidi_output_status(rfile->output, &status);
+               break;
+       case SNDRV_RAWMIDI_STREAM_INPUT:
+               err = snd_rawmidi_input_status(rfile->input, &status);
+               break;
+       default:
+               return -EINVAL;
+       }
+       if (err < 0)
+               return err;
+
+       if (put_timespec(&status.tstamp, &src->tstamp) ||
+           put_user(status.avail, &src->avail) ||
+           put_user(status.xruns, &src->xruns))
+               return -EFAULT;
+
+       return 0;
+}
+#endif /* CONFIG_X86_X32 */
+
 enum {
        SNDRV_RAWMIDI_IOCTL_PARAMS32 = _IOWR('W', 0x10, struct snd_rawmidi_params32),
        SNDRV_RAWMIDI_IOCTL_STATUS32 = _IOWR('W', 0x20, struct snd_rawmidi_status32),
+#ifdef CONFIG_X86_X32
+       SNDRV_RAWMIDI_IOCTL_STATUS_X32 = _IOWR('W', 0x20, struct snd_rawmidi_status_x32),
+#endif /* CONFIG_X86_X32 */
 };
 
 static long snd_rawmidi_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
@@ -115,6 +163,10 @@ static long snd_rawmidi_ioctl_compat(struct file *file, unsigned int cmd, unsign
                return snd_rawmidi_ioctl_params_compat(rfile, argp);
        case SNDRV_RAWMIDI_IOCTL_STATUS32:
                return snd_rawmidi_ioctl_status_compat(rfile, argp);
+#ifdef CONFIG_X86_X32
+       case SNDRV_RAWMIDI_IOCTL_STATUS_X32:
+               return snd_rawmidi_ioctl_status_x32(rfile, argp);
+#endif /* CONFIG_X86_X32 */
        }
        return -ENOIOCTLCMD;
 }
index 8db156b..8cdf489 100644 (file)
@@ -149,8 +149,6 @@ odev_release(struct inode *inode, struct file *file)
        if ((dp = file->private_data) == NULL)
                return 0;
 
-       snd_seq_oss_drain_write(dp);
-
        mutex_lock(&register_mutex);
        snd_seq_oss_release(dp);
        mutex_unlock(&register_mutex);
index b439243..d7b4d01 100644 (file)
@@ -127,7 +127,6 @@ int snd_seq_oss_write(struct seq_oss_devinfo *dp, const char __user *buf, int co
 unsigned int snd_seq_oss_poll(struct seq_oss_devinfo *dp, struct file *file, poll_table * wait);
 
 void snd_seq_oss_reset(struct seq_oss_devinfo *dp);
-void snd_seq_oss_drain_write(struct seq_oss_devinfo *dp);
 
 /* */
 void snd_seq_oss_process_queue(struct seq_oss_devinfo *dp, abstime_t time);
index 6779e82..92c96a9 100644 (file)
@@ -436,22 +436,6 @@ snd_seq_oss_release(struct seq_oss_devinfo *dp)
 
 
 /*
- * Wait until the queue is empty (if we don't have nonblock)
- */
-void
-snd_seq_oss_drain_write(struct seq_oss_devinfo *dp)
-{
-       if (! dp->timer->running)
-               return;
-       if (is_write_mode(dp->file_mode) && !is_nonblock_mode(dp->file_mode) &&
-           dp->writeq) {
-               while (snd_seq_oss_writeq_sync(dp->writeq))
-                       ;
-       }
-}
-
-
-/*
  * reset sequencer devices
  */
 void
index 8010766..c850345 100644 (file)
@@ -383,15 +383,20 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
 
        if (snd_BUG_ON(!pool))
                return -EINVAL;
-       if (pool->ptr)                  /* should be atomic? */
-               return 0;
 
-       pool->ptr = vmalloc(sizeof(struct snd_seq_event_cell) * pool->size);
-       if (!pool->ptr)
+       cellptr = vmalloc(sizeof(struct snd_seq_event_cell) * pool->size);
+       if (!cellptr)
                return -ENOMEM;
 
        /* add new cells to the free cell list */
        spin_lock_irqsave(&pool->lock, flags);
+       if (pool->ptr) {
+               spin_unlock_irqrestore(&pool->lock, flags);
+               vfree(cellptr);
+               return 0;
+       }
+
+       pool->ptr = cellptr;
        pool->free = NULL;
 
        for (cell = 0; cell < pool->size; cell++) {
index 921fb2b..fe686ee 100644 (file)
@@ -535,19 +535,22 @@ static void delete_and_unsubscribe_port(struct snd_seq_client *client,
                                        bool is_src, bool ack)
 {
        struct snd_seq_port_subs_info *grp;
+       struct list_head *list;
+       bool empty;
 
        grp = is_src ? &port->c_src : &port->c_dest;
+       list = is_src ? &subs->src_list : &subs->dest_list;
        down_write(&grp->list_mutex);
        write_lock_irq(&grp->list_lock);
-       if (is_src)
-               list_del(&subs->src_list);
-       else
-               list_del(&subs->dest_list);
+       empty = list_empty(list);
+       if (!empty)
+               list_del_init(list);
        grp->exclusive = 0;
        write_unlock_irq(&grp->list_lock);
        up_write(&grp->list_mutex);
 
-       unsubscribe_port(client, port, grp, &subs->info, ack);
+       if (!empty)
+               unsubscribe_port(client, port, grp, &subs->info, ack);
 }
 
 /* connect two ports */
index 9b513a0..dca817f 100644 (file)
@@ -422,7 +422,7 @@ static void snd_timer_notify1(struct snd_timer_instance *ti, int event)
        spin_lock_irqsave(&timer->lock, flags);
        list_for_each_entry(ts, &ti->slave_active_head, active_list)
                if (ts->ccallback)
-                       ts->ccallback(ti, event + 100, &tstamp, resolution);
+                       ts->ccallback(ts, event + 100, &tstamp, resolution);
        spin_unlock_irqrestore(&timer->lock, flags);
 }
 
@@ -518,9 +518,13 @@ static int _snd_timer_stop(struct snd_timer_instance *timeri, int event)
                        spin_unlock_irqrestore(&slave_active_lock, flags);
                        return -EBUSY;
                }
+               if (timeri->timer)
+                       spin_lock(&timeri->timer->lock);
                timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
                list_del_init(&timeri->ack_list);
                list_del_init(&timeri->active_list);
+               if (timeri->timer)
+                       spin_unlock(&timeri->timer->lock);
                spin_unlock_irqrestore(&slave_active_lock, flags);
                goto __end;
        }
@@ -1929,6 +1933,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 {
        struct snd_timer_user *tu;
        long result = 0, unit;
+       int qhead;
        int err = 0;
 
        tu = file->private_data;
@@ -1940,7 +1945,7 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 
                        if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {
                                err = -EAGAIN;
-                               break;
+                               goto _error;
                        }
 
                        set_current_state(TASK_INTERRUPTIBLE);
@@ -1955,42 +1960,37 @@ static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
 
                        if (tu->disconnected) {
                                err = -ENODEV;
-                               break;
+                               goto _error;
                        }
                        if (signal_pending(current)) {
                                err = -ERESTARTSYS;
-                               break;
+                               goto _error;
                        }
                }
 
+               qhead = tu->qhead++;
+               tu->qhead %= tu->queue_size;
                spin_unlock_irq(&tu->qlock);
-               if (err < 0)
-                       goto _error;
 
                if (tu->tread) {
-                       if (copy_to_user(buffer, &tu->tqueue[tu->qhead++],
-                                        sizeof(struct snd_timer_tread))) {
+                       if (copy_to_user(buffer, &tu->tqueue[qhead],
+                                        sizeof(struct snd_timer_tread)))
                                err = -EFAULT;
-                               goto _error;
-                       }
                } else {
-                       if (copy_to_user(buffer, &tu->queue[tu->qhead++],
-                                        sizeof(struct snd_timer_read))) {
+                       if (copy_to_user(buffer, &tu->queue[qhead],
+                                        sizeof(struct snd_timer_read)))
                                err = -EFAULT;
-                               goto _error;
-                       }
                }
 
-               tu->qhead %= tu->queue_size;
-
-               result += unit;
-               buffer += unit;
-
                spin_lock_irq(&tu->qlock);
                tu->qused--;
+               if (err < 0)
+                       goto _error;
+               result += unit;
+               buffer += unit;
        }
-       spin_unlock_irq(&tu->qlock);
  _error:
+       spin_unlock_irq(&tu->qlock);
        return result > 0 ? result : err;
 }
 
index e05802a..2e90822 100644 (file)
@@ -70,13 +70,14 @@ static int snd_timer_user_status_compat(struct file *file,
                                        struct snd_timer_status32 __user *_status)
 {
        struct snd_timer_user *tu;
-       struct snd_timer_status status;
+       struct snd_timer_status32 status;
        
        tu = file->private_data;
        if (snd_BUG_ON(!tu->timeri))
                return -ENXIO;
        memset(&status, 0, sizeof(status));
-       status.tstamp = tu->tstamp;
+       status.tstamp.tv_sec = tu->tstamp.tv_sec;
+       status.tstamp.tv_nsec = tu->tstamp.tv_nsec;
        status.resolution = snd_timer_resolution(tu->timeri);
        status.lost = tu->timeri->lost;
        status.overrun = tu->overrun;
@@ -88,12 +89,21 @@ static int snd_timer_user_status_compat(struct file *file,
        return 0;
 }
 
+#ifdef CONFIG_X86_X32
+/* X32 ABI has the same struct as x86-64 */
+#define snd_timer_user_status_x32(file, s) \
+       snd_timer_user_status(file, s)
+#endif /* CONFIG_X86_X32 */
+
 /*
  */
 
 enum {
        SNDRV_TIMER_IOCTL_INFO32 = _IOR('T', 0x11, struct snd_timer_info32),
        SNDRV_TIMER_IOCTL_STATUS32 = _IOW('T', 0x14, struct snd_timer_status32),
+#ifdef CONFIG_X86_X32
+       SNDRV_TIMER_IOCTL_STATUS_X32 = _IOW('T', 0x14, struct snd_timer_status),
+#endif /* CONFIG_X86_X32 */
 };
 
 static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
@@ -122,6 +132,10 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns
                return snd_timer_user_info_compat(file, argp);
        case SNDRV_TIMER_IOCTL_STATUS32:
                return snd_timer_user_status_compat(file, argp);
+#ifdef CONFIG_X86_X32
+       case SNDRV_TIMER_IOCTL_STATUS_X32:
+               return snd_timer_user_status_x32(file, argp);
+#endif /* CONFIG_X86_X32 */
        }
        return -ENOIOCTLCMD;
 }
index bde3330..c0f8f61 100644 (file)
@@ -87,7 +87,7 @@ MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-128) for dummy driver.");
 module_param(fake_buffer, bool, 0444);
 MODULE_PARM_DESC(fake_buffer, "Fake buffer allocations.");
 #ifdef CONFIG_HIGH_RES_TIMERS
-module_param(hrtimer, bool, 0444);
+module_param(hrtimer, bool, 0644);
 MODULE_PARM_DESC(hrtimer, "Use hrtimer as the timer source.");
 #endif
 
@@ -109,6 +109,9 @@ struct dummy_timer_ops {
        snd_pcm_uframes_t (*pointer)(struct snd_pcm_substream *);
 };
 
+#define get_dummy_ops(substream) \
+       (*(const struct dummy_timer_ops **)(substream)->runtime->private_data)
+
 struct dummy_model {
        const char *name;
        int (*playback_constraints)(struct snd_pcm_runtime *runtime);
@@ -137,7 +140,6 @@ struct snd_dummy {
        int iobox;
        struct snd_kcontrol *cd_volume_ctl;
        struct snd_kcontrol *cd_switch_ctl;
-       const struct dummy_timer_ops *timer_ops;
 };
 
 /*
@@ -231,6 +233,8 @@ static struct dummy_model *dummy_models[] = {
  */
 
 struct dummy_systimer_pcm {
+       /* ops must be the first item */
+       const struct dummy_timer_ops *timer_ops;
        spinlock_t lock;
        struct timer_list timer;
        unsigned long base_time;
@@ -366,6 +370,8 @@ static const struct dummy_timer_ops dummy_systimer_ops = {
  */
 
 struct dummy_hrtimer_pcm {
+       /* ops must be the first item */
+       const struct dummy_timer_ops *timer_ops;
        ktime_t base_time;
        ktime_t period_time;
        atomic_t running;
@@ -492,31 +498,25 @@ static const struct dummy_timer_ops dummy_hrtimer_ops = {
 
 static int dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
 {
-       struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
-
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
        case SNDRV_PCM_TRIGGER_RESUME:
-               return dummy->timer_ops->start(substream);
+               return get_dummy_ops(substream)->start(substream);
        case SNDRV_PCM_TRIGGER_STOP:
        case SNDRV_PCM_TRIGGER_SUSPEND:
-               return dummy->timer_ops->stop(substream);
+               return get_dummy_ops(substream)->stop(substream);
        }
        return -EINVAL;
 }
 
 static int dummy_pcm_prepare(struct snd_pcm_substream *substream)
 {
-       struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
-
-       return dummy->timer_ops->prepare(substream);
+       return get_dummy_ops(substream)->prepare(substream);
 }
 
 static snd_pcm_uframes_t dummy_pcm_pointer(struct snd_pcm_substream *substream)
 {
-       struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
-
-       return dummy->timer_ops->pointer(substream);
+       return get_dummy_ops(substream)->pointer(substream);
 }
 
 static struct snd_pcm_hardware dummy_pcm_hardware = {
@@ -562,17 +562,19 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream)
        struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
        struct dummy_model *model = dummy->model;
        struct snd_pcm_runtime *runtime = substream->runtime;
+       const struct dummy_timer_ops *ops;
        int err;
 
-       dummy->timer_ops = &dummy_systimer_ops;
+       ops = &dummy_systimer_ops;
 #ifdef CONFIG_HIGH_RES_TIMERS
        if (hrtimer)
-               dummy->timer_ops = &dummy_hrtimer_ops;
+               ops = &dummy_hrtimer_ops;
 #endif
 
-       err = dummy->timer_ops->create(substream);
+       err = ops->create(substream);
        if (err < 0)
                return err;
+       get_dummy_ops(substream) = ops;
 
        runtime->hw = dummy->pcm_hw;
        if (substream->pcm->device & 1) {
@@ -594,7 +596,7 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream)
                        err = model->capture_constraints(substream->runtime);
        }
        if (err < 0) {
-               dummy->timer_ops->free(substream);
+               get_dummy_ops(substream)->free(substream);
                return err;
        }
        return 0;
@@ -602,8 +604,7 @@ static int dummy_pcm_open(struct snd_pcm_substream *substream)
 
 static int dummy_pcm_close(struct snd_pcm_substream *substream)
 {
-       struct snd_dummy *dummy = snd_pcm_substream_chip(substream);
-       dummy->timer_ops->free(substream);
+       get_dummy_ops(substream)->free(substream);
        return 0;
 }
 
index b02a5e8..0ac92ab 100644 (file)
@@ -63,7 +63,7 @@ struct amdtp_dot {
 #define BYTE_PER_SAMPLE (4)
 #define MAGIC_DOT_BYTE (2)
 #define MAGIC_BYTE_OFF(x) (((x) * BYTE_PER_SAMPLE) + MAGIC_DOT_BYTE)
-static const u8 dot_scrt(const u8 idx, const unsigned int off)
+static u8 dot_scrt(const u8 idx, const unsigned int off)
 {
        /*
         * the length of the added pattern only depends on the lower nibble
index 904ce03..040a96d 100644 (file)
@@ -230,6 +230,7 @@ int snd_tscm_transaction_register(struct snd_tscm *tscm)
        return err;
 error:
        fw_core_remove_address_handler(&tscm->async_handler);
+       tscm->async_handler.callback_data = NULL;
        return err;
 }
 
@@ -276,6 +277,9 @@ void snd_tscm_transaction_unregister(struct snd_tscm *tscm)
        __be32 reg;
        unsigned int i;
 
+       if (tscm->async_handler.callback_data == NULL)
+               return;
+
        /* Turn off FireWire LED. */
        reg = cpu_to_be32(0x0000008e);
        snd_fw_transaction(tscm->unit, TCODE_WRITE_QUADLET_REQUEST,
@@ -297,6 +301,8 @@ void snd_tscm_transaction_unregister(struct snd_tscm *tscm)
                           &reg, sizeof(reg), 0);
 
        fw_core_remove_address_handler(&tscm->async_handler);
+       tscm->async_handler.callback_data = NULL;
+
        for (i = 0; i < TSCM_MIDI_OUT_PORT_MAX; i++)
                snd_fw_async_midi_port_destroy(&tscm->out_ports[i]);
 }
index ee0bc18..e281c33 100644 (file)
@@ -21,7 +21,6 @@ static struct snd_tscm_spec model_specs[] = {
                .pcm_playback_analog_channels = 8,
                .midi_capture_ports = 4,
                .midi_playback_ports = 4,
-               .is_controller = true,
        },
        {
                .name = "FW-1082",
@@ -31,9 +30,16 @@ static struct snd_tscm_spec model_specs[] = {
                .pcm_playback_analog_channels = 2,
                .midi_capture_ports = 2,
                .midi_playback_ports = 2,
-               .is_controller = true,
        },
-       /* FW-1804 may be supported. */
+       {
+               .name = "FW-1804",
+               .has_adat = true,
+               .has_spdif = true,
+               .pcm_capture_analog_channels = 8,
+               .pcm_playback_analog_channels = 2,
+               .midi_capture_ports = 2,
+               .midi_playback_ports = 4,
+       },
 };
 
 static int identify_model(struct snd_tscm *tscm)
index 2d028d2..30ab77e 100644 (file)
@@ -39,7 +39,6 @@ struct snd_tscm_spec {
        unsigned int pcm_playback_analog_channels;
        unsigned int midi_capture_ports;
        unsigned int midi_playback_ports;
-       bool is_controller;
 };
 
 #define TSCM_MIDI_IN_PORT_MAX  4
@@ -72,9 +71,6 @@ struct snd_tscm {
        struct snd_fw_async_midi_port out_ports[TSCM_MIDI_OUT_PORT_MAX];
        u8 running_status[TSCM_MIDI_OUT_PORT_MAX];
        bool on_sysex[TSCM_MIDI_OUT_PORT_MAX];
-
-       /* For control messages. */
-       struct snd_firewire_tascam_status *status;
 };
 
 #define TSCM_ADDR_BASE                 0xffff00000000ull
index b5a17cb..8c48623 100644 (file)
@@ -426,18 +426,22 @@ EXPORT_SYMBOL_GPL(snd_hdac_bus_stop_chip);
  * @bus: HD-audio core bus
  * @status: INTSTS register value
  * @ask: callback to be called for woken streams
+ *
+ * Returns the bits of handled streams, or zero if no stream is handled.
  */
-void snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
+int snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
                                    void (*ack)(struct hdac_bus *,
                                                struct hdac_stream *))
 {
        struct hdac_stream *azx_dev;
        u8 sd_status;
+       int handled = 0;
 
        list_for_each_entry(azx_dev, &bus->stream_list, list) {
                if (status & azx_dev->sd_int_sta_mask) {
                        sd_status = snd_hdac_stream_readb(azx_dev, SD_STS);
                        snd_hdac_stream_writeb(azx_dev, SD_STS, SD_INT_MASK);
+                       handled |= 1 << azx_dev->index;
                        if (!azx_dev->substream || !azx_dev->running ||
                            !(sd_status & SD_INT_COMPLETE))
                                continue;
@@ -445,6 +449,7 @@ void snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status,
                                ack(bus, azx_dev);
                }
        }
+       return handled;
 }
 EXPORT_SYMBOL_GPL(snd_hdac_bus_handle_stream_irq);
 
index 37cf9ce..27de801 100644 (file)
@@ -930,6 +930,8 @@ irqreturn_t azx_interrupt(int irq, void *dev_id)
        struct azx *chip = dev_id;
        struct hdac_bus *bus = azx_bus(chip);
        u32 status;
+       bool active, handled = false;
+       int repeat = 0; /* count for avoiding endless loop */
 
 #ifdef CONFIG_PM
        if (azx_has_pm_runtime(chip))
@@ -939,33 +941,36 @@ irqreturn_t azx_interrupt(int irq, void *dev_id)
 
        spin_lock(&bus->reg_lock);
 
-       if (chip->disabled) {
-               spin_unlock(&bus->reg_lock);
-               return IRQ_NONE;
-       }
-
-       status = azx_readl(chip, INTSTS);
-       if (status == 0 || status == 0xffffffff) {
-               spin_unlock(&bus->reg_lock);
-               return IRQ_NONE;
-       }
+       if (chip->disabled)
+               goto unlock;
 
-       snd_hdac_bus_handle_stream_irq(bus, status, stream_update);
+       do {
+               status = azx_readl(chip, INTSTS);
+               if (status == 0 || status == 0xffffffff)
+                       break;
 
-       /* clear rirb int */
-       status = azx_readb(chip, RIRBSTS);
-       if (status & RIRB_INT_MASK) {
-               if (status & RIRB_INT_RESPONSE) {
-                       if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
-                               udelay(80);
-                       snd_hdac_bus_update_rirb(bus);
+               handled = true;
+               active = false;
+               if (snd_hdac_bus_handle_stream_irq(bus, status, stream_update))
+                       active = true;
+
+               /* clear rirb int */
+               status = azx_readb(chip, RIRBSTS);
+               if (status & RIRB_INT_MASK) {
+                       active = true;
+                       if (status & RIRB_INT_RESPONSE) {
+                               if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
+                                       udelay(80);
+                               snd_hdac_bus_update_rirb(bus);
+                       }
+                       azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
                }
-               azx_writeb(chip, RIRBSTS, RIRB_INT_MASK);
-       }
+       } while (active && ++repeat < 10);
 
+ unlock:
        spin_unlock(&bus->reg_lock);
 
-       return IRQ_HANDLED;
+       return IRQ_RETVAL(handled);
 }
 EXPORT_SYMBOL_GPL(azx_interrupt);
 
index 30c8efe..7ca5b89 100644 (file)
@@ -4028,9 +4028,9 @@ static void pin_power_callback(struct hda_codec *codec,
                               struct hda_jack_callback *jack,
                               bool on)
 {
-       if (jack && jack->tbl->nid)
+       if (jack && jack->nid)
                sync_power_state_change(codec,
-                                       set_pin_power_jack(codec, jack->tbl->nid, on));
+                                       set_pin_power_jack(codec, jack->nid, on));
 }
 
 /* callback only doing power up -- called at first */
index 4045dca..e5240cb 100644 (file)
@@ -363,7 +363,10 @@ enum {
                                        ((pci)->device == 0x0d0c) || \
                                        ((pci)->device == 0x160c))
 
-#define IS_BROXTON(pci)        ((pci)->device == 0x5a98)
+#define IS_SKL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa170)
+#define IS_SKL_LP(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9d70)
+#define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
+#define IS_SKL_PLUS(pci) (IS_SKL(pci) || IS_SKL_LP(pci) || IS_BXT(pci))
 
 static char *driver_short_names[] = {
        [AZX_DRIVER_ICH] = "HDA Intel",
@@ -540,13 +543,13 @@ static void hda_intel_init_chip(struct azx *chip, bool full_reset)
 
        if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
                snd_hdac_set_codec_wakeup(bus, true);
-       if (IS_BROXTON(pci)) {
+       if (IS_SKL_PLUS(pci)) {
                pci_read_config_dword(pci, INTEL_HDA_CGCTL, &val);
                val = val & ~INTEL_HDA_CGCTL_MISCBDCGE;
                pci_write_config_dword(pci, INTEL_HDA_CGCTL, val);
        }
        azx_init_chip(chip, full_reset);
-       if (IS_BROXTON(pci)) {
+       if (IS_SKL_PLUS(pci)) {
                pci_read_config_dword(pci, INTEL_HDA_CGCTL, &val);
                val = val | INTEL_HDA_CGCTL_MISCBDCGE;
                pci_write_config_dword(pci, INTEL_HDA_CGCTL, val);
@@ -555,7 +558,7 @@ static void hda_intel_init_chip(struct azx *chip, bool full_reset)
                snd_hdac_set_codec_wakeup(bus, false);
 
        /* reduce dma latency to avoid noise */
-       if (IS_BROXTON(pci))
+       if (IS_BXT(pci))
                bxt_reduce_dma_latency(chip);
 }
 
@@ -977,11 +980,6 @@ static int azx_resume(struct device *dev)
 /* put codec down to D3 at hibernation for Intel SKL+;
  * otherwise BIOS may still access the codec and screw up the driver
  */
-#define IS_SKL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa170)
-#define IS_SKL_LP(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9d70)
-#define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98)
-#define IS_SKL_PLUS(pci) (IS_SKL(pci) || IS_SKL_LP(pci) || IS_BXT(pci))
-
 static int azx_freeze_noirq(struct device *dev)
 {
        struct pci_dev *pci = to_pci_dev(dev);
@@ -2168,10 +2166,10 @@ static void azx_remove(struct pci_dev *pci)
        struct hda_intel *hda;
 
        if (card) {
-               /* flush the pending probing work */
+               /* cancel the pending probing work */
                chip = card->private_data;
                hda = container_of(chip, struct hda_intel, chip);
-               flush_work(&hda->probe_work);
+               cancel_work_sync(&hda->probe_work);
 
                snd_card_free(card);
        }
index c945e25..a33234e 100644 (file)
@@ -259,7 +259,7 @@ snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
                if (!callback)
                        return ERR_PTR(-ENOMEM);
                callback->func = func;
-               callback->tbl = jack;
+               callback->nid = jack->nid;
                callback->next = jack->callback;
                jack->callback = callback;
        }
index 858708a..e9814c0 100644 (file)
@@ -21,7 +21,7 @@ struct hda_jack_callback;
 typedef void (*hda_jack_callback_fn) (struct hda_codec *, struct hda_jack_callback *);
 
 struct hda_jack_callback {
-       struct hda_jack_tbl *tbl;
+       hda_nid_t nid;
        hda_jack_callback_fn func;
        unsigned int private_data;      /* arbitrary data */
        struct hda_jack_callback *next;
index 4ef2259..9ceb2bc 100644 (file)
@@ -4427,13 +4427,16 @@ static void ca0132_process_dsp_response(struct hda_codec *codec,
 static void hp_callback(struct hda_codec *codec, struct hda_jack_callback *cb)
 {
        struct ca0132_spec *spec = codec->spec;
+       struct hda_jack_tbl *tbl;
 
        /* Delay enabling the HP amp, to let the mic-detection
         * state machine run.
         */
        cancel_delayed_work_sync(&spec->unsol_hp_work);
        schedule_delayed_work(&spec->unsol_hp_work, msecs_to_jiffies(500));
-       cb->tbl->block_report = 1;
+       tbl = snd_hda_jack_tbl_get(codec, cb->nid);
+       if (tbl)
+               tbl->block_report = 1;
 }
 
 static void amic_callback(struct hda_codec *codec, struct hda_jack_callback *cb)
index 1f52b55..bcbc4ee 100644 (file)
@@ -448,7 +448,8 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
        eld = &per_pin->sink_eld;
 
        mutex_lock(&per_pin->lock);
-       if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data)) {
+       if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) ||
+           eld->eld_size > ELD_MAX_SIZE) {
                mutex_unlock(&per_pin->lock);
                snd_BUG();
                return -EINVAL;
@@ -1193,7 +1194,7 @@ static void check_presence_and_report(struct hda_codec *codec, hda_nid_t nid)
 static void jack_callback(struct hda_codec *codec,
                          struct hda_jack_callback *jack)
 {
-       check_presence_and_report(codec, jack->tbl->nid);
+       check_presence_and_report(codec, jack->nid);
 }
 
 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
@@ -2476,13 +2477,6 @@ static int patch_generic_hdmi(struct hda_codec *codec)
                        is_broxton(codec))
                codec->core.link_power_control = 1;
 
-       if (codec_has_acomp(codec)) {
-               codec->depop_delay = 0;
-               spec->i915_audio_ops.audio_ptr = codec;
-               spec->i915_audio_ops.pin_eld_notify = intel_pin_eld_notify;
-               snd_hdac_i915_register_notifier(&spec->i915_audio_ops);
-       }
-
        if (hdmi_parse_codec(codec) < 0) {
                if (spec->i915_bound)
                        snd_hdac_i915_exit(&codec->bus->core);
@@ -2504,6 +2498,18 @@ static int patch_generic_hdmi(struct hda_codec *codec)
 
        init_channel_allocations();
 
+       if (codec_has_acomp(codec)) {
+               codec->depop_delay = 0;
+               spec->i915_audio_ops.audio_ptr = codec;
+               /* intel_audio_codec_enable() or intel_audio_codec_disable()
+                * will call pin_eld_notify with using audio_ptr pointer
+                * We need make sure audio_ptr is really setup
+                */
+               wmb();
+               spec->i915_audio_ops.pin_eld_notify = intel_pin_eld_notify;
+               snd_hdac_i915_register_notifier(&spec->i915_audio_ops);
+       }
+
        return 0;
 }
 
index 21992fb..93d2156 100644 (file)
@@ -282,7 +282,7 @@ static void alc_update_knob_master(struct hda_codec *codec,
        uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
        if (!uctl)
                return;
-       val = snd_hda_codec_read(codec, jack->tbl->nid, 0,
+       val = snd_hda_codec_read(codec, jack->nid, 0,
                                 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
        val &= HDA_AMP_VOLMASK;
        uctl->value.integer.value[0] = val;
@@ -1787,7 +1787,6 @@ enum {
        ALC882_FIXUP_NO_PRIMARY_HP,
        ALC887_FIXUP_ASUS_BASS,
        ALC887_FIXUP_BASS_CHMAP,
-       ALC882_FIXUP_DISABLE_AAMIX,
 };
 
 static void alc889_fixup_coef(struct hda_codec *codec,
@@ -1949,8 +1948,6 @@ static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
 
 static void alc_fixup_bass_chmap(struct hda_codec *codec,
                                 const struct hda_fixup *fix, int action);
-static void alc_fixup_disable_aamix(struct hda_codec *codec,
-                                   const struct hda_fixup *fix, int action);
 
 static const struct hda_fixup alc882_fixups[] = {
        [ALC882_FIXUP_ABIT_AW9D_MAX] = {
@@ -2188,10 +2185,6 @@ static const struct hda_fixup alc882_fixups[] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc_fixup_bass_chmap,
        },
-       [ALC882_FIXUP_DISABLE_AAMIX] = {
-               .type = HDA_FIXUP_FUNC,
-               .v.func = alc_fixup_disable_aamix,
-       },
 };
 
 static const struct snd_pci_quirk alc882_fixup_tbl[] = {
@@ -2230,6 +2223,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
        SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
        SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
        SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
+       SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
 
        /* All Apple entries are in codec SSIDs */
        SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
@@ -2259,7 +2253,6 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
        SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
        SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE),
-       SND_PCI_QUIRK(0x1458, 0xa182, "Gigabyte Z170X-UD3", ALC882_FIXUP_DISABLE_AAMIX),
        SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
        SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
        SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
@@ -3808,6 +3801,10 @@ static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
 
 static void alc_headset_mode_default(struct hda_codec *codec)
 {
+       static struct coef_fw coef0225[] = {
+               UPDATE_COEF(0x45, 0x3f<<10, 0x34<<10),
+               {}
+       };
        static struct coef_fw coef0255[] = {
                WRITE_COEF(0x45, 0xc089),
                WRITE_COEF(0x45, 0xc489),
@@ -3849,6 +3846,9 @@ static void alc_headset_mode_default(struct hda_codec *codec)
        };
 
        switch (codec->core.vendor_id) {
+       case 0x10ec0225:
+               alc_process_coef_fw(codec, coef0225);
+               break;
        case 0x10ec0255:
        case 0x10ec0256:
                alc_process_coef_fw(codec, coef0255);
@@ -4756,6 +4756,9 @@ enum {
        ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE,
        ALC293_FIXUP_LENOVO_SPK_NOISE,
        ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY,
+       ALC255_FIXUP_DELL_SPK_NOISE,
+       ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
+       ALC280_FIXUP_HP_HEADSET_MIC,
 };
 
 static const struct hda_fixup alc269_fixups[] = {
@@ -5375,6 +5378,29 @@ static const struct hda_fixup alc269_fixups[] = {
                .type = HDA_FIXUP_FUNC,
                .v.func = alc233_fixup_lenovo_line2_mic_hotkey,
        },
+       [ALC255_FIXUP_DELL_SPK_NOISE] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc_fixup_disable_aamix,
+               .chained = true,
+               .chain_id = ALC255_FIXUP_DELL1_MIC_NO_PRESENCE
+       },
+       [ALC225_FIXUP_DELL1_MIC_NO_PRESENCE] = {
+               .type = HDA_FIXUP_VERBS,
+               .v.verbs = (const struct hda_verb[]) {
+                       /* Disable pass-through path for FRONT 14h */
+                       { 0x20, AC_VERB_SET_COEF_INDEX, 0x36 },
+                       { 0x20, AC_VERB_SET_PROC_COEF, 0x57d7 },
+                       {}
+               },
+               .chained = true,
+               .chain_id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE
+       },
+       [ALC280_FIXUP_HP_HEADSET_MIC] = {
+               .type = HDA_FIXUP_FUNC,
+               .v.func = alc_fixup_disable_aamix,
+               .chained = true,
+               .chain_id = ALC269_FIXUP_HEADSET_MIC,
+       },
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -5386,6 +5412,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1025, 0x080d, "Acer Aspire V5-122P", ALC269_FIXUP_ASPIRE_HEADSET_MIC),
        SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
        SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
+       SND_PCI_QUIRK(0x1025, 0x0762, "Acer Aspire E1-472", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
        SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
        SND_PCI_QUIRK(0x1025, 0x079b, "Acer Aspire V5-573G", ALC282_FIXUP_ASPIRE_V5_PINS),
        SND_PCI_QUIRK(0x1025, 0x106d, "Acer Cloudbook 14", ALC283_FIXUP_CHROME_BOOK),
@@ -5417,6 +5444,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x1028, 0x06df, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
        SND_PCI_QUIRK(0x1028, 0x06e0, "Dell", ALC293_FIXUP_DISABLE_AAMIX_MULTIJACK),
        SND_PCI_QUIRK(0x1028, 0x0704, "Dell XPS 13", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
+       SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
        SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
        SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
@@ -5477,6 +5505,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
        SND_PCI_QUIRK(0x103c, 0x2335, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
        SND_PCI_QUIRK(0x103c, 0x2336, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
        SND_PCI_QUIRK(0x103c, 0x2337, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC1),
+       SND_PCI_QUIRK(0x103c, 0x221c, "HP EliteBook 755 G2", ALC280_FIXUP_HP_HEADSET_MIC),
        SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
        SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
        SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
@@ -5645,10 +5674,10 @@ static const struct hda_model_fixup alc269_fixup_models[] = {
        {0x21, 0x03211020}
 
 static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
-       SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
+       SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
                ALC225_STANDARD_PINS,
                {0x14, 0x901701a0}),
-       SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
+       SND_HDA_PIN_QUIRK(0x10ec0225, 0x1028, "Dell", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE,
                ALC225_STANDARD_PINS,
                {0x14, 0x901701b0}),
        SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell", ALC255_FIXUP_DELL2_MIC_NO_PRESENCE,
index 2c7c5eb..37b70f8 100644 (file)
@@ -493,9 +493,9 @@ static void jack_update_power(struct hda_codec *codec,
        if (!spec->num_pwrs)
                return;
 
-       if (jack && jack->tbl->nid) {
-               stac_toggle_power_map(codec, jack->tbl->nid,
-                                     snd_hda_jack_detect(codec, jack->tbl->nid),
+       if (jack && jack->nid) {
+               stac_toggle_power_map(codec, jack->nid,
+                                     snd_hda_jack_detect(codec, jack->nid),
                                      true);
                return;
        }
index 2875b4f..7c8941b 100644 (file)
@@ -2879,7 +2879,7 @@ static int snd_hdsp_get_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl
 {
        struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
 
-       ucontrol->value.enumerated.item[0] = hdsp_dds_offset(hdsp);
+       ucontrol->value.integer.value[0] = hdsp_dds_offset(hdsp);
        return 0;
 }
 
@@ -2891,7 +2891,7 @@ static int snd_hdsp_put_dds_offset(struct snd_kcontrol *kcontrol, struct snd_ctl
 
        if (!snd_hdsp_use_is_exclusive(hdsp))
                return -EBUSY;
-       val = ucontrol->value.enumerated.item[0];
+       val = ucontrol->value.integer.value[0];
        spin_lock_irq(&hdsp->lock);
        if (val != hdsp_dds_offset(hdsp))
                change = (hdsp_set_dds_offset(hdsp, val) == 0) ? 1 : 0;
index 8bc8016..a4a999a 100644 (file)
@@ -1601,6 +1601,9 @@ static void hdspm_set_dds_value(struct hdspm *hdspm, int rate)
 {
        u64 n;
 
+       if (snd_BUG_ON(rate <= 0))
+               return;
+
        if (rate >= 112000)
                rate /= 4;
        else if (rate >= 56000)
@@ -2215,6 +2218,8 @@ static int hdspm_get_system_sample_rate(struct hdspm *hdspm)
                } else {
                        /* slave mode, return external sample rate */
                        rate = hdspm_external_sample_rate(hdspm);
+                       if (!rate)
+                               rate = hdspm->system_sample_rate;
                }
        }
 
@@ -2260,8 +2265,11 @@ static int snd_hdspm_put_system_sample_rate(struct snd_kcontrol *kcontrol,
                                            ucontrol)
 {
        struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
+       int rate = ucontrol->value.integer.value[0];
 
-       hdspm_set_dds_value(hdspm, ucontrol->value.enumerated.item[0]);
+       if (rate < 27000 || rate > 207000)
+               return -EINVAL;
+       hdspm_set_dds_value(hdspm, ucontrol->value.integer.value[0]);
        return 0;
 }
 
@@ -4449,7 +4457,7 @@ static int snd_hdspm_get_tco_word_term(struct snd_kcontrol *kcontrol,
 {
        struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
 
-       ucontrol->value.enumerated.item[0] = hdspm->tco->term;
+       ucontrol->value.integer.value[0] = hdspm->tco->term;
 
        return 0;
 }
@@ -4460,8 +4468,8 @@ static int snd_hdspm_put_tco_word_term(struct snd_kcontrol *kcontrol,
 {
        struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
 
-       if (hdspm->tco->term != ucontrol->value.enumerated.item[0]) {
-               hdspm->tco->term = ucontrol->value.enumerated.item[0];
+       if (hdspm->tco->term != ucontrol->value.integer.value[0]) {
+               hdspm->tco->term = ucontrol->value.integer.value[0];
 
                hdspm_tco_write(hdspm);
 
index 3191e0a..d1fb035 100644 (file)
@@ -635,6 +635,7 @@ static int acp_dma_open(struct snd_pcm_substream *substream)
                                            SNDRV_PCM_HW_PARAM_PERIODS);
        if (ret < 0) {
                dev_err(prtd->platform->dev, "set integer constraint failed\n");
+               kfree(adata);
                return ret;
        }
 
index affb192..faae693 100644 (file)
@@ -1130,7 +1130,7 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol,
        struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
 
        mutex_lock(&drvdata->ctrl_lock);
-       ucontrol->value.integer.value[0] = drvdata->sid_status;
+       ucontrol->value.enumerated.item[0] = drvdata->sid_status;
        mutex_unlock(&drvdata->ctrl_lock);
 
        return 0;
@@ -1147,7 +1147,7 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol,
 
        dev_dbg(codec->dev, "%s: Enter\n", __func__);
 
-       if (ucontrol->value.integer.value[0] != SID_APPLY_FIR) {
+       if (ucontrol->value.enumerated.item[0] != SID_APPLY_FIR) {
                dev_err(codec->dev,
                        "%s: ERROR: This control supports '%s' only!\n",
                        __func__, enum_sid_state[SID_APPLY_FIR]);
@@ -1199,7 +1199,7 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol,
        struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev);
 
        mutex_lock(&drvdata->ctrl_lock);
-       ucontrol->value.integer.value[0] = drvdata->anc_status;
+       ucontrol->value.enumerated.item[0] = drvdata->anc_status;
        mutex_unlock(&drvdata->ctrl_lock);
 
        return 0;
@@ -1220,7 +1220,7 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol,
 
        mutex_lock(&drvdata->ctrl_lock);
 
-       req = ucontrol->value.integer.value[0];
+       req = ucontrol->value.enumerated.item[0];
        if (req >= ARRAY_SIZE(enum_anc_state)) {
                status = -EINVAL;
                goto cleanup;
index e13583e..5ae87a0 100644 (file)
@@ -103,9 +103,9 @@ bool adau17x1_has_dsp(struct adau *adau);
 #define ADAU17X1_CLOCK_CONTROL_CORECLK_SRC_PLL BIT(3)
 #define ADAU17X1_CLOCK_CONTROL_SYSCLK_EN       BIT(0)
 
-#define ADAU17X1_SERIAL_PORT1_BCLK32           (0x0 << 5)
-#define ADAU17X1_SERIAL_PORT1_BCLK48           (0x1 << 5)
-#define ADAU17X1_SERIAL_PORT1_BCLK64           (0x2 << 5)
+#define ADAU17X1_SERIAL_PORT1_BCLK64           (0x0 << 5)
+#define ADAU17X1_SERIAL_PORT1_BCLK32           (0x1 << 5)
+#define ADAU17X1_SERIAL_PORT1_BCLK48           (0x2 << 5)
 #define ADAU17X1_SERIAL_PORT1_BCLK128          (0x3 << 5)
 #define ADAU17X1_SERIAL_PORT1_BCLK256          (0x4 << 5)
 #define ADAU17X1_SERIAL_PORT1_BCLK_MASK                (0x7 << 5)
index 33143fe..9178531 100644 (file)
@@ -1929,6 +1929,25 @@ static struct {
        { 1000000, 13500000, 0,  1 },
 };
 
+static const unsigned int pseudo_fref_max[ARIZONA_FLL_MAX_FRATIO] = {
+       13500000,
+        6144000,
+        6144000,
+        3072000,
+        3072000,
+        2822400,
+        2822400,
+        1536000,
+        1536000,
+        1536000,
+        1536000,
+        1536000,
+        1536000,
+        1536000,
+        1536000,
+         768000,
+};
+
 static struct {
        unsigned int min;
        unsigned int max;
@@ -2042,16 +2061,32 @@ static int arizona_calc_fratio(struct arizona_fll *fll,
        /* Adjust FRATIO/refdiv to avoid integer mode if possible */
        refdiv = cfg->refdiv;
 
+       arizona_fll_dbg(fll, "pseudo: initial ratio=%u fref=%u refdiv=%u\n",
+                       init_ratio, Fref, refdiv);
+
        while (div <= ARIZONA_FLL_MAX_REFDIV) {
                for (ratio = init_ratio; ratio <= ARIZONA_FLL_MAX_FRATIO;
                     ratio++) {
                        if ((ARIZONA_FLL_VCO_CORNER / 2) /
-                           (fll->vco_mult * ratio) < Fref)
+                           (fll->vco_mult * ratio) < Fref) {
+                               arizona_fll_dbg(fll, "pseudo: hit VCO corner\n");
                                break;
+                       }
+
+                       if (Fref > pseudo_fref_max[ratio - 1]) {
+                               arizona_fll_dbg(fll,
+                                       "pseudo: exceeded max fref(%u) for ratio=%u\n",
+                                       pseudo_fref_max[ratio - 1],
+                                       ratio);
+                               break;
+                       }
 
                        if (target % (ratio * Fref)) {
                                cfg->refdiv = refdiv;
                                cfg->fratio = ratio - 1;
+                               arizona_fll_dbg(fll,
+                                       "pseudo: found fref=%u refdiv=%d(%d) ratio=%d\n",
+                                       Fref, refdiv, div, ratio);
                                return ratio;
                        }
                }
@@ -2060,6 +2095,9 @@ static int arizona_calc_fratio(struct arizona_fll *fll,
                        if (target % (ratio * Fref)) {
                                cfg->refdiv = refdiv;
                                cfg->fratio = ratio - 1;
+                               arizona_fll_dbg(fll,
+                                       "pseudo: found fref=%u refdiv=%d(%d) ratio=%d\n",
+                                       Fref, refdiv, div, ratio);
                                return ratio;
                        }
                }
@@ -2068,6 +2106,9 @@ static int arizona_calc_fratio(struct arizona_fll *fll,
                Fref /= 2;
                refdiv++;
                init_ratio = arizona_find_fratio(Fref, NULL);
+               arizona_fll_dbg(fll,
+                               "pseudo: change fref=%u refdiv=%d(%d) ratio=%u\n",
+                               Fref, refdiv, div, init_ratio);
        }
 
        arizona_fll_warn(fll, "Falling back to integer mode operation\n");
index b395152..35488f1 100644 (file)
@@ -60,15 +60,15 @@ static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol,
        switch (value) {
        default:
        case 0:
-               ucontrol->value.integer.value[0] = 0;
+               ucontrol->value.enumerated.item[0] = 0;
                break;
        /* same value : (L+R)/2 and (R+L)/2 */
        case 1:
        case 2:
-               ucontrol->value.integer.value[0] = 1;
+               ucontrol->value.enumerated.item[0] = 1;
                break;
        case 3:
-               ucontrol->value.integer.value[0] = 2;
+               ucontrol->value.enumerated.item[0] = 2;
                break;
        }
 
@@ -85,7 +85,7 @@ static int cs42l51_set_chan_mix(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        unsigned char val;
 
-       switch (ucontrol->value.integer.value[0]) {
+       switch (ucontrol->value.enumerated.item[0]) {
        default:
        case 0:
                val = CHAN_MIX_NORMAL;
index 1d5a89c..461506a 100644 (file)
@@ -334,7 +334,7 @@ static int da732x_hpf_set(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value;
        unsigned int reg = enum_ctrl->reg;
-       unsigned int sel = ucontrol->value.integer.value[0];
+       unsigned int sel = ucontrol->value.enumerated.item[0];
        unsigned int bits;
 
        switch (sel) {
@@ -368,13 +368,13 @@ static int da732x_hpf_get(struct snd_kcontrol *kcontrol,
 
        switch (val) {
        case DA732X_HPF_VOICE_EN:
-               ucontrol->value.integer.value[0] = DA732X_HPF_VOICE;
+               ucontrol->value.enumerated.item[0] = DA732X_HPF_VOICE;
                break;
        case DA732X_HPF_MUSIC_EN:
-               ucontrol->value.integer.value[0] = DA732X_HPF_MUSIC;
+               ucontrol->value.enumerated.item[0] = DA732X_HPF_MUSIC;
                break;
        default:
-               ucontrol->value.integer.value[0] = DA732X_HPF_DISABLED;
+               ucontrol->value.enumerated.item[0] = DA732X_HPF_DISABLED;
                break;
        }
 
index 20dcc49..fc22804 100644 (file)
@@ -1496,7 +1496,7 @@ static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol,
        struct max98088_pdata *pdata = max98088->pdata;
        int channel = max98088_get_channel(codec, kcontrol->id.name);
        struct max98088_cdata *cdata;
-       int sel = ucontrol->value.integer.value[0];
+       int sel = ucontrol->value.enumerated.item[0];
 
        if (channel < 0)
               return channel;
index 1fedac5..3577003 100644 (file)
@@ -1499,7 +1499,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
        struct max98095_pdata *pdata = max98095->pdata;
        int channel = max98095_get_eq_channel(kcontrol->id.name);
        struct max98095_cdata *cdata;
-       unsigned int sel = ucontrol->value.integer.value[0];
+       unsigned int sel = ucontrol->value.enumerated.item[0];
        struct max98095_eq_cfg *coef_set;
        int fs, best, best_val, i;
        int regmask, regsave;
@@ -1653,7 +1653,7 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
        struct max98095_pdata *pdata = max98095->pdata;
        int channel = max98095_get_bq_channel(codec, kcontrol->id.name);
        struct max98095_cdata *cdata;
-       unsigned int sel = ucontrol->value.integer.value[0];
+       unsigned int sel = ucontrol->value.enumerated.item[0];
        struct max98095_biquad_cfg *coef_set;
        int fs, best, best_val, i;
        int regmask, regsave;
index bc08f0c..1bd3164 100644 (file)
@@ -266,6 +266,8 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic)
                } else {
                        *mic = false;
                        regmap_write(rt286->regmap, RT286_SET_MIC1, 0x20);
+                       regmap_update_bits(rt286->regmap,
+                               RT286_CBJ_CTRL1, 0x0400, 0x0000);
                }
        } else {
                regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf);
@@ -470,24 +472,6 @@ static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w,
        return 0;
 }
 
-static int rt286_vref_event(struct snd_soc_dapm_widget *w,
-                            struct snd_kcontrol *kcontrol, int event)
-{
-       struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
-
-       switch (event) {
-       case SND_SOC_DAPM_PRE_PMU:
-               snd_soc_update_bits(codec,
-                       RT286_CBJ_CTRL1, 0x0400, 0x0000);
-               mdelay(50);
-               break;
-       default:
-               return 0;
-       }
-
-       return 0;
-}
-
 static int rt286_ldo2_event(struct snd_soc_dapm_widget *w,
                             struct snd_kcontrol *kcontrol, int event)
 {
@@ -536,7 +520,7 @@ static const struct snd_soc_dapm_widget rt286_dapm_widgets[] = {
        SND_SOC_DAPM_SUPPLY_S("HV", 1, RT286_POWER_CTRL1,
                12, 1, NULL, 0),
        SND_SOC_DAPM_SUPPLY("VREF", RT286_POWER_CTRL1,
-               0, 1, rt286_vref_event, SND_SOC_DAPM_PRE_PMU),
+               0, 1, NULL, 0),
        SND_SOC_DAPM_SUPPLY_S("LDO1", 1, RT286_POWER_CTRL2,
                2, 0, NULL, 0),
        SND_SOC_DAPM_SUPPLY_S("LDO2", 2, RT286_POWER_CTRL1,
@@ -911,8 +895,6 @@ static int rt286_set_bias_level(struct snd_soc_codec *codec,
        case SND_SOC_BIAS_ON:
                mdelay(10);
                snd_soc_update_bits(codec,
-                       RT286_CBJ_CTRL1, 0x0400, 0x0400);
-               snd_soc_update_bits(codec,
                        RT286_DC_GAIN, 0x200, 0x0);
 
                break;
@@ -920,8 +902,6 @@ static int rt286_set_bias_level(struct snd_soc_codec *codec,
        case SND_SOC_BIAS_STANDBY:
                snd_soc_write(codec,
                        RT286_SET_AUDIO_POWER, AC_PWRST_D3);
-               snd_soc_update_bits(codec,
-                       RT286_CBJ_CTRL1, 0x0400, 0x0000);
                break;
 
        default:
index c61d38b..93e8c90 100644 (file)
@@ -776,7 +776,7 @@ static const struct snd_kcontrol_new rt5645_snd_controls[] = {
 
        /* IN1/IN2 Control */
        SOC_SINGLE_TLV("IN1 Boost", RT5645_IN1_CTRL1,
-               RT5645_BST_SFT1, 8, 0, bst_tlv),
+               RT5645_BST_SFT1, 12, 0, bst_tlv),
        SOC_SINGLE_TLV("IN2 Boost", RT5645_IN2_CTRL,
                RT5645_BST_SFT2, 8, 0, bst_tlv),
 
index 820d8fa..fb8ea05 100644 (file)
@@ -3985,7 +3985,6 @@ static int rt5659_i2c_probe(struct i2c_client *i2c,
        if (rt5659 == NULL)
                return -ENOMEM;
 
-       rt5659->i2c = i2c;
        i2c_set_clientdata(i2c, rt5659);
 
        if (pdata)
@@ -4157,24 +4156,17 @@ static int rt5659_i2c_probe(struct i2c_client *i2c,
 
        INIT_DELAYED_WORK(&rt5659->jack_detect_work, rt5659_jack_detect_work);
 
-       if (rt5659->i2c->irq) {
-               ret = request_threaded_irq(rt5659->i2c->irq, NULL, rt5659_irq,
-                       IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
+       if (i2c->irq) {
+               ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL,
+                       rt5659_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
                        | IRQF_ONESHOT, "rt5659", rt5659);
                if (ret)
                        dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret);
 
        }
 
-       ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5659,
+       return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5659,
                        rt5659_dai, ARRAY_SIZE(rt5659_dai));
-
-       if (ret) {
-               if (rt5659->i2c->irq)
-                       free_irq(rt5659->i2c->irq, rt5659);
-       }
-
-       return 0;
 }
 
 static int rt5659_i2c_remove(struct i2c_client *i2c)
@@ -4191,24 +4183,29 @@ void rt5659_i2c_shutdown(struct i2c_client *client)
        regmap_write(rt5659->regmap, RT5659_RESET, 0);
 }
 
+#ifdef CONFIG_OF
 static const struct of_device_id rt5659_of_match[] = {
        { .compatible = "realtek,rt5658", },
        { .compatible = "realtek,rt5659", },
-       {},
+       { },
 };
+MODULE_DEVICE_TABLE(of, rt5659_of_match);
+#endif
 
+#ifdef CONFIG_ACPI
 static struct acpi_device_id rt5659_acpi_match[] = {
-               { "10EC5658", 0},
-               { "10EC5659", 0},
-               { },
+       { "10EC5658", 0, },
+       { "10EC5659", 0, },
+       { },
 };
 MODULE_DEVICE_TABLE(acpi, rt5659_acpi_match);
+#endif
 
 struct i2c_driver rt5659_i2c_driver = {
        .driver = {
                .name = "rt5659",
                .owner = THIS_MODULE,
-               .of_match_table = rt5659_of_match,
+               .of_match_table = of_match_ptr(rt5659_of_match),
                .acpi_match_table = ACPI_PTR(rt5659_acpi_match),
        },
        .probe = rt5659_i2c_probe,
index 8f07ee9..d31c9e5 100644 (file)
@@ -1792,7 +1792,6 @@ struct rt5659_priv {
        struct snd_soc_codec *codec;
        struct rt5659_platform_data pdata;
        struct regmap *regmap;
-       struct i2c_client *i2c;
        struct gpio_desc *gpiod_ldo1_en;
        struct gpio_desc *gpiod_reset;
        struct snd_soc_jack *hs_jack;
index 21ca3a5..d374c18 100644 (file)
@@ -31,7 +31,10 @@ static int sigmadsp_write_i2c(void *control_data,
 
        kfree(buf);
 
-       return ret;
+       if (ret < 0)
+               return ret;
+
+       return 0;
 }
 
 static int sigmadsp_read_i2c(void *control_data,
index 781398f..f7a6ce7 100644 (file)
@@ -446,7 +446,7 @@ static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec);
 
-       ucontrol->value.integer.value[0] = dac33->fifo_mode;
+       ucontrol->value.enumerated.item[0] = dac33->fifo_mode;
 
        return 0;
 }
@@ -458,17 +458,16 @@ static int dac33_set_fifo_mode(struct snd_kcontrol *kcontrol,
        struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec);
        int ret = 0;
 
-       if (dac33->fifo_mode == ucontrol->value.integer.value[0])
+       if (dac33->fifo_mode == ucontrol->value.enumerated.item[0])
                return 0;
        /* Do not allow changes while stream is running*/
        if (snd_soc_codec_is_active(codec))
                return -EPERM;
 
-       if (ucontrol->value.integer.value[0] < 0 ||
-           ucontrol->value.integer.value[0] >= DAC33_FIFO_LAST_MODE)
+       if (ucontrol->value.enumerated.item[0] >= DAC33_FIFO_LAST_MODE)
                ret = -EINVAL;
        else
-               dac33->fifo_mode = ucontrol->value.integer.value[0];
+               dac33->fifo_mode = ucontrol->value.enumerated.item[0];
 
        return ret;
 }
index 7693c11..1b79778 100644 (file)
@@ -175,7 +175,7 @@ static int snd_wl1273_get_audio_route(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
 
-       ucontrol->value.integer.value[0] = wl1273->mode;
+       ucontrol->value.enumerated.item[0] = wl1273->mode;
 
        return 0;
 }
@@ -193,18 +193,17 @@ static int snd_wl1273_set_audio_route(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
 
-       if (wl1273->mode == ucontrol->value.integer.value[0])
+       if (wl1273->mode == ucontrol->value.enumerated.item[0])
                return 0;
 
        /* Do not allow changes while stream is running */
        if (snd_soc_codec_is_active(codec))
                return -EPERM;
 
-       if (ucontrol->value.integer.value[0] < 0 ||
-           ucontrol->value.integer.value[0] >=  ARRAY_SIZE(wl1273_audio_route))
+       if (ucontrol->value.enumerated.item[0] >=  ARRAY_SIZE(wl1273_audio_route))
                return -EINVAL;
 
-       wl1273->mode = ucontrol->value.integer.value[0];
+       wl1273->mode = ucontrol->value.enumerated.item[0];
 
        return 1;
 }
@@ -219,7 +218,7 @@ static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol,
 
        dev_dbg(codec->dev, "%s: enter.\n", __func__);
 
-       ucontrol->value.integer.value[0] = wl1273->core->audio_mode;
+       ucontrol->value.enumerated.item[0] = wl1273->core->audio_mode;
 
        return 0;
 }
@@ -233,7 +232,7 @@ static int snd_wl1273_fm_audio_put(struct snd_kcontrol *kcontrol,
 
        dev_dbg(codec->dev, "%s: enter.\n", __func__);
 
-       val = ucontrol->value.integer.value[0];
+       val = ucontrol->value.enumerated.item[0];
        if (wl1273->core->audio_mode == val)
                return 0;
 
index 6088d30..97c0f1e 100644 (file)
@@ -2382,6 +2382,7 @@ error:
 
 static int wm5110_remove(struct platform_device *pdev)
 {
+       snd_soc_unregister_platform(&pdev->dev);
        snd_soc_unregister_codec(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
 
index 61299ca..6f1024f 100644 (file)
@@ -233,7 +233,7 @@ static int wm8753_get_dai(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
 
-       ucontrol->value.integer.value[0] = wm8753->dai_func;
+       ucontrol->value.enumerated.item[0] = wm8753->dai_func;
        return 0;
 }
 
@@ -244,7 +244,7 @@ static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
        struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec);
        u16 ioctl;
 
-       if (wm8753->dai_func == ucontrol->value.integer.value[0])
+       if (wm8753->dai_func == ucontrol->value.enumerated.item[0])
                return 0;
 
        if (snd_soc_codec_is_active(codec))
@@ -252,7 +252,7 @@ static int wm8753_set_dai(struct snd_kcontrol *kcontrol,
 
        ioctl = snd_soc_read(codec, WM8753_IOCTL);
 
-       wm8753->dai_func = ucontrol->value.integer.value[0];
+       wm8753->dai_func = ucontrol->value.enumerated.item[0];
 
        if (((ioctl >> 2) & 0x3) == wm8753->dai_func)
                return 1;
index 8172e49..edd7a77 100644 (file)
@@ -396,7 +396,7 @@ static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
        struct wm8904_pdata *pdata = wm8904->pdata;
-       int value = ucontrol->value.integer.value[0];
+       int value = ucontrol->value.enumerated.item[0];
 
        if (value >= pdata->num_drc_cfgs)
                return -EINVAL;
@@ -467,7 +467,7 @@ static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec);
        struct wm8904_pdata *pdata = wm8904->pdata;
-       int value = ucontrol->value.integer.value[0];
+       int value = ucontrol->value.enumerated.item[0];
 
        if (value >= pdata->num_retune_mobile_cfgs)
                return -EINVAL;
index c799cca..6b864c0 100644 (file)
@@ -459,7 +459,7 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
-       int value = ucontrol->value.integer.value[0];
+       int value = ucontrol->value.enumerated.item[0];
        int reg;
 
        /* Don't allow on the fly reconfiguration */
@@ -549,7 +549,7 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
-       int value = ucontrol->value.integer.value[0];
+       int value = ucontrol->value.enumerated.item[0];
        int reg;
 
        /* Don't allow on the fly reconfiguration */
@@ -582,7 +582,7 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
-       int value = ucontrol->value.integer.value[0];
+       int value = ucontrol->value.enumerated.item[0];
        int reg;
 
        /* Don't allow on the fly reconfiguration */
@@ -749,7 +749,7 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol,
        struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
        struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
        struct wm8994 *control = wm8994->wm8994;
-       int value = ucontrol->value.integer.value[0];
+       int value = ucontrol->value.enumerated.item[0];
        int reg;
 
        /* Don't allow on the fly reconfiguration */
index ff23772..d7f444f 100644 (file)
@@ -240,13 +240,13 @@ SOC_DOUBLE_R("Capture Volume ZC Switch", WM8960_LINVOL, WM8960_RINVOL,
 SOC_DOUBLE_R("Capture Switch", WM8960_LINVOL, WM8960_RINVOL,
        7, 1, 1),
 
-SOC_SINGLE_TLV("Right Input Boost Mixer RINPUT3 Volume",
+SOC_SINGLE_TLV("Left Input Boost Mixer LINPUT3 Volume",
               WM8960_INBMIX1, 4, 7, 0, lineinboost_tlv),
-SOC_SINGLE_TLV("Right Input Boost Mixer RINPUT2 Volume",
+SOC_SINGLE_TLV("Left Input Boost Mixer LINPUT2 Volume",
               WM8960_INBMIX1, 1, 7, 0, lineinboost_tlv),
-SOC_SINGLE_TLV("Left Input Boost Mixer LINPUT3 Volume",
+SOC_SINGLE_TLV("Right Input Boost Mixer RINPUT3 Volume",
               WM8960_INBMIX2, 4, 7, 0, lineinboost_tlv),
-SOC_SINGLE_TLV("Left Input Boost Mixer LINPUT2 Volume",
+SOC_SINGLE_TLV("Right Input Boost Mixer RINPUT2 Volume",
               WM8960_INBMIX2, 1, 7, 0, lineinboost_tlv),
 SOC_SINGLE_TLV("Right Input Boost Mixer RINPUT1 Volume",
                WM8960_RINPATH, 4, 3, 0, micboost_tlv),
@@ -643,29 +643,31 @@ static int wm8960_configure_clocking(struct snd_soc_codec *codec)
                return -EINVAL;
        }
 
-       /* check if the sysclk frequency is available. */
-       for (i = 0; i < ARRAY_SIZE(sysclk_divs); ++i) {
-               if (sysclk_divs[i] == -1)
-                       continue;
-               sysclk = freq_out / sysclk_divs[i];
-               for (j = 0; j < ARRAY_SIZE(dac_divs); ++j) {
-                       if (sysclk == dac_divs[j] * lrclk) {
+       if (wm8960->clk_id != WM8960_SYSCLK_PLL) {
+               /* check if the sysclk frequency is available. */
+               for (i = 0; i < ARRAY_SIZE(sysclk_divs); ++i) {
+                       if (sysclk_divs[i] == -1)
+                               continue;
+                       sysclk = freq_out / sysclk_divs[i];
+                       for (j = 0; j < ARRAY_SIZE(dac_divs); ++j) {
+                               if (sysclk != dac_divs[j] * lrclk)
+                                       continue;
                                for (k = 0; k < ARRAY_SIZE(bclk_divs); ++k)
                                        if (sysclk == bclk * bclk_divs[k] / 10)
                                                break;
                                if (k != ARRAY_SIZE(bclk_divs))
                                        break;
                        }
+                       if (j != ARRAY_SIZE(dac_divs))
+                               break;
                }
-               if (j != ARRAY_SIZE(dac_divs))
-                       break;
-       }
 
-       if (i != ARRAY_SIZE(sysclk_divs)) {
-               goto configure_clock;
-       } else if (wm8960->clk_id != WM8960_SYSCLK_AUTO) {
-               dev_err(codec->dev, "failed to configure clock\n");
-               return -EINVAL;
+               if (i != ARRAY_SIZE(sysclk_divs)) {
+                       goto configure_clock;
+               } else if (wm8960->clk_id != WM8960_SYSCLK_AUTO) {
+                       dev_err(codec->dev, "failed to configure clock\n");
+                       return -EINVAL;
+               }
        }
        /* get a available pll out frequency and set pll */
        for (i = 0; i < ARRAY_SIZE(sysclk_divs); ++i) {
index 7350ff6..0c002a5 100644 (file)
@@ -497,9 +497,9 @@ static int eqmode_get(struct snd_kcontrol *kcontrol,
 
        reg = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF);
        if (reg & WM8983_EQ3DMODE)
-               ucontrol->value.integer.value[0] = 1;
+               ucontrol->value.enumerated.item[0] = 1;
        else
-               ucontrol->value.integer.value[0] = 0;
+               ucontrol->value.enumerated.item[0] = 0;
 
        return 0;
 }
@@ -511,18 +511,18 @@ static int eqmode_put(struct snd_kcontrol *kcontrol,
        unsigned int regpwr2, regpwr3;
        unsigned int reg_eq;
 
-       if (ucontrol->value.integer.value[0] != 0
-           && ucontrol->value.integer.value[0] != 1)
+       if (ucontrol->value.enumerated.item[0] != 0
+           && ucontrol->value.enumerated.item[0] != 1)
                return -EINVAL;
 
        reg_eq = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF);
        switch ((reg_eq & WM8983_EQ3DMODE) >> WM8983_EQ3DMODE_SHIFT) {
        case 0:
-               if (!ucontrol->value.integer.value[0])
+               if (!ucontrol->value.enumerated.item[0])
                        return 0;
                break;
        case 1:
-               if (ucontrol->value.integer.value[0])
+               if (ucontrol->value.enumerated.item[0])
                        return 0;
                break;
        }
@@ -537,7 +537,7 @@ static int eqmode_put(struct snd_kcontrol *kcontrol,
        /* set the desired eqmode */
        snd_soc_update_bits(codec, WM8983_EQ1_LOW_SHELF,
                            WM8983_EQ3DMODE_MASK,
-                           ucontrol->value.integer.value[0]
+                           ucontrol->value.enumerated.item[0]
                            << WM8983_EQ3DMODE_SHIFT);
        /* restore DAC/ADC configuration */
        snd_soc_write(codec, WM8983_POWER_MANAGEMENT_2, regpwr2);
index 9918152..6ac76fe 100644 (file)
@@ -531,9 +531,9 @@ static int eqmode_get(struct snd_kcontrol *kcontrol,
 
        reg = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF);
        if (reg & WM8985_EQ3DMODE)
-               ucontrol->value.integer.value[0] = 1;
+               ucontrol->value.enumerated.item[0] = 1;
        else
-               ucontrol->value.integer.value[0] = 0;
+               ucontrol->value.enumerated.item[0] = 0;
 
        return 0;
 }
@@ -545,18 +545,18 @@ static int eqmode_put(struct snd_kcontrol *kcontrol,
        unsigned int regpwr2, regpwr3;
        unsigned int reg_eq;
 
-       if (ucontrol->value.integer.value[0] != 0
-                       && ucontrol->value.integer.value[0] != 1)
+       if (ucontrol->value.enumerated.item[0] != 0
+                       && ucontrol->value.enumerated.item[0] != 1)
                return -EINVAL;
 
        reg_eq = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF);
        switch ((reg_eq & WM8985_EQ3DMODE) >> WM8985_EQ3DMODE_SHIFT) {
        case 0:
-               if (!ucontrol->value.integer.value[0])
+               if (!ucontrol->value.enumerated.item[0])
                        return 0;
                break;
        case 1:
-               if (ucontrol->value.integer.value[0])
+               if (ucontrol->value.enumerated.item[0])
                        return 0;
                break;
        }
@@ -573,7 +573,7 @@ static int eqmode_put(struct snd_kcontrol *kcontrol,
        /* set the desired eqmode */
        snd_soc_update_bits(codec, WM8985_EQ1_LOW_SHELF,
                            WM8985_EQ3DMODE_MASK,
-                           ucontrol->value.integer.value[0]
+                           ucontrol->value.enumerated.item[0]
                            << WM8985_EQ3DMODE_SHIFT);
        /* restore DAC/ADC configuration */
        snd_soc_write(codec, WM8985_POWER_MANAGEMENT_2, regpwr2);
index 2ccbb32..a18aecb 100644 (file)
@@ -362,7 +362,7 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol,
        struct wm8994 *control = wm8994->wm8994;
        struct wm8994_pdata *pdata = &control->pdata;
        int drc = wm8994_get_drc(kcontrol->id.name);
-       int value = ucontrol->value.integer.value[0];
+       int value = ucontrol->value.enumerated.item[0];
 
        if (drc < 0)
                return drc;
@@ -469,7 +469,7 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
        struct wm8994 *control = wm8994->wm8994;
        struct wm8994_pdata *pdata = &control->pdata;
        int block = wm8994_get_retune_mobile_block(kcontrol->id.name);
-       int value = ucontrol->value.integer.value[0];
+       int value = ucontrol->value.enumerated.item[0];
 
        if (block < 0)
                return block;
index 8d7d6c0..f99b34f 100644 (file)
@@ -416,7 +416,7 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
        struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec);
        struct wm8996_pdata *pdata = &wm8996->pdata;
        int block = wm8996_get_retune_mobile_block(kcontrol->id.name);
-       int value = ucontrol->value.integer.value[0];
+       int value = ucontrol->value.enumerated.item[0];
 
        if (block < 0)
                return block;
index ccb3b15..363b3b6 100644 (file)
@@ -344,9 +344,9 @@ static int speaker_mode_get(struct snd_kcontrol *kcontrol,
 
        reg = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2);
        if (reg & WM9081_SPK_MODE)
-               ucontrol->value.integer.value[0] = 1;
+               ucontrol->value.enumerated.item[0] = 1;
        else
-               ucontrol->value.integer.value[0] = 0;
+               ucontrol->value.enumerated.item[0] = 0;
 
        return 0;
 }
@@ -365,7 +365,7 @@ static int speaker_mode_put(struct snd_kcontrol *kcontrol,
        unsigned int reg2 = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2);
 
        /* Are we changing anything? */
-       if (ucontrol->value.integer.value[0] ==
+       if (ucontrol->value.enumerated.item[0] ==
            ((reg2 & WM9081_SPK_MODE) != 0))
                return 0;
 
@@ -373,7 +373,7 @@ static int speaker_mode_put(struct snd_kcontrol *kcontrol,
        if (reg_pwr & WM9081_SPK_ENA)
                return -EINVAL;
 
-       if (ucontrol->value.integer.value[0]) {
+       if (ucontrol->value.enumerated.item[0]) {
                /* Class AB */
                reg2 &= ~(WM9081_SPK_INV_MUTE | WM9081_OUT_SPK_CTRL);
                reg2 |= WM9081_SPK_MODE;
index 79e1436..9849643 100644 (file)
@@ -1212,7 +1212,7 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
        if (IS_ERR(wm9713->ac97))
                return PTR_ERR(wm9713->ac97);
 
-       regmap = devm_regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config);
+       regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config);
        if (IS_ERR(regmap)) {
                snd_soc_free_ac97_codec(wm9713->ac97);
                return PTR_ERR(regmap);
index 33806d4..b9195b9 100644 (file)
@@ -586,7 +586,7 @@ static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol,
        struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
        struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec);
 
-       ucontrol->value.integer.value[0] = dsp[e->shift_l].fw;
+       ucontrol->value.enumerated.item[0] = dsp[e->shift_l].fw;
 
        return 0;
 }
@@ -599,10 +599,10 @@ static int wm_adsp_fw_put(struct snd_kcontrol *kcontrol,
        struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec);
        int ret = 0;
 
-       if (ucontrol->value.integer.value[0] == dsp[e->shift_l].fw)
+       if (ucontrol->value.enumerated.item[0] == dsp[e->shift_l].fw)
                return 0;
 
-       if (ucontrol->value.integer.value[0] >= WM_ADSP_NUM_FW)
+       if (ucontrol->value.enumerated.item[0] >= WM_ADSP_NUM_FW)
                return -EINVAL;
 
        mutex_lock(&dsp[e->shift_l].pwr_lock);
@@ -610,7 +610,7 @@ static int wm_adsp_fw_put(struct snd_kcontrol *kcontrol,
        if (dsp[e->shift_l].running || dsp[e->shift_l].compr)
                ret = -EBUSY;
        else
-               dsp[e->shift_l].fw = ucontrol->value.integer.value[0];
+               dsp[e->shift_l].fw = ucontrol->value.enumerated.item[0];
 
        mutex_unlock(&dsp[e->shift_l].pwr_lock);
 
index ce664c2..bff258d 100644 (file)
@@ -645,6 +645,8 @@ static int dw_i2s_probe(struct platform_device *pdev)
 
        dev->dev = &pdev->dev;
 
+       dev->i2s_reg_comp1 = I2S_COMP_PARAM_1;
+       dev->i2s_reg_comp2 = I2S_COMP_PARAM_2;
        if (pdata) {
                dev->capability = pdata->cap;
                clk_id = NULL;
@@ -652,9 +654,6 @@ static int dw_i2s_probe(struct platform_device *pdev)
                if (dev->quirks & DW_I2S_QUIRK_COMP_REG_OFFSET) {
                        dev->i2s_reg_comp1 = pdata->i2s_reg_comp1;
                        dev->i2s_reg_comp2 = pdata->i2s_reg_comp2;
-               } else {
-                       dev->i2s_reg_comp1 = I2S_COMP_PARAM_1;
-                       dev->i2s_reg_comp2 = I2S_COMP_PARAM_2;
                }
                ret = dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata);
        } else {
index a407e83..fb896b2 100644 (file)
@@ -72,8 +72,6 @@ static int imx_spdif_audio_probe(struct platform_device *pdev)
                goto end;
        }
 
-       platform_set_drvdata(pdev, data);
-
 end:
        of_node_put(spdif_np);
 
index 1ded881..2389ab4 100644 (file)
@@ -99,7 +99,7 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
                if (ret && ret != -ENOTSUPP)
                        goto err;
        }
-
+       return 0;
 err:
        return ret;
 }
index 803f95e..7d7c872 100644 (file)
@@ -30,11 +30,15 @@ config SND_SST_IPC_ACPI
 config SND_SOC_INTEL_SST
        tristate
        select SND_SOC_INTEL_SST_ACPI if ACPI
+       select SND_SOC_INTEL_SST_MATCH if ACPI
        depends on (X86 || COMPILE_TEST)
 
 config SND_SOC_INTEL_SST_ACPI
        tristate
 
+config SND_SOC_INTEL_SST_MATCH
+       tristate
+
 config SND_SOC_INTEL_HASWELL
        tristate
 
@@ -57,7 +61,7 @@ config SND_SOC_INTEL_HASWELL_MACH
 config SND_SOC_INTEL_BYT_RT5640_MACH
        tristate "ASoC Audio driver for Intel Baytrail with RT5640 codec"
        depends on X86_INTEL_LPSS && I2C
-       depends on DW_DMAC_CORE=y && (SND_SOC_INTEL_BYTCR_RT5640_MACH = n)
+       depends on DW_DMAC_CORE=y && (SND_SST_IPC_ACPI = n)
        select SND_SOC_INTEL_SST
        select SND_SOC_INTEL_BAYTRAIL
        select SND_SOC_RT5640
@@ -69,7 +73,7 @@ config SND_SOC_INTEL_BYT_RT5640_MACH
 config SND_SOC_INTEL_BYT_MAX98090_MACH
        tristate "ASoC Audio driver for Intel Baytrail with MAX98090 codec"
        depends on X86_INTEL_LPSS && I2C
-       depends on DW_DMAC_CORE=y
+       depends on DW_DMAC_CORE=y && (SND_SST_IPC_ACPI = n)
        select SND_SOC_INTEL_SST
        select SND_SOC_INTEL_BAYTRAIL
        select SND_SOC_MAX98090
@@ -97,6 +101,7 @@ config SND_SOC_INTEL_BYTCR_RT5640_MACH
        select SND_SOC_RT5640
        select SND_SST_MFLD_PLATFORM
        select SND_SST_IPC_ACPI
+       select SND_SOC_INTEL_SST_MATCH if ACPI
        help
           This adds support for ASoC machine driver for Intel(R) Baytrail and Baytrail-CR
           platforms with RT5640 audio codec.
@@ -109,6 +114,7 @@ config SND_SOC_INTEL_BYTCR_RT5651_MACH
        select SND_SOC_RT5651
        select SND_SST_MFLD_PLATFORM
        select SND_SST_IPC_ACPI
+       select SND_SOC_INTEL_SST_MATCH if ACPI
        help
           This adds support for ASoC machine driver for Intel(R) Baytrail and Baytrail-CR
           platforms with RT5651 audio codec.
@@ -121,6 +127,7 @@ config SND_SOC_INTEL_CHT_BSW_RT5672_MACH
         select SND_SOC_RT5670
         select SND_SST_MFLD_PLATFORM
         select SND_SST_IPC_ACPI
+       select SND_SOC_INTEL_SST_MATCH if ACPI
         help
           This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
           platforms with RT5672 audio codec.
@@ -133,6 +140,7 @@ config SND_SOC_INTEL_CHT_BSW_RT5645_MACH
        select SND_SOC_RT5645
        select SND_SST_MFLD_PLATFORM
        select SND_SST_IPC_ACPI
+       select SND_SOC_INTEL_SST_MATCH if ACPI
        help
          This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
          platforms with RT5645/5650 audio codec.
@@ -145,6 +153,7 @@ config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH
        select SND_SOC_TS3A227E
        select SND_SST_MFLD_PLATFORM
        select SND_SST_IPC_ACPI
+       select SND_SOC_INTEL_SST_MATCH if ACPI
        help
       This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell
       platforms with MAX98090 audio codec it also can support TI jack chip as aux device.
index 55c33dc..52ed434 100644 (file)
@@ -528,6 +528,7 @@ static struct snd_soc_dai_driver sst_platform_dai[] = {
        .ops = &sst_compr_dai_ops,
        .playback = {
                .stream_name = "Compress Playback",
+               .channels_min = 1,
        },
 },
 /* BE CPU  Dais */
index 2d3afdd..a7b96a9 100644 (file)
@@ -367,8 +367,12 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
        }
        card->dev = &pdev->dev;
        sprintf(codec_name, "i2c-%s:00", drv->acpi_card->codec_id);
+
        /* set correct codec name */
-       strcpy((char *)card->dai_link[2].codec_name, codec_name);
+       for (i = 0; i < ARRAY_SIZE(cht_dailink); i++)
+               if (!strcmp(card->dai_link[i].codec_name, "i2c-10EC5645:00"))
+                       card->dai_link[i].codec_name = kstrdup(codec_name, GFP_KERNEL);
+
        snd_soc_card_set_drvdata(card, drv);
        ret_val = devm_snd_soc_register_card(&pdev->dev, card);
        if (ret_val) {
index 49c09a0..34f46c7 100644 (file)
@@ -94,7 +94,7 @@ static const struct soc_enum lo_enum =
 static int headset_get_switch(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = hs_switch;
+       ucontrol->value.enumerated.item[0] = hs_switch;
        return 0;
 }
 
@@ -104,12 +104,12 @@ static int headset_set_switch(struct snd_kcontrol *kcontrol,
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
        struct snd_soc_dapm_context *dapm = &card->dapm;
 
-       if (ucontrol->value.integer.value[0] == hs_switch)
+       if (ucontrol->value.enumerated.item[0] == hs_switch)
                return 0;
 
        snd_soc_dapm_mutex_lock(dapm);
 
-       if (ucontrol->value.integer.value[0]) {
+       if (ucontrol->value.enumerated.item[0]) {
                pr_debug("hs_set HS path\n");
                snd_soc_dapm_enable_pin_unlocked(dapm, "Headphones");
                snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT");
@@ -123,7 +123,7 @@ static int headset_set_switch(struct snd_kcontrol *kcontrol,
 
        snd_soc_dapm_mutex_unlock(dapm);
 
-       hs_switch = ucontrol->value.integer.value[0];
+       hs_switch = ucontrol->value.enumerated.item[0];
 
        return 0;
 }
@@ -148,7 +148,7 @@ static void lo_enable_out_pins(struct snd_soc_dapm_context *dapm)
 static int lo_get_switch(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = lo_dac;
+       ucontrol->value.enumerated.item[0] = lo_dac;
        return 0;
 }
 
@@ -158,7 +158,7 @@ static int lo_set_switch(struct snd_kcontrol *kcontrol,
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
        struct snd_soc_dapm_context *dapm = &card->dapm;
 
-       if (ucontrol->value.integer.value[0] == lo_dac)
+       if (ucontrol->value.enumerated.item[0] == lo_dac)
                return 0;
 
        snd_soc_dapm_mutex_lock(dapm);
@@ -168,7 +168,7 @@ static int lo_set_switch(struct snd_kcontrol *kcontrol,
         */
        lo_enable_out_pins(dapm);
 
-       switch (ucontrol->value.integer.value[0]) {
+       switch (ucontrol->value.enumerated.item[0]) {
        case 0:
                pr_debug("set vibra path\n");
                snd_soc_dapm_disable_pin_unlocked(dapm, "VIB1OUT");
@@ -202,7 +202,7 @@ static int lo_set_switch(struct snd_kcontrol *kcontrol,
 
        snd_soc_dapm_mutex_unlock(dapm);
 
-       lo_dac = ucontrol->value.integer.value[0];
+       lo_dac = ucontrol->value.enumerated.item[0];
        return 0;
 }
 
index 7396ddb..2cbcbe4 100644 (file)
@@ -212,7 +212,10 @@ static int skylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
 {
        struct snd_interval *channels = hw_param_interval(params,
                                                SNDRV_PCM_HW_PARAM_CHANNELS);
-       channels->min = channels->max = 4;
+       if (params_channels(params) == 2)
+               channels->min = channels->max = 2;
+       else
+               channels->min = channels->max = 4;
 
        return 0;
 }
index 668fdee..fbbb25c 100644 (file)
@@ -1,13 +1,10 @@
 snd-soc-sst-dsp-objs := sst-dsp.o
-ifneq ($(CONFIG_SND_SST_IPC_ACPI),)
-snd-soc-sst-acpi-objs := sst-match-acpi.o
-else
-snd-soc-sst-acpi-objs := sst-acpi.o sst-match-acpi.o
-endif
-
+snd-soc-sst-acpi-objs := sst-acpi.o
+snd-soc-sst-match-objs := sst-match-acpi.o
 snd-soc-sst-ipc-objs := sst-ipc.o
 
 snd-soc-sst-dsp-$(CONFIG_DW_DMAC_CORE) += sst-firmware.o
 
 obj-$(CONFIG_SND_SOC_INTEL_SST) += snd-soc-sst-dsp.o snd-soc-sst-ipc.o
 obj-$(CONFIG_SND_SOC_INTEL_SST_ACPI) += snd-soc-sst-acpi.o
+obj-$(CONFIG_SND_SOC_INTEL_SST_MATCH) += snd-soc-sst-match.o
index 7a85c57..2c5eda1 100644 (file)
@@ -215,6 +215,7 @@ static struct sst_acpi_desc sst_acpi_broadwell_desc = {
        .dma_size = SST_LPT_DSP_DMA_SIZE,
 };
 
+#if !IS_ENABLED(CONFIG_SND_SST_IPC_ACPI)
 static struct sst_acpi_mach baytrail_machines[] = {
        { "10EC5640", "byt-rt5640", "intel/fw_sst_0f28.bin-48kHz_i2s_master", NULL, NULL, NULL },
        { "193C9890", "byt-max98090", "intel/fw_sst_0f28.bin-48kHz_i2s_master", NULL, NULL, NULL },
@@ -231,11 +232,14 @@ static struct sst_acpi_desc sst_acpi_baytrail_desc = {
        .sst_id = SST_DEV_ID_BYT,
        .resindex_dma_base = -1,
 };
+#endif
 
 static const struct acpi_device_id sst_acpi_match[] = {
        { "INT33C8", (unsigned long)&sst_acpi_haswell_desc },
        { "INT3438", (unsigned long)&sst_acpi_broadwell_desc },
+#if !IS_ENABLED(CONFIG_SND_SST_IPC_ACPI)
        { "80860F28", (unsigned long)&sst_acpi_baytrail_desc },
+#endif
        { }
 };
 MODULE_DEVICE_TABLE(acpi, sst_acpi_match);
index dd077e1..3b4539d 100644 (file)
@@ -41,3 +41,6 @@ struct sst_acpi_mach *sst_acpi_find_machine(struct sst_acpi_mach *machines)
        return NULL;
 }
 EXPORT_SYMBOL_GPL(sst_acpi_find_machine);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Intel Common ACPI Match module");
index de6dac4..4629372 100644 (file)
@@ -688,14 +688,14 @@ int skl_unbind_modules(struct skl_sst *ctx,
        /* get src queue index */
        src_index = skl_get_queue_index(src_mcfg->m_out_pin, dst_id, out_max);
        if (src_index < 0)
-               return -EINVAL;
+               return 0;
 
        msg.src_queue = src_index;
 
        /* get dst queue index */
        dst_index  = skl_get_queue_index(dst_mcfg->m_in_pin, src_id, in_max);
        if (dst_index < 0)
-               return -EINVAL;
+               return 0;
 
        msg.dst_queue = dst_index;
 
@@ -747,7 +747,7 @@ int skl_bind_modules(struct skl_sst *ctx,
 
        skl_dump_bind_info(ctx, src_mcfg, dst_mcfg);
 
-       if (src_mcfg->m_state < SKL_MODULE_INIT_DONE &&
+       if (src_mcfg->m_state < SKL_MODULE_INIT_DONE ||
                dst_mcfg->m_state < SKL_MODULE_INIT_DONE)
                return 0;
 
index f355325..b6e6b61 100644 (file)
@@ -863,6 +863,7 @@ static int skl_get_delay_from_lpib(struct hdac_ext_bus *ebus,
                else
                        delay += hstream->bufsize;
        }
+       delay = (hstream->bufsize == delay) ? 0 : delay;
 
        if (delay >= hstream->period_bytes) {
                dev_info(bus->dev,
index 4624556..5a4837d 100644 (file)
@@ -54,12 +54,9 @@ static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget *w)
 
 /*
  * Each pipelines needs memory to be allocated. Check if we have free memory
- * from available pool. Then only add this to pool
- * This is freed when pipe is deleted
- * Note: DSP does actual memory management we only keep track for complete
- * pool
+ * from available pool.
  */
-static bool skl_tplg_alloc_pipe_mem(struct skl *skl,
+static bool skl_is_pipe_mem_avail(struct skl *skl,
                                struct skl_module_cfg *mconfig)
 {
        struct skl_sst *ctx = skl->skl_sst;
@@ -74,10 +71,20 @@ static bool skl_tplg_alloc_pipe_mem(struct skl *skl,
                                "exceeds ppl memory available %d mem %d\n",
                                skl->resource.max_mem, skl->resource.mem);
                return false;
+       } else {
+               return true;
        }
+}
 
+/*
+ * Add the mem to the mem pool. This is freed when pipe is deleted.
+ * Note: DSP does actual memory management we only keep track for complete
+ * pool
+ */
+static void skl_tplg_alloc_pipe_mem(struct skl *skl,
+                               struct skl_module_cfg *mconfig)
+{
        skl->resource.mem += mconfig->pipe->memory_pages;
-       return true;
 }
 
 /*
@@ -85,10 +92,10 @@ static bool skl_tplg_alloc_pipe_mem(struct skl *skl,
  * quantified in MCPS (Million Clocks Per Second) required for module/pipe
  *
  * Each pipelines needs mcps to be allocated. Check if we have mcps for this
- * pipe. This adds the mcps to driver counter
- * This is removed on pipeline delete
+ * pipe.
  */
-static bool skl_tplg_alloc_pipe_mcps(struct skl *skl,
+
+static bool skl_is_pipe_mcps_avail(struct skl *skl,
                                struct skl_module_cfg *mconfig)
 {
        struct skl_sst *ctx = skl->skl_sst;
@@ -98,13 +105,18 @@ static bool skl_tplg_alloc_pipe_mcps(struct skl *skl,
                        "%s: module_id %d instance %d\n", __func__,
                        mconfig->id.module_id, mconfig->id.instance_id);
                dev_err(ctx->dev,
-                       "exceeds ppl memory available %d > mem %d\n",
+                       "exceeds ppl mcps available %d > mem %d\n",
                        skl->resource.max_mcps, skl->resource.mcps);
                return false;
+       } else {
+               return true;
        }
+}
 
+static void skl_tplg_alloc_pipe_mcps(struct skl *skl,
+                               struct skl_module_cfg *mconfig)
+{
        skl->resource.mcps += mconfig->mcps;
-       return true;
 }
 
 /*
@@ -411,7 +423,7 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)
                mconfig = w->priv;
 
                /* check resource available */
-               if (!skl_tplg_alloc_pipe_mcps(skl, mconfig))
+               if (!skl_is_pipe_mcps_avail(skl, mconfig))
                        return -ENOMEM;
 
                if (mconfig->is_loadable && ctx->dsp->fw_ops.load_mod) {
@@ -435,6 +447,7 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)
                ret = skl_tplg_set_module_params(w, ctx);
                if (ret < 0)
                        return ret;
+               skl_tplg_alloc_pipe_mcps(skl, mconfig);
        }
 
        return 0;
@@ -477,10 +490,10 @@ static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
        struct skl_sst *ctx = skl->skl_sst;
 
        /* check resource available */
-       if (!skl_tplg_alloc_pipe_mcps(skl, mconfig))
+       if (!skl_is_pipe_mcps_avail(skl, mconfig))
                return -EBUSY;
 
-       if (!skl_tplg_alloc_pipe_mem(skl, mconfig))
+       if (!skl_is_pipe_mem_avail(skl, mconfig))
                return -ENOMEM;
 
        /*
@@ -526,11 +539,15 @@ static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
                src_module = dst_module;
        }
 
+       skl_tplg_alloc_pipe_mem(skl, mconfig);
+       skl_tplg_alloc_pipe_mcps(skl, mconfig);
+
        return 0;
 }
 
 static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w,
                                struct skl *skl,
+                               struct snd_soc_dapm_widget *src_w,
                                struct skl_module_cfg *src_mconfig)
 {
        struct snd_soc_dapm_path *p;
@@ -547,6 +564,10 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w,
                dev_dbg(ctx->dev, "%s: sink widget=%s\n", __func__, p->sink->name);
 
                next_sink = p->sink;
+
+               if (!is_skl_dsp_widget_type(p->sink))
+                       return skl_tplg_bind_sinks(p->sink, skl, src_w, src_mconfig);
+
                /*
                 * here we will check widgets in sink pipelines, so that
                 * can be any widgets type and we are only interested if
@@ -576,7 +597,7 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w,
        }
 
        if (!sink)
-               return skl_tplg_bind_sinks(next_sink, skl, src_mconfig);
+               return skl_tplg_bind_sinks(next_sink, skl, src_w, src_mconfig);
 
        return 0;
 }
@@ -605,7 +626,7 @@ static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
         * if sink is not started, start sink pipe first, then start
         * this pipe
         */
-       ret = skl_tplg_bind_sinks(w, skl, src_mconfig);
+       ret = skl_tplg_bind_sinks(w, skl, w, src_mconfig);
        if (ret)
                return ret;
 
@@ -773,10 +794,7 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
                        continue;
                }
 
-               ret = skl_unbind_modules(ctx, src_module, dst_module);
-               if (ret < 0)
-                       return ret;
-
+               skl_unbind_modules(ctx, src_module, dst_module);
                src_module = dst_module;
        }
 
@@ -814,9 +832,6 @@ static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
                         * This is a connecter and if path is found that means
                         * unbind between source and sink has not happened yet
                         */
-                       ret = skl_stop_pipe(ctx, sink_mconfig->pipe);
-                       if (ret < 0)
-                               return ret;
                        ret = skl_unbind_modules(ctx, src_mconfig,
                                                        sink_mconfig);
                }
@@ -842,6 +857,12 @@ static int skl_tplg_vmixer_event(struct snd_soc_dapm_widget *w,
        case SND_SOC_DAPM_PRE_PMU:
                return skl_tplg_mixer_dapm_pre_pmu_event(w, skl);
 
+       case SND_SOC_DAPM_POST_PMU:
+               return skl_tplg_mixer_dapm_post_pmu_event(w, skl);
+
+       case SND_SOC_DAPM_PRE_PMD:
+               return skl_tplg_mixer_dapm_pre_pmd_event(w, skl);
+
        case SND_SOC_DAPM_POST_PMD:
                return skl_tplg_mixer_dapm_post_pmd_event(w, skl);
        }
@@ -916,6 +937,13 @@ static int skl_tplg_tlv_control_get(struct snd_kcontrol *kcontrol,
                skl_get_module_params(skl->skl_sst, (u32 *)bc->params,
                                      bc->max, bc->param_id, mconfig);
 
+       /* decrement size for TLV header */
+       size -= 2 * sizeof(u32);
+
+       /* check size as we don't want to send kernel data */
+       if (size > bc->max)
+               size = bc->max;
+
        if (bc->params) {
                if (copy_to_user(data, &bc->param_id, sizeof(u32)))
                        return -EFAULT;
@@ -950,7 +978,7 @@ static int skl_tplg_tlv_control_set(struct snd_kcontrol *kcontrol,
                                return -EFAULT;
                } else {
                        if (copy_from_user(ac->params,
-                                          data + 2 * sizeof(u32), size))
+                                          data + 2, size))
                                return -EFAULT;
                }
 
@@ -1510,6 +1538,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus)
                                        &skl_tplg_ops, fw, 0);
        if (ret < 0) {
                dev_err(bus->dev, "tplg component load failed%d\n", ret);
+               release_firmware(fw);
                return -EINVAL;
        }
 
index 443a15d..092705e 100644 (file)
@@ -614,8 +614,6 @@ static int skl_probe(struct pci_dev *pci,
                goto out_unregister;
 
        /*configure PM */
-       pm_runtime_set_autosuspend_delay(bus->dev, SKL_SUSPEND_DELAY);
-       pm_runtime_use_autosuspend(bus->dev);
        pm_runtime_put_noidle(bus->dev);
        pm_runtime_allow(bus->dev);
 
index 15c04e2..9769676 100644 (file)
@@ -9,7 +9,7 @@ config SND_SOC_MEDIATEK
 
 config SND_SOC_MT8173_MAX98090
        tristate "ASoC Audio driver for MT8173 with MAX98090 codec"
-       depends on SND_SOC_MEDIATEK
+       depends on SND_SOC_MEDIATEK && I2C
        select SND_SOC_MAX98090
        help
          This adds ASoC driver for Mediatek MT8173 boards
@@ -19,7 +19,7 @@ config SND_SOC_MT8173_MAX98090
 
 config SND_SOC_MT8173_RT5650_RT5676
        tristate "ASoC Audio driver for MT8173 with RT5650 RT5676 codecs"
-       depends on SND_SOC_MEDIATEK
+       depends on SND_SOC_MEDIATEK && I2C
        select SND_SOC_RT5645
        select SND_SOC_RT5677
        help
index c866ade..a6c7b8d 100644 (file)
@@ -381,9 +381,19 @@ static int mxs_saif_startup(struct snd_pcm_substream *substream,
        __raw_writel(BM_SAIF_CTRL_CLKGATE,
                saif->base + SAIF_CTRL + MXS_CLR_ADDR);
 
+       clk_prepare(saif->clk);
+
        return 0;
 }
 
+static void mxs_saif_shutdown(struct snd_pcm_substream *substream,
+                             struct snd_soc_dai *cpu_dai)
+{
+       struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai);
+
+       clk_unprepare(saif->clk);
+}
+
 /*
  * Should only be called when port is inactive.
  * although can be called multiple times by upper layers.
@@ -424,8 +434,6 @@ static int mxs_saif_hw_params(struct snd_pcm_substream *substream,
                return ret;
        }
 
-       /* prepare clk in hw_param, enable in trigger */
-       clk_prepare(saif->clk);
        if (saif != master_saif) {
                /*
                * Set an initial clock rate for the saif internal logic to work
@@ -611,6 +619,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
 
 static const struct snd_soc_dai_ops mxs_saif_dai_ops = {
        .startup = mxs_saif_startup,
+       .shutdown = mxs_saif_shutdown,
        .trigger = mxs_saif_trigger,
        .prepare = mxs_saif_prepare,
        .hw_params = mxs_saif_hw_params,
index 190f868..fdecb70 100644 (file)
@@ -133,7 +133,7 @@ static struct snd_soc_ops n810_ops = {
 static int n810_get_spk(struct snd_kcontrol *kcontrol,
                        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = n810_spk_func;
+       ucontrol->value.enumerated.item[0] = n810_spk_func;
 
        return 0;
 }
@@ -143,10 +143,10 @@ static int n810_set_spk(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card =  snd_kcontrol_chip(kcontrol);
 
-       if (n810_spk_func == ucontrol->value.integer.value[0])
+       if (n810_spk_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       n810_spk_func = ucontrol->value.integer.value[0];
+       n810_spk_func = ucontrol->value.enumerated.item[0];
        n810_ext_control(&card->dapm);
 
        return 1;
@@ -155,7 +155,7 @@ static int n810_set_spk(struct snd_kcontrol *kcontrol,
 static int n810_get_jack(struct snd_kcontrol *kcontrol,
                         struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = n810_jack_func;
+       ucontrol->value.enumerated.item[0] = n810_jack_func;
 
        return 0;
 }
@@ -165,10 +165,10 @@ static int n810_set_jack(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card =  snd_kcontrol_chip(kcontrol);
 
-       if (n810_jack_func == ucontrol->value.integer.value[0])
+       if (n810_jack_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       n810_jack_func = ucontrol->value.integer.value[0];
+       n810_jack_func = ucontrol->value.enumerated.item[0];
        n810_ext_control(&card->dapm);
 
        return 1;
@@ -177,7 +177,7 @@ static int n810_set_jack(struct snd_kcontrol *kcontrol,
 static int n810_get_input(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = n810_dmic_func;
+       ucontrol->value.enumerated.item[0] = n810_dmic_func;
 
        return 0;
 }
@@ -187,10 +187,10 @@ static int n810_set_input(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card =  snd_kcontrol_chip(kcontrol);
 
-       if (n810_dmic_func == ucontrol->value.integer.value[0])
+       if (n810_dmic_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       n810_dmic_func = ucontrol->value.integer.value[0];
+       n810_dmic_func = ucontrol->value.enumerated.item[0];
        n810_ext_control(&card->dapm);
 
        return 1;
index 5e21f08..5494924 100644 (file)
@@ -132,7 +132,7 @@ static struct snd_soc_ops rx51_ops = {
 static int rx51_get_spk(struct snd_kcontrol *kcontrol,
                        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = rx51_spk_func;
+       ucontrol->value.enumerated.item[0] = rx51_spk_func;
 
        return 0;
 }
@@ -142,10 +142,10 @@ static int rx51_set_spk(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
 
-       if (rx51_spk_func == ucontrol->value.integer.value[0])
+       if (rx51_spk_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       rx51_spk_func = ucontrol->value.integer.value[0];
+       rx51_spk_func = ucontrol->value.enumerated.item[0];
        rx51_ext_control(&card->dapm);
 
        return 1;
@@ -180,7 +180,7 @@ static int rx51_hp_event(struct snd_soc_dapm_widget *w,
 static int rx51_get_input(struct snd_kcontrol *kcontrol,
                          struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = rx51_dmic_func;
+       ucontrol->value.enumerated.item[0] = rx51_dmic_func;
 
        return 0;
 }
@@ -190,10 +190,10 @@ static int rx51_set_input(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
 
-       if (rx51_dmic_func == ucontrol->value.integer.value[0])
+       if (rx51_dmic_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       rx51_dmic_func = ucontrol->value.integer.value[0];
+       rx51_dmic_func = ucontrol->value.enumerated.item[0];
        rx51_ext_control(&card->dapm);
 
        return 1;
@@ -202,7 +202,7 @@ static int rx51_set_input(struct snd_kcontrol *kcontrol,
 static int rx51_get_jack(struct snd_kcontrol *kcontrol,
                         struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = rx51_jack_func;
+       ucontrol->value.enumerated.item[0] = rx51_jack_func;
 
        return 0;
 }
@@ -212,10 +212,10 @@ static int rx51_set_jack(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
 
-       if (rx51_jack_func == ucontrol->value.integer.value[0])
+       if (rx51_jack_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       rx51_jack_func = ucontrol->value.integer.value[0];
+       rx51_jack_func = ucontrol->value.enumerated.item[0];
        rx51_ext_control(&card->dapm);
 
        return 1;
index c97dc13..dcbb7aa 100644 (file)
@@ -163,7 +163,7 @@ static struct snd_soc_ops corgi_ops = {
 static int corgi_get_jack(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = corgi_jack_func;
+       ucontrol->value.enumerated.item[0] = corgi_jack_func;
        return 0;
 }
 
@@ -172,10 +172,10 @@ static int corgi_set_jack(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
 
-       if (corgi_jack_func == ucontrol->value.integer.value[0])
+       if (corgi_jack_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       corgi_jack_func = ucontrol->value.integer.value[0];
+       corgi_jack_func = ucontrol->value.enumerated.item[0];
        corgi_ext_control(&card->dapm);
        return 1;
 }
@@ -183,7 +183,7 @@ static int corgi_set_jack(struct snd_kcontrol *kcontrol,
 static int corgi_get_spk(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = corgi_spk_func;
+       ucontrol->value.enumerated.item[0] = corgi_spk_func;
        return 0;
 }
 
@@ -192,10 +192,10 @@ static int corgi_set_spk(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card =  snd_kcontrol_chip(kcontrol);
 
-       if (corgi_spk_func == ucontrol->value.integer.value[0])
+       if (corgi_spk_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       corgi_spk_func = ucontrol->value.integer.value[0];
+       corgi_spk_func = ucontrol->value.enumerated.item[0];
        corgi_ext_control(&card->dapm);
        return 1;
 }
index 241d0be..62b8377 100644 (file)
@@ -308,17 +308,17 @@ static int magician_set_spk(struct snd_kcontrol *kcontrol,
 static int magician_get_input(struct snd_kcontrol *kcontrol,
                              struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = magician_in_sel;
+       ucontrol->value.enumerated.item[0] = magician_in_sel;
        return 0;
 }
 
 static int magician_set_input(struct snd_kcontrol *kcontrol,
                              struct snd_ctl_elem_value *ucontrol)
 {
-       if (magician_in_sel == ucontrol->value.integer.value[0])
+       if (magician_in_sel == ucontrol->value.enumerated.item[0])
                return 0;
 
-       magician_in_sel = ucontrol->value.integer.value[0];
+       magician_in_sel = ucontrol->value.enumerated.item[0];
 
        switch (magician_in_sel) {
        case MAGICIAN_MIC:
index 84d0e2e..4b3b714 100644 (file)
@@ -138,7 +138,7 @@ static struct snd_soc_ops poodle_ops = {
 static int poodle_get_jack(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = poodle_jack_func;
+       ucontrol->value.enumerated.item[0] = poodle_jack_func;
        return 0;
 }
 
@@ -147,10 +147,10 @@ static int poodle_set_jack(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card =  snd_kcontrol_chip(kcontrol);
 
-       if (poodle_jack_func == ucontrol->value.integer.value[0])
+       if (poodle_jack_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       poodle_jack_func = ucontrol->value.integer.value[0];
+       poodle_jack_func = ucontrol->value.enumerated.item[0];
        poodle_ext_control(&card->dapm);
        return 1;
 }
@@ -158,7 +158,7 @@ static int poodle_set_jack(struct snd_kcontrol *kcontrol,
 static int poodle_get_spk(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = poodle_spk_func;
+       ucontrol->value.enumerated.item[0] = poodle_spk_func;
        return 0;
 }
 
@@ -167,10 +167,10 @@ static int poodle_set_spk(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card =  snd_kcontrol_chip(kcontrol);
 
-       if (poodle_spk_func == ucontrol->value.integer.value[0])
+       if (poodle_spk_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       poodle_spk_func = ucontrol->value.integer.value[0];
+       poodle_spk_func = ucontrol->value.enumerated.item[0];
        poodle_ext_control(&card->dapm);
        return 1;
 }
index b002226..0e02634 100644 (file)
@@ -164,7 +164,7 @@ static struct snd_soc_ops spitz_ops = {
 static int spitz_get_jack(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = spitz_jack_func;
+       ucontrol->value.enumerated.item[0] = spitz_jack_func;
        return 0;
 }
 
@@ -173,10 +173,10 @@ static int spitz_set_jack(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
 
-       if (spitz_jack_func == ucontrol->value.integer.value[0])
+       if (spitz_jack_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       spitz_jack_func = ucontrol->value.integer.value[0];
+       spitz_jack_func = ucontrol->value.enumerated.item[0];
        spitz_ext_control(&card->dapm);
        return 1;
 }
@@ -184,7 +184,7 @@ static int spitz_set_jack(struct snd_kcontrol *kcontrol,
 static int spitz_get_spk(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = spitz_spk_func;
+       ucontrol->value.enumerated.item[0] = spitz_spk_func;
        return 0;
 }
 
@@ -193,10 +193,10 @@ static int spitz_set_spk(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
 
-       if (spitz_spk_func == ucontrol->value.integer.value[0])
+       if (spitz_spk_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       spitz_spk_func = ucontrol->value.integer.value[0];
+       spitz_spk_func = ucontrol->value.enumerated.item[0];
        spitz_ext_control(&card->dapm);
        return 1;
 }
index 49518dd..c508f02 100644 (file)
@@ -95,7 +95,7 @@ static struct snd_soc_ops tosa_ops = {
 static int tosa_get_jack(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = tosa_jack_func;
+       ucontrol->value.enumerated.item[0] = tosa_jack_func;
        return 0;
 }
 
@@ -104,10 +104,10 @@ static int tosa_set_jack(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
 
-       if (tosa_jack_func == ucontrol->value.integer.value[0])
+       if (tosa_jack_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       tosa_jack_func = ucontrol->value.integer.value[0];
+       tosa_jack_func = ucontrol->value.enumerated.item[0];
        tosa_ext_control(&card->dapm);
        return 1;
 }
@@ -115,7 +115,7 @@ static int tosa_set_jack(struct snd_kcontrol *kcontrol,
 static int tosa_get_spk(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
 {
-       ucontrol->value.integer.value[0] = tosa_spk_func;
+       ucontrol->value.enumerated.item[0] = tosa_spk_func;
        return 0;
 }
 
@@ -124,10 +124,10 @@ static int tosa_set_spk(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
 
-       if (tosa_spk_func == ucontrol->value.integer.value[0])
+       if (tosa_spk_func == ucontrol->value.enumerated.item[0])
                return 0;
 
-       tosa_spk_func = ucontrol->value.integer.value[0];
+       tosa_spk_func = ucontrol->value.enumerated.item[0];
        tosa_ext_control(&card->dapm);
        return 1;
 }
index 00b6c9d..e5101e0 100644 (file)
@@ -355,7 +355,6 @@ static struct regmap_config lpass_cpu_regmap_config = {
        .readable_reg = lpass_cpu_regmap_readable,
        .volatile_reg = lpass_cpu_regmap_volatile,
        .cache_type = REGCACHE_FLAT,
-       .val_format_endian = REGMAP_ENDIAN_LITTLE,
 };
 
 int asoc_qcom_lpass_cpu_platform_probe(struct platform_device *pdev)
index 79688aa..4aeb8e1 100644 (file)
@@ -440,18 +440,18 @@ static irqreturn_t lpass_platform_lpaif_irq(int irq, void *data)
 }
 
 static int lpass_platform_alloc_buffer(struct snd_pcm_substream *substream,
-               struct snd_soc_pcm_runtime *soc_runtime)
+               struct snd_soc_pcm_runtime *rt)
 {
        struct snd_dma_buffer *buf = &substream->dma_buffer;
        size_t size = lpass_platform_pcm_hardware.buffer_bytes_max;
 
        buf->dev.type = SNDRV_DMA_TYPE_DEV;
-       buf->dev.dev = soc_runtime->dev;
+       buf->dev.dev = rt->platform->dev;
        buf->private_data = NULL;
-       buf->area = dma_alloc_coherent(soc_runtime->dev, size, &buf->addr,
+       buf->area = dma_alloc_coherent(rt->platform->dev, size, &buf->addr,
                        GFP_KERNEL);
        if (!buf->area) {
-               dev_err(soc_runtime->dev, "%s: Could not allocate DMA buffer\n",
+               dev_err(rt->platform->dev, "%s: Could not allocate DMA buffer\n",
                                __func__);
                return -ENOMEM;
        }
@@ -461,12 +461,12 @@ static int lpass_platform_alloc_buffer(struct snd_pcm_substream *substream,
 }
 
 static void lpass_platform_free_buffer(struct snd_pcm_substream *substream,
-               struct snd_soc_pcm_runtime *soc_runtime)
+               struct snd_soc_pcm_runtime *rt)
 {
        struct snd_dma_buffer *buf = &substream->dma_buffer;
 
        if (buf->area) {
-               dma_free_coherent(soc_runtime->dev, buf->bytes, buf->area,
+               dma_free_coherent(rt->dev, buf->bytes, buf->area,
                                buf->addr);
        }
        buf->area = NULL;
@@ -499,9 +499,6 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime)
 
        snd_soc_pcm_set_drvdata(soc_runtime, data);
 
-       soc_runtime->dev->coherent_dma_mask = DMA_BIT_MASK(32);
-       soc_runtime->dev->dma_mask = &soc_runtime->dev->coherent_dma_mask;
-
        ret = lpass_platform_alloc_buffer(substream, soc_runtime);
        if (ret)
                return ret;
index 84d9e77..70a2559 100644 (file)
@@ -481,10 +481,11 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai,
        unsigned int cdcon_mask = 1 << i2s_regs->cdclkcon_off;
        unsigned int rsrc_mask = 1 << i2s_regs->rclksrc_off;
        u32 mod, mask, val = 0;
+       unsigned long flags;
 
-       spin_lock(i2s->lock);
+       spin_lock_irqsave(i2s->lock, flags);
        mod = readl(i2s->addr + I2SMOD);
-       spin_unlock(i2s->lock);
+       spin_unlock_irqrestore(i2s->lock, flags);
 
        switch (clk_id) {
        case SAMSUNG_I2S_OPCLK:
@@ -575,11 +576,11 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai,
                return -EINVAL;
        }
 
-       spin_lock(i2s->lock);
+       spin_lock_irqsave(i2s->lock, flags);
        mod = readl(i2s->addr + I2SMOD);
        mod = (mod & ~mask) | val;
        writel(mod, i2s->addr + I2SMOD);
-       spin_unlock(i2s->lock);
+       spin_unlock_irqrestore(i2s->lock, flags);
 
        return 0;
 }
@@ -590,6 +591,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai,
        struct i2s_dai *i2s = to_info(dai);
        int lrp_shift, sdf_shift, sdf_mask, lrp_rlow, mod_slave;
        u32 mod, tmp = 0;
+       unsigned long flags;
 
        lrp_shift = i2s->variant_regs->lrp_off;
        sdf_shift = i2s->variant_regs->sdf_off;
@@ -649,7 +651,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai,
                return -EINVAL;
        }
 
-       spin_lock(i2s->lock);
+       spin_lock_irqsave(i2s->lock, flags);
        mod = readl(i2s->addr + I2SMOD);
        /*
         * Don't change the I2S mode if any controller is active on this
@@ -657,7 +659,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai,
         */
        if (any_active(i2s) &&
                ((mod & (sdf_mask | lrp_rlow | mod_slave)) != tmp)) {
-               spin_unlock(i2s->lock);
+               spin_unlock_irqrestore(i2s->lock, flags);
                dev_err(&i2s->pdev->dev,
                                "%s:%d Other DAI busy\n", __func__, __LINE__);
                return -EAGAIN;
@@ -666,7 +668,7 @@ static int i2s_set_fmt(struct snd_soc_dai *dai,
        mod &= ~(sdf_mask | lrp_rlow | mod_slave);
        mod |= tmp;
        writel(mod, i2s->addr + I2SMOD);
-       spin_unlock(i2s->lock);
+       spin_unlock_irqrestore(i2s->lock, flags);
 
        return 0;
 }
@@ -676,6 +678,7 @@ static int i2s_hw_params(struct snd_pcm_substream *substream,
 {
        struct i2s_dai *i2s = to_info(dai);
        u32 mod, mask = 0, val = 0;
+       unsigned long flags;
 
        if (!is_secondary(i2s))
                mask |= (MOD_DC2_EN | MOD_DC1_EN);
@@ -744,11 +747,11 @@ static int i2s_hw_params(struct snd_pcm_substream *substream,
                return -EINVAL;
        }
 
-       spin_lock(i2s->lock);
+       spin_lock_irqsave(i2s->lock, flags);
        mod = readl(i2s->addr + I2SMOD);
        mod = (mod & ~mask) | val;
        writel(mod, i2s->addr + I2SMOD);
-       spin_unlock(i2s->lock);
+       spin_unlock_irqrestore(i2s->lock, flags);
 
        samsung_asoc_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture);
 
index 5a2812f..581175a 100644 (file)
@@ -310,7 +310,7 @@ struct dapm_kcontrol_data {
 };
 
 static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
-       struct snd_kcontrol *kcontrol)
+       struct snd_kcontrol *kcontrol, const char *ctrl_name)
 {
        struct dapm_kcontrol_data *data;
        struct soc_mixer_control *mc;
@@ -333,7 +333,7 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
                if (mc->autodisable) {
                        struct snd_soc_dapm_widget template;
 
-                       name = kasprintf(GFP_KERNEL, "%s %s", kcontrol->id.name,
+                       name = kasprintf(GFP_KERNEL, "%s %s", ctrl_name,
                                         "Autodisable");
                        if (!name) {
                                ret = -ENOMEM;
@@ -371,7 +371,7 @@ static int dapm_kcontrol_data_alloc(struct snd_soc_dapm_widget *widget,
                if (e->autodisable) {
                        struct snd_soc_dapm_widget template;
 
-                       name = kasprintf(GFP_KERNEL, "%s %s", kcontrol->id.name,
+                       name = kasprintf(GFP_KERNEL, "%s %s", ctrl_name,
                                         "Autodisable");
                        if (!name) {
                                ret = -ENOMEM;
@@ -871,7 +871,7 @@ static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w,
 
                kcontrol->private_free = dapm_kcontrol_free;
 
-               ret = dapm_kcontrol_data_alloc(w, kcontrol);
+               ret = dapm_kcontrol_data_alloc(w, kcontrol, name);
                if (ret) {
                        snd_ctl_free_one(kcontrol);
                        goto exit_free;
@@ -3573,7 +3573,7 @@ static int snd_soc_dapm_dai_link_get(struct snd_kcontrol *kcontrol,
 {
        struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol);
 
-       ucontrol->value.integer.value[0] = w->params_select;
+       ucontrol->value.enumerated.item[0] = w->params_select;
 
        return 0;
 }
@@ -3587,13 +3587,13 @@ static int snd_soc_dapm_dai_link_put(struct snd_kcontrol *kcontrol,
        if (w->power)
                return -EBUSY;
 
-       if (ucontrol->value.integer.value[0] == w->params_select)
+       if (ucontrol->value.enumerated.item[0] == w->params_select)
                return 0;
 
-       if (ucontrol->value.integer.value[0] >= w->num_params)
+       if (ucontrol->value.enumerated.item[0] >= w->num_params)
                return -EINVAL;
 
-       w->params_select = ucontrol->value.integer.value[0];
+       w->params_select = ucontrol->value.enumerated.item[0];
 
        return 0;
 }
index e898b42..1af4f23 100644 (file)
@@ -1810,7 +1810,8 @@ int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream)
                    (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) &&
                    (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) &&
                    (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PAUSED) &&
-                   (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP))
+                   (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP) &&
+                   (be->dpcm[stream].state != SND_SOC_DPCM_STATE_SUSPEND))
                        continue;
 
                dev_dbg(be->dev, "ASoC: hw_free BE %s\n",
index cc39f63..007cf58 100644 (file)
@@ -2455,7 +2455,6 @@ int snd_usbmidi_create(struct snd_card *card,
        else
                err = snd_usbmidi_create_endpoints(umidi, endpoints);
        if (err < 0) {
-               snd_usbmidi_free(umidi);
                return err;
        }
 
index 4f6ce1c..c458d60 100644 (file)
@@ -1124,6 +1124,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip)
        case USB_ID(0x045E, 0x076F): /* MS Lifecam HD-6000 */
        case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */
        case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */
+       case USB_ID(0x047F, 0xAA05): /* Plantronics DA45 */
        case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */
        case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */
        case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */
index 81a2eb7..05d8158 100644 (file)
@@ -2068,6 +2068,15 @@ int intel_pt_process_auxtrace_info(union perf_event *event,
                err = -ENOMEM;
                goto err_free_queues;
        }
+
+       /*
+        * Since this thread will not be kept in any rbtree not in a
+        * list, initialize its list node so that at thread__put() the
+        * current thread lifetime assuption is kept and we don't segfault
+        * at list_del_init().
+        */
+       INIT_LIST_HEAD(&pt->unknown_thread->node);
+
        err = thread__set_comm(pt->unknown_thread, "unknown", 0);
        if (err)
                goto err_delete_thread;
index 4f7b0ef..813d9b2 100644 (file)
@@ -399,6 +399,9 @@ static void tracepoint_error(struct parse_events_error *e, int err,
 {
        char help[BUFSIZ];
 
+       if (!e)
+               return;
+
        /*
         * We get error directly from syscall errno ( > 0),
         * or from encoded pointer's error ( < 0).
index 2be10fb..4ce5c5e 100644 (file)
@@ -686,8 +686,9 @@ static int call_probe_finder(Dwarf_Die *sc_die, struct probe_finder *pf)
                pf->fb_ops = NULL;
 #if _ELFUTILS_PREREQ(0, 142)
        } else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa &&
-                  pf->cfi != NULL) {
-               if (dwarf_cfi_addrframe(pf->cfi, pf->addr, &frame) != 0 ||
+                  (pf->cfi_eh != NULL || pf->cfi_dbg != NULL)) {
+               if ((dwarf_cfi_addrframe(pf->cfi_eh, pf->addr, &frame) != 0 &&
+                    (dwarf_cfi_addrframe(pf->cfi_dbg, pf->addr, &frame) != 0)) ||
                    dwarf_frame_cfa(frame, &pf->fb_ops, &nops) != 0) {
                        pr_warning("Failed to get call frame on 0x%jx\n",
                                   (uintmax_t)pf->addr);
@@ -1015,8 +1016,7 @@ static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data)
        return DWARF_CB_OK;
 }
 
-/* Find probe points from debuginfo */
-static int debuginfo__find_probes(struct debuginfo *dbg,
+static int debuginfo__find_probe_location(struct debuginfo *dbg,
                                  struct probe_finder *pf)
 {
        struct perf_probe_point *pp = &pf->pev->point;
@@ -1025,27 +1025,6 @@ static int debuginfo__find_probes(struct debuginfo *dbg,
        Dwarf_Die *diep;
        int ret = 0;
 
-#if _ELFUTILS_PREREQ(0, 142)
-       Elf *elf;
-       GElf_Ehdr ehdr;
-       GElf_Shdr shdr;
-
-       /* Get the call frame information from this dwarf */
-       elf = dwarf_getelf(dbg->dbg);
-       if (elf == NULL)
-               return -EINVAL;
-
-       if (gelf_getehdr(elf, &ehdr) == NULL)
-               return -EINVAL;
-
-       if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&
-           shdr.sh_type == SHT_PROGBITS) {
-               pf->cfi = dwarf_getcfi_elf(elf);
-       } else {
-               pf->cfi = dwarf_getcfi(dbg->dbg);
-       }
-#endif
-
        off = 0;
        pf->lcache = intlist__new(NULL);
        if (!pf->lcache)
@@ -1108,6 +1087,39 @@ found:
        return ret;
 }
 
+/* Find probe points from debuginfo */
+static int debuginfo__find_probes(struct debuginfo *dbg,
+                                 struct probe_finder *pf)
+{
+       int ret = 0;
+
+#if _ELFUTILS_PREREQ(0, 142)
+       Elf *elf;
+       GElf_Ehdr ehdr;
+       GElf_Shdr shdr;
+
+       if (pf->cfi_eh || pf->cfi_dbg)
+               return debuginfo__find_probe_location(dbg, pf);
+
+       /* Get the call frame information from this dwarf */
+       elf = dwarf_getelf(dbg->dbg);
+       if (elf == NULL)
+               return -EINVAL;
+
+       if (gelf_getehdr(elf, &ehdr) == NULL)
+               return -EINVAL;
+
+       if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&
+           shdr.sh_type == SHT_PROGBITS)
+               pf->cfi_eh = dwarf_getcfi_elf(elf);
+
+       pf->cfi_dbg = dwarf_getcfi(dbg->dbg);
+#endif
+
+       ret = debuginfo__find_probe_location(dbg, pf);
+       return ret;
+}
+
 struct local_vars_finder {
        struct probe_finder *pf;
        struct perf_probe_arg *args;
index bed8271..0aec770 100644 (file)
@@ -76,7 +76,10 @@ struct probe_finder {
 
        /* For variable searching */
 #if _ELFUTILS_PREREQ(0, 142)
-       Dwarf_CFI               *cfi;           /* Call Frame Information */
+       /* Call Frame Information from .eh_frame */
+       Dwarf_CFI               *cfi_eh;
+       /* Call Frame Information from .debug_frame */
+       Dwarf_CFI               *cfi_dbg;
 #endif
        Dwarf_Op                *fb_ops;        /* Frame base attribute */
        struct perf_probe_arg   *pvar;          /* Current target variable */
index 2b58edc..afb0c45 100644 (file)
@@ -311,6 +311,16 @@ int perf_stat_process_counter(struct perf_stat_config *config,
 
        aggr->val = aggr->ena = aggr->run = 0;
 
+       /*
+        * We calculate counter's data every interval,
+        * and the display code shows ps->res_stats
+        * avg value. We need to zero the stats for
+        * interval mode, otherwise overall avg running
+        * averages will be shown for each interval.
+        */
+       if (config->interval)
+               init_stats(ps->res_stats);
+
        if (counter->per_pkg)
                zero_per_pkg(counter);
 
index 90bd2ea..b3281dc 100644 (file)
@@ -217,13 +217,16 @@ static int nfit_test_cmd_set_config_data(struct nd_cmd_set_config_hdr *nd_cmd,
        return rc;
 }
 
+#define NFIT_TEST_ARS_RECORDS 4
+
 static int nfit_test_cmd_ars_cap(struct nd_cmd_ars_cap *nd_cmd,
                unsigned int buf_len)
 {
        if (buf_len < sizeof(*nd_cmd))
                return -EINVAL;
 
-       nd_cmd->max_ars_out = 256;
+       nd_cmd->max_ars_out = sizeof(struct nd_cmd_ars_status)
+               + NFIT_TEST_ARS_RECORDS * sizeof(struct nd_ars_record);
        nd_cmd->status = (ND_ARS_PERSISTENT | ND_ARS_VOLATILE) << 16;
 
        return 0;
@@ -246,7 +249,8 @@ static int nfit_test_cmd_ars_status(struct nd_cmd_ars_status *nd_cmd,
        if (buf_len < sizeof(*nd_cmd))
                return -EINVAL;
 
-       nd_cmd->out_length = 256;
+       nd_cmd->out_length = sizeof(struct nd_cmd_ars_status);
+       /* TODO: emit error records */
        nd_cmd->num_records = 0;
        nd_cmd->address = 0;
        nd_cmd->length = -1ULL;
index 77edcdc..0572784 100755 (executable)
@@ -88,7 +88,11 @@ test_delete()
                exit 1
        fi
 
-       rm $file
+       rm $file 2>/dev/null
+       if [ $? -ne 0 ]; then
+               chattr -i $file
+               rm $file
+       fi
 
        if [ -e $file ]; then
                echo "$file couldn't be deleted" >&2
@@ -111,6 +115,7 @@ test_zero_size_delete()
                exit 1
        fi
 
+       chattr -i $file
        printf "$attrs" > $file
 
        if [ -e $file ]; then
@@ -141,7 +146,11 @@ test_valid_filenames()
                        echo "$file could not be created" >&2
                        ret=1
                else
-                       rm $file
+                       rm $file 2>/dev/null
+                       if [ $? -ne 0 ]; then
+                               chattr -i $file
+                               rm $file
+                       fi
                fi
        done
 
@@ -174,7 +183,11 @@ test_invalid_filenames()
 
                if [ -e $file ]; then
                        echo "Creating $file should have failed" >&2
-                       rm $file
+                       rm $file 2>/dev/null
+                       if [ $? -ne 0 ]; then
+                               chattr -i $file
+                               rm $file
+                       fi
                        ret=1
                fi
        done
index 8c07644..4af74f7 100644 (file)
@@ -1,10 +1,68 @@
+#include <errno.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <linux/fs.h>
+
+static int set_immutable(const char *path, int immutable)
+{
+       unsigned int flags;
+       int fd;
+       int rc;
+       int error;
+
+       fd = open(path, O_RDONLY);
+       if (fd < 0)
+               return fd;
+
+       rc = ioctl(fd, FS_IOC_GETFLAGS, &flags);
+       if (rc < 0) {
+               error = errno;
+               close(fd);
+               errno = error;
+               return rc;
+       }
+
+       if (immutable)
+               flags |= FS_IMMUTABLE_FL;
+       else
+               flags &= ~FS_IMMUTABLE_FL;
+
+       rc = ioctl(fd, FS_IOC_SETFLAGS, &flags);
+       error = errno;
+       close(fd);
+       errno = error;
+       return rc;
+}
+
+static int get_immutable(const char *path)
+{
+       unsigned int flags;
+       int fd;
+       int rc;
+       int error;
+
+       fd = open(path, O_RDONLY);
+       if (fd < 0)
+               return fd;
+
+       rc = ioctl(fd, FS_IOC_GETFLAGS, &flags);
+       if (rc < 0) {
+               error = errno;
+               close(fd);
+               errno = error;
+               return rc;
+       }
+       close(fd);
+       if (flags & FS_IMMUTABLE_FL)
+               return 1;
+       return 0;
+}
 
 int main(int argc, char **argv)
 {
@@ -27,7 +85,7 @@ int main(int argc, char **argv)
        buf[4] = 0;
 
        /* create a test variable */
-       fd = open(path, O_WRONLY | O_CREAT);
+       fd = open(path, O_WRONLY | O_CREAT, 0600);
        if (fd < 0) {
                perror("open(O_WRONLY)");
                return EXIT_FAILURE;
@@ -41,6 +99,18 @@ int main(int argc, char **argv)
 
        close(fd);
 
+       rc = get_immutable(path);
+       if (rc < 0) {
+               perror("ioctl(FS_IOC_GETFLAGS)");
+               return EXIT_FAILURE;
+       } else if (rc) {
+               rc = set_immutable(path, 0);
+               if (rc < 0) {
+                       perror("ioctl(FS_IOC_SETFLAGS)");
+                       return EXIT_FAILURE;
+               }
+       }
+
        fd = open(path, O_RDONLY);
        if (fd < 0) {
                perror("open");
index 773e276..1e1abe0 100644 (file)
@@ -39,28 +39,23 @@ instance_slam() {
 }
 
 instance_slam &
-x=`jobs -l`
-p1=`echo $x | cut -d' ' -f2`
+p1=$!
 echo $p1
 
 instance_slam &
-x=`jobs -l | tail -1`
-p2=`echo $x | cut -d' ' -f2`
+p2=$!
 echo $p2
 
 instance_slam &
-x=`jobs -l | tail -1`
-p3=`echo $x | cut -d' ' -f2`
+p3=$!
 echo $p3
 
 instance_slam &
-x=`jobs -l | tail -1`
-p4=`echo $x | cut -d' ' -f2`
+p4=$!
 echo $p4
 
 instance_slam &
-x=`jobs -l | tail -1`
-p5=`echo $x | cut -d' ' -f2`
+p5=$!
 echo $p5
 
 ls -lR >/dev/null
index 69bca18..ea60646 100644 (file)
@@ -143,7 +143,7 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level)
  * Check if there was a change in the timer state (should we raise or lower
  * the line level to the GIC).
  */
-static void kvm_timer_update_state(struct kvm_vcpu *vcpu)
+static int kvm_timer_update_state(struct kvm_vcpu *vcpu)
 {
        struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
 
@@ -154,10 +154,12 @@ static void kvm_timer_update_state(struct kvm_vcpu *vcpu)
         * until we call this function from kvm_timer_flush_hwstate.
         */
        if (!vgic_initialized(vcpu->kvm))
-           return;
+               return -ENODEV;
 
        if (kvm_timer_should_fire(vcpu) != timer->irq.level)
                kvm_timer_update_irq(vcpu, !timer->irq.level);
+
+       return 0;
 }
 
 /*
@@ -218,7 +220,8 @@ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu)
        bool phys_active;
        int ret;
 
-       kvm_timer_update_state(vcpu);
+       if (kvm_timer_update_state(vcpu))
+               return;
 
        /*
        * If we enter the guest with the virtual input level to the VGIC
index 043032c..00429b3 100644 (file)
@@ -1875,8 +1875,8 @@ void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu)
 static int vgic_vcpu_init_maps(struct kvm_vcpu *vcpu, int nr_irqs)
 {
        struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
-
-       int sz = (nr_irqs - VGIC_NR_PRIVATE_IRQS) / 8;
+       int nr_longs = BITS_TO_LONGS(nr_irqs - VGIC_NR_PRIVATE_IRQS);
+       int sz = nr_longs * sizeof(unsigned long);
        vgic_cpu->pending_shared = kzalloc(sz, GFP_KERNEL);
        vgic_cpu->active_shared = kzalloc(sz, GFP_KERNEL);
        vgic_cpu->pend_act_shared = kzalloc(sz, GFP_KERNEL);
index 3531599..db2dd33 100644 (file)
@@ -172,7 +172,7 @@ int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva,
         * do alloc nowait since if we are going to sleep anyway we
         * may as well sleep faulting in page
         */
-       work = kmem_cache_zalloc(async_pf_cache, GFP_NOWAIT);
+       work = kmem_cache_zalloc(async_pf_cache, GFP_NOWAIT | __GFP_NOWARN);
        if (!work)
                return 0;
 
index a11cfd2..9102ae1 100644 (file)
@@ -1952,6 +1952,9 @@ static void grow_halt_poll_ns(struct kvm_vcpu *vcpu)
        else
                val *= halt_poll_ns_grow;
 
+       if (val > halt_poll_ns)
+               val = halt_poll_ns;
+
        vcpu->halt_poll_ns = val;
        trace_kvm_halt_poll_ns_grow(vcpu->vcpu_id, val, old);
 }